babylon.module.d.ts 6.4 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032145033145034145035145036145037145038145039145040145041145042145043145044145045145046145047145048145049145050145051145052145053145054145055145056145057145058145059145060145061145062145063145064145065145066145067145068145069145070145071145072145073145074145075145076145077145078145079145080145081145082145083145084145085145086145087145088145089145090145091145092145093145094145095145096145097145098145099145100145101145102145103145104145105145106145107145108145109145110145111145112145113145114145115145116145117145118145119145120145121145122145123145124145125145126145127145128145129145130145131145132145133145134145135145136145137145138145139145140145141145142145143145144145145145146145147145148145149145150145151145152145153145154145155145156145157145158145159145160145161145162145163145164145165145166145167145168145169145170145171145172145173145174145175145176145177145178145179145180145181145182145183145184145185145186145187145188145189145190145191145192145193145194145195145196145197145198145199145200145201145202145203145204145205145206145207145208145209145210145211145212145213145214145215145216145217145218145219145220145221145222145223145224145225145226145227145228145229145230145231145232145233145234145235145236145237145238145239145240145241145242145243145244145245145246145247145248145249145250145251145252145253145254145255145256145257145258145259145260145261145262145263145264145265145266145267145268145269145270145271145272145273145274145275145276145277145278145279145280145281145282145283145284145285145286145287145288145289145290145291145292145293145294145295145296145297145298145299145300145301145302145303145304145305145306145307145308145309145310145311145312145313145314145315145316145317145318145319145320145321145322145323145324145325145326145327145328145329145330145331145332145333145334145335145336145337145338145339145340145341145342145343145344145345145346145347145348145349145350145351145352145353145354145355145356145357145358145359145360145361145362145363145364145365145366145367145368145369145370145371145372145373145374145375145376145377145378145379145380145381145382145383145384145385145386145387145388145389145390145391145392145393145394145395145396145397145398145399145400145401145402145403145404145405145406145407145408145409145410145411145412145413145414145415145416145417145418145419145420145421145422145423145424145425145426145427145428145429145430145431145432145433145434145435145436145437145438145439145440145441145442145443145444145445145446145447145448145449145450145451145452145453145454145455145456145457145458145459145460145461145462145463145464145465145466145467145468145469145470145471145472145473145474145475145476145477145478145479145480145481145482145483145484145485145486145487145488145489145490145491145492145493145494145495145496145497145498145499145500145501145502145503145504145505145506145507145508145509145510145511145512145513145514145515145516145517145518145519145520145521145522145523145524145525145526145527145528145529145530145531145532145533145534145535145536145537145538145539145540145541145542145543145544145545145546145547145548145549145550145551145552145553145554145555145556145557145558145559145560145561145562145563145564145565145566145567145568145569145570145571145572145573145574145575145576145577145578145579145580145581145582145583145584145585145586145587145588145589145590145591145592145593145594145595145596145597145598145599145600145601145602145603145604145605145606145607145608145609145610145611145612145613145614145615145616145617145618145619145620145621145622145623145624145625145626145627145628145629145630145631145632145633145634145635145636145637145638145639145640145641145642145643145644145645145646145647145648145649145650145651145652145653145654145655145656145657145658145659145660145661145662145663145664145665145666145667145668145669145670145671145672145673145674145675145676145677145678145679145680145681145682145683145684145685145686145687145688145689145690145691145692145693145694145695145696145697145698145699145700145701145702145703145704145705145706145707145708145709145710145711145712145713145714145715145716145717145718145719145720145721145722145723145724145725145726145727145728145729145730145731145732145733145734145735145736145737145738145739145740145741145742145743145744145745145746145747145748145749145750145751145752145753145754145755145756145757145758145759145760145761145762145763145764145765145766145767145768145769145770145771145772145773145774145775145776145777145778145779145780145781145782145783145784145785145786145787145788145789145790145791145792145793145794145795145796145797145798145799145800145801145802145803145804145805145806145807145808145809145810145811145812145813145814145815145816145817145818145819145820145821145822145823145824145825145826145827145828145829145830145831145832145833145834145835145836145837145838145839145840145841145842145843145844145845145846145847145848145849145850145851145852145853145854145855145856145857145858145859145860145861145862145863145864145865145866145867145868145869145870145871145872145873145874145875145876145877145878145879145880145881145882145883145884145885145886145887145888145889145890145891145892145893145894145895145896145897145898145899145900145901145902145903145904145905145906145907145908145909145910145911145912145913145914145915145916145917145918145919145920145921145922145923145924145925145926145927145928145929145930145931145932145933145934145935145936145937145938145939145940145941145942145943145944145945145946145947145948145949145950145951145952145953145954145955145956145957145958145959145960145961145962145963145964145965145966145967145968145969145970145971145972145973145974145975145976145977145978145979145980145981145982145983145984145985145986145987145988145989145990145991145992145993145994145995145996145997145998145999146000146001146002146003146004146005146006146007146008146009146010146011146012146013146014146015146016146017146018146019146020146021146022146023146024146025146026146027146028146029146030146031146032146033146034146035146036146037146038146039146040146041146042146043146044146045146046146047146048146049146050146051146052146053146054146055146056146057146058146059146060146061146062146063146064146065146066146067146068146069146070146071146072146073146074146075146076146077146078146079146080146081146082146083146084146085146086146087146088146089146090146091146092146093146094146095146096146097146098146099146100146101146102146103146104146105146106146107146108146109146110146111146112146113146114146115146116146117146118146119146120146121146122146123146124146125146126146127146128146129146130146131146132146133146134146135146136146137146138146139146140146141146142146143146144146145146146146147146148146149146150146151146152146153146154146155146156146157146158146159146160146161146162146163146164146165146166146167146168146169146170146171146172146173146174146175146176146177146178146179146180146181146182146183146184146185146186146187146188146189146190146191146192146193146194146195146196146197146198146199146200146201146202146203146204146205146206146207146208146209146210146211146212146213146214146215146216146217146218146219146220146221146222146223146224146225146226146227146228146229146230146231146232146233146234146235146236146237146238146239146240146241146242146243146244146245146246146247146248146249146250146251146252146253146254146255146256146257146258146259146260146261146262146263146264146265146266146267146268146269146270146271146272146273146274146275146276146277146278146279146280146281146282146283146284146285146286146287146288146289146290146291146292146293146294146295146296146297146298146299146300146301146302146303146304146305146306146307146308146309146310146311146312146313146314146315146316146317146318146319146320146321146322146323146324146325146326146327146328146329146330146331146332146333146334146335146336146337146338146339146340146341146342146343146344146345146346146347146348146349146350146351146352146353146354146355146356146357146358146359146360146361146362146363146364146365146366146367146368146369146370146371146372146373146374146375146376146377146378146379146380146381146382146383146384146385146386146387146388146389146390146391146392146393146394146395146396146397146398146399146400146401146402146403146404146405146406146407146408146409146410146411146412146413146414146415146416146417146418146419146420146421146422146423146424146425146426146427146428146429146430146431146432146433146434146435146436146437146438146439146440146441146442146443146444146445146446146447146448146449146450146451146452146453146454146455146456146457146458146459146460146461146462146463146464146465146466146467146468146469146470146471146472146473146474146475146476146477146478146479146480146481146482146483146484146485146486146487146488146489146490146491146492146493146494146495146496146497146498146499146500146501146502146503146504146505146506146507146508146509146510146511146512146513146514146515146516146517146518146519146520146521146522146523146524146525146526146527146528146529146530146531146532146533146534146535146536146537146538146539146540146541146542146543146544146545146546146547146548146549146550146551146552146553146554146555146556146557146558146559146560146561146562146563146564146565146566146567146568146569146570146571146572146573146574146575146576146577146578146579146580146581146582146583146584146585146586146587146588146589146590146591146592146593146594146595146596146597146598146599146600146601146602146603146604146605146606146607146608146609146610146611146612146613146614146615146616146617146618146619146620146621146622146623146624146625146626146627146628146629146630146631146632146633146634146635146636146637146638146639146640146641146642146643146644146645146646146647146648146649146650146651146652146653146654146655146656146657146658146659146660146661146662146663146664146665146666146667146668146669146670146671146672146673146674146675146676146677146678146679146680146681146682146683146684146685146686146687146688146689146690146691146692146693146694146695146696146697146698146699146700146701146702146703146704146705146706146707146708146709146710146711146712146713146714146715146716146717146718146719146720146721146722146723146724146725146726146727146728146729146730146731146732146733146734146735146736146737146738146739146740146741146742146743146744146745146746146747146748146749146750146751146752146753146754146755146756146757146758146759146760146761146762146763146764146765146766146767146768146769146770146771146772146773146774146775146776146777146778146779146780146781146782146783146784146785146786146787146788146789146790146791146792146793146794146795146796146797146798146799146800146801146802146803146804146805146806146807146808146809146810146811146812146813146814146815146816146817146818146819146820146821146822146823146824146825146826146827146828146829146830146831146832146833146834146835146836146837146838146839146840146841146842146843146844146845146846146847146848146849146850146851146852146853146854146855146856146857146858146859146860146861146862146863146864146865146866146867146868146869146870146871146872146873146874146875146876146877146878146879146880146881146882146883146884146885146886146887146888146889146890146891146892146893146894146895146896146897146898146899146900146901146902146903146904146905146906146907146908146909146910146911146912146913146914146915146916146917146918146919146920146921146922146923146924146925146926146927146928146929146930146931146932146933146934146935146936146937146938146939146940146941146942146943146944146945146946146947146948146949146950146951146952146953146954146955146956146957146958146959146960146961146962146963146964146965146966146967146968146969146970146971146972146973146974146975146976146977146978146979146980146981146982146983146984146985146986146987146988146989146990146991146992146993146994146995146996146997146998146999147000147001147002147003147004147005147006147007147008147009147010147011147012147013147014147015147016147017147018147019147020147021147022147023147024147025147026147027147028147029147030147031147032147033147034147035147036147037147038147039147040147041147042147043147044147045147046147047147048147049147050147051147052147053147054147055147056147057147058147059147060147061147062147063147064147065147066147067147068147069147070147071147072147073147074147075147076147077147078147079147080147081147082147083147084147085147086147087147088147089147090147091147092147093147094147095147096147097147098147099147100147101147102147103147104147105147106147107147108147109147110147111147112147113147114147115147116147117147118147119147120147121147122147123147124147125147126147127147128147129147130147131147132147133147134147135147136147137147138147139147140147141147142147143147144147145147146147147147148147149147150147151147152147153147154147155147156147157147158147159147160147161147162147163147164147165147166147167147168147169147170147171147172147173147174147175147176147177147178147179147180147181147182147183147184147185147186147187147188147189147190147191147192147193147194147195147196147197147198147199147200147201147202147203147204147205147206147207147208147209147210147211147212147213147214147215147216147217147218147219147220147221147222147223147224147225147226147227147228147229147230147231147232147233147234147235147236147237147238147239147240147241147242147243147244147245147246147247147248147249147250147251147252147253147254147255147256147257147258147259147260147261147262147263147264147265147266147267147268147269147270147271147272147273147274147275147276147277147278147279147280147281147282147283147284147285147286147287147288147289147290147291147292147293147294147295147296147297147298147299147300147301147302147303147304147305147306147307147308147309147310147311147312147313147314147315147316147317147318147319147320147321147322147323147324147325147326147327147328147329147330147331147332147333147334147335147336147337147338147339147340147341147342147343147344147345147346147347147348147349147350147351147352147353147354147355147356147357147358147359147360147361147362147363147364147365147366147367147368147369147370147371147372147373147374147375147376147377147378147379147380147381147382147383147384147385147386147387147388147389147390147391147392147393147394147395147396147397147398147399147400147401147402147403147404147405147406147407147408147409147410147411147412147413147414147415147416147417147418147419147420147421147422147423147424147425147426147427147428147429147430147431147432147433147434147435147436147437147438147439147440147441147442147443147444147445147446147447147448147449147450147451147452147453147454147455147456147457147458147459147460147461147462147463147464147465147466147467147468147469147470147471147472147473147474147475147476147477147478147479147480147481147482147483147484147485147486147487147488147489147490147491147492147493147494147495147496147497147498147499147500147501147502147503147504147505147506147507147508147509147510147511147512147513147514147515147516147517147518147519147520147521147522147523147524147525147526147527147528147529147530147531147532147533147534147535147536147537147538147539147540147541147542147543147544147545147546147547147548147549147550147551147552147553147554147555147556147557147558147559147560147561147562147563147564147565147566147567147568147569147570147571147572147573147574147575147576147577147578147579147580147581147582147583147584147585147586147587147588147589147590147591147592147593147594147595147596147597147598147599147600147601147602147603147604147605147606147607147608147609147610147611147612147613147614147615147616147617147618147619147620147621147622147623147624147625147626147627147628147629147630147631147632147633147634147635147636147637147638147639147640147641147642147643147644147645147646147647147648147649147650147651147652147653147654147655147656147657147658147659147660147661147662147663147664147665147666147667147668147669147670147671147672147673147674147675147676147677147678147679147680147681147682147683147684147685147686147687147688147689147690147691147692147693147694147695147696147697147698147699147700147701147702147703147704147705147706147707147708147709147710147711147712147713147714147715147716147717147718147719147720147721147722147723147724147725147726147727147728147729147730147731147732147733147734147735147736147737147738147739147740147741147742147743147744147745147746147747147748147749147750147751147752147753147754147755147756147757147758147759147760147761147762147763147764147765147766147767147768147769147770147771147772147773147774147775147776147777147778147779147780147781147782147783147784147785147786147787147788147789147790147791147792147793147794147795147796147797147798147799147800147801147802147803147804147805147806147807147808147809147810147811147812147813147814147815147816147817147818147819147820147821147822147823147824147825147826147827147828147829147830147831147832147833147834147835147836147837147838147839147840147841147842147843147844147845147846147847147848147849147850147851147852147853147854147855147856147857147858147859147860147861147862147863147864147865147866147867147868147869147870147871147872147873147874147875147876147877147878147879147880147881147882147883147884147885147886147887147888147889147890147891147892147893147894147895147896147897147898147899147900147901147902147903147904147905147906147907147908147909147910147911147912147913147914147915147916147917147918147919147920147921147922147923147924147925147926147927147928147929147930147931147932147933147934147935147936147937147938147939147940147941147942147943147944147945147946147947147948147949147950147951147952147953147954147955147956147957147958147959147960147961147962147963147964147965147966147967147968147969147970147971147972147973147974147975147976147977147978147979147980147981147982147983147984147985147986147987147988147989147990147991147992147993147994147995147996147997147998147999148000148001148002148003148004148005148006148007148008148009148010148011148012148013148014148015148016148017148018148019148020148021148022148023148024148025148026148027148028148029148030148031148032148033148034148035148036148037148038148039148040148041148042148043148044148045148046148047148048148049148050148051148052148053148054148055148056148057148058148059148060148061148062148063148064148065148066148067148068148069148070148071148072148073148074148075148076148077148078148079148080148081148082148083148084148085148086148087148088148089148090148091148092148093148094148095148096148097148098148099148100148101148102148103148104148105148106148107148108148109148110148111148112148113148114148115148116148117148118148119148120148121148122148123148124148125148126148127148128148129148130148131148132148133148134148135148136148137148138148139148140148141148142148143148144148145148146148147148148148149148150148151148152148153148154148155148156148157148158148159148160148161148162148163148164148165148166148167148168148169148170148171148172148173148174148175148176148177148178148179148180148181148182148183148184148185148186148187148188148189148190148191148192148193148194148195148196148197148198148199148200148201148202148203148204148205148206148207148208148209148210148211148212148213148214148215148216148217148218148219148220148221148222148223148224148225148226148227148228148229148230148231148232148233148234148235148236148237148238148239148240148241148242148243148244148245148246148247148248148249148250148251148252148253148254148255148256148257148258148259148260148261148262148263148264148265148266148267148268148269148270148271148272148273148274148275148276148277148278148279148280148281148282148283148284148285148286148287148288148289148290148291148292148293148294148295148296148297148298148299148300148301148302148303148304148305148306148307148308148309148310148311148312148313148314148315148316148317148318148319148320148321148322148323148324148325148326148327148328148329148330148331148332148333148334148335148336148337148338148339148340148341148342148343148344148345148346148347148348148349148350148351148352148353148354148355148356148357148358148359148360148361148362148363148364148365148366148367148368148369148370148371148372148373148374148375148376148377148378148379148380148381148382148383148384148385148386148387148388148389148390148391148392148393148394148395148396148397148398148399148400148401148402148403148404148405148406148407148408148409148410148411148412148413148414148415148416148417148418148419148420148421148422148423148424148425148426148427148428148429148430148431148432148433148434148435148436148437148438148439148440148441148442148443148444148445148446148447148448148449148450148451148452148453148454148455148456148457148458148459148460148461148462148463148464148465148466148467148468148469148470148471148472148473148474148475148476148477148478148479148480148481148482148483148484148485148486148487148488148489148490148491148492148493148494148495148496148497148498148499148500148501148502148503148504148505148506148507148508148509148510148511148512148513148514148515148516148517148518148519148520148521148522148523148524148525148526148527148528148529148530148531148532148533148534148535148536148537148538148539148540148541148542148543148544148545148546148547148548148549148550148551148552148553148554148555148556148557148558148559148560148561148562148563148564148565148566148567148568148569148570148571148572148573148574148575148576148577148578148579148580148581148582148583148584148585148586148587148588148589148590148591148592148593148594148595148596148597148598148599148600148601148602148603148604148605148606148607148608148609148610148611148612148613148614148615148616148617148618148619148620148621148622148623148624148625148626148627148628148629148630148631148632148633148634148635148636148637148638148639148640148641148642148643148644148645148646148647148648148649148650148651148652148653148654148655148656148657148658148659148660148661148662148663148664148665148666148667148668148669148670148671148672148673148674148675148676148677148678148679148680148681148682148683148684148685148686148687148688148689148690148691148692148693148694148695148696148697148698148699148700148701148702148703148704148705148706148707148708148709148710148711148712148713148714148715148716148717148718148719148720148721148722148723148724148725148726148727148728148729148730148731148732148733148734148735148736148737148738148739148740148741148742148743148744148745148746148747148748148749148750148751148752148753148754148755148756148757148758148759148760148761148762148763148764148765148766148767148768148769148770148771148772148773148774148775148776148777148778148779148780148781148782148783148784148785148786148787148788148789148790148791148792148793148794148795148796148797148798148799148800148801148802148803148804148805148806148807148808148809148810148811148812148813148814148815148816148817148818148819148820148821148822148823148824148825148826148827148828148829148830148831148832148833148834148835148836148837148838148839148840148841148842148843148844148845148846148847148848148849148850148851148852148853148854148855148856148857148858148859148860148861148862148863148864148865148866148867148868148869148870148871148872148873148874148875148876148877148878148879148880148881148882148883148884148885148886148887148888148889148890148891148892148893148894148895148896148897148898148899148900148901148902148903148904148905148906148907148908148909148910148911148912148913148914148915148916148917148918148919148920148921148922148923148924148925148926148927148928148929148930148931148932148933148934148935148936148937148938148939148940148941148942148943148944148945148946148947148948148949148950148951148952148953148954148955148956148957148958148959148960148961148962148963148964148965148966148967148968148969148970148971148972148973148974148975148976148977148978148979148980148981148982148983148984148985148986148987148988148989148990148991148992148993148994148995148996148997148998148999149000149001149002149003149004149005149006149007149008149009149010149011149012149013149014149015149016149017149018149019149020149021149022149023149024149025149026149027149028149029149030149031149032149033149034149035149036149037149038149039149040149041149042149043149044149045149046149047149048149049149050149051149052149053149054149055149056149057149058149059149060149061149062149063149064149065149066149067149068149069149070149071149072149073149074149075149076149077149078149079149080149081149082149083149084149085149086149087149088149089149090149091149092149093149094149095149096149097149098149099149100149101149102149103149104149105149106149107149108149109149110149111149112149113149114149115149116149117149118149119149120149121149122149123149124149125149126149127149128149129149130149131149132149133149134149135149136149137149138149139149140149141149142149143149144149145149146149147149148149149149150149151149152149153149154149155149156149157149158149159149160149161149162149163149164149165149166149167149168149169149170149171149172149173149174149175149176149177149178149179149180149181149182149183149184149185149186149187149188149189149190149191149192149193149194149195149196149197149198149199149200149201149202149203149204149205149206149207149208149209149210149211149212149213149214149215149216149217149218149219149220149221149222149223149224149225149226149227149228149229149230149231149232149233149234149235149236149237149238149239149240149241149242149243149244149245149246149247149248149249149250149251149252149253149254149255149256149257149258149259149260149261149262149263149264149265149266149267149268149269149270149271149272149273149274149275149276149277149278149279149280149281149282149283149284149285149286149287149288149289149290149291149292149293149294149295149296149297149298149299149300149301149302149303149304149305149306149307149308149309149310149311149312149313149314149315149316149317149318149319149320149321149322149323149324149325149326149327149328149329149330149331149332149333149334149335149336149337149338149339149340149341149342149343149344149345149346149347149348149349149350149351149352149353149354149355149356149357149358149359149360149361149362149363149364149365149366149367149368149369149370149371149372149373149374149375149376149377149378149379149380149381149382149383149384149385149386149387149388149389149390149391149392149393149394149395149396149397149398149399149400149401149402149403149404149405149406149407149408149409149410149411149412149413149414149415149416149417149418149419149420149421149422149423149424149425149426149427149428149429149430149431149432149433149434149435149436149437149438149439149440149441149442149443149444149445149446149447149448149449149450149451149452149453149454149455149456149457149458149459149460149461149462149463149464149465149466149467149468149469149470149471149472149473149474149475149476149477149478149479149480149481149482149483149484149485149486149487149488149489149490149491149492149493149494149495149496149497149498149499149500149501149502149503149504149505149506149507149508149509149510149511149512149513149514149515149516149517149518149519149520149521149522149523149524149525149526149527149528149529149530149531149532149533149534149535149536149537149538149539149540149541149542149543149544149545149546149547149548149549149550149551149552149553149554149555149556149557149558149559149560149561149562149563149564149565149566149567149568149569149570149571149572149573149574149575149576149577149578149579149580149581149582149583149584149585149586149587149588149589149590149591149592149593149594149595149596149597149598149599149600149601149602149603149604149605149606149607149608149609149610149611149612149613149614149615149616149617149618149619149620149621149622149623149624149625149626149627149628149629149630149631149632149633149634149635149636149637149638149639149640149641149642149643149644149645149646149647149648149649149650149651149652149653149654149655149656149657149658149659149660149661149662149663149664149665149666149667149668149669149670149671149672149673149674149675149676149677149678149679149680149681149682149683149684149685149686149687149688149689149690149691149692149693149694149695149696149697149698149699149700149701149702149703149704149705149706149707149708149709149710149711149712149713149714149715149716149717149718149719149720149721149722149723149724149725149726149727149728149729149730149731149732149733149734149735149736149737149738149739149740149741149742149743149744149745149746149747149748149749149750149751149752149753149754149755149756149757149758149759149760149761149762149763149764149765149766149767149768149769149770149771149772149773149774149775149776149777149778149779149780149781149782149783149784149785149786149787149788149789149790149791149792149793149794149795149796149797149798149799149800149801149802149803149804149805149806149807149808149809149810149811149812149813149814149815149816149817149818149819149820149821149822149823149824149825149826149827149828149829149830149831149832149833149834149835149836149837149838149839149840149841149842149843149844149845149846149847149848149849149850149851149852149853149854149855149856149857149858149859149860149861149862149863149864149865149866149867149868149869149870149871149872149873149874149875149876149877149878149879149880149881149882149883149884149885149886149887149888149889149890149891149892149893149894149895149896149897149898149899149900149901149902149903149904149905149906149907149908149909149910149911149912149913149914149915149916149917149918149919149920149921149922149923149924149925149926149927149928149929149930149931149932149933149934149935149936149937149938149939149940149941149942149943149944149945149946149947149948149949149950149951149952149953149954149955149956149957149958149959149960149961149962149963149964149965149966149967149968149969149970149971149972149973149974149975149976149977149978149979149980149981149982149983149984149985149986149987149988149989149990149991149992149993149994149995149996149997149998149999150000150001150002150003150004150005150006150007150008150009150010150011150012150013150014150015150016150017150018150019150020150021150022150023150024150025150026150027150028150029150030150031150032150033150034150035150036150037150038150039150040150041150042150043150044150045150046150047150048150049150050150051150052150053150054150055150056150057150058150059150060150061150062150063150064150065150066150067150068150069150070150071150072150073150074150075150076150077150078150079150080150081150082150083150084150085150086150087150088150089150090150091150092150093150094150095150096150097150098150099150100150101150102150103150104150105150106150107150108150109150110150111150112150113150114150115150116150117150118150119150120150121150122150123150124150125150126150127150128150129150130150131150132150133150134150135150136150137150138150139150140150141150142150143150144150145150146150147150148150149150150150151150152150153150154150155150156150157150158150159150160150161150162150163150164150165150166150167150168150169150170150171150172150173150174150175150176150177150178150179150180150181150182150183150184150185150186150187150188150189150190150191150192150193150194150195150196150197150198150199150200150201150202150203150204150205150206150207150208150209150210150211150212150213150214150215150216150217150218150219150220150221150222150223150224150225150226150227150228150229150230150231150232150233150234150235150236150237150238150239150240150241150242150243150244150245150246150247150248150249150250150251150252150253150254150255150256150257150258150259150260150261150262150263150264150265150266150267150268150269150270150271150272150273150274150275150276150277150278150279150280150281150282150283150284150285150286150287150288150289150290150291150292150293150294150295150296150297150298150299150300150301150302150303150304150305150306150307150308150309150310150311150312150313150314150315150316150317150318150319150320150321150322150323150324150325150326150327150328150329150330150331150332150333150334150335150336150337150338150339150340150341150342150343150344150345150346150347150348150349150350150351150352150353150354150355150356150357150358150359150360150361150362150363150364150365150366150367150368150369150370150371150372150373150374150375150376150377150378150379150380150381150382150383150384150385150386150387150388150389150390150391150392150393150394150395150396150397150398150399150400150401150402150403150404150405150406150407150408150409150410150411150412150413150414150415150416150417150418150419150420150421150422150423150424150425150426150427150428150429150430150431150432150433150434150435150436150437150438150439150440150441150442150443150444150445150446150447150448150449150450150451150452150453150454150455150456150457150458150459150460150461150462150463150464150465150466150467150468150469150470150471150472150473150474150475150476150477150478150479150480150481150482150483150484150485150486150487150488150489150490150491150492150493150494150495150496150497150498150499150500150501150502150503150504150505150506150507150508150509150510150511150512150513150514150515150516150517150518150519150520150521150522150523150524150525150526150527150528150529150530150531150532150533150534150535150536150537150538150539150540150541150542150543150544150545150546150547150548150549150550150551150552150553150554150555150556150557150558150559150560150561150562150563150564150565150566150567150568150569150570150571150572150573150574150575150576150577150578150579150580150581150582150583150584150585150586150587150588150589150590150591150592150593150594150595150596150597150598150599150600150601150602150603150604150605150606150607150608150609150610150611150612150613150614150615150616150617150618150619150620150621150622150623150624150625150626150627150628150629150630150631150632150633150634150635150636150637150638150639150640150641150642150643150644150645150646150647150648150649150650150651150652150653150654150655150656150657150658150659150660150661150662150663150664150665150666150667150668150669150670150671150672150673150674150675150676150677150678150679150680150681150682150683150684150685150686150687150688150689150690150691150692150693150694150695150696150697150698150699150700150701150702150703150704150705150706150707150708150709150710150711150712150713150714150715150716150717150718150719150720150721150722150723150724150725150726150727150728150729150730150731150732150733150734150735150736150737150738150739150740150741150742150743150744150745150746150747150748150749150750150751150752150753150754150755150756150757150758150759150760150761150762150763150764150765150766150767150768150769150770150771150772150773150774150775150776150777150778150779150780150781150782150783150784150785150786150787150788150789150790150791150792150793150794150795150796150797150798150799150800150801150802150803150804150805150806150807150808150809150810150811150812150813150814150815150816150817150818150819150820150821150822150823150824150825150826150827150828150829150830150831150832150833150834150835150836150837150838150839150840150841150842150843150844150845150846150847150848150849150850150851150852150853150854150855150856150857150858150859150860150861150862150863150864150865150866150867150868150869150870150871150872150873150874150875150876150877150878150879150880150881150882150883150884150885150886150887150888150889150890150891150892150893150894150895150896150897150898150899150900150901150902150903150904150905150906150907150908150909150910150911150912150913150914150915150916150917150918150919150920150921150922150923150924150925150926150927150928150929
  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. * Represens 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. /** Id of the the submesh that was picked */
  10487. subMeshId: number;
  10488. /** If a sprite was picked, this will be the sprite the pick collided with */
  10489. pickedSprite: Nullable<Sprite>;
  10490. /**
  10491. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10492. */
  10493. originMesh: Nullable<AbstractMesh>;
  10494. /**
  10495. * The ray that was used to perform the picking.
  10496. */
  10497. ray: Nullable<Ray>;
  10498. /**
  10499. * Gets the normal correspodning to the face the pick collided with
  10500. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10501. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10502. * @returns The normal correspodning to the face the pick collided with
  10503. */
  10504. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10505. /**
  10506. * Gets the texture coordinates of where the pick occured
  10507. * @returns the vector containing the coordnates of the texture
  10508. */
  10509. getTextureCoordinates(): Nullable<Vector2>;
  10510. }
  10511. }
  10512. declare module "babylonjs/Culling/ray" {
  10513. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  10514. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  10515. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10516. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10517. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  10518. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  10519. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  10520. import { Plane } from "babylonjs/Maths/math.plane";
  10521. /**
  10522. * Class representing a ray with position and direction
  10523. */
  10524. export class Ray {
  10525. /** origin point */
  10526. origin: Vector3;
  10527. /** direction */
  10528. direction: Vector3;
  10529. /** length of the ray */
  10530. length: number;
  10531. private static readonly TmpVector3;
  10532. private _tmpRay;
  10533. /**
  10534. * Creates a new ray
  10535. * @param origin origin point
  10536. * @param direction direction
  10537. * @param length length of the ray
  10538. */
  10539. constructor(
  10540. /** origin point */
  10541. origin: Vector3,
  10542. /** direction */
  10543. direction: Vector3,
  10544. /** length of the ray */
  10545. length?: number);
  10546. /**
  10547. * Checks if the ray intersects a box
  10548. * This does not account for the ray lenght by design to improve perfs.
  10549. * @param minimum bound of the box
  10550. * @param maximum bound of the box
  10551. * @param intersectionTreshold extra extend to be added to the box in all direction
  10552. * @returns if the box was hit
  10553. */
  10554. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10555. /**
  10556. * Checks if the ray intersects a box
  10557. * This does not account for the ray lenght by design to improve perfs.
  10558. * @param box the bounding box to check
  10559. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10560. * @returns if the box was hit
  10561. */
  10562. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10563. /**
  10564. * If the ray hits a sphere
  10565. * @param sphere the bounding sphere to check
  10566. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10567. * @returns true if it hits the sphere
  10568. */
  10569. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10570. /**
  10571. * If the ray hits a triange
  10572. * @param vertex0 triangle vertex
  10573. * @param vertex1 triangle vertex
  10574. * @param vertex2 triangle vertex
  10575. * @returns intersection information if hit
  10576. */
  10577. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10578. /**
  10579. * Checks if ray intersects a plane
  10580. * @param plane the plane to check
  10581. * @returns the distance away it was hit
  10582. */
  10583. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10584. /**
  10585. * Calculate the intercept of a ray on a given axis
  10586. * @param axis to check 'x' | 'y' | 'z'
  10587. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10588. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10589. */
  10590. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10591. /**
  10592. * Checks if ray intersects a mesh
  10593. * @param mesh the mesh to check
  10594. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10595. * @returns picking info of the intersecton
  10596. */
  10597. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10598. /**
  10599. * Checks if ray intersects a mesh
  10600. * @param meshes the meshes to check
  10601. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10602. * @param results array to store result in
  10603. * @returns Array of picking infos
  10604. */
  10605. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10606. private _comparePickingInfo;
  10607. private static smallnum;
  10608. private static rayl;
  10609. /**
  10610. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10611. * @param sega the first point of the segment to test the intersection against
  10612. * @param segb the second point of the segment to test the intersection against
  10613. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10614. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10615. */
  10616. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10617. /**
  10618. * Update the ray from viewport position
  10619. * @param x position
  10620. * @param y y position
  10621. * @param viewportWidth viewport width
  10622. * @param viewportHeight viewport height
  10623. * @param world world matrix
  10624. * @param view view matrix
  10625. * @param projection projection matrix
  10626. * @returns this ray updated
  10627. */
  10628. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10629. /**
  10630. * Creates a ray with origin and direction of 0,0,0
  10631. * @returns the new ray
  10632. */
  10633. static Zero(): Ray;
  10634. /**
  10635. * Creates a new ray from screen space and viewport
  10636. * @param x position
  10637. * @param y y position
  10638. * @param viewportWidth viewport width
  10639. * @param viewportHeight viewport height
  10640. * @param world world matrix
  10641. * @param view view matrix
  10642. * @param projection projection matrix
  10643. * @returns new ray
  10644. */
  10645. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10646. /**
  10647. * 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
  10648. * transformed to the given world matrix.
  10649. * @param origin The origin point
  10650. * @param end The end point
  10651. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10652. * @returns the new ray
  10653. */
  10654. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  10655. /**
  10656. * Transforms a ray by a matrix
  10657. * @param ray ray to transform
  10658. * @param matrix matrix to apply
  10659. * @returns the resulting new ray
  10660. */
  10661. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10662. /**
  10663. * Transforms a ray by a matrix
  10664. * @param ray ray to transform
  10665. * @param matrix matrix to apply
  10666. * @param result ray to store result in
  10667. */
  10668. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10669. /**
  10670. * Unproject a ray from screen space to object space
  10671. * @param sourceX defines the screen space x coordinate to use
  10672. * @param sourceY defines the screen space y coordinate to use
  10673. * @param viewportWidth defines the current width of the viewport
  10674. * @param viewportHeight defines the current height of the viewport
  10675. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10676. * @param view defines the view matrix to use
  10677. * @param projection defines the projection matrix to use
  10678. */
  10679. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10680. }
  10681. /**
  10682. * Type used to define predicate used to select faces when a mesh intersection is detected
  10683. */
  10684. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10685. module "babylonjs/scene" {
  10686. interface Scene {
  10687. /** @hidden */
  10688. _tempPickingRay: Nullable<Ray>;
  10689. /** @hidden */
  10690. _cachedRayForTransform: Ray;
  10691. /** @hidden */
  10692. _pickWithRayInverseMatrix: Matrix;
  10693. /** @hidden */
  10694. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10695. /** @hidden */
  10696. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10697. }
  10698. }
  10699. }
  10700. declare module "babylonjs/sceneComponent" {
  10701. import { Scene } from "babylonjs/scene";
  10702. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10703. import { SubMesh } from "babylonjs/Meshes/subMesh";
  10704. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  10705. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  10706. import { Nullable } from "babylonjs/types";
  10707. import { Camera } from "babylonjs/Cameras/camera";
  10708. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  10709. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10710. import { AbstractScene } from "babylonjs/abstractScene";
  10711. import { Mesh } from "babylonjs/Meshes/mesh";
  10712. /**
  10713. * Groups all the scene component constants in one place to ease maintenance.
  10714. * @hidden
  10715. */
  10716. export class SceneComponentConstants {
  10717. static readonly NAME_EFFECTLAYER: string;
  10718. static readonly NAME_LAYER: string;
  10719. static readonly NAME_LENSFLARESYSTEM: string;
  10720. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10721. static readonly NAME_PARTICLESYSTEM: string;
  10722. static readonly NAME_GAMEPAD: string;
  10723. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10724. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10725. static readonly NAME_DEPTHRENDERER: string;
  10726. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10727. static readonly NAME_SPRITE: string;
  10728. static readonly NAME_OUTLINERENDERER: string;
  10729. static readonly NAME_PROCEDURALTEXTURE: string;
  10730. static readonly NAME_SHADOWGENERATOR: string;
  10731. static readonly NAME_OCTREE: string;
  10732. static readonly NAME_PHYSICSENGINE: string;
  10733. static readonly NAME_AUDIO: string;
  10734. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10735. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10736. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10737. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10738. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10739. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10740. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10741. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10742. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10743. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10744. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10745. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10746. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10747. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10748. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10749. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10750. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10751. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10752. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10753. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10754. static readonly STEP_AFTERRENDER_AUDIO: number;
  10755. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10756. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10757. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10758. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10759. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10760. static readonly STEP_POINTERMOVE_SPRITE: number;
  10761. static readonly STEP_POINTERDOWN_SPRITE: number;
  10762. static readonly STEP_POINTERUP_SPRITE: number;
  10763. }
  10764. /**
  10765. * This represents a scene component.
  10766. *
  10767. * This is used to decouple the dependency the scene is having on the different workloads like
  10768. * layers, post processes...
  10769. */
  10770. export interface ISceneComponent {
  10771. /**
  10772. * The name of the component. Each component must have a unique name.
  10773. */
  10774. name: string;
  10775. /**
  10776. * The scene the component belongs to.
  10777. */
  10778. scene: Scene;
  10779. /**
  10780. * Register the component to one instance of a scene.
  10781. */
  10782. register(): void;
  10783. /**
  10784. * Rebuilds the elements related to this component in case of
  10785. * context lost for instance.
  10786. */
  10787. rebuild(): void;
  10788. /**
  10789. * Disposes the component and the associated ressources.
  10790. */
  10791. dispose(): void;
  10792. }
  10793. /**
  10794. * This represents a SERIALIZABLE scene component.
  10795. *
  10796. * This extends Scene Component to add Serialization methods on top.
  10797. */
  10798. export interface ISceneSerializableComponent extends ISceneComponent {
  10799. /**
  10800. * Adds all the elements from the container to the scene
  10801. * @param container the container holding the elements
  10802. */
  10803. addFromContainer(container: AbstractScene): void;
  10804. /**
  10805. * Removes all the elements in the container from the scene
  10806. * @param container contains the elements to remove
  10807. * @param dispose if the removed element should be disposed (default: false)
  10808. */
  10809. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10810. /**
  10811. * Serializes the component data to the specified json object
  10812. * @param serializationObject The object to serialize to
  10813. */
  10814. serialize(serializationObject: any): void;
  10815. }
  10816. /**
  10817. * Strong typing of a Mesh related stage step action
  10818. */
  10819. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10820. /**
  10821. * Strong typing of a Evaluate Sub Mesh related stage step action
  10822. */
  10823. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10824. /**
  10825. * Strong typing of a Active Mesh related stage step action
  10826. */
  10827. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10828. /**
  10829. * Strong typing of a Camera related stage step action
  10830. */
  10831. export type CameraStageAction = (camera: Camera) => void;
  10832. /**
  10833. * Strong typing of a Camera Frame buffer related stage step action
  10834. */
  10835. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10836. /**
  10837. * Strong typing of a Render Target related stage step action
  10838. */
  10839. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10840. /**
  10841. * Strong typing of a RenderingGroup related stage step action
  10842. */
  10843. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10844. /**
  10845. * Strong typing of a Mesh Render related stage step action
  10846. */
  10847. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10848. /**
  10849. * Strong typing of a simple stage step action
  10850. */
  10851. export type SimpleStageAction = () => void;
  10852. /**
  10853. * Strong typing of a render target action.
  10854. */
  10855. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10856. /**
  10857. * Strong typing of a pointer move action.
  10858. */
  10859. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10860. /**
  10861. * Strong typing of a pointer up/down action.
  10862. */
  10863. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10864. /**
  10865. * Representation of a stage in the scene (Basically a list of ordered steps)
  10866. * @hidden
  10867. */
  10868. export class Stage<T extends Function> extends Array<{
  10869. index: number;
  10870. component: ISceneComponent;
  10871. action: T;
  10872. }> {
  10873. /**
  10874. * Hide ctor from the rest of the world.
  10875. * @param items The items to add.
  10876. */
  10877. private constructor();
  10878. /**
  10879. * Creates a new Stage.
  10880. * @returns A new instance of a Stage
  10881. */
  10882. static Create<T extends Function>(): Stage<T>;
  10883. /**
  10884. * Registers a step in an ordered way in the targeted stage.
  10885. * @param index Defines the position to register the step in
  10886. * @param component Defines the component attached to the step
  10887. * @param action Defines the action to launch during the step
  10888. */
  10889. registerStep(index: number, component: ISceneComponent, action: T): void;
  10890. /**
  10891. * Clears all the steps from the stage.
  10892. */
  10893. clear(): void;
  10894. }
  10895. }
  10896. declare module "babylonjs/Sprites/spriteSceneComponent" {
  10897. import { Nullable } from "babylonjs/types";
  10898. import { Observable } from "babylonjs/Misc/observable";
  10899. import { Scene } from "babylonjs/scene";
  10900. import { Sprite } from "babylonjs/Sprites/sprite";
  10901. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  10902. import { Ray } from "babylonjs/Culling/ray";
  10903. import { Camera } from "babylonjs/Cameras/camera";
  10904. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10905. import { ISceneComponent } from "babylonjs/sceneComponent";
  10906. module "babylonjs/scene" {
  10907. interface Scene {
  10908. /** @hidden */
  10909. _pointerOverSprite: Nullable<Sprite>;
  10910. /** @hidden */
  10911. _pickedDownSprite: Nullable<Sprite>;
  10912. /** @hidden */
  10913. _tempSpritePickingRay: Nullable<Ray>;
  10914. /**
  10915. * All of the sprite managers added to this scene
  10916. * @see http://doc.babylonjs.com/babylon101/sprites
  10917. */
  10918. spriteManagers: Array<ISpriteManager>;
  10919. /**
  10920. * An event triggered when sprites rendering is about to start
  10921. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10922. */
  10923. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10924. /**
  10925. * An event triggered when sprites rendering is done
  10926. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10927. */
  10928. onAfterSpritesRenderingObservable: Observable<Scene>;
  10929. /** @hidden */
  10930. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10931. /** Launch a ray to try to pick a sprite in the scene
  10932. * @param x position on screen
  10933. * @param y position on screen
  10934. * @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
  10935. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10936. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10937. * @returns a PickingInfo
  10938. */
  10939. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10940. /** Use the given ray to pick a sprite in the scene
  10941. * @param ray The ray (in world space) to use to pick meshes
  10942. * @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
  10943. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10944. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10945. * @returns a PickingInfo
  10946. */
  10947. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10948. /** @hidden */
  10949. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10950. /** Launch a ray to try to pick sprites in the scene
  10951. * @param x position on screen
  10952. * @param y position on screen
  10953. * @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
  10954. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10955. * @returns a PickingInfo array
  10956. */
  10957. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10958. /** Use the given ray to pick sprites in the scene
  10959. * @param ray The ray (in world space) to use to pick meshes
  10960. * @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
  10961. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10962. * @returns a PickingInfo array
  10963. */
  10964. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10965. /**
  10966. * Force the sprite under the pointer
  10967. * @param sprite defines the sprite to use
  10968. */
  10969. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10970. /**
  10971. * Gets the sprite under the pointer
  10972. * @returns a Sprite or null if no sprite is under the pointer
  10973. */
  10974. getPointerOverSprite(): Nullable<Sprite>;
  10975. }
  10976. }
  10977. /**
  10978. * Defines the sprite scene component responsible to manage sprites
  10979. * in a given scene.
  10980. */
  10981. export class SpriteSceneComponent implements ISceneComponent {
  10982. /**
  10983. * The component name helpfull to identify the component in the list of scene components.
  10984. */
  10985. readonly name: string;
  10986. /**
  10987. * The scene the component belongs to.
  10988. */
  10989. scene: Scene;
  10990. /** @hidden */
  10991. private _spritePredicate;
  10992. /**
  10993. * Creates a new instance of the component for the given scene
  10994. * @param scene Defines the scene to register the component in
  10995. */
  10996. constructor(scene: Scene);
  10997. /**
  10998. * Registers the component in a given scene
  10999. */
  11000. register(): void;
  11001. /**
  11002. * Rebuilds the elements related to this component in case of
  11003. * context lost for instance.
  11004. */
  11005. rebuild(): void;
  11006. /**
  11007. * Disposes the component and the associated ressources.
  11008. */
  11009. dispose(): void;
  11010. private _pickSpriteButKeepRay;
  11011. private _pointerMove;
  11012. private _pointerDown;
  11013. private _pointerUp;
  11014. }
  11015. }
  11016. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11017. /** @hidden */
  11018. export var fogFragmentDeclaration: {
  11019. name: string;
  11020. shader: string;
  11021. };
  11022. }
  11023. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11024. /** @hidden */
  11025. export var fogFragment: {
  11026. name: string;
  11027. shader: string;
  11028. };
  11029. }
  11030. declare module "babylonjs/Shaders/sprites.fragment" {
  11031. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11032. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11033. /** @hidden */
  11034. export var spritesPixelShader: {
  11035. name: string;
  11036. shader: string;
  11037. };
  11038. }
  11039. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11040. /** @hidden */
  11041. export var fogVertexDeclaration: {
  11042. name: string;
  11043. shader: string;
  11044. };
  11045. }
  11046. declare module "babylonjs/Shaders/sprites.vertex" {
  11047. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11048. /** @hidden */
  11049. export var spritesVertexShader: {
  11050. name: string;
  11051. shader: string;
  11052. };
  11053. }
  11054. declare module "babylonjs/Sprites/spriteManager" {
  11055. import { IDisposable, Scene } from "babylonjs/scene";
  11056. import { Nullable } from "babylonjs/types";
  11057. import { Observable } from "babylonjs/Misc/observable";
  11058. import { Sprite } from "babylonjs/Sprites/sprite";
  11059. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11060. import { Camera } from "babylonjs/Cameras/camera";
  11061. import { Texture } from "babylonjs/Materials/Textures/texture";
  11062. import "babylonjs/Shaders/sprites.fragment";
  11063. import "babylonjs/Shaders/sprites.vertex";
  11064. import { Ray } from "babylonjs/Culling/ray";
  11065. /**
  11066. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11067. */
  11068. export interface ISpriteManager extends IDisposable {
  11069. /**
  11070. * Gets manager's name
  11071. */
  11072. name: string;
  11073. /**
  11074. * Restricts the camera to viewing objects with the same layerMask.
  11075. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11076. */
  11077. layerMask: number;
  11078. /**
  11079. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11080. */
  11081. isPickable: boolean;
  11082. /**
  11083. * Gets the hosting scene
  11084. */
  11085. scene: Scene;
  11086. /**
  11087. * Specifies the rendering group id for this mesh (0 by default)
  11088. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11089. */
  11090. renderingGroupId: number;
  11091. /**
  11092. * Defines the list of sprites managed by the manager.
  11093. */
  11094. sprites: Array<Sprite>;
  11095. /**
  11096. * Gets or sets the spritesheet texture
  11097. */
  11098. texture: Texture;
  11099. /** Defines the default width of a cell in the spritesheet */
  11100. cellWidth: number;
  11101. /** Defines the default height of a cell in the spritesheet */
  11102. cellHeight: number;
  11103. /**
  11104. * Tests the intersection of a sprite with a specific ray.
  11105. * @param ray The ray we are sending to test the collision
  11106. * @param camera The camera space we are sending rays in
  11107. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11108. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11109. * @returns picking info or null.
  11110. */
  11111. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11112. /**
  11113. * Intersects the sprites with a ray
  11114. * @param ray defines the ray to intersect with
  11115. * @param camera defines the current active camera
  11116. * @param predicate defines a predicate used to select candidate sprites
  11117. * @returns null if no hit or a PickingInfo array
  11118. */
  11119. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11120. /**
  11121. * Renders the list of sprites on screen.
  11122. */
  11123. render(): void;
  11124. }
  11125. /**
  11126. * Class used to manage multiple sprites on the same spritesheet
  11127. * @see http://doc.babylonjs.com/babylon101/sprites
  11128. */
  11129. export class SpriteManager implements ISpriteManager {
  11130. /** defines the manager's name */
  11131. name: string;
  11132. /** Define the Url to load snippets */
  11133. static SnippetUrl: string;
  11134. /** Snippet ID if the manager was created from the snippet server */
  11135. snippetId: string;
  11136. /** Gets the list of sprites */
  11137. sprites: Sprite[];
  11138. /** Gets or sets the rendering group id (0 by default) */
  11139. renderingGroupId: number;
  11140. /** Gets or sets camera layer mask */
  11141. layerMask: number;
  11142. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11143. fogEnabled: boolean;
  11144. /** Gets or sets a boolean indicating if the sprites are pickable */
  11145. isPickable: boolean;
  11146. /** Defines the default width of a cell in the spritesheet */
  11147. cellWidth: number;
  11148. /** Defines the default height of a cell in the spritesheet */
  11149. cellHeight: number;
  11150. /** Associative array from JSON sprite data file */
  11151. private _cellData;
  11152. /** Array of sprite names from JSON sprite data file */
  11153. private _spriteMap;
  11154. /** True when packed cell data from JSON file is ready*/
  11155. private _packedAndReady;
  11156. private _textureContent;
  11157. /**
  11158. * An event triggered when the manager is disposed.
  11159. */
  11160. onDisposeObservable: Observable<SpriteManager>;
  11161. private _onDisposeObserver;
  11162. /**
  11163. * Callback called when the manager is disposed
  11164. */
  11165. set onDispose(callback: () => void);
  11166. private _capacity;
  11167. private _fromPacked;
  11168. private _spriteTexture;
  11169. private _epsilon;
  11170. private _scene;
  11171. private _vertexData;
  11172. private _buffer;
  11173. private _vertexBuffers;
  11174. private _indexBuffer;
  11175. private _effectBase;
  11176. private _effectFog;
  11177. /**
  11178. * Gets or sets the unique id of the sprite
  11179. */
  11180. uniqueId: number;
  11181. /**
  11182. * Gets the array of sprites
  11183. */
  11184. get children(): Sprite[];
  11185. /**
  11186. * Gets the hosting scene
  11187. */
  11188. get scene(): Scene;
  11189. /**
  11190. * Gets the capacity of the manager
  11191. */
  11192. get capacity(): number;
  11193. /**
  11194. * Gets or sets the spritesheet texture
  11195. */
  11196. get texture(): Texture;
  11197. set texture(value: Texture);
  11198. private _blendMode;
  11199. /**
  11200. * Blend mode use to render the particle, it can be any of
  11201. * the static Constants.ALPHA_x properties provided in this class.
  11202. * Default value is Constants.ALPHA_COMBINE
  11203. */
  11204. get blendMode(): number;
  11205. set blendMode(blendMode: number);
  11206. /** Disables writing to the depth buffer when rendering the sprites.
  11207. * It can be handy to disable depth writing when using textures without alpha channel
  11208. * and setting some specific blend modes.
  11209. */
  11210. disableDepthWrite: boolean;
  11211. /**
  11212. * Creates a new sprite manager
  11213. * @param name defines the manager's name
  11214. * @param imgUrl defines the sprite sheet url
  11215. * @param capacity defines the maximum allowed number of sprites
  11216. * @param cellSize defines the size of a sprite cell
  11217. * @param scene defines the hosting scene
  11218. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11219. * @param samplingMode defines the smapling mode to use with spritesheet
  11220. * @param fromPacked set to false; do not alter
  11221. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11222. */
  11223. constructor(
  11224. /** defines the manager's name */
  11225. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11226. /**
  11227. * Returns the string "SpriteManager"
  11228. * @returns "SpriteManager"
  11229. */
  11230. getClassName(): string;
  11231. private _makePacked;
  11232. private _appendSpriteVertex;
  11233. private _checkTextureAlpha;
  11234. /**
  11235. * Intersects the sprites with a ray
  11236. * @param ray defines the ray to intersect with
  11237. * @param camera defines the current active camera
  11238. * @param predicate defines a predicate used to select candidate sprites
  11239. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11240. * @returns null if no hit or a PickingInfo
  11241. */
  11242. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11243. /**
  11244. * Intersects the sprites with a ray
  11245. * @param ray defines the ray to intersect with
  11246. * @param camera defines the current active camera
  11247. * @param predicate defines a predicate used to select candidate sprites
  11248. * @returns null if no hit or a PickingInfo array
  11249. */
  11250. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11251. /**
  11252. * Render all child sprites
  11253. */
  11254. render(): void;
  11255. /**
  11256. * Release associated resources
  11257. */
  11258. dispose(): void;
  11259. /**
  11260. * Serializes the sprite manager to a JSON object
  11261. * @param serializeTexture defines if the texture must be serialized as well
  11262. * @returns the JSON object
  11263. */
  11264. serialize(serializeTexture?: boolean): any;
  11265. /**
  11266. * Parses a JSON object to create a new sprite manager.
  11267. * @param parsedManager The JSON object to parse
  11268. * @param scene The scene to create the sprite managerin
  11269. * @param rootUrl The root url to use to load external dependencies like texture
  11270. * @returns the new sprite manager
  11271. */
  11272. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11273. /**
  11274. * Creates a sprite manager from a snippet saved in a remote file
  11275. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11276. * @param url defines the url to load from
  11277. * @param scene defines the hosting scene
  11278. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11279. * @returns a promise that will resolve to the new sprite manager
  11280. */
  11281. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11282. /**
  11283. * Creates a sprite manager from a snippet saved by the sprite editor
  11284. * @param snippetId defines the snippet to load
  11285. * @param scene defines the hosting scene
  11286. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11287. * @returns a promise that will resolve to the new sprite manager
  11288. */
  11289. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11290. }
  11291. }
  11292. declare module "babylonjs/Misc/gradients" {
  11293. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  11294. /** Interface used by value gradients (color, factor, ...) */
  11295. export interface IValueGradient {
  11296. /**
  11297. * Gets or sets the gradient value (between 0 and 1)
  11298. */
  11299. gradient: number;
  11300. }
  11301. /** Class used to store color4 gradient */
  11302. export class ColorGradient implements IValueGradient {
  11303. /**
  11304. * Gets or sets the gradient value (between 0 and 1)
  11305. */
  11306. gradient: number;
  11307. /**
  11308. * Gets or sets first associated color
  11309. */
  11310. color1: Color4;
  11311. /**
  11312. * Gets or sets second associated color
  11313. */
  11314. color2?: Color4 | undefined;
  11315. /**
  11316. * Creates a new color4 gradient
  11317. * @param gradient gets or sets the gradient value (between 0 and 1)
  11318. * @param color1 gets or sets first associated color
  11319. * @param color2 gets or sets first second color
  11320. */
  11321. constructor(
  11322. /**
  11323. * Gets or sets the gradient value (between 0 and 1)
  11324. */
  11325. gradient: number,
  11326. /**
  11327. * Gets or sets first associated color
  11328. */
  11329. color1: Color4,
  11330. /**
  11331. * Gets or sets second associated color
  11332. */
  11333. color2?: Color4 | undefined);
  11334. /**
  11335. * Will get a color picked randomly between color1 and color2.
  11336. * If color2 is undefined then color1 will be used
  11337. * @param result defines the target Color4 to store the result in
  11338. */
  11339. getColorToRef(result: Color4): void;
  11340. }
  11341. /** Class used to store color 3 gradient */
  11342. export class Color3Gradient implements IValueGradient {
  11343. /**
  11344. * Gets or sets the gradient value (between 0 and 1)
  11345. */
  11346. gradient: number;
  11347. /**
  11348. * Gets or sets the associated color
  11349. */
  11350. color: Color3;
  11351. /**
  11352. * Creates a new color3 gradient
  11353. * @param gradient gets or sets the gradient value (between 0 and 1)
  11354. * @param color gets or sets associated color
  11355. */
  11356. constructor(
  11357. /**
  11358. * Gets or sets the gradient value (between 0 and 1)
  11359. */
  11360. gradient: number,
  11361. /**
  11362. * Gets or sets the associated color
  11363. */
  11364. color: Color3);
  11365. }
  11366. /** Class used to store factor gradient */
  11367. export class FactorGradient implements IValueGradient {
  11368. /**
  11369. * Gets or sets the gradient value (between 0 and 1)
  11370. */
  11371. gradient: number;
  11372. /**
  11373. * Gets or sets first associated factor
  11374. */
  11375. factor1: number;
  11376. /**
  11377. * Gets or sets second associated factor
  11378. */
  11379. factor2?: number | undefined;
  11380. /**
  11381. * Creates a new factor gradient
  11382. * @param gradient gets or sets the gradient value (between 0 and 1)
  11383. * @param factor1 gets or sets first associated factor
  11384. * @param factor2 gets or sets second associated factor
  11385. */
  11386. constructor(
  11387. /**
  11388. * Gets or sets the gradient value (between 0 and 1)
  11389. */
  11390. gradient: number,
  11391. /**
  11392. * Gets or sets first associated factor
  11393. */
  11394. factor1: number,
  11395. /**
  11396. * Gets or sets second associated factor
  11397. */
  11398. factor2?: number | undefined);
  11399. /**
  11400. * Will get a number picked randomly between factor1 and factor2.
  11401. * If factor2 is undefined then factor1 will be used
  11402. * @returns the picked number
  11403. */
  11404. getFactor(): number;
  11405. }
  11406. /**
  11407. * Helper used to simplify some generic gradient tasks
  11408. */
  11409. export class GradientHelper {
  11410. /**
  11411. * Gets the current gradient from an array of IValueGradient
  11412. * @param ratio defines the current ratio to get
  11413. * @param gradients defines the array of IValueGradient
  11414. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11415. */
  11416. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11417. }
  11418. }
  11419. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  11420. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11421. import { Nullable } from "babylonjs/types";
  11422. module "babylonjs/Engines/thinEngine" {
  11423. interface ThinEngine {
  11424. /**
  11425. * Creates a dynamic texture
  11426. * @param width defines the width of the texture
  11427. * @param height defines the height of the texture
  11428. * @param generateMipMaps defines if the engine should generate the mip levels
  11429. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11430. * @returns the dynamic texture inside an InternalTexture
  11431. */
  11432. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  11433. /**
  11434. * Update the content of a dynamic texture
  11435. * @param texture defines the texture to update
  11436. * @param canvas defines the canvas containing the source
  11437. * @param invertY defines if data must be stored with Y axis inverted
  11438. * @param premulAlpha defines if alpha is stored as premultiplied
  11439. * @param format defines the format of the data
  11440. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  11441. */
  11442. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  11443. }
  11444. }
  11445. }
  11446. declare module "babylonjs/Misc/canvasGenerator" {
  11447. /**
  11448. * Helper class used to generate a canvas to manipulate images
  11449. */
  11450. export class CanvasGenerator {
  11451. /**
  11452. * Create a new canvas (or offscreen canvas depending on the context)
  11453. * @param width defines the expected width
  11454. * @param height defines the expected height
  11455. * @return a new canvas or offscreen canvas
  11456. */
  11457. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  11458. }
  11459. }
  11460. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  11461. import { Scene } from "babylonjs/scene";
  11462. import { Texture } from "babylonjs/Materials/Textures/texture";
  11463. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  11464. /**
  11465. * A class extending Texture allowing drawing on a texture
  11466. * @see http://doc.babylonjs.com/how_to/dynamictexture
  11467. */
  11468. export class DynamicTexture extends Texture {
  11469. private _generateMipMaps;
  11470. private _canvas;
  11471. private _context;
  11472. /**
  11473. * Creates a DynamicTexture
  11474. * @param name defines the name of the texture
  11475. * @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
  11476. * @param scene defines the scene where you want the texture
  11477. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  11478. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  11479. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  11480. */
  11481. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  11482. /**
  11483. * Get the current class name of the texture useful for serialization or dynamic coding.
  11484. * @returns "DynamicTexture"
  11485. */
  11486. getClassName(): string;
  11487. /**
  11488. * Gets the current state of canRescale
  11489. */
  11490. get canRescale(): boolean;
  11491. private _recreate;
  11492. /**
  11493. * Scales the texture
  11494. * @param ratio the scale factor to apply to both width and height
  11495. */
  11496. scale(ratio: number): void;
  11497. /**
  11498. * Resizes the texture
  11499. * @param width the new width
  11500. * @param height the new height
  11501. */
  11502. scaleTo(width: number, height: number): void;
  11503. /**
  11504. * Gets the context of the canvas used by the texture
  11505. * @returns the canvas context of the dynamic texture
  11506. */
  11507. getContext(): CanvasRenderingContext2D;
  11508. /**
  11509. * Clears the texture
  11510. */
  11511. clear(): void;
  11512. /**
  11513. * Updates the texture
  11514. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  11515. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  11516. */
  11517. update(invertY?: boolean, premulAlpha?: boolean): void;
  11518. /**
  11519. * Draws text onto the texture
  11520. * @param text defines the text to be drawn
  11521. * @param x defines the placement of the text from the left
  11522. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  11523. * @param font defines the font to be used with font-style, font-size, font-name
  11524. * @param color defines the color used for the text
  11525. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  11526. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  11527. * @param update defines whether texture is immediately update (default is true)
  11528. */
  11529. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  11530. /**
  11531. * Clones the texture
  11532. * @returns the clone of the texture.
  11533. */
  11534. clone(): DynamicTexture;
  11535. /**
  11536. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  11537. * @returns a serialized dynamic texture object
  11538. */
  11539. serialize(): any;
  11540. /** @hidden */
  11541. _rebuild(): void;
  11542. }
  11543. }
  11544. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  11545. import { Nullable } from "babylonjs/types";
  11546. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11547. import { Scene } from "babylonjs/scene";
  11548. module "babylonjs/Engines/thinEngine" {
  11549. interface ThinEngine {
  11550. /**
  11551. * Creates a raw texture
  11552. * @param data defines the data to store in the texture
  11553. * @param width defines the width of the texture
  11554. * @param height defines the height of the texture
  11555. * @param format defines the format of the data
  11556. * @param generateMipMaps defines if the engine should generate the mip levels
  11557. * @param invertY defines if data must be stored with Y axis inverted
  11558. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11559. * @param compression defines the compression used (null by default)
  11560. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11561. * @returns the raw texture inside an InternalTexture
  11562. */
  11563. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11564. /**
  11565. * Update a raw texture
  11566. * @param texture defines the texture to update
  11567. * @param data defines the data to store in the texture
  11568. * @param format defines the format of the data
  11569. * @param invertY defines if data must be stored with Y axis inverted
  11570. */
  11571. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11572. /**
  11573. * Update a raw texture
  11574. * @param texture defines the texture to update
  11575. * @param data defines the data to store in the texture
  11576. * @param format defines the format of the data
  11577. * @param invertY defines if data must be stored with Y axis inverted
  11578. * @param compression defines the compression used (null by default)
  11579. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11580. */
  11581. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11582. /**
  11583. * Creates a new raw cube texture
  11584. * @param data defines the array of data to use to create each face
  11585. * @param size defines the size of the textures
  11586. * @param format defines the format of the data
  11587. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11588. * @param generateMipMaps defines if the engine should generate the mip levels
  11589. * @param invertY defines if data must be stored with Y axis inverted
  11590. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11591. * @param compression defines the compression used (null by default)
  11592. * @returns the cube texture as an InternalTexture
  11593. */
  11594. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11595. /**
  11596. * Update a raw cube texture
  11597. * @param texture defines the texture to udpdate
  11598. * @param data defines the data to store
  11599. * @param format defines the data format
  11600. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11601. * @param invertY defines if data must be stored with Y axis inverted
  11602. */
  11603. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11604. /**
  11605. * Update a raw cube texture
  11606. * @param texture defines the texture to udpdate
  11607. * @param data defines the data to store
  11608. * @param format defines the data format
  11609. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11610. * @param invertY defines if data must be stored with Y axis inverted
  11611. * @param compression defines the compression used (null by default)
  11612. */
  11613. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11614. /**
  11615. * Update a raw cube texture
  11616. * @param texture defines the texture to udpdate
  11617. * @param data defines the data to store
  11618. * @param format defines the data format
  11619. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11620. * @param invertY defines if data must be stored with Y axis inverted
  11621. * @param compression defines the compression used (null by default)
  11622. * @param level defines which level of the texture to update
  11623. */
  11624. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11625. /**
  11626. * Creates a new raw cube texture from a specified url
  11627. * @param url defines the url where the data is located
  11628. * @param scene defines the current scene
  11629. * @param size defines the size of the textures
  11630. * @param format defines the format of the data
  11631. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11632. * @param noMipmap defines if the engine should avoid generating the mip levels
  11633. * @param callback defines a callback used to extract texture data from loaded data
  11634. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11635. * @param onLoad defines a callback called when texture is loaded
  11636. * @param onError defines a callback called if there is an error
  11637. * @returns the cube texture as an InternalTexture
  11638. */
  11639. 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;
  11640. /**
  11641. * Creates a new raw cube texture from a specified url
  11642. * @param url defines the url where the data is located
  11643. * @param scene defines the current scene
  11644. * @param size defines the size of the textures
  11645. * @param format defines the format of the data
  11646. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11647. * @param noMipmap defines if the engine should avoid generating the mip levels
  11648. * @param callback defines a callback used to extract texture data from loaded data
  11649. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11650. * @param onLoad defines a callback called when texture is loaded
  11651. * @param onError defines a callback called if there is an error
  11652. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11653. * @param invertY defines if data must be stored with Y axis inverted
  11654. * @returns the cube texture as an InternalTexture
  11655. */
  11656. 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;
  11657. /**
  11658. * Creates a new raw 3D texture
  11659. * @param data defines the data used to create the texture
  11660. * @param width defines the width of the texture
  11661. * @param height defines the height of the texture
  11662. * @param depth defines the depth of the texture
  11663. * @param format defines the format of the texture
  11664. * @param generateMipMaps defines if the engine must generate mip levels
  11665. * @param invertY defines if data must be stored with Y axis inverted
  11666. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11667. * @param compression defines the compressed used (can be null)
  11668. * @param textureType defines the compressed used (can be null)
  11669. * @returns a new raw 3D texture (stored in an InternalTexture)
  11670. */
  11671. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11672. /**
  11673. * Update a raw 3D texture
  11674. * @param texture defines the texture to update
  11675. * @param data defines the data to store
  11676. * @param format defines the data format
  11677. * @param invertY defines if data must be stored with Y axis inverted
  11678. */
  11679. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11680. /**
  11681. * Update a raw 3D texture
  11682. * @param texture defines the texture to update
  11683. * @param data defines the data to store
  11684. * @param format defines the data format
  11685. * @param invertY defines if data must be stored with Y axis inverted
  11686. * @param compression defines the used compression (can be null)
  11687. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11688. */
  11689. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11690. /**
  11691. * Creates a new raw 2D array texture
  11692. * @param data defines the data used to create the texture
  11693. * @param width defines the width of the texture
  11694. * @param height defines the height of the texture
  11695. * @param depth defines the number of layers of the texture
  11696. * @param format defines the format of the texture
  11697. * @param generateMipMaps defines if the engine must generate mip levels
  11698. * @param invertY defines if data must be stored with Y axis inverted
  11699. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11700. * @param compression defines the compressed used (can be null)
  11701. * @param textureType defines the compressed used (can be null)
  11702. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11703. */
  11704. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11705. /**
  11706. * Update a raw 2D array texture
  11707. * @param texture defines the texture to update
  11708. * @param data defines the data to store
  11709. * @param format defines the data format
  11710. * @param invertY defines if data must be stored with Y axis inverted
  11711. */
  11712. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11713. /**
  11714. * Update a raw 2D array texture
  11715. * @param texture defines the texture to update
  11716. * @param data defines the data to store
  11717. * @param format defines the data format
  11718. * @param invertY defines if data must be stored with Y axis inverted
  11719. * @param compression defines the used compression (can be null)
  11720. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11721. */
  11722. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11723. }
  11724. }
  11725. }
  11726. declare module "babylonjs/Materials/Textures/rawTexture" {
  11727. import { Scene } from "babylonjs/scene";
  11728. import { Texture } from "babylonjs/Materials/Textures/texture";
  11729. import "babylonjs/Engines/Extensions/engine.rawTexture";
  11730. /**
  11731. * Raw texture can help creating a texture directly from an array of data.
  11732. * This can be super useful if you either get the data from an uncompressed source or
  11733. * if you wish to create your texture pixel by pixel.
  11734. */
  11735. export class RawTexture extends Texture {
  11736. /**
  11737. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11738. */
  11739. format: number;
  11740. /**
  11741. * Instantiates a new RawTexture.
  11742. * Raw texture can help creating a texture directly from an array of data.
  11743. * This can be super useful if you either get the data from an uncompressed source or
  11744. * if you wish to create your texture pixel by pixel.
  11745. * @param data define the array of data to use to create the texture
  11746. * @param width define the width of the texture
  11747. * @param height define the height of the texture
  11748. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11749. * @param scene define the scene the texture belongs to
  11750. * @param generateMipMaps define whether mip maps should be generated or not
  11751. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11752. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11753. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11754. */
  11755. constructor(data: ArrayBufferView, width: number, height: number,
  11756. /**
  11757. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11758. */
  11759. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11760. /**
  11761. * Updates the texture underlying data.
  11762. * @param data Define the new data of the texture
  11763. */
  11764. update(data: ArrayBufferView): void;
  11765. /**
  11766. * Creates a luminance texture from some data.
  11767. * @param data Define the texture data
  11768. * @param width Define the width of the texture
  11769. * @param height Define the height of the texture
  11770. * @param scene Define the scene the texture belongs to
  11771. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11772. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11773. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11774. * @returns the luminance texture
  11775. */
  11776. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11777. /**
  11778. * Creates a luminance alpha texture from some data.
  11779. * @param data Define the texture data
  11780. * @param width Define the width of the texture
  11781. * @param height Define the height of the texture
  11782. * @param scene Define the scene the texture belongs to
  11783. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11784. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11785. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11786. * @returns the luminance alpha texture
  11787. */
  11788. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11789. /**
  11790. * Creates an alpha texture from some data.
  11791. * @param data Define the texture data
  11792. * @param width Define the width of the texture
  11793. * @param height Define the height of the texture
  11794. * @param scene Define the scene the texture belongs to
  11795. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11796. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11797. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11798. * @returns the alpha texture
  11799. */
  11800. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11801. /**
  11802. * Creates a RGB texture from some data.
  11803. * @param data Define the texture data
  11804. * @param width Define the width of the texture
  11805. * @param height Define the height of the texture
  11806. * @param scene Define the scene the texture belongs to
  11807. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11808. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11809. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11810. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11811. * @returns the RGB alpha texture
  11812. */
  11813. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11814. /**
  11815. * Creates a RGBA texture from some data.
  11816. * @param data Define the texture data
  11817. * @param width Define the width of the texture
  11818. * @param height Define the height of the texture
  11819. * @param scene Define the scene the texture belongs to
  11820. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11821. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11822. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11823. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11824. * @returns the RGBA texture
  11825. */
  11826. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11827. /**
  11828. * Creates a R texture from some data.
  11829. * @param data Define the texture data
  11830. * @param width Define the width of the texture
  11831. * @param height Define the height of the texture
  11832. * @param scene Define the scene the texture belongs to
  11833. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11834. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11835. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11836. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11837. * @returns the R texture
  11838. */
  11839. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11840. }
  11841. }
  11842. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  11843. import { Scene } from "babylonjs/scene";
  11844. import { ISceneComponent } from "babylonjs/sceneComponent";
  11845. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  11846. module "babylonjs/abstractScene" {
  11847. interface AbstractScene {
  11848. /**
  11849. * The list of procedural textures added to the scene
  11850. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11851. */
  11852. proceduralTextures: Array<ProceduralTexture>;
  11853. }
  11854. }
  11855. /**
  11856. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11857. * in a given scene.
  11858. */
  11859. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11860. /**
  11861. * The component name helpfull to identify the component in the list of scene components.
  11862. */
  11863. readonly name: string;
  11864. /**
  11865. * The scene the component belongs to.
  11866. */
  11867. scene: Scene;
  11868. /**
  11869. * Creates a new instance of the component for the given scene
  11870. * @param scene Defines the scene to register the component in
  11871. */
  11872. constructor(scene: Scene);
  11873. /**
  11874. * Registers the component in a given scene
  11875. */
  11876. register(): void;
  11877. /**
  11878. * Rebuilds the elements related to this component in case of
  11879. * context lost for instance.
  11880. */
  11881. rebuild(): void;
  11882. /**
  11883. * Disposes the component and the associated ressources.
  11884. */
  11885. dispose(): void;
  11886. private _beforeClear;
  11887. }
  11888. }
  11889. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  11890. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11891. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  11892. module "babylonjs/Engines/thinEngine" {
  11893. interface ThinEngine {
  11894. /**
  11895. * Creates a new render target cube texture
  11896. * @param size defines the size of the texture
  11897. * @param options defines the options used to create the texture
  11898. * @returns a new render target cube texture stored in an InternalTexture
  11899. */
  11900. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11901. }
  11902. }
  11903. }
  11904. declare module "babylonjs/Shaders/procedural.vertex" {
  11905. /** @hidden */
  11906. export var proceduralVertexShader: {
  11907. name: string;
  11908. shader: string;
  11909. };
  11910. }
  11911. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  11912. import { Observable } from "babylonjs/Misc/observable";
  11913. import { Nullable } from "babylonjs/types";
  11914. import { Scene } from "babylonjs/scene";
  11915. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11916. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  11917. import { Effect } from "babylonjs/Materials/effect";
  11918. import { Texture } from "babylonjs/Materials/Textures/texture";
  11919. import "babylonjs/Engines/Extensions/engine.renderTarget";
  11920. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  11921. import "babylonjs/Shaders/procedural.vertex";
  11922. /**
  11923. * 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.
  11924. * This is the base class of any Procedural texture and contains most of the shareable code.
  11925. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11926. */
  11927. export class ProceduralTexture extends Texture {
  11928. isCube: boolean;
  11929. /**
  11930. * Define if the texture is enabled or not (disabled texture will not render)
  11931. */
  11932. isEnabled: boolean;
  11933. /**
  11934. * Define if the texture must be cleared before rendering (default is true)
  11935. */
  11936. autoClear: boolean;
  11937. /**
  11938. * Callback called when the texture is generated
  11939. */
  11940. onGenerated: () => void;
  11941. /**
  11942. * Event raised when the texture is generated
  11943. */
  11944. onGeneratedObservable: Observable<ProceduralTexture>;
  11945. /** @hidden */
  11946. _generateMipMaps: boolean;
  11947. /** @hidden **/
  11948. _effect: Effect;
  11949. /** @hidden */
  11950. _textures: {
  11951. [key: string]: Texture;
  11952. };
  11953. /** @hidden */
  11954. protected _fallbackTexture: Nullable<Texture>;
  11955. private _size;
  11956. private _currentRefreshId;
  11957. private _frameId;
  11958. private _refreshRate;
  11959. private _vertexBuffers;
  11960. private _indexBuffer;
  11961. private _uniforms;
  11962. private _samplers;
  11963. private _fragment;
  11964. private _floats;
  11965. private _ints;
  11966. private _floatsArrays;
  11967. private _colors3;
  11968. private _colors4;
  11969. private _vectors2;
  11970. private _vectors3;
  11971. private _matrices;
  11972. private _fallbackTextureUsed;
  11973. private _fullEngine;
  11974. private _cachedDefines;
  11975. private _contentUpdateId;
  11976. private _contentData;
  11977. /**
  11978. * Instantiates a new procedural texture.
  11979. * 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.
  11980. * This is the base class of any Procedural texture and contains most of the shareable code.
  11981. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11982. * @param name Define the name of the texture
  11983. * @param size Define the size of the texture to create
  11984. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11985. * @param scene Define the scene the texture belongs to
  11986. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11987. * @param generateMipMaps Define if the texture should creates mip maps or not
  11988. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11989. */
  11990. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11991. /**
  11992. * The effect that is created when initializing the post process.
  11993. * @returns The created effect corresponding the the postprocess.
  11994. */
  11995. getEffect(): Effect;
  11996. /**
  11997. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11998. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11999. */
  12000. getContent(): Nullable<ArrayBufferView>;
  12001. private _createIndexBuffer;
  12002. /** @hidden */
  12003. _rebuild(): void;
  12004. /**
  12005. * Resets the texture in order to recreate its associated resources.
  12006. * This can be called in case of context loss
  12007. */
  12008. reset(): void;
  12009. protected _getDefines(): string;
  12010. /**
  12011. * Is the texture ready to be used ? (rendered at least once)
  12012. * @returns true if ready, otherwise, false.
  12013. */
  12014. isReady(): boolean;
  12015. /**
  12016. * Resets the refresh counter of the texture and start bak from scratch.
  12017. * Could be useful to regenerate the texture if it is setup to render only once.
  12018. */
  12019. resetRefreshCounter(): void;
  12020. /**
  12021. * Set the fragment shader to use in order to render the texture.
  12022. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  12023. */
  12024. setFragment(fragment: any): void;
  12025. /**
  12026. * Define the refresh rate of the texture or the rendering frequency.
  12027. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  12028. */
  12029. get refreshRate(): number;
  12030. set refreshRate(value: number);
  12031. /** @hidden */
  12032. _shouldRender(): boolean;
  12033. /**
  12034. * Get the size the texture is rendering at.
  12035. * @returns the size (texture is always squared)
  12036. */
  12037. getRenderSize(): number;
  12038. /**
  12039. * Resize the texture to new value.
  12040. * @param size Define the new size the texture should have
  12041. * @param generateMipMaps Define whether the new texture should create mip maps
  12042. */
  12043. resize(size: number, generateMipMaps: boolean): void;
  12044. private _checkUniform;
  12045. /**
  12046. * Set a texture in the shader program used to render.
  12047. * @param name Define the name of the uniform samplers as defined in the shader
  12048. * @param texture Define the texture to bind to this sampler
  12049. * @return the texture itself allowing "fluent" like uniform updates
  12050. */
  12051. setTexture(name: string, texture: Texture): ProceduralTexture;
  12052. /**
  12053. * Set a float in the shader.
  12054. * @param name Define the name of the uniform as defined in the shader
  12055. * @param value Define the value to give to the uniform
  12056. * @return the texture itself allowing "fluent" like uniform updates
  12057. */
  12058. setFloat(name: string, value: number): ProceduralTexture;
  12059. /**
  12060. * Set a int in the shader.
  12061. * @param name Define the name of the uniform as defined in the shader
  12062. * @param value Define the value to give to the uniform
  12063. * @return the texture itself allowing "fluent" like uniform updates
  12064. */
  12065. setInt(name: string, value: number): ProceduralTexture;
  12066. /**
  12067. * Set an array of floats in the shader.
  12068. * @param name Define the name of the uniform as defined in the shader
  12069. * @param value Define the value to give to the uniform
  12070. * @return the texture itself allowing "fluent" like uniform updates
  12071. */
  12072. setFloats(name: string, value: number[]): ProceduralTexture;
  12073. /**
  12074. * Set a vec3 in the shader from a Color3.
  12075. * @param name Define the name of the uniform as defined in the shader
  12076. * @param value Define the value to give to the uniform
  12077. * @return the texture itself allowing "fluent" like uniform updates
  12078. */
  12079. setColor3(name: string, value: Color3): ProceduralTexture;
  12080. /**
  12081. * Set a vec4 in the shader from a Color4.
  12082. * @param name Define the name of the uniform as defined in the shader
  12083. * @param value Define the value to give to the uniform
  12084. * @return the texture itself allowing "fluent" like uniform updates
  12085. */
  12086. setColor4(name: string, value: Color4): ProceduralTexture;
  12087. /**
  12088. * Set a vec2 in the shader from a Vector2.
  12089. * @param name Define the name of the uniform as defined in the shader
  12090. * @param value Define the value to give to the uniform
  12091. * @return the texture itself allowing "fluent" like uniform updates
  12092. */
  12093. setVector2(name: string, value: Vector2): ProceduralTexture;
  12094. /**
  12095. * Set a vec3 in the shader from a Vector3.
  12096. * @param name Define the name of the uniform as defined in the shader
  12097. * @param value Define the value to give to the uniform
  12098. * @return the texture itself allowing "fluent" like uniform updates
  12099. */
  12100. setVector3(name: string, value: Vector3): ProceduralTexture;
  12101. /**
  12102. * Set a mat4 in the shader from a MAtrix.
  12103. * @param name Define the name of the uniform as defined in the shader
  12104. * @param value Define the value to give to the uniform
  12105. * @return the texture itself allowing "fluent" like uniform updates
  12106. */
  12107. setMatrix(name: string, value: Matrix): ProceduralTexture;
  12108. /**
  12109. * Render the texture to its associated render target.
  12110. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  12111. */
  12112. render(useCameraPostProcess?: boolean): void;
  12113. /**
  12114. * Clone the texture.
  12115. * @returns the cloned texture
  12116. */
  12117. clone(): ProceduralTexture;
  12118. /**
  12119. * Dispose the texture and release its asoociated resources.
  12120. */
  12121. dispose(): void;
  12122. }
  12123. }
  12124. declare module "babylonjs/Particles/baseParticleSystem" {
  12125. import { Nullable } from "babylonjs/types";
  12126. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  12127. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12128. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  12129. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  12130. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  12131. import { Scene } from "babylonjs/scene";
  12132. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  12133. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  12134. import { Texture } from "babylonjs/Materials/Textures/texture";
  12135. import { Color4 } from "babylonjs/Maths/math.color";
  12136. import { Animation } from "babylonjs/Animations/animation";
  12137. /**
  12138. * This represents the base class for particle system in Babylon.
  12139. * 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.
  12140. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12141. * @example https://doc.babylonjs.com/babylon101/particles
  12142. */
  12143. export class BaseParticleSystem {
  12144. /**
  12145. * Source color is added to the destination color without alpha affecting the result
  12146. */
  12147. static BLENDMODE_ONEONE: number;
  12148. /**
  12149. * Blend current color and particle color using particle’s alpha
  12150. */
  12151. static BLENDMODE_STANDARD: number;
  12152. /**
  12153. * Add current color and particle color multiplied by particle’s alpha
  12154. */
  12155. static BLENDMODE_ADD: number;
  12156. /**
  12157. * Multiply current color with particle color
  12158. */
  12159. static BLENDMODE_MULTIPLY: number;
  12160. /**
  12161. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  12162. */
  12163. static BLENDMODE_MULTIPLYADD: number;
  12164. /**
  12165. * List of animations used by the particle system.
  12166. */
  12167. animations: Animation[];
  12168. /**
  12169. * Gets or sets the unique id of the particle system
  12170. */
  12171. uniqueId: number;
  12172. /**
  12173. * The id of the Particle system.
  12174. */
  12175. id: string;
  12176. /**
  12177. * The friendly name of the Particle system.
  12178. */
  12179. name: string;
  12180. /**
  12181. * Snippet ID if the particle system was created from the snippet server
  12182. */
  12183. snippetId: string;
  12184. /**
  12185. * The rendering group used by the Particle system to chose when to render.
  12186. */
  12187. renderingGroupId: number;
  12188. /**
  12189. * The emitter represents the Mesh or position we are attaching the particle system to.
  12190. */
  12191. emitter: Nullable<AbstractMesh | Vector3>;
  12192. /**
  12193. * The maximum number of particles to emit per frame
  12194. */
  12195. emitRate: number;
  12196. /**
  12197. * If you want to launch only a few particles at once, that can be done, as well.
  12198. */
  12199. manualEmitCount: number;
  12200. /**
  12201. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  12202. */
  12203. updateSpeed: number;
  12204. /**
  12205. * The amount of time the particle system is running (depends of the overall update speed).
  12206. */
  12207. targetStopDuration: number;
  12208. /**
  12209. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  12210. */
  12211. disposeOnStop: boolean;
  12212. /**
  12213. * Minimum power of emitting particles.
  12214. */
  12215. minEmitPower: number;
  12216. /**
  12217. * Maximum power of emitting particles.
  12218. */
  12219. maxEmitPower: number;
  12220. /**
  12221. * Minimum life time of emitting particles.
  12222. */
  12223. minLifeTime: number;
  12224. /**
  12225. * Maximum life time of emitting particles.
  12226. */
  12227. maxLifeTime: number;
  12228. /**
  12229. * Minimum Size of emitting particles.
  12230. */
  12231. minSize: number;
  12232. /**
  12233. * Maximum Size of emitting particles.
  12234. */
  12235. maxSize: number;
  12236. /**
  12237. * Minimum scale of emitting particles on X axis.
  12238. */
  12239. minScaleX: number;
  12240. /**
  12241. * Maximum scale of emitting particles on X axis.
  12242. */
  12243. maxScaleX: number;
  12244. /**
  12245. * Minimum scale of emitting particles on Y axis.
  12246. */
  12247. minScaleY: number;
  12248. /**
  12249. * Maximum scale of emitting particles on Y axis.
  12250. */
  12251. maxScaleY: number;
  12252. /**
  12253. * Gets or sets the minimal initial rotation in radians.
  12254. */
  12255. minInitialRotation: number;
  12256. /**
  12257. * Gets or sets the maximal initial rotation in radians.
  12258. */
  12259. maxInitialRotation: number;
  12260. /**
  12261. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  12262. */
  12263. minAngularSpeed: number;
  12264. /**
  12265. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  12266. */
  12267. maxAngularSpeed: number;
  12268. /**
  12269. * The texture used to render each particle. (this can be a spritesheet)
  12270. */
  12271. particleTexture: Nullable<Texture>;
  12272. /**
  12273. * The layer mask we are rendering the particles through.
  12274. */
  12275. layerMask: number;
  12276. /**
  12277. * This can help using your own shader to render the particle system.
  12278. * The according effect will be created
  12279. */
  12280. customShader: any;
  12281. /**
  12282. * By default particle system starts as soon as they are created. This prevents the
  12283. * automatic start to happen and let you decide when to start emitting particles.
  12284. */
  12285. preventAutoStart: boolean;
  12286. private _noiseTexture;
  12287. /**
  12288. * Gets or sets a texture used to add random noise to particle positions
  12289. */
  12290. get noiseTexture(): Nullable<ProceduralTexture>;
  12291. set noiseTexture(value: Nullable<ProceduralTexture>);
  12292. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12293. noiseStrength: Vector3;
  12294. /**
  12295. * Callback triggered when the particle animation is ending.
  12296. */
  12297. onAnimationEnd: Nullable<() => void>;
  12298. /**
  12299. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12300. */
  12301. blendMode: number;
  12302. /**
  12303. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12304. * to override the particles.
  12305. */
  12306. forceDepthWrite: boolean;
  12307. /** 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 */
  12308. preWarmCycles: number;
  12309. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12310. preWarmStepOffset: number;
  12311. /**
  12312. * 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)
  12313. */
  12314. spriteCellChangeSpeed: number;
  12315. /**
  12316. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12317. */
  12318. startSpriteCellID: number;
  12319. /**
  12320. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12321. */
  12322. endSpriteCellID: number;
  12323. /**
  12324. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12325. */
  12326. spriteCellWidth: number;
  12327. /**
  12328. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12329. */
  12330. spriteCellHeight: number;
  12331. /**
  12332. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12333. */
  12334. spriteRandomStartCell: boolean;
  12335. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12336. translationPivot: Vector2;
  12337. /** @hidden */
  12338. protected _isAnimationSheetEnabled: boolean;
  12339. /**
  12340. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12341. */
  12342. beginAnimationOnStart: boolean;
  12343. /**
  12344. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12345. */
  12346. beginAnimationFrom: number;
  12347. /**
  12348. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12349. */
  12350. beginAnimationTo: number;
  12351. /**
  12352. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12353. */
  12354. beginAnimationLoop: boolean;
  12355. /**
  12356. * Gets or sets a world offset applied to all particles
  12357. */
  12358. worldOffset: Vector3;
  12359. /**
  12360. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12361. */
  12362. get isAnimationSheetEnabled(): boolean;
  12363. set isAnimationSheetEnabled(value: boolean);
  12364. /**
  12365. * Get hosting scene
  12366. * @returns the scene
  12367. */
  12368. getScene(): Scene;
  12369. /**
  12370. * You can use gravity if you want to give an orientation to your particles.
  12371. */
  12372. gravity: Vector3;
  12373. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12374. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12375. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12376. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12377. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12378. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12379. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12380. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12381. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12382. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12383. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12384. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12385. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12386. /**
  12387. * Defines the delay in milliseconds before starting the system (0 by default)
  12388. */
  12389. startDelay: number;
  12390. /**
  12391. * Gets the current list of drag gradients.
  12392. * You must use addDragGradient and removeDragGradient to udpate this list
  12393. * @returns the list of drag gradients
  12394. */
  12395. getDragGradients(): Nullable<Array<FactorGradient>>;
  12396. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12397. limitVelocityDamping: number;
  12398. /**
  12399. * Gets the current list of limit velocity gradients.
  12400. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12401. * @returns the list of limit velocity gradients
  12402. */
  12403. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12404. /**
  12405. * Gets the current list of color gradients.
  12406. * You must use addColorGradient and removeColorGradient to udpate this list
  12407. * @returns the list of color gradients
  12408. */
  12409. getColorGradients(): Nullable<Array<ColorGradient>>;
  12410. /**
  12411. * Gets the current list of size gradients.
  12412. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12413. * @returns the list of size gradients
  12414. */
  12415. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12416. /**
  12417. * Gets the current list of color remap gradients.
  12418. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12419. * @returns the list of color remap gradients
  12420. */
  12421. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12422. /**
  12423. * Gets the current list of alpha remap gradients.
  12424. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12425. * @returns the list of alpha remap gradients
  12426. */
  12427. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12428. /**
  12429. * Gets the current list of life time gradients.
  12430. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12431. * @returns the list of life time gradients
  12432. */
  12433. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12434. /**
  12435. * Gets the current list of angular speed gradients.
  12436. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12437. * @returns the list of angular speed gradients
  12438. */
  12439. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12440. /**
  12441. * Gets the current list of velocity gradients.
  12442. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12443. * @returns the list of velocity gradients
  12444. */
  12445. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12446. /**
  12447. * Gets the current list of start size gradients.
  12448. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12449. * @returns the list of start size gradients
  12450. */
  12451. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12452. /**
  12453. * Gets the current list of emit rate gradients.
  12454. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12455. * @returns the list of emit rate gradients
  12456. */
  12457. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12458. /**
  12459. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12460. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12461. */
  12462. get direction1(): Vector3;
  12463. set direction1(value: Vector3);
  12464. /**
  12465. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12466. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12467. */
  12468. get direction2(): Vector3;
  12469. set direction2(value: Vector3);
  12470. /**
  12471. * 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.
  12472. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12473. */
  12474. get minEmitBox(): Vector3;
  12475. set minEmitBox(value: Vector3);
  12476. /**
  12477. * 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.
  12478. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12479. */
  12480. get maxEmitBox(): Vector3;
  12481. set maxEmitBox(value: Vector3);
  12482. /**
  12483. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12484. */
  12485. color1: Color4;
  12486. /**
  12487. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12488. */
  12489. color2: Color4;
  12490. /**
  12491. * Color the particle will have at the end of its lifetime
  12492. */
  12493. colorDead: Color4;
  12494. /**
  12495. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12496. */
  12497. textureMask: Color4;
  12498. /**
  12499. * The particle emitter type defines the emitter used by the particle system.
  12500. * It can be for example box, sphere, or cone...
  12501. */
  12502. particleEmitterType: IParticleEmitterType;
  12503. /** @hidden */
  12504. _isSubEmitter: boolean;
  12505. /**
  12506. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12507. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12508. */
  12509. billboardMode: number;
  12510. protected _isBillboardBased: boolean;
  12511. /**
  12512. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12513. */
  12514. get isBillboardBased(): boolean;
  12515. set isBillboardBased(value: boolean);
  12516. /**
  12517. * The scene the particle system belongs to.
  12518. */
  12519. protected _scene: Scene;
  12520. /**
  12521. * Local cache of defines for image processing.
  12522. */
  12523. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12524. /**
  12525. * Default configuration related to image processing available in the standard Material.
  12526. */
  12527. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  12528. /**
  12529. * Gets the image processing configuration used either in this material.
  12530. */
  12531. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  12532. /**
  12533. * Sets the Default image processing configuration used either in the this material.
  12534. *
  12535. * If sets to null, the scene one is in use.
  12536. */
  12537. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  12538. /**
  12539. * Attaches a new image processing configuration to the Standard Material.
  12540. * @param configuration
  12541. */
  12542. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12543. /** @hidden */
  12544. protected _reset(): void;
  12545. /** @hidden */
  12546. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12547. /**
  12548. * Instantiates a particle system.
  12549. * 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.
  12550. * @param name The name of the particle system
  12551. */
  12552. constructor(name: string);
  12553. /**
  12554. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12555. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12556. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12557. * @returns the emitter
  12558. */
  12559. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12560. /**
  12561. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12562. * @param radius The radius of the hemisphere to emit from
  12563. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12564. * @returns the emitter
  12565. */
  12566. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12567. /**
  12568. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12569. * @param radius The radius of the sphere to emit from
  12570. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12571. * @returns the emitter
  12572. */
  12573. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12574. /**
  12575. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12576. * @param radius The radius of the sphere to emit from
  12577. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12578. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12579. * @returns the emitter
  12580. */
  12581. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12582. /**
  12583. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12584. * @param radius The radius of the emission cylinder
  12585. * @param height The height of the emission cylinder
  12586. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12587. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12588. * @returns the emitter
  12589. */
  12590. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12591. /**
  12592. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12593. * @param radius The radius of the cylinder to emit from
  12594. * @param height The height of the emission cylinder
  12595. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12596. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12597. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12598. * @returns the emitter
  12599. */
  12600. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12601. /**
  12602. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12603. * @param radius The radius of the cone to emit from
  12604. * @param angle The base angle of the cone
  12605. * @returns the emitter
  12606. */
  12607. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12608. /**
  12609. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12610. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12611. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12612. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12613. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12614. * @returns the emitter
  12615. */
  12616. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12617. }
  12618. }
  12619. declare module "babylonjs/Particles/subEmitter" {
  12620. import { Scene } from "babylonjs/scene";
  12621. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  12622. /**
  12623. * Type of sub emitter
  12624. */
  12625. export enum SubEmitterType {
  12626. /**
  12627. * Attached to the particle over it's lifetime
  12628. */
  12629. ATTACHED = 0,
  12630. /**
  12631. * Created when the particle dies
  12632. */
  12633. END = 1
  12634. }
  12635. /**
  12636. * Sub emitter class used to emit particles from an existing particle
  12637. */
  12638. export class SubEmitter {
  12639. /**
  12640. * the particle system to be used by the sub emitter
  12641. */
  12642. particleSystem: ParticleSystem;
  12643. /**
  12644. * Type of the submitter (Default: END)
  12645. */
  12646. type: SubEmitterType;
  12647. /**
  12648. * 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)
  12649. * Note: This only is supported when using an emitter of type Mesh
  12650. */
  12651. inheritDirection: boolean;
  12652. /**
  12653. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12654. */
  12655. inheritedVelocityAmount: number;
  12656. /**
  12657. * Creates a sub emitter
  12658. * @param particleSystem the particle system to be used by the sub emitter
  12659. */
  12660. constructor(
  12661. /**
  12662. * the particle system to be used by the sub emitter
  12663. */
  12664. particleSystem: ParticleSystem);
  12665. /**
  12666. * Clones the sub emitter
  12667. * @returns the cloned sub emitter
  12668. */
  12669. clone(): SubEmitter;
  12670. /**
  12671. * Serialize current object to a JSON object
  12672. * @returns the serialized object
  12673. */
  12674. serialize(): any;
  12675. /** @hidden */
  12676. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  12677. /**
  12678. * Creates a new SubEmitter from a serialized JSON version
  12679. * @param serializationObject defines the JSON object to read from
  12680. * @param scene defines the hosting scene
  12681. * @param rootUrl defines the rootUrl for data loading
  12682. * @returns a new SubEmitter
  12683. */
  12684. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  12685. /** Release associated resources */
  12686. dispose(): void;
  12687. }
  12688. }
  12689. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  12690. /** @hidden */
  12691. export var imageProcessingDeclaration: {
  12692. name: string;
  12693. shader: string;
  12694. };
  12695. }
  12696. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  12697. /** @hidden */
  12698. export var imageProcessingFunctions: {
  12699. name: string;
  12700. shader: string;
  12701. };
  12702. }
  12703. declare module "babylonjs/Shaders/particles.fragment" {
  12704. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  12705. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  12706. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  12707. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  12708. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  12709. /** @hidden */
  12710. export var particlesPixelShader: {
  12711. name: string;
  12712. shader: string;
  12713. };
  12714. }
  12715. declare module "babylonjs/Shaders/particles.vertex" {
  12716. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  12717. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  12718. /** @hidden */
  12719. export var particlesVertexShader: {
  12720. name: string;
  12721. shader: string;
  12722. };
  12723. }
  12724. declare module "babylonjs/Particles/particleSystem" {
  12725. import { Nullable } from "babylonjs/types";
  12726. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  12727. import { Observable } from "babylonjs/Misc/observable";
  12728. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12729. import { Effect } from "babylonjs/Materials/effect";
  12730. import { Scene, IDisposable } from "babylonjs/scene";
  12731. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  12732. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  12733. import { Particle } from "babylonjs/Particles/particle";
  12734. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  12735. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  12736. import "babylonjs/Shaders/particles.fragment";
  12737. import "babylonjs/Shaders/particles.vertex";
  12738. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  12739. /**
  12740. * This represents a particle system in Babylon.
  12741. * 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.
  12742. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12743. * @example https://doc.babylonjs.com/babylon101/particles
  12744. */
  12745. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12746. /**
  12747. * Billboard mode will only apply to Y axis
  12748. */
  12749. static readonly BILLBOARDMODE_Y: number;
  12750. /**
  12751. * Billboard mode will apply to all axes
  12752. */
  12753. static readonly BILLBOARDMODE_ALL: number;
  12754. /**
  12755. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12756. */
  12757. static readonly BILLBOARDMODE_STRETCHED: number;
  12758. /**
  12759. * This function can be defined to provide custom update for active particles.
  12760. * This function will be called instead of regular update (age, position, color, etc.).
  12761. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12762. */
  12763. updateFunction: (particles: Particle[]) => void;
  12764. private _emitterWorldMatrix;
  12765. /**
  12766. * This function can be defined to specify initial direction for every new particle.
  12767. * It by default use the emitterType defined function
  12768. */
  12769. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12770. /**
  12771. * This function can be defined to specify initial position for every new particle.
  12772. * It by default use the emitterType defined function
  12773. */
  12774. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12775. /**
  12776. * @hidden
  12777. */
  12778. _inheritedVelocityOffset: Vector3;
  12779. /**
  12780. * An event triggered when the system is disposed
  12781. */
  12782. onDisposeObservable: Observable<IParticleSystem>;
  12783. private _onDisposeObserver;
  12784. /**
  12785. * Sets a callback that will be triggered when the system is disposed
  12786. */
  12787. set onDispose(callback: () => void);
  12788. private _particles;
  12789. private _epsilon;
  12790. private _capacity;
  12791. private _stockParticles;
  12792. private _newPartsExcess;
  12793. private _vertexData;
  12794. private _vertexBuffer;
  12795. private _vertexBuffers;
  12796. private _spriteBuffer;
  12797. private _indexBuffer;
  12798. private _effect;
  12799. private _customEffect;
  12800. private _cachedDefines;
  12801. private _scaledColorStep;
  12802. private _colorDiff;
  12803. private _scaledDirection;
  12804. private _scaledGravity;
  12805. private _currentRenderId;
  12806. private _alive;
  12807. private _useInstancing;
  12808. private _started;
  12809. private _stopped;
  12810. private _actualFrame;
  12811. private _scaledUpdateSpeed;
  12812. private _vertexBufferSize;
  12813. /** @hidden */
  12814. _currentEmitRateGradient: Nullable<FactorGradient>;
  12815. /** @hidden */
  12816. _currentEmitRate1: number;
  12817. /** @hidden */
  12818. _currentEmitRate2: number;
  12819. /** @hidden */
  12820. _currentStartSizeGradient: Nullable<FactorGradient>;
  12821. /** @hidden */
  12822. _currentStartSize1: number;
  12823. /** @hidden */
  12824. _currentStartSize2: number;
  12825. private readonly _rawTextureWidth;
  12826. private _rampGradientsTexture;
  12827. private _useRampGradients;
  12828. /** Gets or sets a boolean indicating that ramp gradients must be used
  12829. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12830. */
  12831. get useRampGradients(): boolean;
  12832. set useRampGradients(value: boolean);
  12833. /**
  12834. * 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.
  12835. * 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: [])
  12836. */
  12837. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12838. private _subEmitters;
  12839. /**
  12840. * @hidden
  12841. * If the particle systems emitter should be disposed when the particle system is disposed
  12842. */
  12843. _disposeEmitterOnDispose: boolean;
  12844. /**
  12845. * The current active Sub-systems, this property is used by the root particle system only.
  12846. */
  12847. activeSubSystems: Array<ParticleSystem>;
  12848. /**
  12849. * Specifies if the particles are updated in emitter local space or world space
  12850. */
  12851. isLocal: boolean;
  12852. private _rootParticleSystem;
  12853. /**
  12854. * Gets the current list of active particles
  12855. */
  12856. get particles(): Particle[];
  12857. /**
  12858. * Gets the number of particles active at the same time.
  12859. * @returns The number of active particles.
  12860. */
  12861. getActiveCount(): number;
  12862. /**
  12863. * Returns the string "ParticleSystem"
  12864. * @returns a string containing the class name
  12865. */
  12866. getClassName(): string;
  12867. /**
  12868. * Gets a boolean indicating that the system is stopping
  12869. * @returns true if the system is currently stopping
  12870. */
  12871. isStopping(): boolean;
  12872. /**
  12873. * Gets the custom effect used to render the particles
  12874. * @param blendMode Blend mode for which the effect should be retrieved
  12875. * @returns The effect
  12876. */
  12877. getCustomEffect(blendMode?: number): Nullable<Effect>;
  12878. /**
  12879. * Sets the custom effect used to render the particles
  12880. * @param effect The effect to set
  12881. * @param blendMode Blend mode for which the effect should be set
  12882. */
  12883. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  12884. /** @hidden */
  12885. private _onBeforeDrawParticlesObservable;
  12886. /**
  12887. * Observable that will be called just before the particles are drawn
  12888. */
  12889. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  12890. /**
  12891. * Gets the name of the particle vertex shader
  12892. */
  12893. get vertexShaderName(): string;
  12894. /**
  12895. * Instantiates a particle system.
  12896. * 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.
  12897. * @param name The name of the particle system
  12898. * @param capacity The max number of particles alive at the same time
  12899. * @param scene The scene the particle system belongs to
  12900. * @param customEffect a custom effect used to change the way particles are rendered by default
  12901. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  12902. * @param epsilon Offset used to render the particles
  12903. */
  12904. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  12905. private _addFactorGradient;
  12906. private _removeFactorGradient;
  12907. /**
  12908. * Adds a new life time gradient
  12909. * @param gradient defines the gradient to use (between 0 and 1)
  12910. * @param factor defines the life time factor to affect to the specified gradient
  12911. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12912. * @returns the current particle system
  12913. */
  12914. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12915. /**
  12916. * Remove a specific life time gradient
  12917. * @param gradient defines the gradient to remove
  12918. * @returns the current particle system
  12919. */
  12920. removeLifeTimeGradient(gradient: number): IParticleSystem;
  12921. /**
  12922. * Adds a new size gradient
  12923. * @param gradient defines the gradient to use (between 0 and 1)
  12924. * @param factor defines the size factor to affect to the specified gradient
  12925. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12926. * @returns the current particle system
  12927. */
  12928. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12929. /**
  12930. * Remove a specific size gradient
  12931. * @param gradient defines the gradient to remove
  12932. * @returns the current particle system
  12933. */
  12934. removeSizeGradient(gradient: number): IParticleSystem;
  12935. /**
  12936. * Adds a new color remap gradient
  12937. * @param gradient defines the gradient to use (between 0 and 1)
  12938. * @param min defines the color remap minimal range
  12939. * @param max defines the color remap maximal range
  12940. * @returns the current particle system
  12941. */
  12942. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12943. /**
  12944. * Remove a specific color remap gradient
  12945. * @param gradient defines the gradient to remove
  12946. * @returns the current particle system
  12947. */
  12948. removeColorRemapGradient(gradient: number): IParticleSystem;
  12949. /**
  12950. * Adds a new alpha remap gradient
  12951. * @param gradient defines the gradient to use (between 0 and 1)
  12952. * @param min defines the alpha remap minimal range
  12953. * @param max defines the alpha remap maximal range
  12954. * @returns the current particle system
  12955. */
  12956. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12957. /**
  12958. * Remove a specific alpha remap gradient
  12959. * @param gradient defines the gradient to remove
  12960. * @returns the current particle system
  12961. */
  12962. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  12963. /**
  12964. * Adds a new angular speed gradient
  12965. * @param gradient defines the gradient to use (between 0 and 1)
  12966. * @param factor defines the angular speed to affect to the specified gradient
  12967. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12968. * @returns the current particle system
  12969. */
  12970. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12971. /**
  12972. * Remove a specific angular speed gradient
  12973. * @param gradient defines the gradient to remove
  12974. * @returns the current particle system
  12975. */
  12976. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  12977. /**
  12978. * Adds a new velocity gradient
  12979. * @param gradient defines the gradient to use (between 0 and 1)
  12980. * @param factor defines the velocity to affect to the specified gradient
  12981. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12982. * @returns the current particle system
  12983. */
  12984. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12985. /**
  12986. * Remove a specific velocity gradient
  12987. * @param gradient defines the gradient to remove
  12988. * @returns the current particle system
  12989. */
  12990. removeVelocityGradient(gradient: number): IParticleSystem;
  12991. /**
  12992. * Adds a new limit velocity gradient
  12993. * @param gradient defines the gradient to use (between 0 and 1)
  12994. * @param factor defines the limit velocity value to affect to the specified gradient
  12995. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12996. * @returns the current particle system
  12997. */
  12998. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12999. /**
  13000. * Remove a specific limit velocity gradient
  13001. * @param gradient defines the gradient to remove
  13002. * @returns the current particle system
  13003. */
  13004. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13005. /**
  13006. * Adds a new drag gradient
  13007. * @param gradient defines the gradient to use (between 0 and 1)
  13008. * @param factor defines the drag value to affect to the specified gradient
  13009. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13010. * @returns the current particle system
  13011. */
  13012. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13013. /**
  13014. * Remove a specific drag gradient
  13015. * @param gradient defines the gradient to remove
  13016. * @returns the current particle system
  13017. */
  13018. removeDragGradient(gradient: number): IParticleSystem;
  13019. /**
  13020. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13021. * @param gradient defines the gradient to use (between 0 and 1)
  13022. * @param factor defines the emit rate value to affect to the specified gradient
  13023. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13024. * @returns the current particle system
  13025. */
  13026. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13027. /**
  13028. * Remove a specific emit rate gradient
  13029. * @param gradient defines the gradient to remove
  13030. * @returns the current particle system
  13031. */
  13032. removeEmitRateGradient(gradient: number): IParticleSystem;
  13033. /**
  13034. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13035. * @param gradient defines the gradient to use (between 0 and 1)
  13036. * @param factor defines the start size value to affect to the specified gradient
  13037. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13038. * @returns the current particle system
  13039. */
  13040. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13041. /**
  13042. * Remove a specific start size gradient
  13043. * @param gradient defines the gradient to remove
  13044. * @returns the current particle system
  13045. */
  13046. removeStartSizeGradient(gradient: number): IParticleSystem;
  13047. private _createRampGradientTexture;
  13048. /**
  13049. * Gets the current list of ramp gradients.
  13050. * You must use addRampGradient and removeRampGradient to udpate this list
  13051. * @returns the list of ramp gradients
  13052. */
  13053. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13054. /** Force the system to rebuild all gradients that need to be resync */
  13055. forceRefreshGradients(): void;
  13056. private _syncRampGradientTexture;
  13057. /**
  13058. * Adds a new ramp gradient used to remap particle colors
  13059. * @param gradient defines the gradient to use (between 0 and 1)
  13060. * @param color defines the color to affect to the specified gradient
  13061. * @returns the current particle system
  13062. */
  13063. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  13064. /**
  13065. * Remove a specific ramp gradient
  13066. * @param gradient defines the gradient to remove
  13067. * @returns the current particle system
  13068. */
  13069. removeRampGradient(gradient: number): ParticleSystem;
  13070. /**
  13071. * Adds a new color gradient
  13072. * @param gradient defines the gradient to use (between 0 and 1)
  13073. * @param color1 defines the color to affect to the specified gradient
  13074. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13075. * @returns this particle system
  13076. */
  13077. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13078. /**
  13079. * Remove a specific color gradient
  13080. * @param gradient defines the gradient to remove
  13081. * @returns this particle system
  13082. */
  13083. removeColorGradient(gradient: number): IParticleSystem;
  13084. private _fetchR;
  13085. protected _reset(): void;
  13086. private _resetEffect;
  13087. private _createVertexBuffers;
  13088. private _createIndexBuffer;
  13089. /**
  13090. * Gets the maximum number of particles active at the same time.
  13091. * @returns The max number of active particles.
  13092. */
  13093. getCapacity(): number;
  13094. /**
  13095. * Gets whether there are still active particles in the system.
  13096. * @returns True if it is alive, otherwise false.
  13097. */
  13098. isAlive(): boolean;
  13099. /**
  13100. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13101. * @returns True if it has been started, otherwise false.
  13102. */
  13103. isStarted(): boolean;
  13104. private _prepareSubEmitterInternalArray;
  13105. /**
  13106. * Starts the particle system and begins to emit
  13107. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  13108. */
  13109. start(delay?: number): void;
  13110. /**
  13111. * Stops the particle system.
  13112. * @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.
  13113. */
  13114. stop(stopSubEmitters?: boolean): void;
  13115. /**
  13116. * Remove all active particles
  13117. */
  13118. reset(): void;
  13119. /**
  13120. * @hidden (for internal use only)
  13121. */
  13122. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  13123. /**
  13124. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  13125. * Its lifetime will start back at 0.
  13126. */
  13127. recycleParticle: (particle: Particle) => void;
  13128. private _stopSubEmitters;
  13129. private _createParticle;
  13130. private _removeFromRoot;
  13131. private _emitFromParticle;
  13132. private _update;
  13133. /** @hidden */
  13134. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  13135. /** @hidden */
  13136. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  13137. /**
  13138. * Fill the defines array according to the current settings of the particle system
  13139. * @param defines Array to be updated
  13140. * @param blendMode blend mode to take into account when updating the array
  13141. */
  13142. fillDefines(defines: Array<string>, blendMode: number): void;
  13143. /**
  13144. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  13145. * @param uniforms Uniforms array to fill
  13146. * @param attributes Attributes array to fill
  13147. * @param samplers Samplers array to fill
  13148. */
  13149. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  13150. /** @hidden */
  13151. private _getEffect;
  13152. /**
  13153. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  13154. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  13155. */
  13156. animate(preWarmOnly?: boolean): void;
  13157. private _appendParticleVertices;
  13158. /**
  13159. * Rebuilds the particle system.
  13160. */
  13161. rebuild(): void;
  13162. /**
  13163. * Is this system ready to be used/rendered
  13164. * @return true if the system is ready
  13165. */
  13166. isReady(): boolean;
  13167. private _render;
  13168. /**
  13169. * Renders the particle system in its current state.
  13170. * @returns the current number of particles
  13171. */
  13172. render(): number;
  13173. /**
  13174. * Disposes the particle system and free the associated resources
  13175. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13176. */
  13177. dispose(disposeTexture?: boolean): void;
  13178. /**
  13179. * Clones the particle system.
  13180. * @param name The name of the cloned object
  13181. * @param newEmitter The new emitter to use
  13182. * @returns the cloned particle system
  13183. */
  13184. clone(name: string, newEmitter: any): ParticleSystem;
  13185. /**
  13186. * Serializes the particle system to a JSON object
  13187. * @param serializeTexture defines if the texture must be serialized as well
  13188. * @returns the JSON object
  13189. */
  13190. serialize(serializeTexture?: boolean): any;
  13191. /** @hidden */
  13192. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  13193. /** @hidden */
  13194. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  13195. /**
  13196. * Parses a JSON object to create a particle system.
  13197. * @param parsedParticleSystem The JSON object to parse
  13198. * @param scene The scene to create the particle system in
  13199. * @param rootUrl The root url to use to load external dependencies like texture
  13200. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  13201. * @returns the Parsed particle system
  13202. */
  13203. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  13204. }
  13205. }
  13206. declare module "babylonjs/Particles/particle" {
  13207. import { Nullable } from "babylonjs/types";
  13208. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  13209. import { Color4 } from "babylonjs/Maths/math.color";
  13210. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  13211. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  13212. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  13213. /**
  13214. * A particle represents one of the element emitted by a particle system.
  13215. * This is mainly define by its coordinates, direction, velocity and age.
  13216. */
  13217. export class Particle {
  13218. /**
  13219. * The particle system the particle belongs to.
  13220. */
  13221. particleSystem: ParticleSystem;
  13222. private static _Count;
  13223. /**
  13224. * Unique ID of the particle
  13225. */
  13226. id: number;
  13227. /**
  13228. * The world position of the particle in the scene.
  13229. */
  13230. position: Vector3;
  13231. /**
  13232. * The world direction of the particle in the scene.
  13233. */
  13234. direction: Vector3;
  13235. /**
  13236. * The color of the particle.
  13237. */
  13238. color: Color4;
  13239. /**
  13240. * The color change of the particle per step.
  13241. */
  13242. colorStep: Color4;
  13243. /**
  13244. * Defines how long will the life of the particle be.
  13245. */
  13246. lifeTime: number;
  13247. /**
  13248. * The current age of the particle.
  13249. */
  13250. age: number;
  13251. /**
  13252. * The current size of the particle.
  13253. */
  13254. size: number;
  13255. /**
  13256. * The current scale of the particle.
  13257. */
  13258. scale: Vector2;
  13259. /**
  13260. * The current angle of the particle.
  13261. */
  13262. angle: number;
  13263. /**
  13264. * Defines how fast is the angle changing.
  13265. */
  13266. angularSpeed: number;
  13267. /**
  13268. * Defines the cell index used by the particle to be rendered from a sprite.
  13269. */
  13270. cellIndex: number;
  13271. /**
  13272. * The information required to support color remapping
  13273. */
  13274. remapData: Vector4;
  13275. /** @hidden */
  13276. _randomCellOffset?: number;
  13277. /** @hidden */
  13278. _initialDirection: Nullable<Vector3>;
  13279. /** @hidden */
  13280. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  13281. /** @hidden */
  13282. _initialStartSpriteCellID: number;
  13283. /** @hidden */
  13284. _initialEndSpriteCellID: number;
  13285. /** @hidden */
  13286. _currentColorGradient: Nullable<ColorGradient>;
  13287. /** @hidden */
  13288. _currentColor1: Color4;
  13289. /** @hidden */
  13290. _currentColor2: Color4;
  13291. /** @hidden */
  13292. _currentSizeGradient: Nullable<FactorGradient>;
  13293. /** @hidden */
  13294. _currentSize1: number;
  13295. /** @hidden */
  13296. _currentSize2: number;
  13297. /** @hidden */
  13298. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  13299. /** @hidden */
  13300. _currentAngularSpeed1: number;
  13301. /** @hidden */
  13302. _currentAngularSpeed2: number;
  13303. /** @hidden */
  13304. _currentVelocityGradient: Nullable<FactorGradient>;
  13305. /** @hidden */
  13306. _currentVelocity1: number;
  13307. /** @hidden */
  13308. _currentVelocity2: number;
  13309. /** @hidden */
  13310. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13311. /** @hidden */
  13312. _currentLimitVelocity1: number;
  13313. /** @hidden */
  13314. _currentLimitVelocity2: number;
  13315. /** @hidden */
  13316. _currentDragGradient: Nullable<FactorGradient>;
  13317. /** @hidden */
  13318. _currentDrag1: number;
  13319. /** @hidden */
  13320. _currentDrag2: number;
  13321. /** @hidden */
  13322. _randomNoiseCoordinates1: Vector3;
  13323. /** @hidden */
  13324. _randomNoiseCoordinates2: Vector3;
  13325. /** @hidden */
  13326. _localPosition?: Vector3;
  13327. /**
  13328. * Creates a new instance Particle
  13329. * @param particleSystem the particle system the particle belongs to
  13330. */
  13331. constructor(
  13332. /**
  13333. * The particle system the particle belongs to.
  13334. */
  13335. particleSystem: ParticleSystem);
  13336. private updateCellInfoFromSystem;
  13337. /**
  13338. * Defines how the sprite cell index is updated for the particle
  13339. */
  13340. updateCellIndex(): void;
  13341. /** @hidden */
  13342. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13343. /** @hidden */
  13344. _inheritParticleInfoToSubEmitters(): void;
  13345. /** @hidden */
  13346. _reset(): void;
  13347. /**
  13348. * Copy the properties of particle to another one.
  13349. * @param other the particle to copy the information to.
  13350. */
  13351. copyTo(other: Particle): void;
  13352. }
  13353. }
  13354. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  13355. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13356. import { Effect } from "babylonjs/Materials/effect";
  13357. import { Particle } from "babylonjs/Particles/particle";
  13358. import { Scene } from "babylonjs/scene";
  13359. /**
  13360. * Particle emitter represents a volume emitting particles.
  13361. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13362. */
  13363. export interface IParticleEmitterType {
  13364. /**
  13365. * Called by the particle System when the direction is computed for the created particle.
  13366. * @param worldMatrix is the world matrix of the particle system
  13367. * @param directionToUpdate is the direction vector to update with the result
  13368. * @param particle is the particle we are computed the direction for
  13369. * @param isLocal defines if the direction should be set in local space
  13370. */
  13371. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13372. /**
  13373. * Called by the particle System when the position is computed for the created particle.
  13374. * @param worldMatrix is the world matrix of the particle system
  13375. * @param positionToUpdate is the position vector to update with the result
  13376. * @param particle is the particle we are computed the position for
  13377. * @param isLocal defines if the position should be set in local space
  13378. */
  13379. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13380. /**
  13381. * Clones the current emitter and returns a copy of it
  13382. * @returns the new emitter
  13383. */
  13384. clone(): IParticleEmitterType;
  13385. /**
  13386. * Called by the GPUParticleSystem to setup the update shader
  13387. * @param effect defines the update shader
  13388. */
  13389. applyToShader(effect: Effect): void;
  13390. /**
  13391. * Returns a string to use to update the GPU particles update shader
  13392. * @returns the effect defines string
  13393. */
  13394. getEffectDefines(): string;
  13395. /**
  13396. * Returns a string representing the class name
  13397. * @returns a string containing the class name
  13398. */
  13399. getClassName(): string;
  13400. /**
  13401. * Serializes the particle system to a JSON object.
  13402. * @returns the JSON object
  13403. */
  13404. serialize(): any;
  13405. /**
  13406. * Parse properties from a JSON object
  13407. * @param serializationObject defines the JSON object
  13408. * @param scene defines the hosting scene
  13409. */
  13410. parse(serializationObject: any, scene: Scene): void;
  13411. }
  13412. }
  13413. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  13414. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13415. import { Effect } from "babylonjs/Materials/effect";
  13416. import { Particle } from "babylonjs/Particles/particle";
  13417. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13418. /**
  13419. * Particle emitter emitting particles from the inside of a box.
  13420. * It emits the particles randomly between 2 given directions.
  13421. */
  13422. export class BoxParticleEmitter implements IParticleEmitterType {
  13423. /**
  13424. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13425. */
  13426. direction1: Vector3;
  13427. /**
  13428. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13429. */
  13430. direction2: Vector3;
  13431. /**
  13432. * 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.
  13433. */
  13434. minEmitBox: Vector3;
  13435. /**
  13436. * 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.
  13437. */
  13438. maxEmitBox: Vector3;
  13439. /**
  13440. * Creates a new instance BoxParticleEmitter
  13441. */
  13442. constructor();
  13443. /**
  13444. * Called by the particle System when the direction is computed for the created particle.
  13445. * @param worldMatrix is the world matrix of the particle system
  13446. * @param directionToUpdate is the direction vector to update with the result
  13447. * @param particle is the particle we are computed the direction for
  13448. * @param isLocal defines if the direction should be set in local space
  13449. */
  13450. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13451. /**
  13452. * Called by the particle System when the position is computed for the created particle.
  13453. * @param worldMatrix is the world matrix of the particle system
  13454. * @param positionToUpdate is the position vector to update with the result
  13455. * @param particle is the particle we are computed the position for
  13456. * @param isLocal defines if the position should be set in local space
  13457. */
  13458. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13459. /**
  13460. * Clones the current emitter and returns a copy of it
  13461. * @returns the new emitter
  13462. */
  13463. clone(): BoxParticleEmitter;
  13464. /**
  13465. * Called by the GPUParticleSystem to setup the update shader
  13466. * @param effect defines the update shader
  13467. */
  13468. applyToShader(effect: Effect): void;
  13469. /**
  13470. * Returns a string to use to update the GPU particles update shader
  13471. * @returns a string containng the defines string
  13472. */
  13473. getEffectDefines(): string;
  13474. /**
  13475. * Returns the string "BoxParticleEmitter"
  13476. * @returns a string containing the class name
  13477. */
  13478. getClassName(): string;
  13479. /**
  13480. * Serializes the particle system to a JSON object.
  13481. * @returns the JSON object
  13482. */
  13483. serialize(): any;
  13484. /**
  13485. * Parse properties from a JSON object
  13486. * @param serializationObject defines the JSON object
  13487. */
  13488. parse(serializationObject: any): void;
  13489. }
  13490. }
  13491. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  13492. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13493. import { Effect } from "babylonjs/Materials/effect";
  13494. import { Particle } from "babylonjs/Particles/particle";
  13495. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13496. /**
  13497. * Particle emitter emitting particles from the inside of a cone.
  13498. * It emits the particles alongside the cone volume from the base to the particle.
  13499. * The emission direction might be randomized.
  13500. */
  13501. export class ConeParticleEmitter implements IParticleEmitterType {
  13502. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13503. directionRandomizer: number;
  13504. private _radius;
  13505. private _angle;
  13506. private _height;
  13507. /**
  13508. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13509. */
  13510. radiusRange: number;
  13511. /**
  13512. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13513. */
  13514. heightRange: number;
  13515. /**
  13516. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13517. */
  13518. emitFromSpawnPointOnly: boolean;
  13519. /**
  13520. * Gets or sets the radius of the emission cone
  13521. */
  13522. get radius(): number;
  13523. set radius(value: number);
  13524. /**
  13525. * Gets or sets the angle of the emission cone
  13526. */
  13527. get angle(): number;
  13528. set angle(value: number);
  13529. private _buildHeight;
  13530. /**
  13531. * Creates a new instance ConeParticleEmitter
  13532. * @param radius the radius of the emission cone (1 by default)
  13533. * @param angle the cone base angle (PI by default)
  13534. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13535. */
  13536. constructor(radius?: number, angle?: number,
  13537. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13538. directionRandomizer?: number);
  13539. /**
  13540. * Called by the particle System when the direction is computed for the created particle.
  13541. * @param worldMatrix is the world matrix of the particle system
  13542. * @param directionToUpdate is the direction vector to update with the result
  13543. * @param particle is the particle we are computed the direction for
  13544. * @param isLocal defines if the direction should be set in local space
  13545. */
  13546. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13547. /**
  13548. * Called by the particle System when the position is computed for the created particle.
  13549. * @param worldMatrix is the world matrix of the particle system
  13550. * @param positionToUpdate is the position vector to update with the result
  13551. * @param particle is the particle we are computed the position for
  13552. * @param isLocal defines if the position should be set in local space
  13553. */
  13554. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13555. /**
  13556. * Clones the current emitter and returns a copy of it
  13557. * @returns the new emitter
  13558. */
  13559. clone(): ConeParticleEmitter;
  13560. /**
  13561. * Called by the GPUParticleSystem to setup the update shader
  13562. * @param effect defines the update shader
  13563. */
  13564. applyToShader(effect: Effect): void;
  13565. /**
  13566. * Returns a string to use to update the GPU particles update shader
  13567. * @returns a string containng the defines string
  13568. */
  13569. getEffectDefines(): string;
  13570. /**
  13571. * Returns the string "ConeParticleEmitter"
  13572. * @returns a string containing the class name
  13573. */
  13574. getClassName(): string;
  13575. /**
  13576. * Serializes the particle system to a JSON object.
  13577. * @returns the JSON object
  13578. */
  13579. serialize(): any;
  13580. /**
  13581. * Parse properties from a JSON object
  13582. * @param serializationObject defines the JSON object
  13583. */
  13584. parse(serializationObject: any): void;
  13585. }
  13586. }
  13587. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  13588. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13589. import { Effect } from "babylonjs/Materials/effect";
  13590. import { Particle } from "babylonjs/Particles/particle";
  13591. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13592. /**
  13593. * Particle emitter emitting particles from the inside of a cylinder.
  13594. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13595. */
  13596. export class CylinderParticleEmitter implements IParticleEmitterType {
  13597. /**
  13598. * The radius of the emission cylinder.
  13599. */
  13600. radius: number;
  13601. /**
  13602. * The height of the emission cylinder.
  13603. */
  13604. height: number;
  13605. /**
  13606. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13607. */
  13608. radiusRange: number;
  13609. /**
  13610. * How much to randomize the particle direction [0-1].
  13611. */
  13612. directionRandomizer: number;
  13613. /**
  13614. * Creates a new instance CylinderParticleEmitter
  13615. * @param radius the radius of the emission cylinder (1 by default)
  13616. * @param height the height of the emission cylinder (1 by default)
  13617. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13618. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13619. */
  13620. constructor(
  13621. /**
  13622. * The radius of the emission cylinder.
  13623. */
  13624. radius?: number,
  13625. /**
  13626. * The height of the emission cylinder.
  13627. */
  13628. height?: number,
  13629. /**
  13630. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13631. */
  13632. radiusRange?: number,
  13633. /**
  13634. * How much to randomize the particle direction [0-1].
  13635. */
  13636. directionRandomizer?: number);
  13637. /**
  13638. * Called by the particle System when the direction is computed for the created particle.
  13639. * @param worldMatrix is the world matrix of the particle system
  13640. * @param directionToUpdate is the direction vector to update with the result
  13641. * @param particle is the particle we are computed the direction for
  13642. * @param isLocal defines if the direction should be set in local space
  13643. */
  13644. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13645. /**
  13646. * Called by the particle System when the position is computed for the created particle.
  13647. * @param worldMatrix is the world matrix of the particle system
  13648. * @param positionToUpdate is the position vector to update with the result
  13649. * @param particle is the particle we are computed the position for
  13650. * @param isLocal defines if the position should be set in local space
  13651. */
  13652. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13653. /**
  13654. * Clones the current emitter and returns a copy of it
  13655. * @returns the new emitter
  13656. */
  13657. clone(): CylinderParticleEmitter;
  13658. /**
  13659. * Called by the GPUParticleSystem to setup the update shader
  13660. * @param effect defines the update shader
  13661. */
  13662. applyToShader(effect: Effect): void;
  13663. /**
  13664. * Returns a string to use to update the GPU particles update shader
  13665. * @returns a string containng the defines string
  13666. */
  13667. getEffectDefines(): string;
  13668. /**
  13669. * Returns the string "CylinderParticleEmitter"
  13670. * @returns a string containing the class name
  13671. */
  13672. getClassName(): string;
  13673. /**
  13674. * Serializes the particle system to a JSON object.
  13675. * @returns the JSON object
  13676. */
  13677. serialize(): any;
  13678. /**
  13679. * Parse properties from a JSON object
  13680. * @param serializationObject defines the JSON object
  13681. */
  13682. parse(serializationObject: any): void;
  13683. }
  13684. /**
  13685. * Particle emitter emitting particles from the inside of a cylinder.
  13686. * It emits the particles randomly between two vectors.
  13687. */
  13688. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13689. /**
  13690. * The min limit of the emission direction.
  13691. */
  13692. direction1: Vector3;
  13693. /**
  13694. * The max limit of the emission direction.
  13695. */
  13696. direction2: Vector3;
  13697. /**
  13698. * Creates a new instance CylinderDirectedParticleEmitter
  13699. * @param radius the radius of the emission cylinder (1 by default)
  13700. * @param height the height of the emission cylinder (1 by default)
  13701. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13702. * @param direction1 the min limit of the emission direction (up vector by default)
  13703. * @param direction2 the max limit of the emission direction (up vector by default)
  13704. */
  13705. constructor(radius?: number, height?: number, radiusRange?: number,
  13706. /**
  13707. * The min limit of the emission direction.
  13708. */
  13709. direction1?: Vector3,
  13710. /**
  13711. * The max limit of the emission direction.
  13712. */
  13713. direction2?: Vector3);
  13714. /**
  13715. * Called by the particle System when the direction is computed for the created particle.
  13716. * @param worldMatrix is the world matrix of the particle system
  13717. * @param directionToUpdate is the direction vector to update with the result
  13718. * @param particle is the particle we are computed the direction for
  13719. */
  13720. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13721. /**
  13722. * Clones the current emitter and returns a copy of it
  13723. * @returns the new emitter
  13724. */
  13725. clone(): CylinderDirectedParticleEmitter;
  13726. /**
  13727. * Called by the GPUParticleSystem to setup the update shader
  13728. * @param effect defines the update shader
  13729. */
  13730. applyToShader(effect: Effect): void;
  13731. /**
  13732. * Returns a string to use to update the GPU particles update shader
  13733. * @returns a string containng the defines string
  13734. */
  13735. getEffectDefines(): string;
  13736. /**
  13737. * Returns the string "CylinderDirectedParticleEmitter"
  13738. * @returns a string containing the class name
  13739. */
  13740. getClassName(): string;
  13741. /**
  13742. * Serializes the particle system to a JSON object.
  13743. * @returns the JSON object
  13744. */
  13745. serialize(): any;
  13746. /**
  13747. * Parse properties from a JSON object
  13748. * @param serializationObject defines the JSON object
  13749. */
  13750. parse(serializationObject: any): void;
  13751. }
  13752. }
  13753. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  13754. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13755. import { Effect } from "babylonjs/Materials/effect";
  13756. import { Particle } from "babylonjs/Particles/particle";
  13757. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13758. /**
  13759. * Particle emitter emitting particles from the inside of a hemisphere.
  13760. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13761. */
  13762. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13763. /**
  13764. * The radius of the emission hemisphere.
  13765. */
  13766. radius: number;
  13767. /**
  13768. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13769. */
  13770. radiusRange: number;
  13771. /**
  13772. * How much to randomize the particle direction [0-1].
  13773. */
  13774. directionRandomizer: number;
  13775. /**
  13776. * Creates a new instance HemisphericParticleEmitter
  13777. * @param radius the radius of the emission hemisphere (1 by default)
  13778. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13779. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13780. */
  13781. constructor(
  13782. /**
  13783. * The radius of the emission hemisphere.
  13784. */
  13785. radius?: number,
  13786. /**
  13787. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13788. */
  13789. radiusRange?: number,
  13790. /**
  13791. * How much to randomize the particle direction [0-1].
  13792. */
  13793. directionRandomizer?: number);
  13794. /**
  13795. * Called by the particle System when the direction is computed for the created particle.
  13796. * @param worldMatrix is the world matrix of the particle system
  13797. * @param directionToUpdate is the direction vector to update with the result
  13798. * @param particle is the particle we are computed the direction for
  13799. * @param isLocal defines if the direction should be set in local space
  13800. */
  13801. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13802. /**
  13803. * Called by the particle System when the position is computed for the created particle.
  13804. * @param worldMatrix is the world matrix of the particle system
  13805. * @param positionToUpdate is the position vector to update with the result
  13806. * @param particle is the particle we are computed the position for
  13807. * @param isLocal defines if the position should be set in local space
  13808. */
  13809. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13810. /**
  13811. * Clones the current emitter and returns a copy of it
  13812. * @returns the new emitter
  13813. */
  13814. clone(): HemisphericParticleEmitter;
  13815. /**
  13816. * Called by the GPUParticleSystem to setup the update shader
  13817. * @param effect defines the update shader
  13818. */
  13819. applyToShader(effect: Effect): void;
  13820. /**
  13821. * Returns a string to use to update the GPU particles update shader
  13822. * @returns a string containng the defines string
  13823. */
  13824. getEffectDefines(): string;
  13825. /**
  13826. * Returns the string "HemisphericParticleEmitter"
  13827. * @returns a string containing the class name
  13828. */
  13829. getClassName(): string;
  13830. /**
  13831. * Serializes the particle system to a JSON object.
  13832. * @returns the JSON object
  13833. */
  13834. serialize(): any;
  13835. /**
  13836. * Parse properties from a JSON object
  13837. * @param serializationObject defines the JSON object
  13838. */
  13839. parse(serializationObject: any): void;
  13840. }
  13841. }
  13842. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  13843. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13844. import { Effect } from "babylonjs/Materials/effect";
  13845. import { Particle } from "babylonjs/Particles/particle";
  13846. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13847. /**
  13848. * Particle emitter emitting particles from a point.
  13849. * It emits the particles randomly between 2 given directions.
  13850. */
  13851. export class PointParticleEmitter implements IParticleEmitterType {
  13852. /**
  13853. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13854. */
  13855. direction1: Vector3;
  13856. /**
  13857. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13858. */
  13859. direction2: Vector3;
  13860. /**
  13861. * Creates a new instance PointParticleEmitter
  13862. */
  13863. constructor();
  13864. /**
  13865. * Called by the particle System when the direction is computed for the created particle.
  13866. * @param worldMatrix is the world matrix of the particle system
  13867. * @param directionToUpdate is the direction vector to update with the result
  13868. * @param particle is the particle we are computed the direction for
  13869. * @param isLocal defines if the direction should be set in local space
  13870. */
  13871. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13872. /**
  13873. * Called by the particle System when the position is computed for the created particle.
  13874. * @param worldMatrix is the world matrix of the particle system
  13875. * @param positionToUpdate is the position vector to update with the result
  13876. * @param particle is the particle we are computed the position for
  13877. * @param isLocal defines if the position should be set in local space
  13878. */
  13879. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13880. /**
  13881. * Clones the current emitter and returns a copy of it
  13882. * @returns the new emitter
  13883. */
  13884. clone(): PointParticleEmitter;
  13885. /**
  13886. * Called by the GPUParticleSystem to setup the update shader
  13887. * @param effect defines the update shader
  13888. */
  13889. applyToShader(effect: Effect): void;
  13890. /**
  13891. * Returns a string to use to update the GPU particles update shader
  13892. * @returns a string containng the defines string
  13893. */
  13894. getEffectDefines(): string;
  13895. /**
  13896. * Returns the string "PointParticleEmitter"
  13897. * @returns a string containing the class name
  13898. */
  13899. getClassName(): string;
  13900. /**
  13901. * Serializes the particle system to a JSON object.
  13902. * @returns the JSON object
  13903. */
  13904. serialize(): any;
  13905. /**
  13906. * Parse properties from a JSON object
  13907. * @param serializationObject defines the JSON object
  13908. */
  13909. parse(serializationObject: any): void;
  13910. }
  13911. }
  13912. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  13913. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13914. import { Effect } from "babylonjs/Materials/effect";
  13915. import { Particle } from "babylonjs/Particles/particle";
  13916. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13917. /**
  13918. * Particle emitter emitting particles from the inside of a sphere.
  13919. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  13920. */
  13921. export class SphereParticleEmitter implements IParticleEmitterType {
  13922. /**
  13923. * The radius of the emission sphere.
  13924. */
  13925. radius: number;
  13926. /**
  13927. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13928. */
  13929. radiusRange: number;
  13930. /**
  13931. * How much to randomize the particle direction [0-1].
  13932. */
  13933. directionRandomizer: number;
  13934. /**
  13935. * Creates a new instance SphereParticleEmitter
  13936. * @param radius the radius of the emission sphere (1 by default)
  13937. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13938. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13939. */
  13940. constructor(
  13941. /**
  13942. * The radius of the emission sphere.
  13943. */
  13944. radius?: number,
  13945. /**
  13946. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13947. */
  13948. radiusRange?: number,
  13949. /**
  13950. * How much to randomize the particle direction [0-1].
  13951. */
  13952. directionRandomizer?: number);
  13953. /**
  13954. * Called by the particle System when the direction is computed for the created particle.
  13955. * @param worldMatrix is the world matrix of the particle system
  13956. * @param directionToUpdate is the direction vector to update with the result
  13957. * @param particle is the particle we are computed the direction for
  13958. * @param isLocal defines if the direction should be set in local space
  13959. */
  13960. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13961. /**
  13962. * Called by the particle System when the position is computed for the created particle.
  13963. * @param worldMatrix is the world matrix of the particle system
  13964. * @param positionToUpdate is the position vector to update with the result
  13965. * @param particle is the particle we are computed the position for
  13966. * @param isLocal defines if the position should be set in local space
  13967. */
  13968. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13969. /**
  13970. * Clones the current emitter and returns a copy of it
  13971. * @returns the new emitter
  13972. */
  13973. clone(): SphereParticleEmitter;
  13974. /**
  13975. * Called by the GPUParticleSystem to setup the update shader
  13976. * @param effect defines the update shader
  13977. */
  13978. applyToShader(effect: Effect): void;
  13979. /**
  13980. * Returns a string to use to update the GPU particles update shader
  13981. * @returns a string containng the defines string
  13982. */
  13983. getEffectDefines(): string;
  13984. /**
  13985. * Returns the string "SphereParticleEmitter"
  13986. * @returns a string containing the class name
  13987. */
  13988. getClassName(): string;
  13989. /**
  13990. * Serializes the particle system to a JSON object.
  13991. * @returns the JSON object
  13992. */
  13993. serialize(): any;
  13994. /**
  13995. * Parse properties from a JSON object
  13996. * @param serializationObject defines the JSON object
  13997. */
  13998. parse(serializationObject: any): void;
  13999. }
  14000. /**
  14001. * Particle emitter emitting particles from the inside of a sphere.
  14002. * It emits the particles randomly between two vectors.
  14003. */
  14004. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  14005. /**
  14006. * The min limit of the emission direction.
  14007. */
  14008. direction1: Vector3;
  14009. /**
  14010. * The max limit of the emission direction.
  14011. */
  14012. direction2: Vector3;
  14013. /**
  14014. * Creates a new instance SphereDirectedParticleEmitter
  14015. * @param radius the radius of the emission sphere (1 by default)
  14016. * @param direction1 the min limit of the emission direction (up vector by default)
  14017. * @param direction2 the max limit of the emission direction (up vector by default)
  14018. */
  14019. constructor(radius?: number,
  14020. /**
  14021. * The min limit of the emission direction.
  14022. */
  14023. direction1?: Vector3,
  14024. /**
  14025. * The max limit of the emission direction.
  14026. */
  14027. direction2?: Vector3);
  14028. /**
  14029. * Called by the particle System when the direction is computed for the created particle.
  14030. * @param worldMatrix is the world matrix of the particle system
  14031. * @param directionToUpdate is the direction vector to update with the result
  14032. * @param particle is the particle we are computed the direction for
  14033. */
  14034. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  14035. /**
  14036. * Clones the current emitter and returns a copy of it
  14037. * @returns the new emitter
  14038. */
  14039. clone(): SphereDirectedParticleEmitter;
  14040. /**
  14041. * Called by the GPUParticleSystem to setup the update shader
  14042. * @param effect defines the update shader
  14043. */
  14044. applyToShader(effect: Effect): void;
  14045. /**
  14046. * Returns a string to use to update the GPU particles update shader
  14047. * @returns a string containng the defines string
  14048. */
  14049. getEffectDefines(): string;
  14050. /**
  14051. * Returns the string "SphereDirectedParticleEmitter"
  14052. * @returns a string containing the class name
  14053. */
  14054. getClassName(): string;
  14055. /**
  14056. * Serializes the particle system to a JSON object.
  14057. * @returns the JSON object
  14058. */
  14059. serialize(): any;
  14060. /**
  14061. * Parse properties from a JSON object
  14062. * @param serializationObject defines the JSON object
  14063. */
  14064. parse(serializationObject: any): void;
  14065. }
  14066. }
  14067. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  14068. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14069. import { Effect } from "babylonjs/Materials/effect";
  14070. import { Particle } from "babylonjs/Particles/particle";
  14071. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14072. import { Nullable } from "babylonjs/types";
  14073. /**
  14074. * Particle emitter emitting particles from a custom list of positions.
  14075. */
  14076. export class CustomParticleEmitter implements IParticleEmitterType {
  14077. /**
  14078. * Gets or sets the position generator that will create the inital position of each particle.
  14079. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  14080. */
  14081. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  14082. /**
  14083. * Gets or sets the destination generator that will create the final destination of each particle.
  14084. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  14085. */
  14086. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  14087. /**
  14088. * Creates a new instance CustomParticleEmitter
  14089. */
  14090. constructor();
  14091. /**
  14092. * Called by the particle System when the direction is computed for the created particle.
  14093. * @param worldMatrix is the world matrix of the particle system
  14094. * @param directionToUpdate is the direction vector to update with the result
  14095. * @param particle is the particle we are computed the direction for
  14096. * @param isLocal defines if the direction should be set in local space
  14097. */
  14098. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14099. /**
  14100. * Called by the particle System when the position is computed for the created particle.
  14101. * @param worldMatrix is the world matrix of the particle system
  14102. * @param positionToUpdate is the position vector to update with the result
  14103. * @param particle is the particle we are computed the position for
  14104. * @param isLocal defines if the position should be set in local space
  14105. */
  14106. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14107. /**
  14108. * Clones the current emitter and returns a copy of it
  14109. * @returns the new emitter
  14110. */
  14111. clone(): CustomParticleEmitter;
  14112. /**
  14113. * Called by the GPUParticleSystem to setup the update shader
  14114. * @param effect defines the update shader
  14115. */
  14116. applyToShader(effect: Effect): void;
  14117. /**
  14118. * Returns a string to use to update the GPU particles update shader
  14119. * @returns a string containng the defines string
  14120. */
  14121. getEffectDefines(): string;
  14122. /**
  14123. * Returns the string "PointParticleEmitter"
  14124. * @returns a string containing the class name
  14125. */
  14126. getClassName(): string;
  14127. /**
  14128. * Serializes the particle system to a JSON object.
  14129. * @returns the JSON object
  14130. */
  14131. serialize(): any;
  14132. /**
  14133. * Parse properties from a JSON object
  14134. * @param serializationObject defines the JSON object
  14135. */
  14136. parse(serializationObject: any): void;
  14137. }
  14138. }
  14139. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  14140. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14141. import { Effect } from "babylonjs/Materials/effect";
  14142. import { Particle } from "babylonjs/Particles/particle";
  14143. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14144. import { Nullable } from "babylonjs/types";
  14145. import { Scene } from "babylonjs/scene";
  14146. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14147. /**
  14148. * Particle emitter emitting particles from the inside of a box.
  14149. * It emits the particles randomly between 2 given directions.
  14150. */
  14151. export class MeshParticleEmitter implements IParticleEmitterType {
  14152. private _indices;
  14153. private _positions;
  14154. private _normals;
  14155. private _storedNormal;
  14156. private _mesh;
  14157. /**
  14158. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14159. */
  14160. direction1: Vector3;
  14161. /**
  14162. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14163. */
  14164. direction2: Vector3;
  14165. /**
  14166. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  14167. */
  14168. useMeshNormalsForDirection: boolean;
  14169. /** Defines the mesh to use as source */
  14170. get mesh(): Nullable<AbstractMesh>;
  14171. set mesh(value: Nullable<AbstractMesh>);
  14172. /**
  14173. * Creates a new instance MeshParticleEmitter
  14174. * @param mesh defines the mesh to use as source
  14175. */
  14176. constructor(mesh?: Nullable<AbstractMesh>);
  14177. /**
  14178. * Called by the particle System when the direction is computed for the created particle.
  14179. * @param worldMatrix is the world matrix of the particle system
  14180. * @param directionToUpdate is the direction vector to update with the result
  14181. * @param particle is the particle we are computed the direction for
  14182. * @param isLocal defines if the direction should be set in local space
  14183. */
  14184. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14185. /**
  14186. * Called by the particle System when the position is computed for the created particle.
  14187. * @param worldMatrix is the world matrix of the particle system
  14188. * @param positionToUpdate is the position vector to update with the result
  14189. * @param particle is the particle we are computed the position for
  14190. * @param isLocal defines if the position should be set in local space
  14191. */
  14192. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14193. /**
  14194. * Clones the current emitter and returns a copy of it
  14195. * @returns the new emitter
  14196. */
  14197. clone(): MeshParticleEmitter;
  14198. /**
  14199. * Called by the GPUParticleSystem to setup the update shader
  14200. * @param effect defines the update shader
  14201. */
  14202. applyToShader(effect: Effect): void;
  14203. /**
  14204. * Returns a string to use to update the GPU particles update shader
  14205. * @returns a string containng the defines string
  14206. */
  14207. getEffectDefines(): string;
  14208. /**
  14209. * Returns the string "BoxParticleEmitter"
  14210. * @returns a string containing the class name
  14211. */
  14212. getClassName(): string;
  14213. /**
  14214. * Serializes the particle system to a JSON object.
  14215. * @returns the JSON object
  14216. */
  14217. serialize(): any;
  14218. /**
  14219. * Parse properties from a JSON object
  14220. * @param serializationObject defines the JSON object
  14221. * @param scene defines the hosting scene
  14222. */
  14223. parse(serializationObject: any, scene: Scene): void;
  14224. }
  14225. }
  14226. declare module "babylonjs/Particles/EmitterTypes/index" {
  14227. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  14228. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  14229. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  14230. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  14231. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14232. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  14233. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  14234. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  14235. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  14236. }
  14237. declare module "babylonjs/Particles/IParticleSystem" {
  14238. import { Nullable } from "babylonjs/types";
  14239. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  14240. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  14241. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14242. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  14243. import { Texture } from "babylonjs/Materials/Textures/texture";
  14244. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14245. import { Scene } from "babylonjs/scene";
  14246. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  14247. import { Effect } from "babylonjs/Materials/effect";
  14248. import { Observable } from "babylonjs/Misc/observable";
  14249. import { Animation } from "babylonjs/Animations/animation";
  14250. /**
  14251. * Interface representing a particle system in Babylon.js.
  14252. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  14253. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  14254. */
  14255. export interface IParticleSystem {
  14256. /**
  14257. * List of animations used by the particle system.
  14258. */
  14259. animations: Animation[];
  14260. /**
  14261. * The id of the Particle system.
  14262. */
  14263. id: string;
  14264. /**
  14265. * The name of the Particle system.
  14266. */
  14267. name: string;
  14268. /**
  14269. * The emitter represents the Mesh or position we are attaching the particle system to.
  14270. */
  14271. emitter: Nullable<AbstractMesh | Vector3>;
  14272. /**
  14273. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14274. */
  14275. isBillboardBased: boolean;
  14276. /**
  14277. * The rendering group used by the Particle system to chose when to render.
  14278. */
  14279. renderingGroupId: number;
  14280. /**
  14281. * The layer mask we are rendering the particles through.
  14282. */
  14283. layerMask: number;
  14284. /**
  14285. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14286. */
  14287. updateSpeed: number;
  14288. /**
  14289. * The amount of time the particle system is running (depends of the overall update speed).
  14290. */
  14291. targetStopDuration: number;
  14292. /**
  14293. * The texture used to render each particle. (this can be a spritesheet)
  14294. */
  14295. particleTexture: Nullable<Texture>;
  14296. /**
  14297. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  14298. */
  14299. blendMode: number;
  14300. /**
  14301. * Minimum life time of emitting particles.
  14302. */
  14303. minLifeTime: number;
  14304. /**
  14305. * Maximum life time of emitting particles.
  14306. */
  14307. maxLifeTime: number;
  14308. /**
  14309. * Minimum Size of emitting particles.
  14310. */
  14311. minSize: number;
  14312. /**
  14313. * Maximum Size of emitting particles.
  14314. */
  14315. maxSize: number;
  14316. /**
  14317. * Minimum scale of emitting particles on X axis.
  14318. */
  14319. minScaleX: number;
  14320. /**
  14321. * Maximum scale of emitting particles on X axis.
  14322. */
  14323. maxScaleX: number;
  14324. /**
  14325. * Minimum scale of emitting particles on Y axis.
  14326. */
  14327. minScaleY: number;
  14328. /**
  14329. * Maximum scale of emitting particles on Y axis.
  14330. */
  14331. maxScaleY: number;
  14332. /**
  14333. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14334. */
  14335. color1: Color4;
  14336. /**
  14337. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14338. */
  14339. color2: Color4;
  14340. /**
  14341. * Color the particle will have at the end of its lifetime.
  14342. */
  14343. colorDead: Color4;
  14344. /**
  14345. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  14346. */
  14347. emitRate: number;
  14348. /**
  14349. * You can use gravity if you want to give an orientation to your particles.
  14350. */
  14351. gravity: Vector3;
  14352. /**
  14353. * Minimum power of emitting particles.
  14354. */
  14355. minEmitPower: number;
  14356. /**
  14357. * Maximum power of emitting particles.
  14358. */
  14359. maxEmitPower: number;
  14360. /**
  14361. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14362. */
  14363. minAngularSpeed: number;
  14364. /**
  14365. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14366. */
  14367. maxAngularSpeed: number;
  14368. /**
  14369. * Gets or sets the minimal initial rotation in radians.
  14370. */
  14371. minInitialRotation: number;
  14372. /**
  14373. * Gets or sets the maximal initial rotation in radians.
  14374. */
  14375. maxInitialRotation: number;
  14376. /**
  14377. * The particle emitter type defines the emitter used by the particle system.
  14378. * It can be for example box, sphere, or cone...
  14379. */
  14380. particleEmitterType: Nullable<IParticleEmitterType>;
  14381. /**
  14382. * Defines the delay in milliseconds before starting the system (0 by default)
  14383. */
  14384. startDelay: number;
  14385. /**
  14386. * 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
  14387. */
  14388. preWarmCycles: number;
  14389. /**
  14390. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14391. */
  14392. preWarmStepOffset: number;
  14393. /**
  14394. * 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)
  14395. */
  14396. spriteCellChangeSpeed: number;
  14397. /**
  14398. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14399. */
  14400. startSpriteCellID: number;
  14401. /**
  14402. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14403. */
  14404. endSpriteCellID: number;
  14405. /**
  14406. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14407. */
  14408. spriteCellWidth: number;
  14409. /**
  14410. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14411. */
  14412. spriteCellHeight: number;
  14413. /**
  14414. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14415. */
  14416. spriteRandomStartCell: boolean;
  14417. /**
  14418. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14419. */
  14420. isAnimationSheetEnabled: boolean;
  14421. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14422. translationPivot: Vector2;
  14423. /**
  14424. * Gets or sets a texture used to add random noise to particle positions
  14425. */
  14426. noiseTexture: Nullable<BaseTexture>;
  14427. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14428. noiseStrength: Vector3;
  14429. /**
  14430. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14431. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14432. */
  14433. billboardMode: number;
  14434. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14435. limitVelocityDamping: number;
  14436. /**
  14437. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14438. */
  14439. beginAnimationOnStart: boolean;
  14440. /**
  14441. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14442. */
  14443. beginAnimationFrom: number;
  14444. /**
  14445. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14446. */
  14447. beginAnimationTo: number;
  14448. /**
  14449. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14450. */
  14451. beginAnimationLoop: boolean;
  14452. /**
  14453. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14454. */
  14455. disposeOnStop: boolean;
  14456. /**
  14457. * Specifies if the particles are updated in emitter local space or world space
  14458. */
  14459. isLocal: boolean;
  14460. /** Snippet ID if the particle system was created from the snippet server */
  14461. snippetId: string;
  14462. /**
  14463. * Gets the maximum number of particles active at the same time.
  14464. * @returns The max number of active particles.
  14465. */
  14466. getCapacity(): number;
  14467. /**
  14468. * Gets the number of particles active at the same time.
  14469. * @returns The number of active particles.
  14470. */
  14471. getActiveCount(): number;
  14472. /**
  14473. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14474. * @returns True if it has been started, otherwise false.
  14475. */
  14476. isStarted(): boolean;
  14477. /**
  14478. * Animates the particle system for this frame.
  14479. */
  14480. animate(): void;
  14481. /**
  14482. * Renders the particle system in its current state.
  14483. * @returns the current number of particles
  14484. */
  14485. render(): number;
  14486. /**
  14487. * Dispose the particle system and frees its associated resources.
  14488. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14489. */
  14490. dispose(disposeTexture?: boolean): void;
  14491. /**
  14492. * An event triggered when the system is disposed
  14493. */
  14494. onDisposeObservable: Observable<IParticleSystem>;
  14495. /**
  14496. * Clones the particle system.
  14497. * @param name The name of the cloned object
  14498. * @param newEmitter The new emitter to use
  14499. * @returns the cloned particle system
  14500. */
  14501. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14502. /**
  14503. * Serializes the particle system to a JSON object
  14504. * @param serializeTexture defines if the texture must be serialized as well
  14505. * @returns the JSON object
  14506. */
  14507. serialize(serializeTexture: boolean): any;
  14508. /**
  14509. * Rebuild the particle system
  14510. */
  14511. rebuild(): void;
  14512. /** Force the system to rebuild all gradients that need to be resync */
  14513. forceRefreshGradients(): void;
  14514. /**
  14515. * Starts the particle system and begins to emit
  14516. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14517. */
  14518. start(delay?: number): void;
  14519. /**
  14520. * Stops the particle system.
  14521. */
  14522. stop(): void;
  14523. /**
  14524. * Remove all active particles
  14525. */
  14526. reset(): void;
  14527. /**
  14528. * Gets a boolean indicating that the system is stopping
  14529. * @returns true if the system is currently stopping
  14530. */
  14531. isStopping(): boolean;
  14532. /**
  14533. * Is this system ready to be used/rendered
  14534. * @return true if the system is ready
  14535. */
  14536. isReady(): boolean;
  14537. /**
  14538. * Returns the string "ParticleSystem"
  14539. * @returns a string containing the class name
  14540. */
  14541. getClassName(): string;
  14542. /**
  14543. * Gets the custom effect used to render the particles
  14544. * @param blendMode Blend mode for which the effect should be retrieved
  14545. * @returns The effect
  14546. */
  14547. getCustomEffect(blendMode: number): Nullable<Effect>;
  14548. /**
  14549. * Sets the custom effect used to render the particles
  14550. * @param effect The effect to set
  14551. * @param blendMode Blend mode for which the effect should be set
  14552. */
  14553. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14554. /**
  14555. * Fill the defines array according to the current settings of the particle system
  14556. * @param defines Array to be updated
  14557. * @param blendMode blend mode to take into account when updating the array
  14558. */
  14559. fillDefines(defines: Array<string>, blendMode: number): void;
  14560. /**
  14561. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14562. * @param uniforms Uniforms array to fill
  14563. * @param attributes Attributes array to fill
  14564. * @param samplers Samplers array to fill
  14565. */
  14566. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14567. /**
  14568. * Observable that will be called just before the particles are drawn
  14569. */
  14570. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14571. /**
  14572. * Gets the name of the particle vertex shader
  14573. */
  14574. vertexShaderName: string;
  14575. /**
  14576. * Adds a new color gradient
  14577. * @param gradient defines the gradient to use (between 0 and 1)
  14578. * @param color1 defines the color to affect to the specified gradient
  14579. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14580. * @returns the current particle system
  14581. */
  14582. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14583. /**
  14584. * Remove a specific color gradient
  14585. * @param gradient defines the gradient to remove
  14586. * @returns the current particle system
  14587. */
  14588. removeColorGradient(gradient: number): IParticleSystem;
  14589. /**
  14590. * Adds a new size gradient
  14591. * @param gradient defines the gradient to use (between 0 and 1)
  14592. * @param factor defines the size factor to affect to the specified gradient
  14593. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14594. * @returns the current particle system
  14595. */
  14596. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14597. /**
  14598. * Remove a specific size gradient
  14599. * @param gradient defines the gradient to remove
  14600. * @returns the current particle system
  14601. */
  14602. removeSizeGradient(gradient: number): IParticleSystem;
  14603. /**
  14604. * Gets the current list of color gradients.
  14605. * You must use addColorGradient and removeColorGradient to udpate this list
  14606. * @returns the list of color gradients
  14607. */
  14608. getColorGradients(): Nullable<Array<ColorGradient>>;
  14609. /**
  14610. * Gets the current list of size gradients.
  14611. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14612. * @returns the list of size gradients
  14613. */
  14614. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14615. /**
  14616. * Gets the current list of angular speed gradients.
  14617. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14618. * @returns the list of angular speed gradients
  14619. */
  14620. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14621. /**
  14622. * Adds a new angular speed gradient
  14623. * @param gradient defines the gradient to use (between 0 and 1)
  14624. * @param factor defines the angular speed to affect to the specified gradient
  14625. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14626. * @returns the current particle system
  14627. */
  14628. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14629. /**
  14630. * Remove a specific angular speed gradient
  14631. * @param gradient defines the gradient to remove
  14632. * @returns the current particle system
  14633. */
  14634. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14635. /**
  14636. * Gets the current list of velocity gradients.
  14637. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14638. * @returns the list of velocity gradients
  14639. */
  14640. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14641. /**
  14642. * Adds a new velocity gradient
  14643. * @param gradient defines the gradient to use (between 0 and 1)
  14644. * @param factor defines the velocity to affect to the specified gradient
  14645. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14646. * @returns the current particle system
  14647. */
  14648. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14649. /**
  14650. * Remove a specific velocity gradient
  14651. * @param gradient defines the gradient to remove
  14652. * @returns the current particle system
  14653. */
  14654. removeVelocityGradient(gradient: number): IParticleSystem;
  14655. /**
  14656. * Gets the current list of limit velocity gradients.
  14657. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14658. * @returns the list of limit velocity gradients
  14659. */
  14660. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14661. /**
  14662. * Adds a new limit velocity gradient
  14663. * @param gradient defines the gradient to use (between 0 and 1)
  14664. * @param factor defines the limit velocity to affect to the specified gradient
  14665. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14666. * @returns the current particle system
  14667. */
  14668. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14669. /**
  14670. * Remove a specific limit velocity gradient
  14671. * @param gradient defines the gradient to remove
  14672. * @returns the current particle system
  14673. */
  14674. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14675. /**
  14676. * Adds a new drag gradient
  14677. * @param gradient defines the gradient to use (between 0 and 1)
  14678. * @param factor defines the drag to affect to the specified gradient
  14679. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14680. * @returns the current particle system
  14681. */
  14682. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14683. /**
  14684. * Remove a specific drag gradient
  14685. * @param gradient defines the gradient to remove
  14686. * @returns the current particle system
  14687. */
  14688. removeDragGradient(gradient: number): IParticleSystem;
  14689. /**
  14690. * Gets the current list of drag gradients.
  14691. * You must use addDragGradient and removeDragGradient to udpate this list
  14692. * @returns the list of drag gradients
  14693. */
  14694. getDragGradients(): Nullable<Array<FactorGradient>>;
  14695. /**
  14696. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14697. * @param gradient defines the gradient to use (between 0 and 1)
  14698. * @param factor defines the emit rate to affect to the specified gradient
  14699. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14700. * @returns the current particle system
  14701. */
  14702. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14703. /**
  14704. * Remove a specific emit rate gradient
  14705. * @param gradient defines the gradient to remove
  14706. * @returns the current particle system
  14707. */
  14708. removeEmitRateGradient(gradient: number): IParticleSystem;
  14709. /**
  14710. * Gets the current list of emit rate gradients.
  14711. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14712. * @returns the list of emit rate gradients
  14713. */
  14714. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14715. /**
  14716. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14717. * @param gradient defines the gradient to use (between 0 and 1)
  14718. * @param factor defines the start size to affect to the specified gradient
  14719. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14720. * @returns the current particle system
  14721. */
  14722. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14723. /**
  14724. * Remove a specific start size gradient
  14725. * @param gradient defines the gradient to remove
  14726. * @returns the current particle system
  14727. */
  14728. removeStartSizeGradient(gradient: number): IParticleSystem;
  14729. /**
  14730. * Gets the current list of start size gradients.
  14731. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14732. * @returns the list of start size gradients
  14733. */
  14734. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14735. /**
  14736. * Adds a new life time gradient
  14737. * @param gradient defines the gradient to use (between 0 and 1)
  14738. * @param factor defines the life time factor to affect to the specified gradient
  14739. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14740. * @returns the current particle system
  14741. */
  14742. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14743. /**
  14744. * Remove a specific life time gradient
  14745. * @param gradient defines the gradient to remove
  14746. * @returns the current particle system
  14747. */
  14748. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14749. /**
  14750. * Gets the current list of life time gradients.
  14751. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14752. * @returns the list of life time gradients
  14753. */
  14754. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14755. /**
  14756. * Gets the current list of color gradients.
  14757. * You must use addColorGradient and removeColorGradient to udpate this list
  14758. * @returns the list of color gradients
  14759. */
  14760. getColorGradients(): Nullable<Array<ColorGradient>>;
  14761. /**
  14762. * Adds a new ramp gradient used to remap particle colors
  14763. * @param gradient defines the gradient to use (between 0 and 1)
  14764. * @param color defines the color to affect to the specified gradient
  14765. * @returns the current particle system
  14766. */
  14767. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14768. /**
  14769. * Gets the current list of ramp gradients.
  14770. * You must use addRampGradient and removeRampGradient to udpate this list
  14771. * @returns the list of ramp gradients
  14772. */
  14773. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14774. /** Gets or sets a boolean indicating that ramp gradients must be used
  14775. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14776. */
  14777. useRampGradients: boolean;
  14778. /**
  14779. * Adds a new color remap gradient
  14780. * @param gradient defines the gradient to use (between 0 and 1)
  14781. * @param min defines the color remap minimal range
  14782. * @param max defines the color remap maximal range
  14783. * @returns the current particle system
  14784. */
  14785. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14786. /**
  14787. * Gets the current list of color remap gradients.
  14788. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14789. * @returns the list of color remap gradients
  14790. */
  14791. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14792. /**
  14793. * Adds a new alpha remap gradient
  14794. * @param gradient defines the gradient to use (between 0 and 1)
  14795. * @param min defines the alpha remap minimal range
  14796. * @param max defines the alpha remap maximal range
  14797. * @returns the current particle system
  14798. */
  14799. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14800. /**
  14801. * Gets the current list of alpha remap gradients.
  14802. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14803. * @returns the list of alpha remap gradients
  14804. */
  14805. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14806. /**
  14807. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14808. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14809. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14810. * @returns the emitter
  14811. */
  14812. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14813. /**
  14814. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14815. * @param radius The radius of the hemisphere to emit from
  14816. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14817. * @returns the emitter
  14818. */
  14819. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14820. /**
  14821. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14822. * @param radius The radius of the sphere to emit from
  14823. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14824. * @returns the emitter
  14825. */
  14826. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14827. /**
  14828. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14829. * @param radius The radius of the sphere to emit from
  14830. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14831. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14832. * @returns the emitter
  14833. */
  14834. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14835. /**
  14836. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14837. * @param radius The radius of the emission cylinder
  14838. * @param height The height of the emission cylinder
  14839. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14840. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14841. * @returns the emitter
  14842. */
  14843. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  14844. /**
  14845. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14846. * @param radius The radius of the cylinder to emit from
  14847. * @param height The height of the emission cylinder
  14848. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14849. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14850. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14851. * @returns the emitter
  14852. */
  14853. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14854. /**
  14855. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14856. * @param radius The radius of the cone to emit from
  14857. * @param angle The base angle of the cone
  14858. * @returns the emitter
  14859. */
  14860. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  14861. /**
  14862. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14863. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14864. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14865. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14866. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14867. * @returns the emitter
  14868. */
  14869. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14870. /**
  14871. * Get hosting scene
  14872. * @returns the scene
  14873. */
  14874. getScene(): Scene;
  14875. }
  14876. }
  14877. declare module "babylonjs/Meshes/transformNode" {
  14878. import { DeepImmutable } from "babylonjs/types";
  14879. import { Observable } from "babylonjs/Misc/observable";
  14880. import { Nullable } from "babylonjs/types";
  14881. import { Camera } from "babylonjs/Cameras/camera";
  14882. import { Scene } from "babylonjs/scene";
  14883. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14884. import { Node } from "babylonjs/node";
  14885. import { Bone } from "babylonjs/Bones/bone";
  14886. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14887. import { Space } from "babylonjs/Maths/math.axis";
  14888. /**
  14889. * 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.
  14890. * @see https://doc.babylonjs.com/how_to/transformnode
  14891. */
  14892. export class TransformNode extends Node {
  14893. /**
  14894. * Object will not rotate to face the camera
  14895. */
  14896. static BILLBOARDMODE_NONE: number;
  14897. /**
  14898. * Object will rotate to face the camera but only on the x axis
  14899. */
  14900. static BILLBOARDMODE_X: number;
  14901. /**
  14902. * Object will rotate to face the camera but only on the y axis
  14903. */
  14904. static BILLBOARDMODE_Y: number;
  14905. /**
  14906. * Object will rotate to face the camera but only on the z axis
  14907. */
  14908. static BILLBOARDMODE_Z: number;
  14909. /**
  14910. * Object will rotate to face the camera
  14911. */
  14912. static BILLBOARDMODE_ALL: number;
  14913. /**
  14914. * Object will rotate to face the camera's position instead of orientation
  14915. */
  14916. static BILLBOARDMODE_USE_POSITION: number;
  14917. private _forward;
  14918. private _forwardInverted;
  14919. private _up;
  14920. private _right;
  14921. private _rightInverted;
  14922. private _position;
  14923. private _rotation;
  14924. private _rotationQuaternion;
  14925. protected _scaling: Vector3;
  14926. protected _isDirty: boolean;
  14927. private _transformToBoneReferal;
  14928. private _isAbsoluteSynced;
  14929. private _billboardMode;
  14930. /**
  14931. * Gets or sets the billboard mode. Default is 0.
  14932. *
  14933. * | Value | Type | Description |
  14934. * | --- | --- | --- |
  14935. * | 0 | BILLBOARDMODE_NONE | |
  14936. * | 1 | BILLBOARDMODE_X | |
  14937. * | 2 | BILLBOARDMODE_Y | |
  14938. * | 4 | BILLBOARDMODE_Z | |
  14939. * | 7 | BILLBOARDMODE_ALL | |
  14940. *
  14941. */
  14942. get billboardMode(): number;
  14943. set billboardMode(value: number);
  14944. private _preserveParentRotationForBillboard;
  14945. /**
  14946. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14947. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14948. */
  14949. get preserveParentRotationForBillboard(): boolean;
  14950. set preserveParentRotationForBillboard(value: boolean);
  14951. /**
  14952. * 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
  14953. */
  14954. scalingDeterminant: number;
  14955. private _infiniteDistance;
  14956. /**
  14957. * Gets or sets the distance of the object to max, often used by skybox
  14958. */
  14959. get infiniteDistance(): boolean;
  14960. set infiniteDistance(value: boolean);
  14961. /**
  14962. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14963. * By default the system will update normals to compensate
  14964. */
  14965. ignoreNonUniformScaling: boolean;
  14966. /**
  14967. * 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
  14968. */
  14969. reIntegrateRotationIntoRotationQuaternion: boolean;
  14970. /** @hidden */
  14971. _poseMatrix: Nullable<Matrix>;
  14972. /** @hidden */
  14973. _localMatrix: Matrix;
  14974. private _usePivotMatrix;
  14975. private _absolutePosition;
  14976. private _absoluteScaling;
  14977. private _absoluteRotationQuaternion;
  14978. private _pivotMatrix;
  14979. private _pivotMatrixInverse;
  14980. protected _postMultiplyPivotMatrix: boolean;
  14981. protected _isWorldMatrixFrozen: boolean;
  14982. /** @hidden */
  14983. _indexInSceneTransformNodesArray: number;
  14984. /**
  14985. * An event triggered after the world matrix is updated
  14986. */
  14987. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14988. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14989. /**
  14990. * Gets a string identifying the name of the class
  14991. * @returns "TransformNode" string
  14992. */
  14993. getClassName(): string;
  14994. /**
  14995. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14996. */
  14997. get position(): Vector3;
  14998. set position(newPosition: Vector3);
  14999. /**
  15000. * 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)).
  15001. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  15002. */
  15003. get rotation(): Vector3;
  15004. set rotation(newRotation: Vector3);
  15005. /**
  15006. * 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)).
  15007. */
  15008. get scaling(): Vector3;
  15009. set scaling(newScaling: Vector3);
  15010. /**
  15011. * 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).
  15012. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  15013. */
  15014. get rotationQuaternion(): Nullable<Quaternion>;
  15015. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  15016. /**
  15017. * The forward direction of that transform in world space.
  15018. */
  15019. get forward(): Vector3;
  15020. /**
  15021. * The up direction of that transform in world space.
  15022. */
  15023. get up(): Vector3;
  15024. /**
  15025. * The right direction of that transform in world space.
  15026. */
  15027. get right(): Vector3;
  15028. /**
  15029. * Copies the parameter passed Matrix into the mesh Pose matrix.
  15030. * @param matrix the matrix to copy the pose from
  15031. * @returns this TransformNode.
  15032. */
  15033. updatePoseMatrix(matrix: Matrix): TransformNode;
  15034. /**
  15035. * Returns the mesh Pose matrix.
  15036. * @returns the pose matrix
  15037. */
  15038. getPoseMatrix(): Matrix;
  15039. /** @hidden */
  15040. _isSynchronized(): boolean;
  15041. /** @hidden */
  15042. _initCache(): void;
  15043. /**
  15044. * Flag the transform node as dirty (Forcing it to update everything)
  15045. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  15046. * @returns this transform node
  15047. */
  15048. markAsDirty(property: string): TransformNode;
  15049. /**
  15050. * Returns the current mesh absolute position.
  15051. * Returns a Vector3.
  15052. */
  15053. get absolutePosition(): Vector3;
  15054. /**
  15055. * Returns the current mesh absolute scaling.
  15056. * Returns a Vector3.
  15057. */
  15058. get absoluteScaling(): Vector3;
  15059. /**
  15060. * Returns the current mesh absolute rotation.
  15061. * Returns a Quaternion.
  15062. */
  15063. get absoluteRotationQuaternion(): Quaternion;
  15064. /**
  15065. * Sets a new matrix to apply before all other transformation
  15066. * @param matrix defines the transform matrix
  15067. * @returns the current TransformNode
  15068. */
  15069. setPreTransformMatrix(matrix: Matrix): TransformNode;
  15070. /**
  15071. * Sets a new pivot matrix to the current node
  15072. * @param matrix defines the new pivot matrix to use
  15073. * @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
  15074. * @returns the current TransformNode
  15075. */
  15076. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  15077. /**
  15078. * Returns the mesh pivot matrix.
  15079. * Default : Identity.
  15080. * @returns the matrix
  15081. */
  15082. getPivotMatrix(): Matrix;
  15083. /**
  15084. * Instantiate (when possible) or clone that node with its hierarchy
  15085. * @param newParent defines the new parent to use for the instance (or clone)
  15086. * @param options defines options to configure how copy is done
  15087. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  15088. * @returns an instance (or a clone) of the current node with its hiearchy
  15089. */
  15090. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  15091. doNotInstantiate: boolean;
  15092. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  15093. /**
  15094. * Prevents the World matrix to be computed any longer
  15095. * @param newWorldMatrix defines an optional matrix to use as world matrix
  15096. * @returns the TransformNode.
  15097. */
  15098. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  15099. /**
  15100. * Allows back the World matrix computation.
  15101. * @returns the TransformNode.
  15102. */
  15103. unfreezeWorldMatrix(): this;
  15104. /**
  15105. * True if the World matrix has been frozen.
  15106. */
  15107. get isWorldMatrixFrozen(): boolean;
  15108. /**
  15109. * Retuns the mesh absolute position in the World.
  15110. * @returns a Vector3.
  15111. */
  15112. getAbsolutePosition(): Vector3;
  15113. /**
  15114. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  15115. * @param absolutePosition the absolute position to set
  15116. * @returns the TransformNode.
  15117. */
  15118. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  15119. /**
  15120. * Sets the mesh position in its local space.
  15121. * @param vector3 the position to set in localspace
  15122. * @returns the TransformNode.
  15123. */
  15124. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  15125. /**
  15126. * Returns the mesh position in the local space from the current World matrix values.
  15127. * @returns a new Vector3.
  15128. */
  15129. getPositionExpressedInLocalSpace(): Vector3;
  15130. /**
  15131. * Translates the mesh along the passed Vector3 in its local space.
  15132. * @param vector3 the distance to translate in localspace
  15133. * @returns the TransformNode.
  15134. */
  15135. locallyTranslate(vector3: Vector3): TransformNode;
  15136. private static _lookAtVectorCache;
  15137. /**
  15138. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  15139. * @param targetPoint the position (must be in same space as current mesh) to look at
  15140. * @param yawCor optional yaw (y-axis) correction in radians
  15141. * @param pitchCor optional pitch (x-axis) correction in radians
  15142. * @param rollCor optional roll (z-axis) correction in radians
  15143. * @param space the choosen space of the target
  15144. * @returns the TransformNode.
  15145. */
  15146. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  15147. /**
  15148. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15149. * This Vector3 is expressed in the World space.
  15150. * @param localAxis axis to rotate
  15151. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15152. */
  15153. getDirection(localAxis: Vector3): Vector3;
  15154. /**
  15155. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  15156. * localAxis is expressed in the mesh local space.
  15157. * result is computed in the Wordl space from the mesh World matrix.
  15158. * @param localAxis axis to rotate
  15159. * @param result the resulting transformnode
  15160. * @returns this TransformNode.
  15161. */
  15162. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  15163. /**
  15164. * Sets this transform node rotation to the given local axis.
  15165. * @param localAxis the axis in local space
  15166. * @param yawCor optional yaw (y-axis) correction in radians
  15167. * @param pitchCor optional pitch (x-axis) correction in radians
  15168. * @param rollCor optional roll (z-axis) correction in radians
  15169. * @returns this TransformNode
  15170. */
  15171. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  15172. /**
  15173. * Sets a new pivot point to the current node
  15174. * @param point defines the new pivot point to use
  15175. * @param space defines if the point is in world or local space (local by default)
  15176. * @returns the current TransformNode
  15177. */
  15178. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  15179. /**
  15180. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  15181. * @returns the pivot point
  15182. */
  15183. getPivotPoint(): Vector3;
  15184. /**
  15185. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  15186. * @param result the vector3 to store the result
  15187. * @returns this TransformNode.
  15188. */
  15189. getPivotPointToRef(result: Vector3): TransformNode;
  15190. /**
  15191. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  15192. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  15193. */
  15194. getAbsolutePivotPoint(): Vector3;
  15195. /**
  15196. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  15197. * @param result vector3 to store the result
  15198. * @returns this TransformNode.
  15199. */
  15200. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  15201. /**
  15202. * Defines the passed node as the parent of the current node.
  15203. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  15204. * @see https://doc.babylonjs.com/how_to/parenting
  15205. * @param node the node ot set as the parent
  15206. * @returns this TransformNode.
  15207. */
  15208. setParent(node: Nullable<Node>): TransformNode;
  15209. private _nonUniformScaling;
  15210. /**
  15211. * True if the scaling property of this object is non uniform eg. (1,2,1)
  15212. */
  15213. get nonUniformScaling(): boolean;
  15214. /** @hidden */
  15215. _updateNonUniformScalingState(value: boolean): boolean;
  15216. /**
  15217. * Attach the current TransformNode to another TransformNode associated with a bone
  15218. * @param bone Bone affecting the TransformNode
  15219. * @param affectedTransformNode TransformNode associated with the bone
  15220. * @returns this object
  15221. */
  15222. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  15223. /**
  15224. * Detach the transform node if its associated with a bone
  15225. * @returns this object
  15226. */
  15227. detachFromBone(): TransformNode;
  15228. private static _rotationAxisCache;
  15229. /**
  15230. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  15231. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15232. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15233. * The passed axis is also normalized.
  15234. * @param axis the axis to rotate around
  15235. * @param amount the amount to rotate in radians
  15236. * @param space Space to rotate in (Default: local)
  15237. * @returns the TransformNode.
  15238. */
  15239. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  15240. /**
  15241. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  15242. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15243. * The passed axis is also normalized. .
  15244. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  15245. * @param point the point to rotate around
  15246. * @param axis the axis to rotate around
  15247. * @param amount the amount to rotate in radians
  15248. * @returns the TransformNode
  15249. */
  15250. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  15251. /**
  15252. * Translates the mesh along the axis vector for the passed distance in the given space.
  15253. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15254. * @param axis the axis to translate in
  15255. * @param distance the distance to translate
  15256. * @param space Space to rotate in (Default: local)
  15257. * @returns the TransformNode.
  15258. */
  15259. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  15260. /**
  15261. * Adds a rotation step to the mesh current rotation.
  15262. * x, y, z are Euler angles expressed in radians.
  15263. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  15264. * This means this rotation is made in the mesh local space only.
  15265. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  15266. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  15267. * ```javascript
  15268. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  15269. * ```
  15270. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  15271. * 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.
  15272. * @param x Rotation to add
  15273. * @param y Rotation to add
  15274. * @param z Rotation to add
  15275. * @returns the TransformNode.
  15276. */
  15277. addRotation(x: number, y: number, z: number): TransformNode;
  15278. /**
  15279. * @hidden
  15280. */
  15281. protected _getEffectiveParent(): Nullable<Node>;
  15282. /**
  15283. * Computes the world matrix of the node
  15284. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15285. * @returns the world matrix
  15286. */
  15287. computeWorldMatrix(force?: boolean): Matrix;
  15288. /**
  15289. * Resets this nodeTransform's local matrix to Matrix.Identity().
  15290. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  15291. */
  15292. resetLocalMatrix(independentOfChildren?: boolean): void;
  15293. protected _afterComputeWorldMatrix(): void;
  15294. /**
  15295. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  15296. * @param func callback function to add
  15297. *
  15298. * @returns the TransformNode.
  15299. */
  15300. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15301. /**
  15302. * Removes a registered callback function.
  15303. * @param func callback function to remove
  15304. * @returns the TransformNode.
  15305. */
  15306. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15307. /**
  15308. * Gets the position of the current mesh in camera space
  15309. * @param camera defines the camera to use
  15310. * @returns a position
  15311. */
  15312. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  15313. /**
  15314. * Returns the distance from the mesh to the active camera
  15315. * @param camera defines the camera to use
  15316. * @returns the distance
  15317. */
  15318. getDistanceToCamera(camera?: Nullable<Camera>): number;
  15319. /**
  15320. * Clone the current transform node
  15321. * @param name Name of the new clone
  15322. * @param newParent New parent for the clone
  15323. * @param doNotCloneChildren Do not clone children hierarchy
  15324. * @returns the new transform node
  15325. */
  15326. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  15327. /**
  15328. * Serializes the objects information.
  15329. * @param currentSerializationObject defines the object to serialize in
  15330. * @returns the serialized object
  15331. */
  15332. serialize(currentSerializationObject?: any): any;
  15333. /**
  15334. * Returns a new TransformNode object parsed from the source provided.
  15335. * @param parsedTransformNode is the source.
  15336. * @param scene the scne the object belongs to
  15337. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  15338. * @returns a new TransformNode object parsed from the source provided.
  15339. */
  15340. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  15341. /**
  15342. * Get all child-transformNodes of this node
  15343. * @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
  15344. * @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
  15345. * @returns an array of TransformNode
  15346. */
  15347. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  15348. /**
  15349. * Releases resources associated with this transform node.
  15350. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15351. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15352. */
  15353. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15354. /**
  15355. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  15356. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  15357. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  15358. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  15359. * @returns the current mesh
  15360. */
  15361. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  15362. private _syncAbsoluteScalingAndRotation;
  15363. }
  15364. }
  15365. declare module "babylonjs/Animations/animationPropertiesOverride" {
  15366. /**
  15367. * Class used to override all child animations of a given target
  15368. */
  15369. export class AnimationPropertiesOverride {
  15370. /**
  15371. * Gets or sets a value indicating if animation blending must be used
  15372. */
  15373. enableBlending: boolean;
  15374. /**
  15375. * Gets or sets the blending speed to use when enableBlending is true
  15376. */
  15377. blendingSpeed: number;
  15378. /**
  15379. * Gets or sets the default loop mode to use
  15380. */
  15381. loopMode: number;
  15382. }
  15383. }
  15384. declare module "babylonjs/Bones/bone" {
  15385. import { Skeleton } from "babylonjs/Bones/skeleton";
  15386. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  15387. import { Nullable } from "babylonjs/types";
  15388. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15389. import { TransformNode } from "babylonjs/Meshes/transformNode";
  15390. import { Node } from "babylonjs/node";
  15391. import { Space } from "babylonjs/Maths/math.axis";
  15392. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  15393. /**
  15394. * Class used to store bone information
  15395. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15396. */
  15397. export class Bone extends Node {
  15398. /**
  15399. * defines the bone name
  15400. */
  15401. name: string;
  15402. private static _tmpVecs;
  15403. private static _tmpQuat;
  15404. private static _tmpMats;
  15405. /**
  15406. * Gets the list of child bones
  15407. */
  15408. children: Bone[];
  15409. /** Gets the animations associated with this bone */
  15410. animations: import("babylonjs/Animations/animation").Animation[];
  15411. /**
  15412. * Gets or sets bone length
  15413. */
  15414. length: number;
  15415. /**
  15416. * @hidden Internal only
  15417. * Set this value to map this bone to a different index in the transform matrices
  15418. * Set this value to -1 to exclude the bone from the transform matrices
  15419. */
  15420. _index: Nullable<number>;
  15421. private _skeleton;
  15422. private _localMatrix;
  15423. private _restPose;
  15424. private _baseMatrix;
  15425. private _absoluteTransform;
  15426. private _invertedAbsoluteTransform;
  15427. private _parent;
  15428. private _scalingDeterminant;
  15429. private _worldTransform;
  15430. private _localScaling;
  15431. private _localRotation;
  15432. private _localPosition;
  15433. private _needToDecompose;
  15434. private _needToCompose;
  15435. /** @hidden */
  15436. _linkedTransformNode: Nullable<TransformNode>;
  15437. /** @hidden */
  15438. _waitingTransformNodeId: Nullable<string>;
  15439. /** @hidden */
  15440. get _matrix(): Matrix;
  15441. /** @hidden */
  15442. set _matrix(value: Matrix);
  15443. /**
  15444. * Create a new bone
  15445. * @param name defines the bone name
  15446. * @param skeleton defines the parent skeleton
  15447. * @param parentBone defines the parent (can be null if the bone is the root)
  15448. * @param localMatrix defines the local matrix
  15449. * @param restPose defines the rest pose matrix
  15450. * @param baseMatrix defines the base matrix
  15451. * @param index defines index of the bone in the hiearchy
  15452. */
  15453. constructor(
  15454. /**
  15455. * defines the bone name
  15456. */
  15457. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15458. /**
  15459. * Gets the current object class name.
  15460. * @return the class name
  15461. */
  15462. getClassName(): string;
  15463. /**
  15464. * Gets the parent skeleton
  15465. * @returns a skeleton
  15466. */
  15467. getSkeleton(): Skeleton;
  15468. /**
  15469. * Gets parent bone
  15470. * @returns a bone or null if the bone is the root of the bone hierarchy
  15471. */
  15472. getParent(): Nullable<Bone>;
  15473. /**
  15474. * Returns an array containing the root bones
  15475. * @returns an array containing the root bones
  15476. */
  15477. getChildren(): Array<Bone>;
  15478. /**
  15479. * Gets the node index in matrix array generated for rendering
  15480. * @returns the node index
  15481. */
  15482. getIndex(): number;
  15483. /**
  15484. * Sets the parent bone
  15485. * @param parent defines the parent (can be null if the bone is the root)
  15486. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15487. */
  15488. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15489. /**
  15490. * Gets the local matrix
  15491. * @returns a matrix
  15492. */
  15493. getLocalMatrix(): Matrix;
  15494. /**
  15495. * Gets the base matrix (initial matrix which remains unchanged)
  15496. * @returns a matrix
  15497. */
  15498. getBaseMatrix(): Matrix;
  15499. /**
  15500. * Gets the rest pose matrix
  15501. * @returns a matrix
  15502. */
  15503. getRestPose(): Matrix;
  15504. /**
  15505. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15506. */
  15507. getWorldMatrix(): Matrix;
  15508. /**
  15509. * Sets the local matrix to rest pose matrix
  15510. */
  15511. returnToRest(): void;
  15512. /**
  15513. * Gets the inverse of the absolute transform matrix.
  15514. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15515. * @returns a matrix
  15516. */
  15517. getInvertedAbsoluteTransform(): Matrix;
  15518. /**
  15519. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15520. * @returns a matrix
  15521. */
  15522. getAbsoluteTransform(): Matrix;
  15523. /**
  15524. * Links with the given transform node.
  15525. * The local matrix of this bone is copied from the transform node every frame.
  15526. * @param transformNode defines the transform node to link to
  15527. */
  15528. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15529. /**
  15530. * Gets the node used to drive the bone's transformation
  15531. * @returns a transform node or null
  15532. */
  15533. getTransformNode(): Nullable<TransformNode>;
  15534. /** Gets or sets current position (in local space) */
  15535. get position(): Vector3;
  15536. set position(newPosition: Vector3);
  15537. /** Gets or sets current rotation (in local space) */
  15538. get rotation(): Vector3;
  15539. set rotation(newRotation: Vector3);
  15540. /** Gets or sets current rotation quaternion (in local space) */
  15541. get rotationQuaternion(): Quaternion;
  15542. set rotationQuaternion(newRotation: Quaternion);
  15543. /** Gets or sets current scaling (in local space) */
  15544. get scaling(): Vector3;
  15545. set scaling(newScaling: Vector3);
  15546. /**
  15547. * Gets the animation properties override
  15548. */
  15549. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15550. private _decompose;
  15551. private _compose;
  15552. /**
  15553. * Update the base and local matrices
  15554. * @param matrix defines the new base or local matrix
  15555. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15556. * @param updateLocalMatrix defines if the local matrix should be updated
  15557. */
  15558. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15559. /** @hidden */
  15560. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15561. /**
  15562. * Flag the bone as dirty (Forcing it to update everything)
  15563. */
  15564. markAsDirty(): void;
  15565. /** @hidden */
  15566. _markAsDirtyAndCompose(): void;
  15567. private _markAsDirtyAndDecompose;
  15568. /**
  15569. * Translate the bone in local or world space
  15570. * @param vec The amount to translate the bone
  15571. * @param space The space that the translation is in
  15572. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15573. */
  15574. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15575. /**
  15576. * Set the postion of the bone in local or world space
  15577. * @param position The position to set the bone
  15578. * @param space The space that the position is in
  15579. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15580. */
  15581. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15582. /**
  15583. * Set the absolute position of the bone (world space)
  15584. * @param position The position to set the bone
  15585. * @param mesh The mesh that this bone is attached to
  15586. */
  15587. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15588. /**
  15589. * Scale the bone on the x, y and z axes (in local space)
  15590. * @param x The amount to scale the bone on the x axis
  15591. * @param y The amount to scale the bone on the y axis
  15592. * @param z The amount to scale the bone on the z axis
  15593. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15594. */
  15595. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15596. /**
  15597. * Set the bone scaling in local space
  15598. * @param scale defines the scaling vector
  15599. */
  15600. setScale(scale: Vector3): void;
  15601. /**
  15602. * Gets the current scaling in local space
  15603. * @returns the current scaling vector
  15604. */
  15605. getScale(): Vector3;
  15606. /**
  15607. * Gets the current scaling in local space and stores it in a target vector
  15608. * @param result defines the target vector
  15609. */
  15610. getScaleToRef(result: Vector3): void;
  15611. /**
  15612. * Set the yaw, pitch, and roll of the bone in local or world space
  15613. * @param yaw The rotation of the bone on the y axis
  15614. * @param pitch The rotation of the bone on the x axis
  15615. * @param roll The rotation of the bone on the z axis
  15616. * @param space The space that the axes of rotation are in
  15617. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15618. */
  15619. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15620. /**
  15621. * Add a rotation to the bone on an axis in local or world space
  15622. * @param axis The axis to rotate the bone on
  15623. * @param amount The amount to rotate the bone
  15624. * @param space The space that the axis is in
  15625. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15626. */
  15627. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15628. /**
  15629. * Set the rotation of the bone to a particular axis angle in local or world space
  15630. * @param axis The axis to rotate the bone on
  15631. * @param angle The angle that the bone should be rotated to
  15632. * @param space The space that the axis is in
  15633. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15634. */
  15635. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15636. /**
  15637. * Set the euler rotation of the bone in local of world space
  15638. * @param rotation The euler rotation that the bone should be set to
  15639. * @param space The space that the rotation is in
  15640. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15641. */
  15642. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15643. /**
  15644. * Set the quaternion rotation of the bone in local of world space
  15645. * @param quat The quaternion rotation that the bone should be set to
  15646. * @param space The space that the rotation is in
  15647. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15648. */
  15649. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15650. /**
  15651. * Set the rotation matrix of the bone in local of world space
  15652. * @param rotMat The rotation matrix that the bone should be set to
  15653. * @param space The space that the rotation is in
  15654. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15655. */
  15656. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15657. private _rotateWithMatrix;
  15658. private _getNegativeRotationToRef;
  15659. /**
  15660. * Get the position of the bone in local or world space
  15661. * @param space The space that the returned position is in
  15662. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15663. * @returns The position of the bone
  15664. */
  15665. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15666. /**
  15667. * Copy the position of the bone to a vector3 in local or world space
  15668. * @param space The space that the returned position is in
  15669. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15670. * @param result The vector3 to copy the position to
  15671. */
  15672. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15673. /**
  15674. * Get the absolute position of the bone (world space)
  15675. * @param mesh The mesh that this bone is attached to
  15676. * @returns The absolute position of the bone
  15677. */
  15678. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15679. /**
  15680. * Copy the absolute position of the bone (world space) to the result param
  15681. * @param mesh The mesh that this bone is attached to
  15682. * @param result The vector3 to copy the absolute position to
  15683. */
  15684. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15685. /**
  15686. * Compute the absolute transforms of this bone and its children
  15687. */
  15688. computeAbsoluteTransforms(): void;
  15689. /**
  15690. * Get the world direction from an axis that is in the local space of the bone
  15691. * @param localAxis The local direction that is used to compute the world direction
  15692. * @param mesh The mesh that this bone is attached to
  15693. * @returns The world direction
  15694. */
  15695. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15696. /**
  15697. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15698. * @param localAxis The local direction that is used to compute the world direction
  15699. * @param mesh The mesh that this bone is attached to
  15700. * @param result The vector3 that the world direction will be copied to
  15701. */
  15702. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15703. /**
  15704. * Get the euler rotation of the bone in local or world space
  15705. * @param space The space that the rotation should be in
  15706. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15707. * @returns The euler rotation
  15708. */
  15709. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15710. /**
  15711. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15712. * @param space The space that the rotation should be in
  15713. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15714. * @param result The vector3 that the rotation should be copied to
  15715. */
  15716. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15717. /**
  15718. * Get the quaternion rotation of the bone in either local or world space
  15719. * @param space The space that the rotation should be in
  15720. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15721. * @returns The quaternion rotation
  15722. */
  15723. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15724. /**
  15725. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15726. * @param space The space that the rotation should be in
  15727. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15728. * @param result The quaternion that the rotation should be copied to
  15729. */
  15730. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15731. /**
  15732. * Get the rotation matrix of the bone in local or world space
  15733. * @param space The space that the rotation should be in
  15734. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15735. * @returns The rotation matrix
  15736. */
  15737. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15738. /**
  15739. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15740. * @param space The space that the rotation should be in
  15741. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15742. * @param result The quaternion that the rotation should be copied to
  15743. */
  15744. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15745. /**
  15746. * Get the world position of a point that is in the local space of the bone
  15747. * @param position The local position
  15748. * @param mesh The mesh that this bone is attached to
  15749. * @returns The world position
  15750. */
  15751. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15752. /**
  15753. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15754. * @param position The local position
  15755. * @param mesh The mesh that this bone is attached to
  15756. * @param result The vector3 that the world position should be copied to
  15757. */
  15758. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15759. /**
  15760. * Get the local position of a point that is in world space
  15761. * @param position The world position
  15762. * @param mesh The mesh that this bone is attached to
  15763. * @returns The local position
  15764. */
  15765. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15766. /**
  15767. * Get the local position of a point that is in world space and copy it to the result param
  15768. * @param position The world position
  15769. * @param mesh The mesh that this bone is attached to
  15770. * @param result The vector3 that the local position should be copied to
  15771. */
  15772. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15773. }
  15774. }
  15775. declare module "babylonjs/Animations/runtimeAnimation" {
  15776. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  15777. import { Animatable } from "babylonjs/Animations/animatable";
  15778. import { Scene } from "babylonjs/scene";
  15779. /**
  15780. * Defines a runtime animation
  15781. */
  15782. export class RuntimeAnimation {
  15783. private _events;
  15784. /**
  15785. * The current frame of the runtime animation
  15786. */
  15787. private _currentFrame;
  15788. /**
  15789. * The animation used by the runtime animation
  15790. */
  15791. private _animation;
  15792. /**
  15793. * The target of the runtime animation
  15794. */
  15795. private _target;
  15796. /**
  15797. * The initiating animatable
  15798. */
  15799. private _host;
  15800. /**
  15801. * The original value of the runtime animation
  15802. */
  15803. private _originalValue;
  15804. /**
  15805. * The original blend value of the runtime animation
  15806. */
  15807. private _originalBlendValue;
  15808. /**
  15809. * The offsets cache of the runtime animation
  15810. */
  15811. private _offsetsCache;
  15812. /**
  15813. * The high limits cache of the runtime animation
  15814. */
  15815. private _highLimitsCache;
  15816. /**
  15817. * Specifies if the runtime animation has been stopped
  15818. */
  15819. private _stopped;
  15820. /**
  15821. * The blending factor of the runtime animation
  15822. */
  15823. private _blendingFactor;
  15824. /**
  15825. * The BabylonJS scene
  15826. */
  15827. private _scene;
  15828. /**
  15829. * The current value of the runtime animation
  15830. */
  15831. private _currentValue;
  15832. /** @hidden */
  15833. _animationState: _IAnimationState;
  15834. /**
  15835. * The active target of the runtime animation
  15836. */
  15837. private _activeTargets;
  15838. private _currentActiveTarget;
  15839. private _directTarget;
  15840. /**
  15841. * The target path of the runtime animation
  15842. */
  15843. private _targetPath;
  15844. /**
  15845. * The weight of the runtime animation
  15846. */
  15847. private _weight;
  15848. /**
  15849. * The ratio offset of the runtime animation
  15850. */
  15851. private _ratioOffset;
  15852. /**
  15853. * The previous delay of the runtime animation
  15854. */
  15855. private _previousDelay;
  15856. /**
  15857. * The previous ratio of the runtime animation
  15858. */
  15859. private _previousRatio;
  15860. private _enableBlending;
  15861. private _keys;
  15862. private _minFrame;
  15863. private _maxFrame;
  15864. private _minValue;
  15865. private _maxValue;
  15866. private _targetIsArray;
  15867. /**
  15868. * Gets the current frame of the runtime animation
  15869. */
  15870. get currentFrame(): number;
  15871. /**
  15872. * Gets the weight of the runtime animation
  15873. */
  15874. get weight(): number;
  15875. /**
  15876. * Gets the current value of the runtime animation
  15877. */
  15878. get currentValue(): any;
  15879. /**
  15880. * Gets the target path of the runtime animation
  15881. */
  15882. get targetPath(): string;
  15883. /**
  15884. * Gets the actual target of the runtime animation
  15885. */
  15886. get target(): any;
  15887. /**
  15888. * Gets the additive state of the runtime animation
  15889. */
  15890. get isAdditive(): boolean;
  15891. /** @hidden */
  15892. _onLoop: () => void;
  15893. /**
  15894. * Create a new RuntimeAnimation object
  15895. * @param target defines the target of the animation
  15896. * @param animation defines the source animation object
  15897. * @param scene defines the hosting scene
  15898. * @param host defines the initiating Animatable
  15899. */
  15900. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  15901. private _preparePath;
  15902. /**
  15903. * Gets the animation from the runtime animation
  15904. */
  15905. get animation(): Animation;
  15906. /**
  15907. * Resets the runtime animation to the beginning
  15908. * @param restoreOriginal defines whether to restore the target property to the original value
  15909. */
  15910. reset(restoreOriginal?: boolean): void;
  15911. /**
  15912. * Specifies if the runtime animation is stopped
  15913. * @returns Boolean specifying if the runtime animation is stopped
  15914. */
  15915. isStopped(): boolean;
  15916. /**
  15917. * Disposes of the runtime animation
  15918. */
  15919. dispose(): void;
  15920. /**
  15921. * Apply the interpolated value to the target
  15922. * @param currentValue defines the value computed by the animation
  15923. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  15924. */
  15925. setValue(currentValue: any, weight: number): void;
  15926. private _getOriginalValues;
  15927. private _setValue;
  15928. /**
  15929. * Gets the loop pmode of the runtime animation
  15930. * @returns Loop Mode
  15931. */
  15932. private _getCorrectLoopMode;
  15933. /**
  15934. * Move the current animation to a given frame
  15935. * @param frame defines the frame to move to
  15936. */
  15937. goToFrame(frame: number): void;
  15938. /**
  15939. * @hidden Internal use only
  15940. */
  15941. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  15942. /**
  15943. * Execute the current animation
  15944. * @param delay defines the delay to add to the current frame
  15945. * @param from defines the lower bound of the animation range
  15946. * @param to defines the upper bound of the animation range
  15947. * @param loop defines if the current animation must loop
  15948. * @param speedRatio defines the current speed ratio
  15949. * @param weight defines the weight of the animation (default is -1 so no weight)
  15950. * @param onLoop optional callback called when animation loops
  15951. * @returns a boolean indicating if the animation is running
  15952. */
  15953. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  15954. }
  15955. }
  15956. declare module "babylonjs/Animations/animatable" {
  15957. import { Animation } from "babylonjs/Animations/animation";
  15958. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  15959. import { Nullable } from "babylonjs/types";
  15960. import { Observable } from "babylonjs/Misc/observable";
  15961. import { Scene } from "babylonjs/scene";
  15962. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  15963. import { Node } from "babylonjs/node";
  15964. /**
  15965. * Class used to store an actual running animation
  15966. */
  15967. export class Animatable {
  15968. /** defines the target object */
  15969. target: any;
  15970. /** defines the starting frame number (default is 0) */
  15971. fromFrame: number;
  15972. /** defines the ending frame number (default is 100) */
  15973. toFrame: number;
  15974. /** defines if the animation must loop (default is false) */
  15975. loopAnimation: boolean;
  15976. /** defines a callback to call when animation ends if it is not looping */
  15977. onAnimationEnd?: (() => void) | null | undefined;
  15978. /** defines a callback to call when animation loops */
  15979. onAnimationLoop?: (() => void) | null | undefined;
  15980. /** defines whether the animation should be evaluated additively */
  15981. isAdditive: boolean;
  15982. private _localDelayOffset;
  15983. private _pausedDelay;
  15984. private _runtimeAnimations;
  15985. private _paused;
  15986. private _scene;
  15987. private _speedRatio;
  15988. private _weight;
  15989. private _syncRoot;
  15990. /**
  15991. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  15992. * This will only apply for non looping animation (default is true)
  15993. */
  15994. disposeOnEnd: boolean;
  15995. /**
  15996. * Gets a boolean indicating if the animation has started
  15997. */
  15998. animationStarted: boolean;
  15999. /**
  16000. * Observer raised when the animation ends
  16001. */
  16002. onAnimationEndObservable: Observable<Animatable>;
  16003. /**
  16004. * Observer raised when the animation loops
  16005. */
  16006. onAnimationLoopObservable: Observable<Animatable>;
  16007. /**
  16008. * Gets the root Animatable used to synchronize and normalize animations
  16009. */
  16010. get syncRoot(): Nullable<Animatable>;
  16011. /**
  16012. * Gets the current frame of the first RuntimeAnimation
  16013. * Used to synchronize Animatables
  16014. */
  16015. get masterFrame(): number;
  16016. /**
  16017. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  16018. */
  16019. get weight(): number;
  16020. set weight(value: number);
  16021. /**
  16022. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  16023. */
  16024. get speedRatio(): number;
  16025. set speedRatio(value: number);
  16026. /**
  16027. * Creates a new Animatable
  16028. * @param scene defines the hosting scene
  16029. * @param target defines the target object
  16030. * @param fromFrame defines the starting frame number (default is 0)
  16031. * @param toFrame defines the ending frame number (default is 100)
  16032. * @param loopAnimation defines if the animation must loop (default is false)
  16033. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  16034. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  16035. * @param animations defines a group of animation to add to the new Animatable
  16036. * @param onAnimationLoop defines a callback to call when animation loops
  16037. * @param isAdditive defines whether the animation should be evaluated additively
  16038. */
  16039. constructor(scene: Scene,
  16040. /** defines the target object */
  16041. target: any,
  16042. /** defines the starting frame number (default is 0) */
  16043. fromFrame?: number,
  16044. /** defines the ending frame number (default is 100) */
  16045. toFrame?: number,
  16046. /** defines if the animation must loop (default is false) */
  16047. loopAnimation?: boolean, speedRatio?: number,
  16048. /** defines a callback to call when animation ends if it is not looping */
  16049. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  16050. /** defines a callback to call when animation loops */
  16051. onAnimationLoop?: (() => void) | null | undefined,
  16052. /** defines whether the animation should be evaluated additively */
  16053. isAdditive?: boolean);
  16054. /**
  16055. * Synchronize and normalize current Animatable with a source Animatable
  16056. * This is useful when using animation weights and when animations are not of the same length
  16057. * @param root defines the root Animatable to synchronize with
  16058. * @returns the current Animatable
  16059. */
  16060. syncWith(root: Animatable): Animatable;
  16061. /**
  16062. * Gets the list of runtime animations
  16063. * @returns an array of RuntimeAnimation
  16064. */
  16065. getAnimations(): RuntimeAnimation[];
  16066. /**
  16067. * Adds more animations to the current animatable
  16068. * @param target defines the target of the animations
  16069. * @param animations defines the new animations to add
  16070. */
  16071. appendAnimations(target: any, animations: Animation[]): void;
  16072. /**
  16073. * Gets the source animation for a specific property
  16074. * @param property defines the propertyu to look for
  16075. * @returns null or the source animation for the given property
  16076. */
  16077. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  16078. /**
  16079. * Gets the runtime animation for a specific property
  16080. * @param property defines the propertyu to look for
  16081. * @returns null or the runtime animation for the given property
  16082. */
  16083. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  16084. /**
  16085. * Resets the animatable to its original state
  16086. */
  16087. reset(): void;
  16088. /**
  16089. * Allows the animatable to blend with current running animations
  16090. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  16091. * @param blendingSpeed defines the blending speed to use
  16092. */
  16093. enableBlending(blendingSpeed: number): void;
  16094. /**
  16095. * Disable animation blending
  16096. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  16097. */
  16098. disableBlending(): void;
  16099. /**
  16100. * Jump directly to a given frame
  16101. * @param frame defines the frame to jump to
  16102. */
  16103. goToFrame(frame: number): void;
  16104. /**
  16105. * Pause the animation
  16106. */
  16107. pause(): void;
  16108. /**
  16109. * Restart the animation
  16110. */
  16111. restart(): void;
  16112. private _raiseOnAnimationEnd;
  16113. /**
  16114. * Stop and delete the current animation
  16115. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  16116. * @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)
  16117. */
  16118. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  16119. /**
  16120. * Wait asynchronously for the animation to end
  16121. * @returns a promise which will be fullfilled when the animation ends
  16122. */
  16123. waitAsync(): Promise<Animatable>;
  16124. /** @hidden */
  16125. _animate(delay: number): boolean;
  16126. }
  16127. module "babylonjs/scene" {
  16128. interface Scene {
  16129. /** @hidden */
  16130. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  16131. /** @hidden */
  16132. _processLateAnimationBindingsForMatrices(holder: {
  16133. totalWeight: number;
  16134. totalAdditiveWeight: number;
  16135. animations: RuntimeAnimation[];
  16136. additiveAnimations: RuntimeAnimation[];
  16137. originalValue: Matrix;
  16138. }): any;
  16139. /** @hidden */
  16140. _processLateAnimationBindingsForQuaternions(holder: {
  16141. totalWeight: number;
  16142. totalAdditiveWeight: number;
  16143. animations: RuntimeAnimation[];
  16144. additiveAnimations: RuntimeAnimation[];
  16145. originalValue: Quaternion;
  16146. }, refQuaternion: Quaternion): Quaternion;
  16147. /** @hidden */
  16148. _processLateAnimationBindings(): void;
  16149. /**
  16150. * Will start the animation sequence of a given target
  16151. * @param target defines the target
  16152. * @param from defines from which frame should animation start
  16153. * @param to defines until which frame should animation run.
  16154. * @param weight defines the weight to apply to the animation (1.0 by default)
  16155. * @param loop defines if the animation loops
  16156. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16157. * @param onAnimationEnd defines the function to be executed when the animation ends
  16158. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16159. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16160. * @param onAnimationLoop defines the callback to call when an animation loops
  16161. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16162. * @returns the animatable object created for this animation
  16163. */
  16164. 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;
  16165. /**
  16166. * Will start the animation sequence of a given target
  16167. * @param target defines the target
  16168. * @param from defines from which frame should animation start
  16169. * @param to defines until which frame should animation run.
  16170. * @param loop defines if the animation loops
  16171. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16172. * @param onAnimationEnd defines the function to be executed when the animation ends
  16173. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16174. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16175. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  16176. * @param onAnimationLoop defines the callback to call when an animation loops
  16177. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16178. * @returns the animatable object created for this animation
  16179. */
  16180. 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;
  16181. /**
  16182. * Will start the animation sequence of a given target and its hierarchy
  16183. * @param target defines the target
  16184. * @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.
  16185. * @param from defines from which frame should animation start
  16186. * @param to defines until which frame should animation run.
  16187. * @param loop defines if the animation loops
  16188. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16189. * @param onAnimationEnd defines the function to be executed when the animation ends
  16190. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16191. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16192. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16193. * @param onAnimationLoop defines the callback to call when an animation loops
  16194. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16195. * @returns the list of created animatables
  16196. */
  16197. 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[];
  16198. /**
  16199. * Begin a new animation on a given node
  16200. * @param target defines the target where the animation will take place
  16201. * @param animations defines the list of animations to start
  16202. * @param from defines the initial value
  16203. * @param to defines the final value
  16204. * @param loop defines if you want animation to loop (off by default)
  16205. * @param speedRatio defines the speed ratio to apply to all animations
  16206. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16207. * @param onAnimationLoop defines the callback to call when an animation loops
  16208. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16209. * @returns the list of created animatables
  16210. */
  16211. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  16212. /**
  16213. * Begin a new animation on a given node and its hierarchy
  16214. * @param target defines the root node where the animation will take place
  16215. * @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.
  16216. * @param animations defines the list of animations to start
  16217. * @param from defines the initial value
  16218. * @param to defines the final value
  16219. * @param loop defines if you want animation to loop (off by default)
  16220. * @param speedRatio defines the speed ratio to apply to all animations
  16221. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16222. * @param onAnimationLoop defines the callback to call when an animation loops
  16223. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16224. * @returns the list of animatables created for all nodes
  16225. */
  16226. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  16227. /**
  16228. * Gets the animatable associated with a specific target
  16229. * @param target defines the target of the animatable
  16230. * @returns the required animatable if found
  16231. */
  16232. getAnimatableByTarget(target: any): Nullable<Animatable>;
  16233. /**
  16234. * Gets all animatables associated with a given target
  16235. * @param target defines the target to look animatables for
  16236. * @returns an array of Animatables
  16237. */
  16238. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  16239. /**
  16240. * Stops and removes all animations that have been applied to the scene
  16241. */
  16242. stopAllAnimations(): void;
  16243. /**
  16244. * Gets the current delta time used by animation engine
  16245. */
  16246. deltaTime: number;
  16247. }
  16248. }
  16249. module "babylonjs/Bones/bone" {
  16250. interface Bone {
  16251. /**
  16252. * Copy an animation range from another bone
  16253. * @param source defines the source bone
  16254. * @param rangeName defines the range name to copy
  16255. * @param frameOffset defines the frame offset
  16256. * @param rescaleAsRequired defines if rescaling must be applied if required
  16257. * @param skelDimensionsRatio defines the scaling ratio
  16258. * @returns true if operation was successful
  16259. */
  16260. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  16261. }
  16262. }
  16263. }
  16264. declare module "babylonjs/Bones/skeleton" {
  16265. import { Bone } from "babylonjs/Bones/bone";
  16266. import { Observable } from "babylonjs/Misc/observable";
  16267. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16268. import { Scene } from "babylonjs/scene";
  16269. import { Nullable } from "babylonjs/types";
  16270. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16271. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16272. import { Animatable } from "babylonjs/Animations/animatable";
  16273. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  16274. import { Animation } from "babylonjs/Animations/animation";
  16275. import { AnimationRange } from "babylonjs/Animations/animationRange";
  16276. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16277. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  16278. /**
  16279. * Class used to handle skinning animations
  16280. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  16281. */
  16282. export class Skeleton implements IAnimatable {
  16283. /** defines the skeleton name */
  16284. name: string;
  16285. /** defines the skeleton Id */
  16286. id: string;
  16287. /**
  16288. * Defines the list of child bones
  16289. */
  16290. bones: Bone[];
  16291. /**
  16292. * Defines an estimate of the dimension of the skeleton at rest
  16293. */
  16294. dimensionsAtRest: Vector3;
  16295. /**
  16296. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  16297. */
  16298. needInitialSkinMatrix: boolean;
  16299. /**
  16300. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  16301. */
  16302. overrideMesh: Nullable<AbstractMesh>;
  16303. /**
  16304. * Gets the list of animations attached to this skeleton
  16305. */
  16306. animations: Array<Animation>;
  16307. private _scene;
  16308. private _isDirty;
  16309. private _transformMatrices;
  16310. private _transformMatrixTexture;
  16311. private _meshesWithPoseMatrix;
  16312. private _animatables;
  16313. private _identity;
  16314. private _synchronizedWithMesh;
  16315. private _ranges;
  16316. private _lastAbsoluteTransformsUpdateId;
  16317. private _canUseTextureForBones;
  16318. private _uniqueId;
  16319. /** @hidden */
  16320. _numBonesWithLinkedTransformNode: number;
  16321. /** @hidden */
  16322. _hasWaitingData: Nullable<boolean>;
  16323. /**
  16324. * Specifies if the skeleton should be serialized
  16325. */
  16326. doNotSerialize: boolean;
  16327. private _useTextureToStoreBoneMatrices;
  16328. /**
  16329. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  16330. * Please note that this option is not available if the hardware does not support it
  16331. */
  16332. get useTextureToStoreBoneMatrices(): boolean;
  16333. set useTextureToStoreBoneMatrices(value: boolean);
  16334. private _animationPropertiesOverride;
  16335. /**
  16336. * Gets or sets the animation properties override
  16337. */
  16338. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  16339. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  16340. /**
  16341. * List of inspectable custom properties (used by the Inspector)
  16342. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16343. */
  16344. inspectableCustomProperties: IInspectable[];
  16345. /**
  16346. * An observable triggered before computing the skeleton's matrices
  16347. */
  16348. onBeforeComputeObservable: Observable<Skeleton>;
  16349. /**
  16350. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  16351. */
  16352. get isUsingTextureForMatrices(): boolean;
  16353. /**
  16354. * Gets the unique ID of this skeleton
  16355. */
  16356. get uniqueId(): number;
  16357. /**
  16358. * Creates a new skeleton
  16359. * @param name defines the skeleton name
  16360. * @param id defines the skeleton Id
  16361. * @param scene defines the hosting scene
  16362. */
  16363. constructor(
  16364. /** defines the skeleton name */
  16365. name: string,
  16366. /** defines the skeleton Id */
  16367. id: string, scene: Scene);
  16368. /**
  16369. * Gets the current object class name.
  16370. * @return the class name
  16371. */
  16372. getClassName(): string;
  16373. /**
  16374. * Returns an array containing the root bones
  16375. * @returns an array containing the root bones
  16376. */
  16377. getChildren(): Array<Bone>;
  16378. /**
  16379. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  16380. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16381. * @returns a Float32Array containing matrices data
  16382. */
  16383. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  16384. /**
  16385. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  16386. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16387. * @returns a raw texture containing the data
  16388. */
  16389. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  16390. /**
  16391. * Gets the current hosting scene
  16392. * @returns a scene object
  16393. */
  16394. getScene(): Scene;
  16395. /**
  16396. * Gets a string representing the current skeleton data
  16397. * @param fullDetails defines a boolean indicating if we want a verbose version
  16398. * @returns a string representing the current skeleton data
  16399. */
  16400. toString(fullDetails?: boolean): string;
  16401. /**
  16402. * Get bone's index searching by name
  16403. * @param name defines bone's name to search for
  16404. * @return the indice of the bone. Returns -1 if not found
  16405. */
  16406. getBoneIndexByName(name: string): number;
  16407. /**
  16408. * Creater a new animation range
  16409. * @param name defines the name of the range
  16410. * @param from defines the start key
  16411. * @param to defines the end key
  16412. */
  16413. createAnimationRange(name: string, from: number, to: number): void;
  16414. /**
  16415. * Delete a specific animation range
  16416. * @param name defines the name of the range
  16417. * @param deleteFrames defines if frames must be removed as well
  16418. */
  16419. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16420. /**
  16421. * Gets a specific animation range
  16422. * @param name defines the name of the range to look for
  16423. * @returns the requested animation range or null if not found
  16424. */
  16425. getAnimationRange(name: string): Nullable<AnimationRange>;
  16426. /**
  16427. * Gets the list of all animation ranges defined on this skeleton
  16428. * @returns an array
  16429. */
  16430. getAnimationRanges(): Nullable<AnimationRange>[];
  16431. /**
  16432. * Copy animation range from a source skeleton.
  16433. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16434. * @param source defines the source skeleton
  16435. * @param name defines the name of the range to copy
  16436. * @param rescaleAsRequired defines if rescaling must be applied if required
  16437. * @returns true if operation was successful
  16438. */
  16439. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16440. /**
  16441. * Forces the skeleton to go to rest pose
  16442. */
  16443. returnToRest(): void;
  16444. private _getHighestAnimationFrame;
  16445. /**
  16446. * Begin a specific animation range
  16447. * @param name defines the name of the range to start
  16448. * @param loop defines if looping must be turned on (false by default)
  16449. * @param speedRatio defines the speed ratio to apply (1 by default)
  16450. * @param onAnimationEnd defines a callback which will be called when animation will end
  16451. * @returns a new animatable
  16452. */
  16453. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16454. /**
  16455. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16456. * @param skeleton defines the Skeleton containing the animation range to convert
  16457. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16458. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16459. * @returns the original skeleton
  16460. */
  16461. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16462. /** @hidden */
  16463. _markAsDirty(): void;
  16464. /** @hidden */
  16465. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16466. /** @hidden */
  16467. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16468. private _computeTransformMatrices;
  16469. /**
  16470. * Build all resources required to render a skeleton
  16471. */
  16472. prepare(): void;
  16473. /**
  16474. * Gets the list of animatables currently running for this skeleton
  16475. * @returns an array of animatables
  16476. */
  16477. getAnimatables(): IAnimatable[];
  16478. /**
  16479. * Clone the current skeleton
  16480. * @param name defines the name of the new skeleton
  16481. * @param id defines the id of the new skeleton
  16482. * @returns the new skeleton
  16483. */
  16484. clone(name: string, id?: string): Skeleton;
  16485. /**
  16486. * Enable animation blending for this skeleton
  16487. * @param blendingSpeed defines the blending speed to apply
  16488. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  16489. */
  16490. enableBlending(blendingSpeed?: number): void;
  16491. /**
  16492. * Releases all resources associated with the current skeleton
  16493. */
  16494. dispose(): void;
  16495. /**
  16496. * Serialize the skeleton in a JSON object
  16497. * @returns a JSON object
  16498. */
  16499. serialize(): any;
  16500. /**
  16501. * Creates a new skeleton from serialized data
  16502. * @param parsedSkeleton defines the serialized data
  16503. * @param scene defines the hosting scene
  16504. * @returns a new skeleton
  16505. */
  16506. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16507. /**
  16508. * Compute all node absolute transforms
  16509. * @param forceUpdate defines if computation must be done even if cache is up to date
  16510. */
  16511. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16512. /**
  16513. * Gets the root pose matrix
  16514. * @returns a matrix
  16515. */
  16516. getPoseMatrix(): Nullable<Matrix>;
  16517. /**
  16518. * Sorts bones per internal index
  16519. */
  16520. sortBones(): void;
  16521. private _sortBones;
  16522. }
  16523. }
  16524. declare module "babylonjs/Meshes/instancedMesh" {
  16525. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  16526. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16527. import { Camera } from "babylonjs/Cameras/camera";
  16528. import { Node } from "babylonjs/node";
  16529. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16530. import { Mesh } from "babylonjs/Meshes/mesh";
  16531. import { Material } from "babylonjs/Materials/material";
  16532. import { Skeleton } from "babylonjs/Bones/skeleton";
  16533. import { Light } from "babylonjs/Lights/light";
  16534. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  16535. /**
  16536. * Creates an instance based on a source mesh.
  16537. */
  16538. export class InstancedMesh extends AbstractMesh {
  16539. private _sourceMesh;
  16540. private _currentLOD;
  16541. /** @hidden */
  16542. _indexInSourceMeshInstanceArray: number;
  16543. constructor(name: string, source: Mesh);
  16544. /**
  16545. * Returns the string "InstancedMesh".
  16546. */
  16547. getClassName(): string;
  16548. /** Gets the list of lights affecting that mesh */
  16549. get lightSources(): Light[];
  16550. _resyncLightSources(): void;
  16551. _resyncLightSource(light: Light): void;
  16552. _removeLightSource(light: Light, dispose: boolean): void;
  16553. /**
  16554. * If the source mesh receives shadows
  16555. */
  16556. get receiveShadows(): boolean;
  16557. /**
  16558. * The material of the source mesh
  16559. */
  16560. get material(): Nullable<Material>;
  16561. /**
  16562. * Visibility of the source mesh
  16563. */
  16564. get visibility(): number;
  16565. /**
  16566. * Skeleton of the source mesh
  16567. */
  16568. get skeleton(): Nullable<Skeleton>;
  16569. /**
  16570. * Rendering ground id of the source mesh
  16571. */
  16572. get renderingGroupId(): number;
  16573. set renderingGroupId(value: number);
  16574. /**
  16575. * Returns the total number of vertices (integer).
  16576. */
  16577. getTotalVertices(): number;
  16578. /**
  16579. * Returns a positive integer : the total number of indices in this mesh geometry.
  16580. * @returns the numner of indices or zero if the mesh has no geometry.
  16581. */
  16582. getTotalIndices(): number;
  16583. /**
  16584. * The source mesh of the instance
  16585. */
  16586. get sourceMesh(): Mesh;
  16587. /**
  16588. * Creates a new InstancedMesh object from the mesh model.
  16589. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16590. * @param name defines the name of the new instance
  16591. * @returns a new InstancedMesh
  16592. */
  16593. createInstance(name: string): InstancedMesh;
  16594. /**
  16595. * Is this node ready to be used/rendered
  16596. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16597. * @return {boolean} is it ready
  16598. */
  16599. isReady(completeCheck?: boolean): boolean;
  16600. /**
  16601. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16602. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16603. * @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.
  16604. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16605. */
  16606. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16607. /**
  16608. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16609. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16610. * The `data` are either a numeric array either a Float32Array.
  16611. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16612. * 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).
  16613. * Note that a new underlying VertexBuffer object is created each call.
  16614. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16615. *
  16616. * Possible `kind` values :
  16617. * - VertexBuffer.PositionKind
  16618. * - VertexBuffer.UVKind
  16619. * - VertexBuffer.UV2Kind
  16620. * - VertexBuffer.UV3Kind
  16621. * - VertexBuffer.UV4Kind
  16622. * - VertexBuffer.UV5Kind
  16623. * - VertexBuffer.UV6Kind
  16624. * - VertexBuffer.ColorKind
  16625. * - VertexBuffer.MatricesIndicesKind
  16626. * - VertexBuffer.MatricesIndicesExtraKind
  16627. * - VertexBuffer.MatricesWeightsKind
  16628. * - VertexBuffer.MatricesWeightsExtraKind
  16629. *
  16630. * Returns the Mesh.
  16631. */
  16632. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16633. /**
  16634. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16635. * If the mesh has no geometry, it is simply returned as it is.
  16636. * The `data` are either a numeric array either a Float32Array.
  16637. * No new underlying VertexBuffer object is created.
  16638. * 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.
  16639. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16640. *
  16641. * Possible `kind` values :
  16642. * - VertexBuffer.PositionKind
  16643. * - VertexBuffer.UVKind
  16644. * - VertexBuffer.UV2Kind
  16645. * - VertexBuffer.UV3Kind
  16646. * - VertexBuffer.UV4Kind
  16647. * - VertexBuffer.UV5Kind
  16648. * - VertexBuffer.UV6Kind
  16649. * - VertexBuffer.ColorKind
  16650. * - VertexBuffer.MatricesIndicesKind
  16651. * - VertexBuffer.MatricesIndicesExtraKind
  16652. * - VertexBuffer.MatricesWeightsKind
  16653. * - VertexBuffer.MatricesWeightsExtraKind
  16654. *
  16655. * Returns the Mesh.
  16656. */
  16657. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16658. /**
  16659. * Sets the mesh indices.
  16660. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16661. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16662. * This method creates a new index buffer each call.
  16663. * Returns the Mesh.
  16664. */
  16665. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16666. /**
  16667. * Boolean : True if the mesh owns the requested kind of data.
  16668. */
  16669. isVerticesDataPresent(kind: string): boolean;
  16670. /**
  16671. * Returns an array of indices (IndicesArray).
  16672. */
  16673. getIndices(): Nullable<IndicesArray>;
  16674. get _positions(): Nullable<Vector3[]>;
  16675. /**
  16676. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16677. * This means the mesh underlying bounding box and sphere are recomputed.
  16678. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16679. * @returns the current mesh
  16680. */
  16681. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16682. /** @hidden */
  16683. _preActivate(): InstancedMesh;
  16684. /** @hidden */
  16685. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16686. /** @hidden */
  16687. _postActivate(): void;
  16688. getWorldMatrix(): Matrix;
  16689. get isAnInstance(): boolean;
  16690. /**
  16691. * Returns the current associated LOD AbstractMesh.
  16692. */
  16693. getLOD(camera: Camera): AbstractMesh;
  16694. /** @hidden */
  16695. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16696. /** @hidden */
  16697. _syncSubMeshes(): InstancedMesh;
  16698. /** @hidden */
  16699. _generatePointsArray(): boolean;
  16700. /**
  16701. * Creates a new InstancedMesh from the current mesh.
  16702. * - name (string) : the cloned mesh name
  16703. * - newParent (optional Node) : the optional Node to parent the clone to.
  16704. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16705. *
  16706. * Returns the clone.
  16707. */
  16708. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16709. /**
  16710. * Disposes the InstancedMesh.
  16711. * Returns nothing.
  16712. */
  16713. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16714. }
  16715. module "babylonjs/Meshes/mesh" {
  16716. interface Mesh {
  16717. /**
  16718. * Register a custom buffer that will be instanced
  16719. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16720. * @param kind defines the buffer kind
  16721. * @param stride defines the stride in floats
  16722. */
  16723. registerInstancedBuffer(kind: string, stride: number): void;
  16724. /** @hidden */
  16725. _userInstancedBuffersStorage: {
  16726. data: {
  16727. [key: string]: Float32Array;
  16728. };
  16729. sizes: {
  16730. [key: string]: number;
  16731. };
  16732. vertexBuffers: {
  16733. [key: string]: Nullable<VertexBuffer>;
  16734. };
  16735. strides: {
  16736. [key: string]: number;
  16737. };
  16738. };
  16739. }
  16740. }
  16741. module "babylonjs/Meshes/abstractMesh" {
  16742. interface AbstractMesh {
  16743. /**
  16744. * Object used to store instanced buffers defined by user
  16745. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16746. */
  16747. instancedBuffers: {
  16748. [key: string]: any;
  16749. };
  16750. }
  16751. }
  16752. }
  16753. declare module "babylonjs/Materials/shaderMaterial" {
  16754. import { Nullable } from "babylonjs/types";
  16755. import { Scene } from "babylonjs/scene";
  16756. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  16757. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16758. import { Mesh } from "babylonjs/Meshes/mesh";
  16759. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16760. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16761. import { Effect } from "babylonjs/Materials/effect";
  16762. import { Material } from "babylonjs/Materials/material";
  16763. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16764. /**
  16765. * Defines the options associated with the creation of a shader material.
  16766. */
  16767. export interface IShaderMaterialOptions {
  16768. /**
  16769. * Does the material work in alpha blend mode
  16770. */
  16771. needAlphaBlending: boolean;
  16772. /**
  16773. * Does the material work in alpha test mode
  16774. */
  16775. needAlphaTesting: boolean;
  16776. /**
  16777. * The list of attribute names used in the shader
  16778. */
  16779. attributes: string[];
  16780. /**
  16781. * The list of unifrom names used in the shader
  16782. */
  16783. uniforms: string[];
  16784. /**
  16785. * The list of UBO names used in the shader
  16786. */
  16787. uniformBuffers: string[];
  16788. /**
  16789. * The list of sampler names used in the shader
  16790. */
  16791. samplers: string[];
  16792. /**
  16793. * The list of defines used in the shader
  16794. */
  16795. defines: string[];
  16796. }
  16797. /**
  16798. * 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.
  16799. *
  16800. * This returned material effects how the mesh will look based on the code in the shaders.
  16801. *
  16802. * @see http://doc.babylonjs.com/how_to/shader_material
  16803. */
  16804. export class ShaderMaterial extends Material {
  16805. private _shaderPath;
  16806. private _options;
  16807. private _textures;
  16808. private _textureArrays;
  16809. private _floats;
  16810. private _ints;
  16811. private _floatsArrays;
  16812. private _colors3;
  16813. private _colors3Arrays;
  16814. private _colors4;
  16815. private _colors4Arrays;
  16816. private _vectors2;
  16817. private _vectors3;
  16818. private _vectors4;
  16819. private _matrices;
  16820. private _matrixArrays;
  16821. private _matrices3x3;
  16822. private _matrices2x2;
  16823. private _vectors2Arrays;
  16824. private _vectors3Arrays;
  16825. private _vectors4Arrays;
  16826. private _cachedWorldViewMatrix;
  16827. private _cachedWorldViewProjectionMatrix;
  16828. private _renderId;
  16829. private _multiview;
  16830. private _cachedDefines;
  16831. /**
  16832. * Instantiate a new shader material.
  16833. * 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.
  16834. * This returned material effects how the mesh will look based on the code in the shaders.
  16835. * @see http://doc.babylonjs.com/how_to/shader_material
  16836. * @param name Define the name of the material in the scene
  16837. * @param scene Define the scene the material belongs to
  16838. * @param shaderPath Defines the route to the shader code in one of three ways:
  16839. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16840. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  16841. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  16842. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16843. * @param options Define the options used to create the shader
  16844. */
  16845. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16846. /**
  16847. * Gets the shader path used to define the shader code
  16848. * It can be modified to trigger a new compilation
  16849. */
  16850. get shaderPath(): any;
  16851. /**
  16852. * Sets the shader path used to define the shader code
  16853. * It can be modified to trigger a new compilation
  16854. */
  16855. set shaderPath(shaderPath: any);
  16856. /**
  16857. * Gets the options used to compile the shader.
  16858. * They can be modified to trigger a new compilation
  16859. */
  16860. get options(): IShaderMaterialOptions;
  16861. /**
  16862. * Gets the current class name of the material e.g. "ShaderMaterial"
  16863. * Mainly use in serialization.
  16864. * @returns the class name
  16865. */
  16866. getClassName(): string;
  16867. /**
  16868. * Specifies if the material will require alpha blending
  16869. * @returns a boolean specifying if alpha blending is needed
  16870. */
  16871. needAlphaBlending(): boolean;
  16872. /**
  16873. * Specifies if this material should be rendered in alpha test mode
  16874. * @returns a boolean specifying if an alpha test is needed.
  16875. */
  16876. needAlphaTesting(): boolean;
  16877. private _checkUniform;
  16878. /**
  16879. * Set a texture in the shader.
  16880. * @param name Define the name of the uniform samplers as defined in the shader
  16881. * @param texture Define the texture to bind to this sampler
  16882. * @return the material itself allowing "fluent" like uniform updates
  16883. */
  16884. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  16885. /**
  16886. * Set a texture array in the shader.
  16887. * @param name Define the name of the uniform sampler array as defined in the shader
  16888. * @param textures Define the list of textures to bind to this sampler
  16889. * @return the material itself allowing "fluent" like uniform updates
  16890. */
  16891. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  16892. /**
  16893. * Set a float in the shader.
  16894. * @param name Define the name of the uniform as defined in the shader
  16895. * @param value Define the value to give to the uniform
  16896. * @return the material itself allowing "fluent" like uniform updates
  16897. */
  16898. setFloat(name: string, value: number): ShaderMaterial;
  16899. /**
  16900. * Set a int in the shader.
  16901. * @param name Define the name of the uniform as defined in the shader
  16902. * @param value Define the value to give to the uniform
  16903. * @return the material itself allowing "fluent" like uniform updates
  16904. */
  16905. setInt(name: string, value: number): ShaderMaterial;
  16906. /**
  16907. * Set an array of floats in the shader.
  16908. * @param name Define the name of the uniform as defined in the shader
  16909. * @param value Define the value to give to the uniform
  16910. * @return the material itself allowing "fluent" like uniform updates
  16911. */
  16912. setFloats(name: string, value: number[]): ShaderMaterial;
  16913. /**
  16914. * Set a vec3 in the shader from a Color3.
  16915. * @param name Define the name of the uniform as defined in the shader
  16916. * @param value Define the value to give to the uniform
  16917. * @return the material itself allowing "fluent" like uniform updates
  16918. */
  16919. setColor3(name: string, value: Color3): ShaderMaterial;
  16920. /**
  16921. * Set a vec3 array in the shader from a Color3 array.
  16922. * @param name Define the name of the uniform as defined in the shader
  16923. * @param value Define the value to give to the uniform
  16924. * @return the material itself allowing "fluent" like uniform updates
  16925. */
  16926. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16927. /**
  16928. * Set a vec4 in the shader from a Color4.
  16929. * @param name Define the name of the uniform as defined in the shader
  16930. * @param value Define the value to give to the uniform
  16931. * @return the material itself allowing "fluent" like uniform updates
  16932. */
  16933. setColor4(name: string, value: Color4): ShaderMaterial;
  16934. /**
  16935. * Set a vec4 array in the shader from a Color4 array.
  16936. * @param name Define the name of the uniform as defined in the shader
  16937. * @param value Define the value to give to the uniform
  16938. * @return the material itself allowing "fluent" like uniform updates
  16939. */
  16940. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  16941. /**
  16942. * Set a vec2 in the shader from a Vector2.
  16943. * @param name Define the name of the uniform as defined in the shader
  16944. * @param value Define the value to give to the uniform
  16945. * @return the material itself allowing "fluent" like uniform updates
  16946. */
  16947. setVector2(name: string, value: Vector2): ShaderMaterial;
  16948. /**
  16949. * Set a vec3 in the shader from a Vector3.
  16950. * @param name Define the name of the uniform as defined in the shader
  16951. * @param value Define the value to give to the uniform
  16952. * @return the material itself allowing "fluent" like uniform updates
  16953. */
  16954. setVector3(name: string, value: Vector3): ShaderMaterial;
  16955. /**
  16956. * Set a vec4 in the shader from a Vector4.
  16957. * @param name Define the name of the uniform as defined in the shader
  16958. * @param value Define the value to give to the uniform
  16959. * @return the material itself allowing "fluent" like uniform updates
  16960. */
  16961. setVector4(name: string, value: Vector4): ShaderMaterial;
  16962. /**
  16963. * Set a mat4 in the shader from a Matrix.
  16964. * @param name Define the name of the uniform as defined in the shader
  16965. * @param value Define the value to give to the uniform
  16966. * @return the material itself allowing "fluent" like uniform updates
  16967. */
  16968. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16969. /**
  16970. * Set a float32Array in the shader from a matrix array.
  16971. * @param name Define the name of the uniform as defined in the shader
  16972. * @param value Define the value to give to the uniform
  16973. * @return the material itself allowing "fluent" like uniform updates
  16974. */
  16975. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  16976. /**
  16977. * Set a mat3 in the shader from a Float32Array.
  16978. * @param name Define the name of the uniform as defined in the shader
  16979. * @param value Define the value to give to the uniform
  16980. * @return the material itself allowing "fluent" like uniform updates
  16981. */
  16982. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16983. /**
  16984. * Set a mat2 in the shader from a Float32Array.
  16985. * @param name Define the name of the uniform as defined in the shader
  16986. * @param value Define the value to give to the uniform
  16987. * @return the material itself allowing "fluent" like uniform updates
  16988. */
  16989. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  16990. /**
  16991. * Set a vec2 array in the shader from a number array.
  16992. * @param name Define the name of the uniform as defined in the shader
  16993. * @param value Define the value to give to the uniform
  16994. * @return the material itself allowing "fluent" like uniform updates
  16995. */
  16996. setArray2(name: string, value: number[]): ShaderMaterial;
  16997. /**
  16998. * Set a vec3 array in the shader from a number array.
  16999. * @param name Define the name of the uniform as defined in the shader
  17000. * @param value Define the value to give to the uniform
  17001. * @return the material itself allowing "fluent" like uniform updates
  17002. */
  17003. setArray3(name: string, value: number[]): ShaderMaterial;
  17004. /**
  17005. * Set a vec4 array in the shader from a number array.
  17006. * @param name Define the name of the uniform as defined in the shader
  17007. * @param value Define the value to give to the uniform
  17008. * @return the material itself allowing "fluent" like uniform updates
  17009. */
  17010. setArray4(name: string, value: number[]): ShaderMaterial;
  17011. private _checkCache;
  17012. /**
  17013. * Specifies that the submesh is ready to be used
  17014. * @param mesh defines the mesh to check
  17015. * @param subMesh defines which submesh to check
  17016. * @param useInstances specifies that instances should be used
  17017. * @returns a boolean indicating that the submesh is ready or not
  17018. */
  17019. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  17020. /**
  17021. * Checks if the material is ready to render the requested mesh
  17022. * @param mesh Define the mesh to render
  17023. * @param useInstances Define whether or not the material is used with instances
  17024. * @returns true if ready, otherwise false
  17025. */
  17026. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17027. /**
  17028. * Binds the world matrix to the material
  17029. * @param world defines the world transformation matrix
  17030. * @param effectOverride - If provided, use this effect instead of internal effect
  17031. */
  17032. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  17033. /**
  17034. * Binds the submesh to this material by preparing the effect and shader to draw
  17035. * @param world defines the world transformation matrix
  17036. * @param mesh defines the mesh containing the submesh
  17037. * @param subMesh defines the submesh to bind the material to
  17038. */
  17039. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  17040. /**
  17041. * Binds the material to the mesh
  17042. * @param world defines the world transformation matrix
  17043. * @param mesh defines the mesh to bind the material to
  17044. * @param effectOverride - If provided, use this effect instead of internal effect
  17045. */
  17046. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  17047. protected _afterBind(mesh?: Mesh): void;
  17048. /**
  17049. * Gets the active textures from the material
  17050. * @returns an array of textures
  17051. */
  17052. getActiveTextures(): BaseTexture[];
  17053. /**
  17054. * Specifies if the material uses a texture
  17055. * @param texture defines the texture to check against the material
  17056. * @returns a boolean specifying if the material uses the texture
  17057. */
  17058. hasTexture(texture: BaseTexture): boolean;
  17059. /**
  17060. * Makes a duplicate of the material, and gives it a new name
  17061. * @param name defines the new name for the duplicated material
  17062. * @returns the cloned material
  17063. */
  17064. clone(name: string): ShaderMaterial;
  17065. /**
  17066. * Disposes the material
  17067. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17068. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17069. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17070. */
  17071. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17072. /**
  17073. * Serializes this material in a JSON representation
  17074. * @returns the serialized material object
  17075. */
  17076. serialize(): any;
  17077. /**
  17078. * Creates a shader material from parsed shader material data
  17079. * @param source defines the JSON represnetation of the material
  17080. * @param scene defines the hosting scene
  17081. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17082. * @returns a new material
  17083. */
  17084. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17085. }
  17086. }
  17087. declare module "babylonjs/Shaders/color.fragment" {
  17088. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17089. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17090. /** @hidden */
  17091. export var colorPixelShader: {
  17092. name: string;
  17093. shader: string;
  17094. };
  17095. }
  17096. declare module "babylonjs/Shaders/color.vertex" {
  17097. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17098. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17099. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17100. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17101. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17102. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17103. /** @hidden */
  17104. export var colorVertexShader: {
  17105. name: string;
  17106. shader: string;
  17107. };
  17108. }
  17109. declare module "babylonjs/Meshes/linesMesh" {
  17110. import { Nullable } from "babylonjs/types";
  17111. import { Scene } from "babylonjs/scene";
  17112. import { Color3 } from "babylonjs/Maths/math.color";
  17113. import { Node } from "babylonjs/node";
  17114. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17115. import { Mesh } from "babylonjs/Meshes/mesh";
  17116. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17117. import { Effect } from "babylonjs/Materials/effect";
  17118. import { Material } from "babylonjs/Materials/material";
  17119. import "babylonjs/Shaders/color.fragment";
  17120. import "babylonjs/Shaders/color.vertex";
  17121. /**
  17122. * Line mesh
  17123. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17124. */
  17125. export class LinesMesh extends Mesh {
  17126. /**
  17127. * If vertex color should be applied to the mesh
  17128. */
  17129. readonly useVertexColor?: boolean | undefined;
  17130. /**
  17131. * If vertex alpha should be applied to the mesh
  17132. */
  17133. readonly useVertexAlpha?: boolean | undefined;
  17134. /**
  17135. * Color of the line (Default: White)
  17136. */
  17137. color: Color3;
  17138. /**
  17139. * Alpha of the line (Default: 1)
  17140. */
  17141. alpha: number;
  17142. /**
  17143. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17144. * This margin is expressed in world space coordinates, so its value may vary.
  17145. * Default value is 0.1
  17146. */
  17147. intersectionThreshold: number;
  17148. private _colorShader;
  17149. private color4;
  17150. /**
  17151. * Creates a new LinesMesh
  17152. * @param name defines the name
  17153. * @param scene defines the hosting scene
  17154. * @param parent defines the parent mesh if any
  17155. * @param source defines the optional source LinesMesh used to clone data from
  17156. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17157. * When false, achieved by calling a clone(), also passing False.
  17158. * This will make creation of children, recursive.
  17159. * @param useVertexColor defines if this LinesMesh supports vertex color
  17160. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17161. */
  17162. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  17163. /**
  17164. * If vertex color should be applied to the mesh
  17165. */
  17166. useVertexColor?: boolean | undefined,
  17167. /**
  17168. * If vertex alpha should be applied to the mesh
  17169. */
  17170. useVertexAlpha?: boolean | undefined);
  17171. private _addClipPlaneDefine;
  17172. private _removeClipPlaneDefine;
  17173. isReady(): boolean;
  17174. /**
  17175. * Returns the string "LineMesh"
  17176. */
  17177. getClassName(): string;
  17178. /**
  17179. * @hidden
  17180. */
  17181. get material(): Material;
  17182. /**
  17183. * @hidden
  17184. */
  17185. set material(value: Material);
  17186. /**
  17187. * @hidden
  17188. */
  17189. get checkCollisions(): boolean;
  17190. /** @hidden */
  17191. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  17192. /** @hidden */
  17193. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  17194. /**
  17195. * Disposes of the line mesh
  17196. * @param doNotRecurse If children should be disposed
  17197. */
  17198. dispose(doNotRecurse?: boolean): void;
  17199. /**
  17200. * Returns a new LineMesh object cloned from the current one.
  17201. */
  17202. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  17203. /**
  17204. * Creates a new InstancedLinesMesh object from the mesh model.
  17205. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  17206. * @param name defines the name of the new instance
  17207. * @returns a new InstancedLinesMesh
  17208. */
  17209. createInstance(name: string): InstancedLinesMesh;
  17210. }
  17211. /**
  17212. * Creates an instance based on a source LinesMesh
  17213. */
  17214. export class InstancedLinesMesh extends InstancedMesh {
  17215. /**
  17216. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17217. * This margin is expressed in world space coordinates, so its value may vary.
  17218. * Initilized with the intersectionThreshold value of the source LinesMesh
  17219. */
  17220. intersectionThreshold: number;
  17221. constructor(name: string, source: LinesMesh);
  17222. /**
  17223. * Returns the string "InstancedLinesMesh".
  17224. */
  17225. getClassName(): string;
  17226. }
  17227. }
  17228. declare module "babylonjs/Shaders/line.fragment" {
  17229. /** @hidden */
  17230. export var linePixelShader: {
  17231. name: string;
  17232. shader: string;
  17233. };
  17234. }
  17235. declare module "babylonjs/Shaders/line.vertex" {
  17236. /** @hidden */
  17237. export var lineVertexShader: {
  17238. name: string;
  17239. shader: string;
  17240. };
  17241. }
  17242. declare module "babylonjs/Rendering/edgesRenderer" {
  17243. import { Nullable } from "babylonjs/types";
  17244. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17245. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17246. import { Vector3 } from "babylonjs/Maths/math.vector";
  17247. import { IDisposable } from "babylonjs/scene";
  17248. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17249. import "babylonjs/Shaders/line.fragment";
  17250. import "babylonjs/Shaders/line.vertex";
  17251. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  17252. module "babylonjs/Meshes/abstractMesh" {
  17253. interface AbstractMesh {
  17254. /**
  17255. * Gets the edgesRenderer associated with the mesh
  17256. */
  17257. edgesRenderer: Nullable<EdgesRenderer>;
  17258. }
  17259. }
  17260. module "babylonjs/Meshes/linesMesh" {
  17261. interface LinesMesh {
  17262. /**
  17263. * Enables the edge rendering mode on the mesh.
  17264. * This mode makes the mesh edges visible
  17265. * @param epsilon defines the maximal distance between two angles to detect a face
  17266. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17267. * @returns the currentAbstractMesh
  17268. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17269. */
  17270. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17271. }
  17272. }
  17273. module "babylonjs/Meshes/linesMesh" {
  17274. interface InstancedLinesMesh {
  17275. /**
  17276. * Enables the edge rendering mode on the mesh.
  17277. * This mode makes the mesh edges visible
  17278. * @param epsilon defines the maximal distance between two angles to detect a face
  17279. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17280. * @returns the current InstancedLinesMesh
  17281. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17282. */
  17283. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17284. }
  17285. }
  17286. /**
  17287. * Defines the minimum contract an Edges renderer should follow.
  17288. */
  17289. export interface IEdgesRenderer extends IDisposable {
  17290. /**
  17291. * Gets or sets a boolean indicating if the edgesRenderer is active
  17292. */
  17293. isEnabled: boolean;
  17294. /**
  17295. * Renders the edges of the attached mesh,
  17296. */
  17297. render(): void;
  17298. /**
  17299. * Checks wether or not the edges renderer is ready to render.
  17300. * @return true if ready, otherwise false.
  17301. */
  17302. isReady(): boolean;
  17303. }
  17304. /**
  17305. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17306. */
  17307. export class EdgesRenderer implements IEdgesRenderer {
  17308. /**
  17309. * Define the size of the edges with an orthographic camera
  17310. */
  17311. edgesWidthScalerForOrthographic: number;
  17312. /**
  17313. * Define the size of the edges with a perspective camera
  17314. */
  17315. edgesWidthScalerForPerspective: number;
  17316. protected _source: AbstractMesh;
  17317. protected _linesPositions: number[];
  17318. protected _linesNormals: number[];
  17319. protected _linesIndices: number[];
  17320. protected _epsilon: number;
  17321. protected _indicesCount: number;
  17322. protected _lineShader: ShaderMaterial;
  17323. protected _ib: DataBuffer;
  17324. protected _buffers: {
  17325. [key: string]: Nullable<VertexBuffer>;
  17326. };
  17327. protected _checkVerticesInsteadOfIndices: boolean;
  17328. private _meshRebuildObserver;
  17329. private _meshDisposeObserver;
  17330. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17331. isEnabled: boolean;
  17332. /**
  17333. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17334. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17335. * @param source Mesh used to create edges
  17336. * @param epsilon sum of angles in adjacency to check for edge
  17337. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17338. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17339. */
  17340. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17341. protected _prepareRessources(): void;
  17342. /** @hidden */
  17343. _rebuild(): void;
  17344. /**
  17345. * Releases the required resources for the edges renderer
  17346. */
  17347. dispose(): void;
  17348. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17349. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17350. /**
  17351. * Checks if the pair of p0 and p1 is en edge
  17352. * @param faceIndex
  17353. * @param edge
  17354. * @param faceNormals
  17355. * @param p0
  17356. * @param p1
  17357. * @private
  17358. */
  17359. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17360. /**
  17361. * push line into the position, normal and index buffer
  17362. * @protected
  17363. */
  17364. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17365. /**
  17366. * Generates lines edges from adjacencjes
  17367. * @private
  17368. */
  17369. _generateEdgesLines(): void;
  17370. /**
  17371. * Checks wether or not the edges renderer is ready to render.
  17372. * @return true if ready, otherwise false.
  17373. */
  17374. isReady(): boolean;
  17375. /**
  17376. * Renders the edges of the attached mesh,
  17377. */
  17378. render(): void;
  17379. }
  17380. /**
  17381. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17382. */
  17383. export class LineEdgesRenderer extends EdgesRenderer {
  17384. /**
  17385. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17386. * @param source LineMesh used to generate edges
  17387. * @param epsilon not important (specified angle for edge detection)
  17388. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17389. */
  17390. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17391. /**
  17392. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17393. */
  17394. _generateEdgesLines(): void;
  17395. }
  17396. }
  17397. declare module "babylonjs/Rendering/renderingGroup" {
  17398. import { SmartArray, SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  17399. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17400. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17401. import { Nullable } from "babylonjs/types";
  17402. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17403. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  17404. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17405. import { Material } from "babylonjs/Materials/material";
  17406. import { Scene } from "babylonjs/scene";
  17407. /**
  17408. * This represents the object necessary to create a rendering group.
  17409. * This is exclusively used and created by the rendering manager.
  17410. * To modify the behavior, you use the available helpers in your scene or meshes.
  17411. * @hidden
  17412. */
  17413. export class RenderingGroup {
  17414. index: number;
  17415. private static _zeroVector;
  17416. private _scene;
  17417. private _opaqueSubMeshes;
  17418. private _transparentSubMeshes;
  17419. private _alphaTestSubMeshes;
  17420. private _depthOnlySubMeshes;
  17421. private _particleSystems;
  17422. private _spriteManagers;
  17423. private _opaqueSortCompareFn;
  17424. private _alphaTestSortCompareFn;
  17425. private _transparentSortCompareFn;
  17426. private _renderOpaque;
  17427. private _renderAlphaTest;
  17428. private _renderTransparent;
  17429. /** @hidden */
  17430. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  17431. onBeforeTransparentRendering: () => void;
  17432. /**
  17433. * Set the opaque sort comparison function.
  17434. * If null the sub meshes will be render in the order they were created
  17435. */
  17436. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17437. /**
  17438. * Set the alpha test sort comparison function.
  17439. * If null the sub meshes will be render in the order they were created
  17440. */
  17441. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17442. /**
  17443. * Set the transparent sort comparison function.
  17444. * If null the sub meshes will be render in the order they were created
  17445. */
  17446. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17447. /**
  17448. * Creates a new rendering group.
  17449. * @param index The rendering group index
  17450. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17451. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17452. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17453. */
  17454. 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>);
  17455. /**
  17456. * Render all the sub meshes contained in the group.
  17457. * @param customRenderFunction Used to override the default render behaviour of the group.
  17458. * @returns true if rendered some submeshes.
  17459. */
  17460. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17461. /**
  17462. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17463. * @param subMeshes The submeshes to render
  17464. */
  17465. private renderOpaqueSorted;
  17466. /**
  17467. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17468. * @param subMeshes The submeshes to render
  17469. */
  17470. private renderAlphaTestSorted;
  17471. /**
  17472. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17473. * @param subMeshes The submeshes to render
  17474. */
  17475. private renderTransparentSorted;
  17476. /**
  17477. * Renders the submeshes in a specified order.
  17478. * @param subMeshes The submeshes to sort before render
  17479. * @param sortCompareFn The comparison function use to sort
  17480. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17481. * @param transparent Specifies to activate blending if true
  17482. */
  17483. private static renderSorted;
  17484. /**
  17485. * Renders the submeshes in the order they were dispatched (no sort applied).
  17486. * @param subMeshes The submeshes to render
  17487. */
  17488. private static renderUnsorted;
  17489. /**
  17490. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17491. * are rendered back to front if in the same alpha index.
  17492. *
  17493. * @param a The first submesh
  17494. * @param b The second submesh
  17495. * @returns The result of the comparison
  17496. */
  17497. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17498. /**
  17499. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17500. * are rendered back to front.
  17501. *
  17502. * @param a The first submesh
  17503. * @param b The second submesh
  17504. * @returns The result of the comparison
  17505. */
  17506. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17507. /**
  17508. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17509. * are rendered front to back (prevent overdraw).
  17510. *
  17511. * @param a The first submesh
  17512. * @param b The second submesh
  17513. * @returns The result of the comparison
  17514. */
  17515. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17516. /**
  17517. * Resets the different lists of submeshes to prepare a new frame.
  17518. */
  17519. prepare(): void;
  17520. dispose(): void;
  17521. /**
  17522. * Inserts the submesh in its correct queue depending on its material.
  17523. * @param subMesh The submesh to dispatch
  17524. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17525. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17526. */
  17527. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17528. dispatchSprites(spriteManager: ISpriteManager): void;
  17529. dispatchParticles(particleSystem: IParticleSystem): void;
  17530. private _renderParticles;
  17531. private _renderSprites;
  17532. }
  17533. }
  17534. declare module "babylonjs/Rendering/renderingManager" {
  17535. import { Nullable } from "babylonjs/types";
  17536. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17537. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17538. import { SmartArray } from "babylonjs/Misc/smartArray";
  17539. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17540. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17541. import { Material } from "babylonjs/Materials/material";
  17542. import { Scene } from "babylonjs/scene";
  17543. import { Camera } from "babylonjs/Cameras/camera";
  17544. /**
  17545. * Interface describing the different options available in the rendering manager
  17546. * regarding Auto Clear between groups.
  17547. */
  17548. export interface IRenderingManagerAutoClearSetup {
  17549. /**
  17550. * Defines whether or not autoclear is enable.
  17551. */
  17552. autoClear: boolean;
  17553. /**
  17554. * Defines whether or not to autoclear the depth buffer.
  17555. */
  17556. depth: boolean;
  17557. /**
  17558. * Defines whether or not to autoclear the stencil buffer.
  17559. */
  17560. stencil: boolean;
  17561. }
  17562. /**
  17563. * This class is used by the onRenderingGroupObservable
  17564. */
  17565. export class RenderingGroupInfo {
  17566. /**
  17567. * The Scene that being rendered
  17568. */
  17569. scene: Scene;
  17570. /**
  17571. * The camera currently used for the rendering pass
  17572. */
  17573. camera: Nullable<Camera>;
  17574. /**
  17575. * The ID of the renderingGroup being processed
  17576. */
  17577. renderingGroupId: number;
  17578. }
  17579. /**
  17580. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17581. * It is enable to manage the different groups as well as the different necessary sort functions.
  17582. * This should not be used directly aside of the few static configurations
  17583. */
  17584. export class RenderingManager {
  17585. /**
  17586. * The max id used for rendering groups (not included)
  17587. */
  17588. static MAX_RENDERINGGROUPS: number;
  17589. /**
  17590. * The min id used for rendering groups (included)
  17591. */
  17592. static MIN_RENDERINGGROUPS: number;
  17593. /**
  17594. * Used to globally prevent autoclearing scenes.
  17595. */
  17596. static AUTOCLEAR: boolean;
  17597. /**
  17598. * @hidden
  17599. */
  17600. _useSceneAutoClearSetup: boolean;
  17601. private _scene;
  17602. private _renderingGroups;
  17603. private _depthStencilBufferAlreadyCleaned;
  17604. private _autoClearDepthStencil;
  17605. private _customOpaqueSortCompareFn;
  17606. private _customAlphaTestSortCompareFn;
  17607. private _customTransparentSortCompareFn;
  17608. private _renderingGroupInfo;
  17609. /**
  17610. * Instantiates a new rendering group for a particular scene
  17611. * @param scene Defines the scene the groups belongs to
  17612. */
  17613. constructor(scene: Scene);
  17614. private _clearDepthStencilBuffer;
  17615. /**
  17616. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17617. * @hidden
  17618. */
  17619. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17620. /**
  17621. * Resets the different information of the group to prepare a new frame
  17622. * @hidden
  17623. */
  17624. reset(): void;
  17625. /**
  17626. * Dispose and release the group and its associated resources.
  17627. * @hidden
  17628. */
  17629. dispose(): void;
  17630. /**
  17631. * Clear the info related to rendering groups preventing retention points during dispose.
  17632. */
  17633. freeRenderingGroups(): void;
  17634. private _prepareRenderingGroup;
  17635. /**
  17636. * Add a sprite manager to the rendering manager in order to render it this frame.
  17637. * @param spriteManager Define the sprite manager to render
  17638. */
  17639. dispatchSprites(spriteManager: ISpriteManager): void;
  17640. /**
  17641. * Add a particle system to the rendering manager in order to render it this frame.
  17642. * @param particleSystem Define the particle system to render
  17643. */
  17644. dispatchParticles(particleSystem: IParticleSystem): void;
  17645. /**
  17646. * Add a submesh to the manager in order to render it this frame
  17647. * @param subMesh The submesh to dispatch
  17648. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17649. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17650. */
  17651. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17652. /**
  17653. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17654. * This allowed control for front to back rendering or reversly depending of the special needs.
  17655. *
  17656. * @param renderingGroupId The rendering group id corresponding to its index
  17657. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17658. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17659. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17660. */
  17661. 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;
  17662. /**
  17663. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17664. *
  17665. * @param renderingGroupId The rendering group id corresponding to its index
  17666. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17667. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17668. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17669. */
  17670. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17671. /**
  17672. * Gets the current auto clear configuration for one rendering group of the rendering
  17673. * manager.
  17674. * @param index the rendering group index to get the information for
  17675. * @returns The auto clear setup for the requested rendering group
  17676. */
  17677. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17678. }
  17679. }
  17680. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  17681. import { SmartArray } from "babylonjs/Misc/smartArray";
  17682. import { Nullable } from "babylonjs/types";
  17683. import { Scene } from "babylonjs/scene";
  17684. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  17685. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17686. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17687. import { Mesh } from "babylonjs/Meshes/mesh";
  17688. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  17689. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  17690. import { Effect } from "babylonjs/Materials/effect";
  17691. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  17692. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17693. import "babylonjs/Shaders/shadowMap.fragment";
  17694. import "babylonjs/Shaders/shadowMap.vertex";
  17695. import "babylonjs/Shaders/depthBoxBlur.fragment";
  17696. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow";
  17697. import { Observable } from "babylonjs/Misc/observable";
  17698. /**
  17699. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17700. */
  17701. export interface ICustomShaderOptions {
  17702. /**
  17703. * Gets or sets the custom shader name to use
  17704. */
  17705. shaderName: string;
  17706. /**
  17707. * The list of attribute names used in the shader
  17708. */
  17709. attributes?: string[];
  17710. /**
  17711. * The list of unifrom names used in the shader
  17712. */
  17713. uniforms?: string[];
  17714. /**
  17715. * The list of sampler names used in the shader
  17716. */
  17717. samplers?: string[];
  17718. /**
  17719. * The list of defines used in the shader
  17720. */
  17721. defines?: string[];
  17722. }
  17723. /**
  17724. * Interface to implement to create a shadow generator compatible with BJS.
  17725. */
  17726. export interface IShadowGenerator {
  17727. /**
  17728. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17729. * @returns The render target texture if present otherwise, null
  17730. */
  17731. getShadowMap(): Nullable<RenderTargetTexture>;
  17732. /**
  17733. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17734. * @param subMesh The submesh we want to render in the shadow map
  17735. * @param useInstances Defines wether will draw in the map using instances
  17736. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17737. * @returns true if ready otherwise, false
  17738. */
  17739. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17740. /**
  17741. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17742. * @param defines Defines of the material we want to update
  17743. * @param lightIndex Index of the light in the enabled light list of the material
  17744. */
  17745. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  17746. /**
  17747. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17748. * defined in the generator but impacting the effect).
  17749. * It implies the unifroms available on the materials are the standard BJS ones.
  17750. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17751. * @param effect The effect we are binfing the information for
  17752. */
  17753. bindShadowLight(lightIndex: string, effect: Effect): void;
  17754. /**
  17755. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17756. * (eq to shadow prjection matrix * light transform matrix)
  17757. * @returns The transform matrix used to create the shadow map
  17758. */
  17759. getTransformMatrix(): Matrix;
  17760. /**
  17761. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17762. * Cube and 2D textures for instance.
  17763. */
  17764. recreateShadowMap(): void;
  17765. /**
  17766. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17767. * @param onCompiled Callback triggered at the and of the effects compilation
  17768. * @param options Sets of optional options forcing the compilation with different modes
  17769. */
  17770. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17771. useInstances: boolean;
  17772. }>): void;
  17773. /**
  17774. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17775. * @param options Sets of optional options forcing the compilation with different modes
  17776. * @returns A promise that resolves when the compilation completes
  17777. */
  17778. forceCompilationAsync(options?: Partial<{
  17779. useInstances: boolean;
  17780. }>): Promise<void>;
  17781. /**
  17782. * Serializes the shadow generator setup to a json object.
  17783. * @returns The serialized JSON object
  17784. */
  17785. serialize(): any;
  17786. /**
  17787. * Disposes the Shadow map and related Textures and effects.
  17788. */
  17789. dispose(): void;
  17790. }
  17791. /**
  17792. * Default implementation IShadowGenerator.
  17793. * This is the main object responsible of generating shadows in the framework.
  17794. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  17795. */
  17796. export class ShadowGenerator implements IShadowGenerator {
  17797. /**
  17798. * Name of the shadow generator class
  17799. */
  17800. static CLASSNAME: string;
  17801. /**
  17802. * Shadow generator mode None: no filtering applied.
  17803. */
  17804. static readonly FILTER_NONE: number;
  17805. /**
  17806. * Shadow generator mode ESM: Exponential Shadow Mapping.
  17807. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17808. */
  17809. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  17810. /**
  17811. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  17812. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  17813. */
  17814. static readonly FILTER_POISSONSAMPLING: number;
  17815. /**
  17816. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  17817. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17818. */
  17819. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  17820. /**
  17821. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  17822. * edge artifacts on steep falloff.
  17823. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17824. */
  17825. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  17826. /**
  17827. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  17828. * edge artifacts on steep falloff.
  17829. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17830. */
  17831. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  17832. /**
  17833. * Shadow generator mode PCF: Percentage Closer Filtering
  17834. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17835. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  17836. */
  17837. static readonly FILTER_PCF: number;
  17838. /**
  17839. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  17840. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17841. * Contact Hardening
  17842. */
  17843. static readonly FILTER_PCSS: number;
  17844. /**
  17845. * Reserved for PCF and PCSS
  17846. * Highest Quality.
  17847. *
  17848. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  17849. *
  17850. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  17851. */
  17852. static readonly QUALITY_HIGH: number;
  17853. /**
  17854. * Reserved for PCF and PCSS
  17855. * Good tradeoff for quality/perf cross devices
  17856. *
  17857. * Execute PCF on a 3*3 kernel.
  17858. *
  17859. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  17860. */
  17861. static readonly QUALITY_MEDIUM: number;
  17862. /**
  17863. * Reserved for PCF and PCSS
  17864. * The lowest quality but the fastest.
  17865. *
  17866. * Execute PCF on a 1*1 kernel.
  17867. *
  17868. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  17869. */
  17870. static readonly QUALITY_LOW: number;
  17871. /** Gets or sets the custom shader name to use */
  17872. customShaderOptions: ICustomShaderOptions;
  17873. /**
  17874. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  17875. */
  17876. onBeforeShadowMapRenderObservable: Observable<Effect>;
  17877. /**
  17878. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  17879. */
  17880. onAfterShadowMapRenderObservable: Observable<Effect>;
  17881. /**
  17882. * Observable triggered before a mesh is rendered in the shadow map.
  17883. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  17884. */
  17885. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  17886. /**
  17887. * Observable triggered after a mesh is rendered in the shadow map.
  17888. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  17889. */
  17890. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  17891. protected _bias: number;
  17892. /**
  17893. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  17894. */
  17895. get bias(): number;
  17896. /**
  17897. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  17898. */
  17899. set bias(bias: number);
  17900. protected _normalBias: number;
  17901. /**
  17902. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17903. */
  17904. get normalBias(): number;
  17905. /**
  17906. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17907. */
  17908. set normalBias(normalBias: number);
  17909. protected _blurBoxOffset: number;
  17910. /**
  17911. * Gets the blur box offset: offset applied during the blur pass.
  17912. * Only useful if useKernelBlur = false
  17913. */
  17914. get blurBoxOffset(): number;
  17915. /**
  17916. * Sets the blur box offset: offset applied during the blur pass.
  17917. * Only useful if useKernelBlur = false
  17918. */
  17919. set blurBoxOffset(value: number);
  17920. protected _blurScale: number;
  17921. /**
  17922. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  17923. * 2 means half of the size.
  17924. */
  17925. get blurScale(): number;
  17926. /**
  17927. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  17928. * 2 means half of the size.
  17929. */
  17930. set blurScale(value: number);
  17931. protected _blurKernel: number;
  17932. /**
  17933. * Gets the blur kernel: kernel size of the blur pass.
  17934. * Only useful if useKernelBlur = true
  17935. */
  17936. get blurKernel(): number;
  17937. /**
  17938. * Sets the blur kernel: kernel size of the blur pass.
  17939. * Only useful if useKernelBlur = true
  17940. */
  17941. set blurKernel(value: number);
  17942. protected _useKernelBlur: boolean;
  17943. /**
  17944. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  17945. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17946. */
  17947. get useKernelBlur(): boolean;
  17948. /**
  17949. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  17950. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17951. */
  17952. set useKernelBlur(value: boolean);
  17953. protected _depthScale: number;
  17954. /**
  17955. * Gets the depth scale used in ESM mode.
  17956. */
  17957. get depthScale(): number;
  17958. /**
  17959. * Sets the depth scale used in ESM mode.
  17960. * This can override the scale stored on the light.
  17961. */
  17962. set depthScale(value: number);
  17963. protected _validateFilter(filter: number): number;
  17964. protected _filter: number;
  17965. /**
  17966. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  17967. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17968. */
  17969. get filter(): number;
  17970. /**
  17971. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  17972. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17973. */
  17974. set filter(value: number);
  17975. /**
  17976. * Gets if the current filter is set to Poisson Sampling.
  17977. */
  17978. get usePoissonSampling(): boolean;
  17979. /**
  17980. * Sets the current filter to Poisson Sampling.
  17981. */
  17982. set usePoissonSampling(value: boolean);
  17983. /**
  17984. * Gets if the current filter is set to ESM.
  17985. */
  17986. get useExponentialShadowMap(): boolean;
  17987. /**
  17988. * Sets the current filter is to ESM.
  17989. */
  17990. set useExponentialShadowMap(value: boolean);
  17991. /**
  17992. * Gets if the current filter is set to filtered ESM.
  17993. */
  17994. get useBlurExponentialShadowMap(): boolean;
  17995. /**
  17996. * Gets if the current filter is set to filtered ESM.
  17997. */
  17998. set useBlurExponentialShadowMap(value: boolean);
  17999. /**
  18000. * Gets if the current filter is set to "close ESM" (using the inverse of the
  18001. * exponential to prevent steep falloff artifacts).
  18002. */
  18003. get useCloseExponentialShadowMap(): boolean;
  18004. /**
  18005. * Sets the current filter to "close ESM" (using the inverse of the
  18006. * exponential to prevent steep falloff artifacts).
  18007. */
  18008. set useCloseExponentialShadowMap(value: boolean);
  18009. /**
  18010. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  18011. * exponential to prevent steep falloff artifacts).
  18012. */
  18013. get useBlurCloseExponentialShadowMap(): boolean;
  18014. /**
  18015. * Sets the current filter to filtered "close ESM" (using the inverse of the
  18016. * exponential to prevent steep falloff artifacts).
  18017. */
  18018. set useBlurCloseExponentialShadowMap(value: boolean);
  18019. /**
  18020. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  18021. */
  18022. get usePercentageCloserFiltering(): boolean;
  18023. /**
  18024. * Sets the current filter to "PCF" (percentage closer filtering).
  18025. */
  18026. set usePercentageCloserFiltering(value: boolean);
  18027. protected _filteringQuality: number;
  18028. /**
  18029. * Gets the PCF or PCSS Quality.
  18030. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18031. */
  18032. get filteringQuality(): number;
  18033. /**
  18034. * Sets the PCF or PCSS Quality.
  18035. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18036. */
  18037. set filteringQuality(filteringQuality: number);
  18038. /**
  18039. * Gets if the current filter is set to "PCSS" (contact hardening).
  18040. */
  18041. get useContactHardeningShadow(): boolean;
  18042. /**
  18043. * Sets the current filter to "PCSS" (contact hardening).
  18044. */
  18045. set useContactHardeningShadow(value: boolean);
  18046. protected _contactHardeningLightSizeUVRatio: number;
  18047. /**
  18048. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18049. * Using a ratio helps keeping shape stability independently of the map size.
  18050. *
  18051. * It does not account for the light projection as it was having too much
  18052. * instability during the light setup or during light position changes.
  18053. *
  18054. * Only valid if useContactHardeningShadow is true.
  18055. */
  18056. get contactHardeningLightSizeUVRatio(): number;
  18057. /**
  18058. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18059. * Using a ratio helps keeping shape stability independently of the map size.
  18060. *
  18061. * It does not account for the light projection as it was having too much
  18062. * instability during the light setup or during light position changes.
  18063. *
  18064. * Only valid if useContactHardeningShadow is true.
  18065. */
  18066. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  18067. protected _darkness: number;
  18068. /** Gets or sets the actual darkness of a shadow */
  18069. get darkness(): number;
  18070. set darkness(value: number);
  18071. /**
  18072. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  18073. * 0 means strongest and 1 would means no shadow.
  18074. * @returns the darkness.
  18075. */
  18076. getDarkness(): number;
  18077. /**
  18078. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  18079. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  18080. * @returns the shadow generator allowing fluent coding.
  18081. */
  18082. setDarkness(darkness: number): ShadowGenerator;
  18083. protected _transparencyShadow: boolean;
  18084. /** Gets or sets the ability to have transparent shadow */
  18085. get transparencyShadow(): boolean;
  18086. set transparencyShadow(value: boolean);
  18087. /**
  18088. * Sets the ability to have transparent shadow (boolean).
  18089. * @param transparent True if transparent else False
  18090. * @returns the shadow generator allowing fluent coding
  18091. */
  18092. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  18093. /**
  18094. * Enables or disables shadows with varying strength based on the transparency
  18095. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  18096. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  18097. * mesh.visibility * alphaTexture.a
  18098. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  18099. */
  18100. enableSoftTransparentShadow: boolean;
  18101. protected _shadowMap: Nullable<RenderTargetTexture>;
  18102. protected _shadowMap2: Nullable<RenderTargetTexture>;
  18103. /**
  18104. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  18105. * @returns The render target texture if present otherwise, null
  18106. */
  18107. getShadowMap(): Nullable<RenderTargetTexture>;
  18108. /**
  18109. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  18110. * @returns The render target texture if the shadow map is present otherwise, null
  18111. */
  18112. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  18113. /**
  18114. * Gets the class name of that object
  18115. * @returns "ShadowGenerator"
  18116. */
  18117. getClassName(): string;
  18118. /**
  18119. * Helper function to add a mesh and its descendants to the list of shadow casters.
  18120. * @param mesh Mesh to add
  18121. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  18122. * @returns the Shadow Generator itself
  18123. */
  18124. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18125. /**
  18126. * Helper function to remove a mesh and its descendants from the list of shadow casters
  18127. * @param mesh Mesh to remove
  18128. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  18129. * @returns the Shadow Generator itself
  18130. */
  18131. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18132. /**
  18133. * Controls the extent to which the shadows fade out at the edge of the frustum
  18134. */
  18135. frustumEdgeFalloff: number;
  18136. protected _light: IShadowLight;
  18137. /**
  18138. * Returns the associated light object.
  18139. * @returns the light generating the shadow
  18140. */
  18141. getLight(): IShadowLight;
  18142. /**
  18143. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  18144. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  18145. * It might on the other hand introduce peter panning.
  18146. */
  18147. forceBackFacesOnly: boolean;
  18148. protected _scene: Scene;
  18149. protected _lightDirection: Vector3;
  18150. protected _effect: Effect;
  18151. protected _viewMatrix: Matrix;
  18152. protected _projectionMatrix: Matrix;
  18153. protected _transformMatrix: Matrix;
  18154. protected _cachedPosition: Vector3;
  18155. protected _cachedDirection: Vector3;
  18156. protected _cachedDefines: string;
  18157. protected _currentRenderID: number;
  18158. protected _boxBlurPostprocess: Nullable<PostProcess>;
  18159. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  18160. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  18161. protected _blurPostProcesses: PostProcess[];
  18162. protected _mapSize: number;
  18163. protected _currentFaceIndex: number;
  18164. protected _currentFaceIndexCache: number;
  18165. protected _textureType: number;
  18166. protected _defaultTextureMatrix: Matrix;
  18167. protected _storedUniqueId: Nullable<number>;
  18168. /** @hidden */
  18169. static _SceneComponentInitialization: (scene: Scene) => void;
  18170. /**
  18171. * Creates a ShadowGenerator object.
  18172. * A ShadowGenerator is the required tool to use the shadows.
  18173. * Each light casting shadows needs to use its own ShadowGenerator.
  18174. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  18175. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  18176. * @param light The light object generating the shadows.
  18177. * @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.
  18178. */
  18179. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  18180. protected _initializeGenerator(): void;
  18181. protected _createTargetRenderTexture(): void;
  18182. protected _initializeShadowMap(): void;
  18183. protected _initializeBlurRTTAndPostProcesses(): void;
  18184. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  18185. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  18186. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  18187. protected _applyFilterValues(): void;
  18188. /**
  18189. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18190. * @param onCompiled Callback triggered at the and of the effects compilation
  18191. * @param options Sets of optional options forcing the compilation with different modes
  18192. */
  18193. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18194. useInstances: boolean;
  18195. }>): void;
  18196. /**
  18197. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18198. * @param options Sets of optional options forcing the compilation with different modes
  18199. * @returns A promise that resolves when the compilation completes
  18200. */
  18201. forceCompilationAsync(options?: Partial<{
  18202. useInstances: boolean;
  18203. }>): Promise<void>;
  18204. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  18205. private _prepareShadowDefines;
  18206. /**
  18207. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18208. * @param subMesh The submesh we want to render in the shadow map
  18209. * @param useInstances Defines wether will draw in the map using instances
  18210. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18211. * @returns true if ready otherwise, false
  18212. */
  18213. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18214. /**
  18215. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18216. * @param defines Defines of the material we want to update
  18217. * @param lightIndex Index of the light in the enabled light list of the material
  18218. */
  18219. prepareDefines(defines: any, lightIndex: number): void;
  18220. /**
  18221. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18222. * defined in the generator but impacting the effect).
  18223. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18224. * @param effect The effect we are binfing the information for
  18225. */
  18226. bindShadowLight(lightIndex: string, effect: Effect): void;
  18227. /**
  18228. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18229. * (eq to shadow prjection matrix * light transform matrix)
  18230. * @returns The transform matrix used to create the shadow map
  18231. */
  18232. getTransformMatrix(): Matrix;
  18233. /**
  18234. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18235. * Cube and 2D textures for instance.
  18236. */
  18237. recreateShadowMap(): void;
  18238. protected _disposeBlurPostProcesses(): void;
  18239. protected _disposeRTTandPostProcesses(): void;
  18240. /**
  18241. * Disposes the ShadowGenerator.
  18242. * Returns nothing.
  18243. */
  18244. dispose(): void;
  18245. /**
  18246. * Serializes the shadow generator setup to a json object.
  18247. * @returns The serialized JSON object
  18248. */
  18249. serialize(): any;
  18250. /**
  18251. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  18252. * @param parsedShadowGenerator The JSON object to parse
  18253. * @param scene The scene to create the shadow map for
  18254. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  18255. * @returns The parsed shadow generator
  18256. */
  18257. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  18258. }
  18259. }
  18260. declare module "babylonjs/Lights/light" {
  18261. import { Nullable } from "babylonjs/types";
  18262. import { Scene } from "babylonjs/scene";
  18263. import { Vector3 } from "babylonjs/Maths/math.vector";
  18264. import { Color3 } from "babylonjs/Maths/math.color";
  18265. import { Node } from "babylonjs/node";
  18266. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18267. import { Effect } from "babylonjs/Materials/effect";
  18268. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  18269. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  18270. /**
  18271. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  18272. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  18273. * 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.
  18274. */
  18275. export abstract class Light extends Node {
  18276. /**
  18277. * Falloff Default: light is falling off following the material specification:
  18278. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  18279. */
  18280. static readonly FALLOFF_DEFAULT: number;
  18281. /**
  18282. * Falloff Physical: light is falling off following the inverse squared distance law.
  18283. */
  18284. static readonly FALLOFF_PHYSICAL: number;
  18285. /**
  18286. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  18287. * to enhance interoperability with other engines.
  18288. */
  18289. static readonly FALLOFF_GLTF: number;
  18290. /**
  18291. * Falloff Standard: light is falling off like in the standard material
  18292. * to enhance interoperability with other materials.
  18293. */
  18294. static readonly FALLOFF_STANDARD: number;
  18295. /**
  18296. * If every light affecting the material is in this lightmapMode,
  18297. * material.lightmapTexture adds or multiplies
  18298. * (depends on material.useLightmapAsShadowmap)
  18299. * after every other light calculations.
  18300. */
  18301. static readonly LIGHTMAP_DEFAULT: number;
  18302. /**
  18303. * material.lightmapTexture as only diffuse lighting from this light
  18304. * adds only specular lighting from this light
  18305. * adds dynamic shadows
  18306. */
  18307. static readonly LIGHTMAP_SPECULAR: number;
  18308. /**
  18309. * material.lightmapTexture as only lighting
  18310. * no light calculation from this light
  18311. * only adds dynamic shadows from this light
  18312. */
  18313. static readonly LIGHTMAP_SHADOWSONLY: number;
  18314. /**
  18315. * Each light type uses the default quantity according to its type:
  18316. * point/spot lights use luminous intensity
  18317. * directional lights use illuminance
  18318. */
  18319. static readonly INTENSITYMODE_AUTOMATIC: number;
  18320. /**
  18321. * lumen (lm)
  18322. */
  18323. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  18324. /**
  18325. * candela (lm/sr)
  18326. */
  18327. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  18328. /**
  18329. * lux (lm/m^2)
  18330. */
  18331. static readonly INTENSITYMODE_ILLUMINANCE: number;
  18332. /**
  18333. * nit (cd/m^2)
  18334. */
  18335. static readonly INTENSITYMODE_LUMINANCE: number;
  18336. /**
  18337. * Light type const id of the point light.
  18338. */
  18339. static readonly LIGHTTYPEID_POINTLIGHT: number;
  18340. /**
  18341. * Light type const id of the directional light.
  18342. */
  18343. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  18344. /**
  18345. * Light type const id of the spot light.
  18346. */
  18347. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  18348. /**
  18349. * Light type const id of the hemispheric light.
  18350. */
  18351. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  18352. /**
  18353. * Diffuse gives the basic color to an object.
  18354. */
  18355. diffuse: Color3;
  18356. /**
  18357. * Specular produces a highlight color on an object.
  18358. * Note: This is note affecting PBR materials.
  18359. */
  18360. specular: Color3;
  18361. /**
  18362. * Defines the falloff type for this light. This lets overrriding how punctual light are
  18363. * falling off base on range or angle.
  18364. * This can be set to any values in Light.FALLOFF_x.
  18365. *
  18366. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  18367. * other types of materials.
  18368. */
  18369. falloffType: number;
  18370. /**
  18371. * Strength of the light.
  18372. * Note: By default it is define in the framework own unit.
  18373. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  18374. */
  18375. intensity: number;
  18376. private _range;
  18377. protected _inverseSquaredRange: number;
  18378. /**
  18379. * Defines how far from the source the light is impacting in scene units.
  18380. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18381. */
  18382. get range(): number;
  18383. /**
  18384. * Defines how far from the source the light is impacting in scene units.
  18385. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18386. */
  18387. set range(value: number);
  18388. /**
  18389. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  18390. * of light.
  18391. */
  18392. private _photometricScale;
  18393. private _intensityMode;
  18394. /**
  18395. * Gets the photometric scale used to interpret the intensity.
  18396. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18397. */
  18398. get intensityMode(): number;
  18399. /**
  18400. * Sets the photometric scale used to interpret the intensity.
  18401. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18402. */
  18403. set intensityMode(value: number);
  18404. private _radius;
  18405. /**
  18406. * Gets the light radius used by PBR Materials to simulate soft area lights.
  18407. */
  18408. get radius(): number;
  18409. /**
  18410. * sets the light radius used by PBR Materials to simulate soft area lights.
  18411. */
  18412. set radius(value: number);
  18413. private _renderPriority;
  18414. /**
  18415. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  18416. * exceeding the number allowed of the materials.
  18417. */
  18418. renderPriority: number;
  18419. private _shadowEnabled;
  18420. /**
  18421. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18422. * the current shadow generator.
  18423. */
  18424. get shadowEnabled(): boolean;
  18425. /**
  18426. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18427. * the current shadow generator.
  18428. */
  18429. set shadowEnabled(value: boolean);
  18430. private _includedOnlyMeshes;
  18431. /**
  18432. * Gets the only meshes impacted by this light.
  18433. */
  18434. get includedOnlyMeshes(): AbstractMesh[];
  18435. /**
  18436. * Sets the only meshes impacted by this light.
  18437. */
  18438. set includedOnlyMeshes(value: AbstractMesh[]);
  18439. private _excludedMeshes;
  18440. /**
  18441. * Gets the meshes not impacted by this light.
  18442. */
  18443. get excludedMeshes(): AbstractMesh[];
  18444. /**
  18445. * Sets the meshes not impacted by this light.
  18446. */
  18447. set excludedMeshes(value: AbstractMesh[]);
  18448. private _excludeWithLayerMask;
  18449. /**
  18450. * Gets the layer id use to find what meshes are not impacted by the light.
  18451. * Inactive if 0
  18452. */
  18453. get excludeWithLayerMask(): number;
  18454. /**
  18455. * Sets the layer id use to find what meshes are not impacted by the light.
  18456. * Inactive if 0
  18457. */
  18458. set excludeWithLayerMask(value: number);
  18459. private _includeOnlyWithLayerMask;
  18460. /**
  18461. * Gets the layer id use to find what meshes are impacted by the light.
  18462. * Inactive if 0
  18463. */
  18464. get includeOnlyWithLayerMask(): number;
  18465. /**
  18466. * Sets the layer id use to find what meshes are impacted by the light.
  18467. * Inactive if 0
  18468. */
  18469. set includeOnlyWithLayerMask(value: number);
  18470. private _lightmapMode;
  18471. /**
  18472. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18473. */
  18474. get lightmapMode(): number;
  18475. /**
  18476. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18477. */
  18478. set lightmapMode(value: number);
  18479. /**
  18480. * Shadow generator associted to the light.
  18481. * @hidden Internal use only.
  18482. */
  18483. _shadowGenerator: Nullable<IShadowGenerator>;
  18484. /**
  18485. * @hidden Internal use only.
  18486. */
  18487. _excludedMeshesIds: string[];
  18488. /**
  18489. * @hidden Internal use only.
  18490. */
  18491. _includedOnlyMeshesIds: string[];
  18492. /**
  18493. * The current light unifom buffer.
  18494. * @hidden Internal use only.
  18495. */
  18496. _uniformBuffer: UniformBuffer;
  18497. /** @hidden */
  18498. _renderId: number;
  18499. /**
  18500. * Creates a Light object in the scene.
  18501. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18502. * @param name The firendly name of the light
  18503. * @param scene The scene the light belongs too
  18504. */
  18505. constructor(name: string, scene: Scene);
  18506. protected abstract _buildUniformLayout(): void;
  18507. /**
  18508. * Sets the passed Effect "effect" with the Light information.
  18509. * @param effect The effect to update
  18510. * @param lightIndex The index of the light in the effect to update
  18511. * @returns The light
  18512. */
  18513. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18514. /**
  18515. * Sets the passed Effect "effect" with the Light textures.
  18516. * @param effect The effect to update
  18517. * @param lightIndex The index of the light in the effect to update
  18518. * @returns The light
  18519. */
  18520. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18521. /**
  18522. * Binds the lights information from the scene to the effect for the given mesh.
  18523. * @param lightIndex Light index
  18524. * @param scene The scene where the light belongs to
  18525. * @param effect The effect we are binding the data to
  18526. * @param useSpecular Defines if specular is supported
  18527. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18528. */
  18529. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18530. /**
  18531. * Sets the passed Effect "effect" with the Light information.
  18532. * @param effect The effect to update
  18533. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18534. * @returns The light
  18535. */
  18536. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18537. /**
  18538. * Returns the string "Light".
  18539. * @returns the class name
  18540. */
  18541. getClassName(): string;
  18542. /** @hidden */
  18543. readonly _isLight: boolean;
  18544. /**
  18545. * Converts the light information to a readable string for debug purpose.
  18546. * @param fullDetails Supports for multiple levels of logging within scene loading
  18547. * @returns the human readable light info
  18548. */
  18549. toString(fullDetails?: boolean): string;
  18550. /** @hidden */
  18551. protected _syncParentEnabledState(): void;
  18552. /**
  18553. * Set the enabled state of this node.
  18554. * @param value - the new enabled state
  18555. */
  18556. setEnabled(value: boolean): void;
  18557. /**
  18558. * Returns the Light associated shadow generator if any.
  18559. * @return the associated shadow generator.
  18560. */
  18561. getShadowGenerator(): Nullable<IShadowGenerator>;
  18562. /**
  18563. * Returns a Vector3, the absolute light position in the World.
  18564. * @returns the world space position of the light
  18565. */
  18566. getAbsolutePosition(): Vector3;
  18567. /**
  18568. * Specifies if the light will affect the passed mesh.
  18569. * @param mesh The mesh to test against the light
  18570. * @return true the mesh is affected otherwise, false.
  18571. */
  18572. canAffectMesh(mesh: AbstractMesh): boolean;
  18573. /**
  18574. * Sort function to order lights for rendering.
  18575. * @param a First Light object to compare to second.
  18576. * @param b Second Light object to compare first.
  18577. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18578. */
  18579. static CompareLightsPriority(a: Light, b: Light): number;
  18580. /**
  18581. * Releases resources associated with this node.
  18582. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18583. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18584. */
  18585. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18586. /**
  18587. * Returns the light type ID (integer).
  18588. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18589. */
  18590. getTypeID(): number;
  18591. /**
  18592. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18593. * @returns the scaled intensity in intensity mode unit
  18594. */
  18595. getScaledIntensity(): number;
  18596. /**
  18597. * Returns a new Light object, named "name", from the current one.
  18598. * @param name The name of the cloned light
  18599. * @param newParent The parent of this light, if it has one
  18600. * @returns the new created light
  18601. */
  18602. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18603. /**
  18604. * Serializes the current light into a Serialization object.
  18605. * @returns the serialized object.
  18606. */
  18607. serialize(): any;
  18608. /**
  18609. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18610. * This new light is named "name" and added to the passed scene.
  18611. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18612. * @param name The friendly name of the light
  18613. * @param scene The scene the new light will belong to
  18614. * @returns the constructor function
  18615. */
  18616. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18617. /**
  18618. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18619. * @param parsedLight The JSON representation of the light
  18620. * @param scene The scene to create the parsed light in
  18621. * @returns the created light after parsing
  18622. */
  18623. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18624. private _hookArrayForExcluded;
  18625. private _hookArrayForIncludedOnly;
  18626. private _resyncMeshes;
  18627. /**
  18628. * Forces the meshes to update their light related information in their rendering used effects
  18629. * @hidden Internal Use Only
  18630. */
  18631. _markMeshesAsLightDirty(): void;
  18632. /**
  18633. * Recomputes the cached photometric scale if needed.
  18634. */
  18635. private _computePhotometricScale;
  18636. /**
  18637. * Returns the Photometric Scale according to the light type and intensity mode.
  18638. */
  18639. private _getPhotometricScale;
  18640. /**
  18641. * Reorder the light in the scene according to their defined priority.
  18642. * @hidden Internal Use Only
  18643. */
  18644. _reorderLightsInScene(): void;
  18645. /**
  18646. * Prepares the list of defines specific to the light type.
  18647. * @param defines the list of defines
  18648. * @param lightIndex defines the index of the light for the effect
  18649. */
  18650. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18651. }
  18652. }
  18653. declare module "babylonjs/Cameras/targetCamera" {
  18654. import { Nullable } from "babylonjs/types";
  18655. import { Camera } from "babylonjs/Cameras/camera";
  18656. import { Scene } from "babylonjs/scene";
  18657. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  18658. /**
  18659. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18660. * This is the base of the follow, arc rotate cameras and Free camera
  18661. * @see http://doc.babylonjs.com/features/cameras
  18662. */
  18663. export class TargetCamera extends Camera {
  18664. private static _RigCamTransformMatrix;
  18665. private static _TargetTransformMatrix;
  18666. private static _TargetFocalPoint;
  18667. /**
  18668. * Define the current direction the camera is moving to
  18669. */
  18670. cameraDirection: Vector3;
  18671. /**
  18672. * Define the current rotation the camera is rotating to
  18673. */
  18674. cameraRotation: Vector2;
  18675. /**
  18676. * When set, the up vector of the camera will be updated by the rotation of the camera
  18677. */
  18678. updateUpVectorFromRotation: boolean;
  18679. private _tmpQuaternion;
  18680. /**
  18681. * Define the current rotation of the camera
  18682. */
  18683. rotation: Vector3;
  18684. /**
  18685. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18686. */
  18687. rotationQuaternion: Quaternion;
  18688. /**
  18689. * Define the current speed of the camera
  18690. */
  18691. speed: number;
  18692. /**
  18693. * Add constraint to the camera to prevent it to move freely in all directions and
  18694. * around all axis.
  18695. */
  18696. noRotationConstraint: boolean;
  18697. /**
  18698. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18699. * panning
  18700. */
  18701. invertRotation: boolean;
  18702. /**
  18703. * Speed multiplier for inverse camera panning
  18704. */
  18705. inverseRotationSpeed: number;
  18706. /**
  18707. * Define the current target of the camera as an object or a position.
  18708. */
  18709. lockedTarget: any;
  18710. /** @hidden */
  18711. _currentTarget: Vector3;
  18712. /** @hidden */
  18713. _initialFocalDistance: number;
  18714. /** @hidden */
  18715. _viewMatrix: Matrix;
  18716. /** @hidden */
  18717. _camMatrix: Matrix;
  18718. /** @hidden */
  18719. _cameraTransformMatrix: Matrix;
  18720. /** @hidden */
  18721. _cameraRotationMatrix: Matrix;
  18722. /** @hidden */
  18723. _referencePoint: Vector3;
  18724. /** @hidden */
  18725. _transformedReferencePoint: Vector3;
  18726. protected _globalCurrentTarget: Vector3;
  18727. protected _globalCurrentUpVector: Vector3;
  18728. /** @hidden */
  18729. _reset: () => void;
  18730. private _defaultUp;
  18731. /**
  18732. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  18733. * This is the base of the follow, arc rotate cameras and Free camera
  18734. * @see http://doc.babylonjs.com/features/cameras
  18735. * @param name Defines the name of the camera in the scene
  18736. * @param position Defines the start position of the camera in the scene
  18737. * @param scene Defines the scene the camera belongs to
  18738. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18739. */
  18740. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18741. /**
  18742. * Gets the position in front of the camera at a given distance.
  18743. * @param distance The distance from the camera we want the position to be
  18744. * @returns the position
  18745. */
  18746. getFrontPosition(distance: number): Vector3;
  18747. /** @hidden */
  18748. _getLockedTargetPosition(): Nullable<Vector3>;
  18749. private _storedPosition;
  18750. private _storedRotation;
  18751. private _storedRotationQuaternion;
  18752. /**
  18753. * Store current camera state of the camera (fov, position, rotation, etc..)
  18754. * @returns the camera
  18755. */
  18756. storeState(): Camera;
  18757. /**
  18758. * Restored camera state. You must call storeState() first
  18759. * @returns whether it was successful or not
  18760. * @hidden
  18761. */
  18762. _restoreStateValues(): boolean;
  18763. /** @hidden */
  18764. _initCache(): void;
  18765. /** @hidden */
  18766. _updateCache(ignoreParentClass?: boolean): void;
  18767. /** @hidden */
  18768. _isSynchronizedViewMatrix(): boolean;
  18769. /** @hidden */
  18770. _computeLocalCameraSpeed(): number;
  18771. /**
  18772. * Defines the target the camera should look at.
  18773. * @param target Defines the new target as a Vector or a mesh
  18774. */
  18775. setTarget(target: Vector3): void;
  18776. /**
  18777. * Return the current target position of the camera. This value is expressed in local space.
  18778. * @returns the target position
  18779. */
  18780. getTarget(): Vector3;
  18781. /** @hidden */
  18782. _decideIfNeedsToMove(): boolean;
  18783. /** @hidden */
  18784. _updatePosition(): void;
  18785. /** @hidden */
  18786. _checkInputs(): void;
  18787. protected _updateCameraRotationMatrix(): void;
  18788. /**
  18789. * 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)
  18790. * @returns the current camera
  18791. */
  18792. private _rotateUpVectorWithCameraRotationMatrix;
  18793. private _cachedRotationZ;
  18794. private _cachedQuaternionRotationZ;
  18795. /** @hidden */
  18796. _getViewMatrix(): Matrix;
  18797. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  18798. /**
  18799. * @hidden
  18800. */
  18801. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  18802. /**
  18803. * @hidden
  18804. */
  18805. _updateRigCameras(): void;
  18806. private _getRigCamPositionAndTarget;
  18807. /**
  18808. * Gets the current object class name.
  18809. * @return the class name
  18810. */
  18811. getClassName(): string;
  18812. }
  18813. }
  18814. declare module "babylonjs/Events/keyboardEvents" {
  18815. /**
  18816. * Gather the list of keyboard event types as constants.
  18817. */
  18818. export class KeyboardEventTypes {
  18819. /**
  18820. * The keydown event is fired when a key becomes active (pressed).
  18821. */
  18822. static readonly KEYDOWN: number;
  18823. /**
  18824. * The keyup event is fired when a key has been released.
  18825. */
  18826. static readonly KEYUP: number;
  18827. }
  18828. /**
  18829. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18830. */
  18831. export class KeyboardInfo {
  18832. /**
  18833. * Defines the type of event (KeyboardEventTypes)
  18834. */
  18835. type: number;
  18836. /**
  18837. * Defines the related dom event
  18838. */
  18839. event: KeyboardEvent;
  18840. /**
  18841. * Instantiates a new keyboard info.
  18842. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18843. * @param type Defines the type of event (KeyboardEventTypes)
  18844. * @param event Defines the related dom event
  18845. */
  18846. constructor(
  18847. /**
  18848. * Defines the type of event (KeyboardEventTypes)
  18849. */
  18850. type: number,
  18851. /**
  18852. * Defines the related dom event
  18853. */
  18854. event: KeyboardEvent);
  18855. }
  18856. /**
  18857. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18858. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  18859. */
  18860. export class KeyboardInfoPre extends KeyboardInfo {
  18861. /**
  18862. * Defines the type of event (KeyboardEventTypes)
  18863. */
  18864. type: number;
  18865. /**
  18866. * Defines the related dom event
  18867. */
  18868. event: KeyboardEvent;
  18869. /**
  18870. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  18871. */
  18872. skipOnPointerObservable: boolean;
  18873. /**
  18874. * Instantiates a new keyboard pre info.
  18875. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18876. * @param type Defines the type of event (KeyboardEventTypes)
  18877. * @param event Defines the related dom event
  18878. */
  18879. constructor(
  18880. /**
  18881. * Defines the type of event (KeyboardEventTypes)
  18882. */
  18883. type: number,
  18884. /**
  18885. * Defines the related dom event
  18886. */
  18887. event: KeyboardEvent);
  18888. }
  18889. }
  18890. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  18891. import { Nullable } from "babylonjs/types";
  18892. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  18893. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18894. /**
  18895. * Manage the keyboard inputs to control the movement of a free camera.
  18896. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18897. */
  18898. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  18899. /**
  18900. * Defines the camera the input is attached to.
  18901. */
  18902. camera: FreeCamera;
  18903. /**
  18904. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18905. */
  18906. keysUp: number[];
  18907. /**
  18908. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18909. */
  18910. keysUpward: number[];
  18911. /**
  18912. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18913. */
  18914. keysDown: number[];
  18915. /**
  18916. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18917. */
  18918. keysDownward: number[];
  18919. /**
  18920. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18921. */
  18922. keysLeft: number[];
  18923. /**
  18924. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18925. */
  18926. keysRight: number[];
  18927. private _keys;
  18928. private _onCanvasBlurObserver;
  18929. private _onKeyboardObserver;
  18930. private _engine;
  18931. private _scene;
  18932. /**
  18933. * Attach the input controls to a specific dom element to get the input from.
  18934. * @param element Defines the element the controls should be listened from
  18935. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18936. */
  18937. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18938. /**
  18939. * Detach the current controls from the specified dom element.
  18940. * @param element Defines the element to stop listening the inputs from
  18941. */
  18942. detachControl(element: Nullable<HTMLElement>): void;
  18943. /**
  18944. * Update the current camera state depending on the inputs that have been used this frame.
  18945. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18946. */
  18947. checkInputs(): void;
  18948. /**
  18949. * Gets the class name of the current intput.
  18950. * @returns the class name
  18951. */
  18952. getClassName(): string;
  18953. /** @hidden */
  18954. _onLostFocus(): void;
  18955. /**
  18956. * Get the friendly name associated with the input class.
  18957. * @returns the input friendly name
  18958. */
  18959. getSimpleName(): string;
  18960. }
  18961. }
  18962. declare module "babylonjs/Events/pointerEvents" {
  18963. import { Nullable } from "babylonjs/types";
  18964. import { Vector2 } from "babylonjs/Maths/math.vector";
  18965. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  18966. import { Ray } from "babylonjs/Culling/ray";
  18967. /**
  18968. * Gather the list of pointer event types as constants.
  18969. */
  18970. export class PointerEventTypes {
  18971. /**
  18972. * 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.
  18973. */
  18974. static readonly POINTERDOWN: number;
  18975. /**
  18976. * The pointerup event is fired when a pointer is no longer active.
  18977. */
  18978. static readonly POINTERUP: number;
  18979. /**
  18980. * The pointermove event is fired when a pointer changes coordinates.
  18981. */
  18982. static readonly POINTERMOVE: number;
  18983. /**
  18984. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18985. */
  18986. static readonly POINTERWHEEL: number;
  18987. /**
  18988. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18989. */
  18990. static readonly POINTERPICK: number;
  18991. /**
  18992. * The pointertap event is fired when a the object has been touched and released without drag.
  18993. */
  18994. static readonly POINTERTAP: number;
  18995. /**
  18996. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18997. */
  18998. static readonly POINTERDOUBLETAP: number;
  18999. }
  19000. /**
  19001. * Base class of pointer info types.
  19002. */
  19003. export class PointerInfoBase {
  19004. /**
  19005. * Defines the type of event (PointerEventTypes)
  19006. */
  19007. type: number;
  19008. /**
  19009. * Defines the related dom event
  19010. */
  19011. event: PointerEvent | MouseWheelEvent;
  19012. /**
  19013. * Instantiates the base class of pointers info.
  19014. * @param type Defines the type of event (PointerEventTypes)
  19015. * @param event Defines the related dom event
  19016. */
  19017. constructor(
  19018. /**
  19019. * Defines the type of event (PointerEventTypes)
  19020. */
  19021. type: number,
  19022. /**
  19023. * Defines the related dom event
  19024. */
  19025. event: PointerEvent | MouseWheelEvent);
  19026. }
  19027. /**
  19028. * This class is used to store pointer related info for the onPrePointerObservable event.
  19029. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  19030. */
  19031. export class PointerInfoPre extends PointerInfoBase {
  19032. /**
  19033. * Ray from a pointer if availible (eg. 6dof controller)
  19034. */
  19035. ray: Nullable<Ray>;
  19036. /**
  19037. * Defines the local position of the pointer on the canvas.
  19038. */
  19039. localPosition: Vector2;
  19040. /**
  19041. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  19042. */
  19043. skipOnPointerObservable: boolean;
  19044. /**
  19045. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  19046. * @param type Defines the type of event (PointerEventTypes)
  19047. * @param event Defines the related dom event
  19048. * @param localX Defines the local x coordinates of the pointer when the event occured
  19049. * @param localY Defines the local y coordinates of the pointer when the event occured
  19050. */
  19051. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  19052. }
  19053. /**
  19054. * This type contains all the data related to a pointer event in Babylon.js.
  19055. * 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.
  19056. */
  19057. export class PointerInfo extends PointerInfoBase {
  19058. /**
  19059. * Defines the picking info associated to the info (if any)\
  19060. */
  19061. pickInfo: Nullable<PickingInfo>;
  19062. /**
  19063. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  19064. * @param type Defines the type of event (PointerEventTypes)
  19065. * @param event Defines the related dom event
  19066. * @param pickInfo Defines the picking info associated to the info (if any)\
  19067. */
  19068. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  19069. /**
  19070. * Defines the picking info associated to the info (if any)\
  19071. */
  19072. pickInfo: Nullable<PickingInfo>);
  19073. }
  19074. /**
  19075. * Data relating to a touch event on the screen.
  19076. */
  19077. export interface PointerTouch {
  19078. /**
  19079. * X coordinate of touch.
  19080. */
  19081. x: number;
  19082. /**
  19083. * Y coordinate of touch.
  19084. */
  19085. y: number;
  19086. /**
  19087. * Id of touch. Unique for each finger.
  19088. */
  19089. pointerId: number;
  19090. /**
  19091. * Event type passed from DOM.
  19092. */
  19093. type: any;
  19094. }
  19095. }
  19096. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  19097. import { Observable } from "babylonjs/Misc/observable";
  19098. import { Nullable } from "babylonjs/types";
  19099. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19100. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19101. /**
  19102. * Manage the mouse inputs to control the movement of a free camera.
  19103. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  19104. */
  19105. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  19106. /**
  19107. * Define if touch is enabled in the mouse input
  19108. */
  19109. touchEnabled: boolean;
  19110. /**
  19111. * Defines the camera the input is attached to.
  19112. */
  19113. camera: FreeCamera;
  19114. /**
  19115. * Defines the buttons associated with the input to handle camera move.
  19116. */
  19117. buttons: number[];
  19118. /**
  19119. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  19120. */
  19121. angularSensibility: number;
  19122. private _pointerInput;
  19123. private _onMouseMove;
  19124. private _observer;
  19125. private previousPosition;
  19126. /**
  19127. * Observable for when a pointer move event occurs containing the move offset
  19128. */
  19129. onPointerMovedObservable: Observable<{
  19130. offsetX: number;
  19131. offsetY: number;
  19132. }>;
  19133. /**
  19134. * @hidden
  19135. * If the camera should be rotated automatically based on pointer movement
  19136. */
  19137. _allowCameraRotation: boolean;
  19138. /**
  19139. * Manage the mouse inputs to control the movement of a free camera.
  19140. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  19141. * @param touchEnabled Defines if touch is enabled or not
  19142. */
  19143. constructor(
  19144. /**
  19145. * Define if touch is enabled in the mouse input
  19146. */
  19147. touchEnabled?: boolean);
  19148. /**
  19149. * Attach the input controls to a specific dom element to get the input from.
  19150. * @param element Defines the element the controls should be listened from
  19151. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19152. */
  19153. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19154. /**
  19155. * Called on JS contextmenu event.
  19156. * Override this method to provide functionality.
  19157. */
  19158. protected onContextMenu(evt: PointerEvent): void;
  19159. /**
  19160. * Detach the current controls from the specified dom element.
  19161. * @param element Defines the element to stop listening the inputs from
  19162. */
  19163. detachControl(element: Nullable<HTMLElement>): void;
  19164. /**
  19165. * Gets the class name of the current intput.
  19166. * @returns the class name
  19167. */
  19168. getClassName(): string;
  19169. /**
  19170. * Get the friendly name associated with the input class.
  19171. * @returns the input friendly name
  19172. */
  19173. getSimpleName(): string;
  19174. }
  19175. }
  19176. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  19177. import { Nullable } from "babylonjs/types";
  19178. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19179. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19180. /**
  19181. * Manage the touch inputs to control the movement of a free camera.
  19182. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  19183. */
  19184. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  19185. /**
  19186. * Defines the camera the input is attached to.
  19187. */
  19188. camera: FreeCamera;
  19189. /**
  19190. * Defines the touch sensibility for rotation.
  19191. * The higher the faster.
  19192. */
  19193. touchAngularSensibility: number;
  19194. /**
  19195. * Defines the touch sensibility for move.
  19196. * The higher the faster.
  19197. */
  19198. touchMoveSensibility: number;
  19199. private _offsetX;
  19200. private _offsetY;
  19201. private _pointerPressed;
  19202. private _pointerInput;
  19203. private _observer;
  19204. private _onLostFocus;
  19205. /**
  19206. * Attach the input controls to a specific dom element to get the input from.
  19207. * @param element Defines the element the controls should be listened from
  19208. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19209. */
  19210. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19211. /**
  19212. * Detach the current controls from the specified dom element.
  19213. * @param element Defines the element to stop listening the inputs from
  19214. */
  19215. detachControl(element: Nullable<HTMLElement>): void;
  19216. /**
  19217. * Update the current camera state depending on the inputs that have been used this frame.
  19218. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19219. */
  19220. checkInputs(): void;
  19221. /**
  19222. * Gets the class name of the current intput.
  19223. * @returns the class name
  19224. */
  19225. getClassName(): string;
  19226. /**
  19227. * Get the friendly name associated with the input class.
  19228. * @returns the input friendly name
  19229. */
  19230. getSimpleName(): string;
  19231. }
  19232. }
  19233. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  19234. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19235. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  19236. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  19237. import { Nullable } from "babylonjs/types";
  19238. /**
  19239. * Default Inputs manager for the FreeCamera.
  19240. * It groups all the default supported inputs for ease of use.
  19241. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  19242. */
  19243. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  19244. /**
  19245. * @hidden
  19246. */
  19247. _mouseInput: Nullable<FreeCameraMouseInput>;
  19248. /**
  19249. * Instantiates a new FreeCameraInputsManager.
  19250. * @param camera Defines the camera the inputs belong to
  19251. */
  19252. constructor(camera: FreeCamera);
  19253. /**
  19254. * Add keyboard input support to the input manager.
  19255. * @returns the current input manager
  19256. */
  19257. addKeyboard(): FreeCameraInputsManager;
  19258. /**
  19259. * Add mouse input support to the input manager.
  19260. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  19261. * @returns the current input manager
  19262. */
  19263. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  19264. /**
  19265. * Removes the mouse input support from the manager
  19266. * @returns the current input manager
  19267. */
  19268. removeMouse(): FreeCameraInputsManager;
  19269. /**
  19270. * Add touch input support to the input manager.
  19271. * @returns the current input manager
  19272. */
  19273. addTouch(): FreeCameraInputsManager;
  19274. /**
  19275. * Remove all attached input methods from a camera
  19276. */
  19277. clear(): void;
  19278. }
  19279. }
  19280. declare module "babylonjs/Cameras/freeCamera" {
  19281. import { Vector3 } from "babylonjs/Maths/math.vector";
  19282. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19283. import { Scene } from "babylonjs/scene";
  19284. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19285. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  19286. /**
  19287. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19288. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  19289. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  19290. */
  19291. export class FreeCamera extends TargetCamera {
  19292. /**
  19293. * Define the collision ellipsoid of the camera.
  19294. * This is helpful to simulate a camera body like the player body around the camera
  19295. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19296. */
  19297. ellipsoid: Vector3;
  19298. /**
  19299. * Define an offset for the position of the ellipsoid around the camera.
  19300. * This can be helpful to determine the center of the body near the gravity center of the body
  19301. * instead of its head.
  19302. */
  19303. ellipsoidOffset: Vector3;
  19304. /**
  19305. * Enable or disable collisions of the camera with the rest of the scene objects.
  19306. */
  19307. checkCollisions: boolean;
  19308. /**
  19309. * Enable or disable gravity on the camera.
  19310. */
  19311. applyGravity: boolean;
  19312. /**
  19313. * Define the input manager associated to the camera.
  19314. */
  19315. inputs: FreeCameraInputsManager;
  19316. /**
  19317. * Gets the input sensibility for a mouse input. (default is 2000.0)
  19318. * Higher values reduce sensitivity.
  19319. */
  19320. get angularSensibility(): number;
  19321. /**
  19322. * Sets the input sensibility for a mouse input. (default is 2000.0)
  19323. * Higher values reduce sensitivity.
  19324. */
  19325. set angularSensibility(value: number);
  19326. /**
  19327. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19328. */
  19329. get keysUp(): number[];
  19330. set keysUp(value: number[]);
  19331. /**
  19332. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19333. */
  19334. get keysUpward(): number[];
  19335. set keysUpward(value: number[]);
  19336. /**
  19337. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19338. */
  19339. get keysDown(): number[];
  19340. set keysDown(value: number[]);
  19341. /**
  19342. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19343. */
  19344. get keysDownward(): number[];
  19345. set keysDownward(value: number[]);
  19346. /**
  19347. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19348. */
  19349. get keysLeft(): number[];
  19350. set keysLeft(value: number[]);
  19351. /**
  19352. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19353. */
  19354. get keysRight(): number[];
  19355. set keysRight(value: number[]);
  19356. /**
  19357. * Event raised when the camera collide with a mesh in the scene.
  19358. */
  19359. onCollide: (collidedMesh: AbstractMesh) => void;
  19360. private _collider;
  19361. private _needMoveForGravity;
  19362. private _oldPosition;
  19363. private _diffPosition;
  19364. private _newPosition;
  19365. /** @hidden */
  19366. _localDirection: Vector3;
  19367. /** @hidden */
  19368. _transformedDirection: Vector3;
  19369. /**
  19370. * Instantiates a Free Camera.
  19371. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19372. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  19373. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  19374. * @param name Define the name of the camera in the scene
  19375. * @param position Define the start position of the camera in the scene
  19376. * @param scene Define the scene the camera belongs to
  19377. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19378. */
  19379. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19380. /**
  19381. * Attached controls to the current camera.
  19382. * @param element Defines the element the controls should be listened from
  19383. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19384. */
  19385. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19386. /**
  19387. * Detach the current controls from the camera.
  19388. * The camera will stop reacting to inputs.
  19389. * @param element Defines the element to stop listening the inputs from
  19390. */
  19391. detachControl(element: HTMLElement): void;
  19392. private _collisionMask;
  19393. /**
  19394. * Define a collision mask to limit the list of object the camera can collide with
  19395. */
  19396. get collisionMask(): number;
  19397. set collisionMask(mask: number);
  19398. /** @hidden */
  19399. _collideWithWorld(displacement: Vector3): void;
  19400. private _onCollisionPositionChange;
  19401. /** @hidden */
  19402. _checkInputs(): void;
  19403. /** @hidden */
  19404. _decideIfNeedsToMove(): boolean;
  19405. /** @hidden */
  19406. _updatePosition(): void;
  19407. /**
  19408. * Destroy the camera and release the current resources hold by it.
  19409. */
  19410. dispose(): void;
  19411. /**
  19412. * Gets the current object class name.
  19413. * @return the class name
  19414. */
  19415. getClassName(): string;
  19416. }
  19417. }
  19418. declare module "babylonjs/Gamepads/gamepad" {
  19419. import { Observable } from "babylonjs/Misc/observable";
  19420. /**
  19421. * Represents a gamepad control stick position
  19422. */
  19423. export class StickValues {
  19424. /**
  19425. * The x component of the control stick
  19426. */
  19427. x: number;
  19428. /**
  19429. * The y component of the control stick
  19430. */
  19431. y: number;
  19432. /**
  19433. * Initializes the gamepad x and y control stick values
  19434. * @param x The x component of the gamepad control stick value
  19435. * @param y The y component of the gamepad control stick value
  19436. */
  19437. constructor(
  19438. /**
  19439. * The x component of the control stick
  19440. */
  19441. x: number,
  19442. /**
  19443. * The y component of the control stick
  19444. */
  19445. y: number);
  19446. }
  19447. /**
  19448. * An interface which manages callbacks for gamepad button changes
  19449. */
  19450. export interface GamepadButtonChanges {
  19451. /**
  19452. * Called when a gamepad has been changed
  19453. */
  19454. changed: boolean;
  19455. /**
  19456. * Called when a gamepad press event has been triggered
  19457. */
  19458. pressChanged: boolean;
  19459. /**
  19460. * Called when a touch event has been triggered
  19461. */
  19462. touchChanged: boolean;
  19463. /**
  19464. * Called when a value has changed
  19465. */
  19466. valueChanged: boolean;
  19467. }
  19468. /**
  19469. * Represents a gamepad
  19470. */
  19471. export class Gamepad {
  19472. /**
  19473. * The id of the gamepad
  19474. */
  19475. id: string;
  19476. /**
  19477. * The index of the gamepad
  19478. */
  19479. index: number;
  19480. /**
  19481. * The browser gamepad
  19482. */
  19483. browserGamepad: any;
  19484. /**
  19485. * Specifies what type of gamepad this represents
  19486. */
  19487. type: number;
  19488. private _leftStick;
  19489. private _rightStick;
  19490. /** @hidden */
  19491. _isConnected: boolean;
  19492. private _leftStickAxisX;
  19493. private _leftStickAxisY;
  19494. private _rightStickAxisX;
  19495. private _rightStickAxisY;
  19496. /**
  19497. * Triggered when the left control stick has been changed
  19498. */
  19499. private _onleftstickchanged;
  19500. /**
  19501. * Triggered when the right control stick has been changed
  19502. */
  19503. private _onrightstickchanged;
  19504. /**
  19505. * Represents a gamepad controller
  19506. */
  19507. static GAMEPAD: number;
  19508. /**
  19509. * Represents a generic controller
  19510. */
  19511. static GENERIC: number;
  19512. /**
  19513. * Represents an XBox controller
  19514. */
  19515. static XBOX: number;
  19516. /**
  19517. * Represents a pose-enabled controller
  19518. */
  19519. static POSE_ENABLED: number;
  19520. /**
  19521. * Represents an Dual Shock controller
  19522. */
  19523. static DUALSHOCK: number;
  19524. /**
  19525. * Specifies whether the left control stick should be Y-inverted
  19526. */
  19527. protected _invertLeftStickY: boolean;
  19528. /**
  19529. * Specifies if the gamepad has been connected
  19530. */
  19531. get isConnected(): boolean;
  19532. /**
  19533. * Initializes the gamepad
  19534. * @param id The id of the gamepad
  19535. * @param index The index of the gamepad
  19536. * @param browserGamepad The browser gamepad
  19537. * @param leftStickX The x component of the left joystick
  19538. * @param leftStickY The y component of the left joystick
  19539. * @param rightStickX The x component of the right joystick
  19540. * @param rightStickY The y component of the right joystick
  19541. */
  19542. constructor(
  19543. /**
  19544. * The id of the gamepad
  19545. */
  19546. id: string,
  19547. /**
  19548. * The index of the gamepad
  19549. */
  19550. index: number,
  19551. /**
  19552. * The browser gamepad
  19553. */
  19554. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19555. /**
  19556. * Callback triggered when the left joystick has changed
  19557. * @param callback
  19558. */
  19559. onleftstickchanged(callback: (values: StickValues) => void): void;
  19560. /**
  19561. * Callback triggered when the right joystick has changed
  19562. * @param callback
  19563. */
  19564. onrightstickchanged(callback: (values: StickValues) => void): void;
  19565. /**
  19566. * Gets the left joystick
  19567. */
  19568. get leftStick(): StickValues;
  19569. /**
  19570. * Sets the left joystick values
  19571. */
  19572. set leftStick(newValues: StickValues);
  19573. /**
  19574. * Gets the right joystick
  19575. */
  19576. get rightStick(): StickValues;
  19577. /**
  19578. * Sets the right joystick value
  19579. */
  19580. set rightStick(newValues: StickValues);
  19581. /**
  19582. * Updates the gamepad joystick positions
  19583. */
  19584. update(): void;
  19585. /**
  19586. * Disposes the gamepad
  19587. */
  19588. dispose(): void;
  19589. }
  19590. /**
  19591. * Represents a generic gamepad
  19592. */
  19593. export class GenericPad extends Gamepad {
  19594. private _buttons;
  19595. private _onbuttondown;
  19596. private _onbuttonup;
  19597. /**
  19598. * Observable triggered when a button has been pressed
  19599. */
  19600. onButtonDownObservable: Observable<number>;
  19601. /**
  19602. * Observable triggered when a button has been released
  19603. */
  19604. onButtonUpObservable: Observable<number>;
  19605. /**
  19606. * Callback triggered when a button has been pressed
  19607. * @param callback Called when a button has been pressed
  19608. */
  19609. onbuttondown(callback: (buttonPressed: number) => void): void;
  19610. /**
  19611. * Callback triggered when a button has been released
  19612. * @param callback Called when a button has been released
  19613. */
  19614. onbuttonup(callback: (buttonReleased: number) => void): void;
  19615. /**
  19616. * Initializes the generic gamepad
  19617. * @param id The id of the generic gamepad
  19618. * @param index The index of the generic gamepad
  19619. * @param browserGamepad The browser gamepad
  19620. */
  19621. constructor(id: string, index: number, browserGamepad: any);
  19622. private _setButtonValue;
  19623. /**
  19624. * Updates the generic gamepad
  19625. */
  19626. update(): void;
  19627. /**
  19628. * Disposes the generic gamepad
  19629. */
  19630. dispose(): void;
  19631. }
  19632. }
  19633. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  19634. import { Observable } from "babylonjs/Misc/observable";
  19635. import { Nullable } from "babylonjs/types";
  19636. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19637. import { TransformNode } from "babylonjs/Meshes/transformNode";
  19638. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19639. import { Ray } from "babylonjs/Culling/ray";
  19640. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  19641. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  19642. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19643. /**
  19644. * Defines the types of pose enabled controllers that are supported
  19645. */
  19646. export enum PoseEnabledControllerType {
  19647. /**
  19648. * HTC Vive
  19649. */
  19650. VIVE = 0,
  19651. /**
  19652. * Oculus Rift
  19653. */
  19654. OCULUS = 1,
  19655. /**
  19656. * Windows mixed reality
  19657. */
  19658. WINDOWS = 2,
  19659. /**
  19660. * Samsung gear VR
  19661. */
  19662. GEAR_VR = 3,
  19663. /**
  19664. * Google Daydream
  19665. */
  19666. DAYDREAM = 4,
  19667. /**
  19668. * Generic
  19669. */
  19670. GENERIC = 5
  19671. }
  19672. /**
  19673. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19674. */
  19675. export interface MutableGamepadButton {
  19676. /**
  19677. * Value of the button/trigger
  19678. */
  19679. value: number;
  19680. /**
  19681. * If the button/trigger is currently touched
  19682. */
  19683. touched: boolean;
  19684. /**
  19685. * If the button/trigger is currently pressed
  19686. */
  19687. pressed: boolean;
  19688. }
  19689. /**
  19690. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19691. * @hidden
  19692. */
  19693. export interface ExtendedGamepadButton extends GamepadButton {
  19694. /**
  19695. * If the button/trigger is currently pressed
  19696. */
  19697. readonly pressed: boolean;
  19698. /**
  19699. * If the button/trigger is currently touched
  19700. */
  19701. readonly touched: boolean;
  19702. /**
  19703. * Value of the button/trigger
  19704. */
  19705. readonly value: number;
  19706. }
  19707. /** @hidden */
  19708. export interface _GamePadFactory {
  19709. /**
  19710. * Returns whether or not the current gamepad can be created for this type of controller.
  19711. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19712. * @returns true if it can be created, otherwise false
  19713. */
  19714. canCreate(gamepadInfo: any): boolean;
  19715. /**
  19716. * Creates a new instance of the Gamepad.
  19717. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19718. * @returns the new gamepad instance
  19719. */
  19720. create(gamepadInfo: any): Gamepad;
  19721. }
  19722. /**
  19723. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19724. */
  19725. export class PoseEnabledControllerHelper {
  19726. /** @hidden */
  19727. static _ControllerFactories: _GamePadFactory[];
  19728. /** @hidden */
  19729. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19730. /**
  19731. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19732. * @param vrGamepad the gamepad to initialized
  19733. * @returns a vr controller of the type the gamepad identified as
  19734. */
  19735. static InitiateController(vrGamepad: any): Gamepad;
  19736. }
  19737. /**
  19738. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19739. */
  19740. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19741. /**
  19742. * If the controller is used in a webXR session
  19743. */
  19744. isXR: boolean;
  19745. private _deviceRoomPosition;
  19746. private _deviceRoomRotationQuaternion;
  19747. /**
  19748. * The device position in babylon space
  19749. */
  19750. devicePosition: Vector3;
  19751. /**
  19752. * The device rotation in babylon space
  19753. */
  19754. deviceRotationQuaternion: Quaternion;
  19755. /**
  19756. * The scale factor of the device in babylon space
  19757. */
  19758. deviceScaleFactor: number;
  19759. /**
  19760. * (Likely devicePosition should be used instead) The device position in its room space
  19761. */
  19762. position: Vector3;
  19763. /**
  19764. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19765. */
  19766. rotationQuaternion: Quaternion;
  19767. /**
  19768. * The type of controller (Eg. Windows mixed reality)
  19769. */
  19770. controllerType: PoseEnabledControllerType;
  19771. protected _calculatedPosition: Vector3;
  19772. private _calculatedRotation;
  19773. /**
  19774. * The raw pose from the device
  19775. */
  19776. rawPose: DevicePose;
  19777. private _trackPosition;
  19778. private _maxRotationDistFromHeadset;
  19779. private _draggedRoomRotation;
  19780. /**
  19781. * @hidden
  19782. */
  19783. _disableTrackPosition(fixedPosition: Vector3): void;
  19784. /**
  19785. * Internal, the mesh attached to the controller
  19786. * @hidden
  19787. */
  19788. _mesh: Nullable<AbstractMesh>;
  19789. private _poseControlledCamera;
  19790. private _leftHandSystemQuaternion;
  19791. /**
  19792. * Internal, matrix used to convert room space to babylon space
  19793. * @hidden
  19794. */
  19795. _deviceToWorld: Matrix;
  19796. /**
  19797. * Node to be used when casting a ray from the controller
  19798. * @hidden
  19799. */
  19800. _pointingPoseNode: Nullable<TransformNode>;
  19801. /**
  19802. * Name of the child mesh that can be used to cast a ray from the controller
  19803. */
  19804. static readonly POINTING_POSE: string;
  19805. /**
  19806. * Creates a new PoseEnabledController from a gamepad
  19807. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19808. */
  19809. constructor(browserGamepad: any);
  19810. private _workingMatrix;
  19811. /**
  19812. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19813. */
  19814. update(): void;
  19815. /**
  19816. * Updates only the pose device and mesh without doing any button event checking
  19817. */
  19818. protected _updatePoseAndMesh(): void;
  19819. /**
  19820. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19821. * @param poseData raw pose fromthe device
  19822. */
  19823. updateFromDevice(poseData: DevicePose): void;
  19824. /**
  19825. * @hidden
  19826. */
  19827. _meshAttachedObservable: Observable<AbstractMesh>;
  19828. /**
  19829. * Attaches a mesh to the controller
  19830. * @param mesh the mesh to be attached
  19831. */
  19832. attachToMesh(mesh: AbstractMesh): void;
  19833. /**
  19834. * Attaches the controllers mesh to a camera
  19835. * @param camera the camera the mesh should be attached to
  19836. */
  19837. attachToPoseControlledCamera(camera: TargetCamera): void;
  19838. /**
  19839. * Disposes of the controller
  19840. */
  19841. dispose(): void;
  19842. /**
  19843. * The mesh that is attached to the controller
  19844. */
  19845. get mesh(): Nullable<AbstractMesh>;
  19846. /**
  19847. * Gets the ray of the controller in the direction the controller is pointing
  19848. * @param length the length the resulting ray should be
  19849. * @returns a ray in the direction the controller is pointing
  19850. */
  19851. getForwardRay(length?: number): Ray;
  19852. }
  19853. }
  19854. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  19855. import { Observable } from "babylonjs/Misc/observable";
  19856. import { Scene } from "babylonjs/scene";
  19857. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19858. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  19859. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  19860. import { Nullable } from "babylonjs/types";
  19861. /**
  19862. * Defines the WebVRController object that represents controllers tracked in 3D space
  19863. */
  19864. export abstract class WebVRController extends PoseEnabledController {
  19865. /**
  19866. * Internal, the default controller model for the controller
  19867. */
  19868. protected _defaultModel: Nullable<AbstractMesh>;
  19869. /**
  19870. * Fired when the trigger state has changed
  19871. */
  19872. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19873. /**
  19874. * Fired when the main button state has changed
  19875. */
  19876. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19877. /**
  19878. * Fired when the secondary button state has changed
  19879. */
  19880. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19881. /**
  19882. * Fired when the pad state has changed
  19883. */
  19884. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19885. /**
  19886. * Fired when controllers stick values have changed
  19887. */
  19888. onPadValuesChangedObservable: Observable<StickValues>;
  19889. /**
  19890. * Array of button availible on the controller
  19891. */
  19892. protected _buttons: Array<MutableGamepadButton>;
  19893. private _onButtonStateChange;
  19894. /**
  19895. * Fired when a controller button's state has changed
  19896. * @param callback the callback containing the button that was modified
  19897. */
  19898. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19899. /**
  19900. * X and Y axis corresponding to the controllers joystick
  19901. */
  19902. pad: StickValues;
  19903. /**
  19904. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19905. */
  19906. hand: string;
  19907. /**
  19908. * The default controller model for the controller
  19909. */
  19910. get defaultModel(): Nullable<AbstractMesh>;
  19911. /**
  19912. * Creates a new WebVRController from a gamepad
  19913. * @param vrGamepad the gamepad that the WebVRController should be created from
  19914. */
  19915. constructor(vrGamepad: any);
  19916. /**
  19917. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19918. */
  19919. update(): void;
  19920. /**
  19921. * Function to be called when a button is modified
  19922. */
  19923. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19924. /**
  19925. * Loads a mesh and attaches it to the controller
  19926. * @param scene the scene the mesh should be added to
  19927. * @param meshLoaded callback for when the mesh has been loaded
  19928. */
  19929. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19930. private _setButtonValue;
  19931. private _changes;
  19932. private _checkChanges;
  19933. /**
  19934. * Disposes of th webVRCOntroller
  19935. */
  19936. dispose(): void;
  19937. }
  19938. }
  19939. declare module "babylonjs/Lights/hemisphericLight" {
  19940. import { Nullable } from "babylonjs/types";
  19941. import { Scene } from "babylonjs/scene";
  19942. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19943. import { Color3 } from "babylonjs/Maths/math.color";
  19944. import { Effect } from "babylonjs/Materials/effect";
  19945. import { Light } from "babylonjs/Lights/light";
  19946. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  19947. /**
  19948. * The HemisphericLight simulates the ambient environment light,
  19949. * so the passed direction is the light reflection direction, not the incoming direction.
  19950. */
  19951. export class HemisphericLight extends Light {
  19952. /**
  19953. * The groundColor is the light in the opposite direction to the one specified during creation.
  19954. * 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.
  19955. */
  19956. groundColor: Color3;
  19957. /**
  19958. * The light reflection direction, not the incoming direction.
  19959. */
  19960. direction: Vector3;
  19961. /**
  19962. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19963. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19964. * The HemisphericLight can't cast shadows.
  19965. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19966. * @param name The friendly name of the light
  19967. * @param direction The direction of the light reflection
  19968. * @param scene The scene the light belongs to
  19969. */
  19970. constructor(name: string, direction: Vector3, scene: Scene);
  19971. protected _buildUniformLayout(): void;
  19972. /**
  19973. * Returns the string "HemisphericLight".
  19974. * @return The class name
  19975. */
  19976. getClassName(): string;
  19977. /**
  19978. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19979. * Returns the updated direction.
  19980. * @param target The target the direction should point to
  19981. * @return The computed direction
  19982. */
  19983. setDirectionToTarget(target: Vector3): Vector3;
  19984. /**
  19985. * Returns the shadow generator associated to the light.
  19986. * @returns Always null for hemispheric lights because it does not support shadows.
  19987. */
  19988. getShadowGenerator(): Nullable<IShadowGenerator>;
  19989. /**
  19990. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19991. * @param effect The effect to update
  19992. * @param lightIndex The index of the light in the effect to update
  19993. * @returns The hemispheric light
  19994. */
  19995. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19996. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19997. /**
  19998. * Computes the world matrix of the node
  19999. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  20000. * @param useWasUpdatedFlag defines a reserved property
  20001. * @returns the world matrix
  20002. */
  20003. computeWorldMatrix(): Matrix;
  20004. /**
  20005. * Returns the integer 3.
  20006. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  20007. */
  20008. getTypeID(): number;
  20009. /**
  20010. * Prepares the list of defines specific to the light type.
  20011. * @param defines the list of defines
  20012. * @param lightIndex defines the index of the light for the effect
  20013. */
  20014. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  20015. }
  20016. }
  20017. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  20018. /** @hidden */
  20019. export var vrMultiviewToSingleviewPixelShader: {
  20020. name: string;
  20021. shader: string;
  20022. };
  20023. }
  20024. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  20025. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20026. import { Scene } from "babylonjs/scene";
  20027. /**
  20028. * Renders to multiple views with a single draw call
  20029. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  20030. */
  20031. export class MultiviewRenderTarget extends RenderTargetTexture {
  20032. /**
  20033. * Creates a multiview render target
  20034. * @param scene scene used with the render target
  20035. * @param size the size of the render target (used for each view)
  20036. */
  20037. constructor(scene: Scene, size?: number | {
  20038. width: number;
  20039. height: number;
  20040. } | {
  20041. ratio: number;
  20042. });
  20043. /**
  20044. * @hidden
  20045. * @param faceIndex the face index, if its a cube texture
  20046. */
  20047. _bindFrameBuffer(faceIndex?: number): void;
  20048. /**
  20049. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20050. * @returns the view count
  20051. */
  20052. getViewCount(): number;
  20053. }
  20054. }
  20055. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  20056. import { Camera } from "babylonjs/Cameras/camera";
  20057. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20058. import { Nullable } from "babylonjs/types";
  20059. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20060. import { Matrix } from "babylonjs/Maths/math.vector";
  20061. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20062. module "babylonjs/Engines/engine" {
  20063. interface Engine {
  20064. /**
  20065. * Creates a new multiview render target
  20066. * @param width defines the width of the texture
  20067. * @param height defines the height of the texture
  20068. * @returns the created multiview texture
  20069. */
  20070. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  20071. /**
  20072. * Binds a multiview framebuffer to be drawn to
  20073. * @param multiviewTexture texture to bind
  20074. */
  20075. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  20076. }
  20077. }
  20078. module "babylonjs/Cameras/camera" {
  20079. interface Camera {
  20080. /**
  20081. * @hidden
  20082. * 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)
  20083. */
  20084. _useMultiviewToSingleView: boolean;
  20085. /**
  20086. * @hidden
  20087. * 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)
  20088. */
  20089. _multiviewTexture: Nullable<RenderTargetTexture>;
  20090. /**
  20091. * @hidden
  20092. * ensures the multiview texture of the camera exists and has the specified width/height
  20093. * @param width height to set on the multiview texture
  20094. * @param height width to set on the multiview texture
  20095. */
  20096. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  20097. }
  20098. }
  20099. module "babylonjs/scene" {
  20100. interface Scene {
  20101. /** @hidden */
  20102. _transformMatrixR: Matrix;
  20103. /** @hidden */
  20104. _multiviewSceneUbo: Nullable<UniformBuffer>;
  20105. /** @hidden */
  20106. _createMultiviewUbo(): void;
  20107. /** @hidden */
  20108. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  20109. /** @hidden */
  20110. _renderMultiviewToSingleView(camera: Camera): void;
  20111. }
  20112. }
  20113. }
  20114. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  20115. import { Camera } from "babylonjs/Cameras/camera";
  20116. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20117. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  20118. import "babylonjs/Engines/Extensions/engine.multiview";
  20119. /**
  20120. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  20121. * This will not be used for webXR as it supports displaying texture arrays directly
  20122. */
  20123. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  20124. /**
  20125. * Initializes a VRMultiviewToSingleview
  20126. * @param name name of the post process
  20127. * @param camera camera to be applied to
  20128. * @param scaleFactor scaling factor to the size of the output texture
  20129. */
  20130. constructor(name: string, camera: Camera, scaleFactor: number);
  20131. }
  20132. }
  20133. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  20134. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  20135. import { Nullable } from "babylonjs/types";
  20136. import { Size } from "babylonjs/Maths/math.size";
  20137. import { Observable } from "babylonjs/Misc/observable";
  20138. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  20139. /**
  20140. * Interface used to define additional presentation attributes
  20141. */
  20142. export interface IVRPresentationAttributes {
  20143. /**
  20144. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  20145. */
  20146. highRefreshRate: boolean;
  20147. /**
  20148. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  20149. */
  20150. foveationLevel: number;
  20151. }
  20152. module "babylonjs/Engines/engine" {
  20153. interface Engine {
  20154. /** @hidden */
  20155. _vrDisplay: any;
  20156. /** @hidden */
  20157. _vrSupported: boolean;
  20158. /** @hidden */
  20159. _oldSize: Size;
  20160. /** @hidden */
  20161. _oldHardwareScaleFactor: number;
  20162. /** @hidden */
  20163. _vrExclusivePointerMode: boolean;
  20164. /** @hidden */
  20165. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  20166. /** @hidden */
  20167. _onVRDisplayPointerRestricted: () => void;
  20168. /** @hidden */
  20169. _onVRDisplayPointerUnrestricted: () => void;
  20170. /** @hidden */
  20171. _onVrDisplayConnect: Nullable<(display: any) => void>;
  20172. /** @hidden */
  20173. _onVrDisplayDisconnect: Nullable<() => void>;
  20174. /** @hidden */
  20175. _onVrDisplayPresentChange: Nullable<() => void>;
  20176. /**
  20177. * Observable signaled when VR display mode changes
  20178. */
  20179. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  20180. /**
  20181. * Observable signaled when VR request present is complete
  20182. */
  20183. onVRRequestPresentComplete: Observable<boolean>;
  20184. /**
  20185. * Observable signaled when VR request present starts
  20186. */
  20187. onVRRequestPresentStart: Observable<Engine>;
  20188. /**
  20189. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  20190. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  20191. */
  20192. isInVRExclusivePointerMode: boolean;
  20193. /**
  20194. * Gets a boolean indicating if a webVR device was detected
  20195. * @returns true if a webVR device was detected
  20196. */
  20197. isVRDevicePresent(): boolean;
  20198. /**
  20199. * Gets the current webVR device
  20200. * @returns the current webVR device (or null)
  20201. */
  20202. getVRDevice(): any;
  20203. /**
  20204. * Initializes a webVR display and starts listening to display change events
  20205. * The onVRDisplayChangedObservable will be notified upon these changes
  20206. * @returns A promise containing a VRDisplay and if vr is supported
  20207. */
  20208. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  20209. /** @hidden */
  20210. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  20211. /**
  20212. * Gets or sets the presentation attributes used to configure VR rendering
  20213. */
  20214. vrPresentationAttributes?: IVRPresentationAttributes;
  20215. /**
  20216. * Call this function to switch to webVR mode
  20217. * Will do nothing if webVR is not supported or if there is no webVR device
  20218. * @param options the webvr options provided to the camera. mainly used for multiview
  20219. * @see http://doc.babylonjs.com/how_to/webvr_camera
  20220. */
  20221. enableVR(options: WebVROptions): void;
  20222. /** @hidden */
  20223. _onVRFullScreenTriggered(): void;
  20224. }
  20225. }
  20226. }
  20227. declare module "babylonjs/Cameras/VR/webVRCamera" {
  20228. import { Nullable } from "babylonjs/types";
  20229. import { Observable } from "babylonjs/Misc/observable";
  20230. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  20231. import { Scene } from "babylonjs/scene";
  20232. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20233. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  20234. import { Node } from "babylonjs/node";
  20235. import { Ray } from "babylonjs/Culling/ray";
  20236. import "babylonjs/Cameras/RigModes/webVRRigMode";
  20237. import "babylonjs/Engines/Extensions/engine.webVR";
  20238. /**
  20239. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  20240. * IMPORTANT!! The data is right-hand data.
  20241. * @export
  20242. * @interface DevicePose
  20243. */
  20244. export interface DevicePose {
  20245. /**
  20246. * The position of the device, values in array are [x,y,z].
  20247. */
  20248. readonly position: Nullable<Float32Array>;
  20249. /**
  20250. * The linearVelocity of the device, values in array are [x,y,z].
  20251. */
  20252. readonly linearVelocity: Nullable<Float32Array>;
  20253. /**
  20254. * The linearAcceleration of the device, values in array are [x,y,z].
  20255. */
  20256. readonly linearAcceleration: Nullable<Float32Array>;
  20257. /**
  20258. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  20259. */
  20260. readonly orientation: Nullable<Float32Array>;
  20261. /**
  20262. * The angularVelocity of the device, values in array are [x,y,z].
  20263. */
  20264. readonly angularVelocity: Nullable<Float32Array>;
  20265. /**
  20266. * The angularAcceleration of the device, values in array are [x,y,z].
  20267. */
  20268. readonly angularAcceleration: Nullable<Float32Array>;
  20269. }
  20270. /**
  20271. * Interface representing a pose controlled object in Babylon.
  20272. * A pose controlled object has both regular pose values as well as pose values
  20273. * from an external device such as a VR head mounted display
  20274. */
  20275. export interface PoseControlled {
  20276. /**
  20277. * The position of the object in babylon space.
  20278. */
  20279. position: Vector3;
  20280. /**
  20281. * The rotation quaternion of the object in babylon space.
  20282. */
  20283. rotationQuaternion: Quaternion;
  20284. /**
  20285. * The position of the device in babylon space.
  20286. */
  20287. devicePosition?: Vector3;
  20288. /**
  20289. * The rotation quaternion of the device in babylon space.
  20290. */
  20291. deviceRotationQuaternion: Quaternion;
  20292. /**
  20293. * The raw pose coming from the device.
  20294. */
  20295. rawPose: Nullable<DevicePose>;
  20296. /**
  20297. * The scale of the device to be used when translating from device space to babylon space.
  20298. */
  20299. deviceScaleFactor: number;
  20300. /**
  20301. * Updates the poseControlled values based on the input device pose.
  20302. * @param poseData the pose data to update the object with
  20303. */
  20304. updateFromDevice(poseData: DevicePose): void;
  20305. }
  20306. /**
  20307. * Set of options to customize the webVRCamera
  20308. */
  20309. export interface WebVROptions {
  20310. /**
  20311. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  20312. */
  20313. trackPosition?: boolean;
  20314. /**
  20315. * Sets the scale of the vrDevice in babylon space. (default: 1)
  20316. */
  20317. positionScale?: number;
  20318. /**
  20319. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  20320. */
  20321. displayName?: string;
  20322. /**
  20323. * Should the native controller meshes be initialized. (default: true)
  20324. */
  20325. controllerMeshes?: boolean;
  20326. /**
  20327. * Creating a default HemiLight only on controllers. (default: true)
  20328. */
  20329. defaultLightingOnControllers?: boolean;
  20330. /**
  20331. * If you don't want to use the default VR button of the helper. (default: false)
  20332. */
  20333. useCustomVRButton?: boolean;
  20334. /**
  20335. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  20336. */
  20337. customVRButton?: HTMLButtonElement;
  20338. /**
  20339. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  20340. */
  20341. rayLength?: number;
  20342. /**
  20343. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  20344. */
  20345. defaultHeight?: number;
  20346. /**
  20347. * If multiview should be used if availible (default: false)
  20348. */
  20349. useMultiview?: boolean;
  20350. }
  20351. /**
  20352. * This represents a WebVR camera.
  20353. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  20354. * @example http://doc.babylonjs.com/how_to/webvr_camera
  20355. */
  20356. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  20357. private webVROptions;
  20358. /**
  20359. * @hidden
  20360. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  20361. */
  20362. _vrDevice: any;
  20363. /**
  20364. * The rawPose of the vrDevice.
  20365. */
  20366. rawPose: Nullable<DevicePose>;
  20367. private _onVREnabled;
  20368. private _specsVersion;
  20369. private _attached;
  20370. private _frameData;
  20371. protected _descendants: Array<Node>;
  20372. private _deviceRoomPosition;
  20373. /** @hidden */
  20374. _deviceRoomRotationQuaternion: Quaternion;
  20375. private _standingMatrix;
  20376. /**
  20377. * Represents device position in babylon space.
  20378. */
  20379. devicePosition: Vector3;
  20380. /**
  20381. * Represents device rotation in babylon space.
  20382. */
  20383. deviceRotationQuaternion: Quaternion;
  20384. /**
  20385. * The scale of the device to be used when translating from device space to babylon space.
  20386. */
  20387. deviceScaleFactor: number;
  20388. private _deviceToWorld;
  20389. private _worldToDevice;
  20390. /**
  20391. * References to the webVR controllers for the vrDevice.
  20392. */
  20393. controllers: Array<WebVRController>;
  20394. /**
  20395. * Emits an event when a controller is attached.
  20396. */
  20397. onControllersAttachedObservable: Observable<WebVRController[]>;
  20398. /**
  20399. * Emits an event when a controller's mesh has been loaded;
  20400. */
  20401. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20402. /**
  20403. * Emits an event when the HMD's pose has been updated.
  20404. */
  20405. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20406. private _poseSet;
  20407. /**
  20408. * If the rig cameras be used as parent instead of this camera.
  20409. */
  20410. rigParenting: boolean;
  20411. private _lightOnControllers;
  20412. private _defaultHeight?;
  20413. /**
  20414. * Instantiates a WebVRFreeCamera.
  20415. * @param name The name of the WebVRFreeCamera
  20416. * @param position The starting anchor position for the camera
  20417. * @param scene The scene the camera belongs to
  20418. * @param webVROptions a set of customizable options for the webVRCamera
  20419. */
  20420. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20421. /**
  20422. * Gets the device distance from the ground in meters.
  20423. * @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.
  20424. */
  20425. deviceDistanceToRoomGround(): number;
  20426. /**
  20427. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20428. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20429. */
  20430. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20431. /**
  20432. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20433. * @returns A promise with a boolean set to if the standing matrix is supported.
  20434. */
  20435. useStandingMatrixAsync(): Promise<boolean>;
  20436. /**
  20437. * Disposes the camera
  20438. */
  20439. dispose(): void;
  20440. /**
  20441. * Gets a vrController by name.
  20442. * @param name The name of the controller to retreive
  20443. * @returns the controller matching the name specified or null if not found
  20444. */
  20445. getControllerByName(name: string): Nullable<WebVRController>;
  20446. private _leftController;
  20447. /**
  20448. * The controller corresponding to the users left hand.
  20449. */
  20450. get leftController(): Nullable<WebVRController>;
  20451. private _rightController;
  20452. /**
  20453. * The controller corresponding to the users right hand.
  20454. */
  20455. get rightController(): Nullable<WebVRController>;
  20456. /**
  20457. * Casts a ray forward from the vrCamera's gaze.
  20458. * @param length Length of the ray (default: 100)
  20459. * @returns the ray corresponding to the gaze
  20460. */
  20461. getForwardRay(length?: number): Ray;
  20462. /**
  20463. * @hidden
  20464. * Updates the camera based on device's frame data
  20465. */
  20466. _checkInputs(): void;
  20467. /**
  20468. * Updates the poseControlled values based on the input device pose.
  20469. * @param poseData Pose coming from the device
  20470. */
  20471. updateFromDevice(poseData: DevicePose): void;
  20472. private _htmlElementAttached;
  20473. private _detachIfAttached;
  20474. /**
  20475. * WebVR's attach control will start broadcasting frames to the device.
  20476. * Note that in certain browsers (chrome for example) this function must be called
  20477. * within a user-interaction callback. Example:
  20478. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20479. *
  20480. * @param element html element to attach the vrDevice to
  20481. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20482. */
  20483. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20484. /**
  20485. * Detaches the camera from the html element and disables VR
  20486. *
  20487. * @param element html element to detach from
  20488. */
  20489. detachControl(element: HTMLElement): void;
  20490. /**
  20491. * @returns the name of this class
  20492. */
  20493. getClassName(): string;
  20494. /**
  20495. * Calls resetPose on the vrDisplay
  20496. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20497. */
  20498. resetToCurrentRotation(): void;
  20499. /**
  20500. * @hidden
  20501. * Updates the rig cameras (left and right eye)
  20502. */
  20503. _updateRigCameras(): void;
  20504. private _workingVector;
  20505. private _oneVector;
  20506. private _workingMatrix;
  20507. private updateCacheCalled;
  20508. private _correctPositionIfNotTrackPosition;
  20509. /**
  20510. * @hidden
  20511. * Updates the cached values of the camera
  20512. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20513. */
  20514. _updateCache(ignoreParentClass?: boolean): void;
  20515. /**
  20516. * @hidden
  20517. * Get current device position in babylon world
  20518. */
  20519. _computeDevicePosition(): void;
  20520. /**
  20521. * Updates the current device position and rotation in the babylon world
  20522. */
  20523. update(): void;
  20524. /**
  20525. * @hidden
  20526. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20527. * @returns an identity matrix
  20528. */
  20529. _getViewMatrix(): Matrix;
  20530. private _tmpMatrix;
  20531. /**
  20532. * This function is called by the two RIG cameras.
  20533. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20534. * @hidden
  20535. */
  20536. _getWebVRViewMatrix(): Matrix;
  20537. /** @hidden */
  20538. _getWebVRProjectionMatrix(): Matrix;
  20539. private _onGamepadConnectedObserver;
  20540. private _onGamepadDisconnectedObserver;
  20541. private _updateCacheWhenTrackingDisabledObserver;
  20542. /**
  20543. * Initializes the controllers and their meshes
  20544. */
  20545. initControllers(): void;
  20546. }
  20547. }
  20548. declare module "babylonjs/Materials/materialHelper" {
  20549. import { Nullable } from "babylonjs/types";
  20550. import { Scene } from "babylonjs/scene";
  20551. import { Engine } from "babylonjs/Engines/engine";
  20552. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20553. import { Light } from "babylonjs/Lights/light";
  20554. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20555. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  20556. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20557. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20558. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  20559. /**
  20560. * "Static Class" containing the most commonly used helper while dealing with material for
  20561. * rendering purpose.
  20562. *
  20563. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  20564. *
  20565. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  20566. */
  20567. export class MaterialHelper {
  20568. /**
  20569. * Bind the current view position to an effect.
  20570. * @param effect The effect to be bound
  20571. * @param scene The scene the eyes position is used from
  20572. * @param variableName name of the shader variable that will hold the eye position
  20573. */
  20574. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  20575. /**
  20576. * Helps preparing the defines values about the UVs in used in the effect.
  20577. * UVs are shared as much as we can accross channels in the shaders.
  20578. * @param texture The texture we are preparing the UVs for
  20579. * @param defines The defines to update
  20580. * @param key The channel key "diffuse", "specular"... used in the shader
  20581. */
  20582. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  20583. /**
  20584. * Binds a texture matrix value to its corrsponding uniform
  20585. * @param texture The texture to bind the matrix for
  20586. * @param uniformBuffer The uniform buffer receivin the data
  20587. * @param key The channel key "diffuse", "specular"... used in the shader
  20588. */
  20589. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  20590. /**
  20591. * Gets the current status of the fog (should it be enabled?)
  20592. * @param mesh defines the mesh to evaluate for fog support
  20593. * @param scene defines the hosting scene
  20594. * @returns true if fog must be enabled
  20595. */
  20596. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  20597. /**
  20598. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  20599. * @param mesh defines the current mesh
  20600. * @param scene defines the current scene
  20601. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  20602. * @param pointsCloud defines if point cloud rendering has to be turned on
  20603. * @param fogEnabled defines if fog has to be turned on
  20604. * @param alphaTest defines if alpha testing has to be turned on
  20605. * @param defines defines the current list of defines
  20606. */
  20607. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  20608. /**
  20609. * Helper used to prepare the list of defines associated with frame values for shader compilation
  20610. * @param scene defines the current scene
  20611. * @param engine defines the current engine
  20612. * @param defines specifies the list of active defines
  20613. * @param useInstances defines if instances have to be turned on
  20614. * @param useClipPlane defines if clip plane have to be turned on
  20615. * @param useInstances defines if instances have to be turned on
  20616. * @param useThinInstances defines if thin instances have to be turned on
  20617. */
  20618. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  20619. /**
  20620. * Prepares the defines for bones
  20621. * @param mesh The mesh containing the geometry data we will draw
  20622. * @param defines The defines to update
  20623. */
  20624. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  20625. /**
  20626. * Prepares the defines for morph targets
  20627. * @param mesh The mesh containing the geometry data we will draw
  20628. * @param defines The defines to update
  20629. */
  20630. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  20631. /**
  20632. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  20633. * @param mesh The mesh containing the geometry data we will draw
  20634. * @param defines The defines to update
  20635. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  20636. * @param useBones Precise whether bones should be used or not (override mesh info)
  20637. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  20638. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  20639. * @returns false if defines are considered not dirty and have not been checked
  20640. */
  20641. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  20642. /**
  20643. * Prepares the defines related to multiview
  20644. * @param scene The scene we are intending to draw
  20645. * @param defines The defines to update
  20646. */
  20647. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  20648. /**
  20649. * Prepares the defines related to the light information passed in parameter
  20650. * @param scene The scene we are intending to draw
  20651. * @param mesh The mesh the effect is compiling for
  20652. * @param light The light the effect is compiling for
  20653. * @param lightIndex The index of the light
  20654. * @param defines The defines to update
  20655. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20656. * @param state Defines the current state regarding what is needed (normals, etc...)
  20657. */
  20658. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20659. needNormals: boolean;
  20660. needRebuild: boolean;
  20661. shadowEnabled: boolean;
  20662. specularEnabled: boolean;
  20663. lightmapMode: boolean;
  20664. }): void;
  20665. /**
  20666. * Prepares the defines related to the light information passed in parameter
  20667. * @param scene The scene we are intending to draw
  20668. * @param mesh The mesh the effect is compiling for
  20669. * @param defines The defines to update
  20670. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20671. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  20672. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  20673. * @returns true if normals will be required for the rest of the effect
  20674. */
  20675. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  20676. /**
  20677. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  20678. * @param lightIndex defines the light index
  20679. * @param uniformsList The uniform list
  20680. * @param samplersList The sampler list
  20681. * @param projectedLightTexture defines if projected texture must be used
  20682. * @param uniformBuffersList defines an optional list of uniform buffers
  20683. */
  20684. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  20685. /**
  20686. * Prepares the uniforms and samplers list to be used in the effect
  20687. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  20688. * @param samplersList The sampler list
  20689. * @param defines The defines helping in the list generation
  20690. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  20691. */
  20692. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  20693. /**
  20694. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  20695. * @param defines The defines to update while falling back
  20696. * @param fallbacks The authorized effect fallbacks
  20697. * @param maxSimultaneousLights The maximum number of lights allowed
  20698. * @param rank the current rank of the Effect
  20699. * @returns The newly affected rank
  20700. */
  20701. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  20702. private static _TmpMorphInfluencers;
  20703. /**
  20704. * Prepares the list of attributes required for morph targets according to the effect defines.
  20705. * @param attribs The current list of supported attribs
  20706. * @param mesh The mesh to prepare the morph targets attributes for
  20707. * @param influencers The number of influencers
  20708. */
  20709. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  20710. /**
  20711. * Prepares the list of attributes required for morph targets according to the effect defines.
  20712. * @param attribs The current list of supported attribs
  20713. * @param mesh The mesh to prepare the morph targets attributes for
  20714. * @param defines The current Defines of the effect
  20715. */
  20716. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  20717. /**
  20718. * Prepares the list of attributes required for bones according to the effect defines.
  20719. * @param attribs The current list of supported attribs
  20720. * @param mesh The mesh to prepare the bones attributes for
  20721. * @param defines The current Defines of the effect
  20722. * @param fallbacks The current efffect fallback strategy
  20723. */
  20724. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  20725. /**
  20726. * Check and prepare the list of attributes required for instances according to the effect defines.
  20727. * @param attribs The current list of supported attribs
  20728. * @param defines The current MaterialDefines of the effect
  20729. */
  20730. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  20731. /**
  20732. * Add the list of attributes required for instances to the attribs array.
  20733. * @param attribs The current list of supported attribs
  20734. */
  20735. static PushAttributesForInstances(attribs: string[]): void;
  20736. /**
  20737. * Binds the light information to the effect.
  20738. * @param light The light containing the generator
  20739. * @param effect The effect we are binding the data to
  20740. * @param lightIndex The light index in the effect used to render
  20741. */
  20742. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  20743. /**
  20744. * Binds the lights information from the scene to the effect for the given mesh.
  20745. * @param light Light to bind
  20746. * @param lightIndex Light index
  20747. * @param scene The scene where the light belongs to
  20748. * @param effect The effect we are binding the data to
  20749. * @param useSpecular Defines if specular is supported
  20750. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20751. */
  20752. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  20753. /**
  20754. * Binds the lights information from the scene to the effect for the given mesh.
  20755. * @param scene The scene the lights belongs to
  20756. * @param mesh The mesh we are binding the information to render
  20757. * @param effect The effect we are binding the data to
  20758. * @param defines The generated defines for the effect
  20759. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  20760. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20761. */
  20762. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  20763. private static _tempFogColor;
  20764. /**
  20765. * Binds the fog information from the scene to the effect for the given mesh.
  20766. * @param scene The scene the lights belongs to
  20767. * @param mesh The mesh we are binding the information to render
  20768. * @param effect The effect we are binding the data to
  20769. * @param linearSpace Defines if the fog effect is applied in linear space
  20770. */
  20771. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  20772. /**
  20773. * Binds the bones information from the mesh to the effect.
  20774. * @param mesh The mesh we are binding the information to render
  20775. * @param effect The effect we are binding the data to
  20776. */
  20777. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  20778. /**
  20779. * Binds the morph targets information from the mesh to the effect.
  20780. * @param abstractMesh The mesh we are binding the information to render
  20781. * @param effect The effect we are binding the data to
  20782. */
  20783. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  20784. /**
  20785. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  20786. * @param defines The generated defines used in the effect
  20787. * @param effect The effect we are binding the data to
  20788. * @param scene The scene we are willing to render with logarithmic scale for
  20789. */
  20790. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  20791. /**
  20792. * Binds the clip plane information from the scene to the effect.
  20793. * @param scene The scene the clip plane information are extracted from
  20794. * @param effect The effect we are binding the data to
  20795. */
  20796. static BindClipPlane(effect: Effect, scene: Scene): void;
  20797. }
  20798. }
  20799. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  20800. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  20801. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  20802. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  20803. import { Nullable } from "babylonjs/types";
  20804. import { Effect } from "babylonjs/Materials/effect";
  20805. import { Matrix } from "babylonjs/Maths/math.vector";
  20806. import { Scene } from "babylonjs/scene";
  20807. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  20808. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  20809. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  20810. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  20811. import { Observable } from "babylonjs/Misc/observable";
  20812. /**
  20813. * Block used to expose an input value
  20814. */
  20815. export class InputBlock extends NodeMaterialBlock {
  20816. private _mode;
  20817. private _associatedVariableName;
  20818. private _storedValue;
  20819. private _valueCallback;
  20820. private _type;
  20821. private _animationType;
  20822. /** Gets or set a value used to limit the range of float values */
  20823. min: number;
  20824. /** Gets or set a value used to limit the range of float values */
  20825. max: number;
  20826. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  20827. isBoolean: boolean;
  20828. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  20829. matrixMode: number;
  20830. /** @hidden */
  20831. _systemValue: Nullable<NodeMaterialSystemValues>;
  20832. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  20833. visibleInInspector: boolean;
  20834. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  20835. isConstant: boolean;
  20836. /** Gets or sets the group to use to display this block in the Inspector */
  20837. groupInInspector: string;
  20838. /** Gets an observable raised when the value is changed */
  20839. onValueChangedObservable: Observable<InputBlock>;
  20840. /**
  20841. * Gets or sets the connection point type (default is float)
  20842. */
  20843. get type(): NodeMaterialBlockConnectionPointTypes;
  20844. /**
  20845. * Creates a new InputBlock
  20846. * @param name defines the block name
  20847. * @param target defines the target of that block (Vertex by default)
  20848. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  20849. */
  20850. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  20851. /**
  20852. * Gets the output component
  20853. */
  20854. get output(): NodeMaterialConnectionPoint;
  20855. /**
  20856. * Set the source of this connection point to a vertex attribute
  20857. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  20858. * @returns the current connection point
  20859. */
  20860. setAsAttribute(attributeName?: string): InputBlock;
  20861. /**
  20862. * Set the source of this connection point to a system value
  20863. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  20864. * @returns the current connection point
  20865. */
  20866. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  20867. /**
  20868. * Gets or sets the value of that point.
  20869. * Please note that this value will be ignored if valueCallback is defined
  20870. */
  20871. get value(): any;
  20872. set value(value: any);
  20873. /**
  20874. * Gets or sets a callback used to get the value of that point.
  20875. * Please note that setting this value will force the connection point to ignore the value property
  20876. */
  20877. get valueCallback(): () => any;
  20878. set valueCallback(value: () => any);
  20879. /**
  20880. * Gets or sets the associated variable name in the shader
  20881. */
  20882. get associatedVariableName(): string;
  20883. set associatedVariableName(value: string);
  20884. /** Gets or sets the type of animation applied to the input */
  20885. get animationType(): AnimatedInputBlockTypes;
  20886. set animationType(value: AnimatedInputBlockTypes);
  20887. /**
  20888. * Gets a boolean indicating that this connection point not defined yet
  20889. */
  20890. get isUndefined(): boolean;
  20891. /**
  20892. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  20893. * In this case the connection point name must be the name of the uniform to use.
  20894. * Can only be set on inputs
  20895. */
  20896. get isUniform(): boolean;
  20897. set isUniform(value: boolean);
  20898. /**
  20899. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  20900. * In this case the connection point name must be the name of the attribute to use
  20901. * Can only be set on inputs
  20902. */
  20903. get isAttribute(): boolean;
  20904. set isAttribute(value: boolean);
  20905. /**
  20906. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  20907. * Can only be set on exit points
  20908. */
  20909. get isVarying(): boolean;
  20910. set isVarying(value: boolean);
  20911. /**
  20912. * Gets a boolean indicating that the current connection point is a system value
  20913. */
  20914. get isSystemValue(): boolean;
  20915. /**
  20916. * Gets or sets the current well known value or null if not defined as a system value
  20917. */
  20918. get systemValue(): Nullable<NodeMaterialSystemValues>;
  20919. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  20920. /**
  20921. * Gets the current class name
  20922. * @returns the class name
  20923. */
  20924. getClassName(): string;
  20925. /**
  20926. * Animate the input if animationType !== None
  20927. * @param scene defines the rendering scene
  20928. */
  20929. animate(scene: Scene): void;
  20930. private _emitDefine;
  20931. initialize(state: NodeMaterialBuildState): void;
  20932. /**
  20933. * Set the input block to its default value (based on its type)
  20934. */
  20935. setDefaultValue(): void;
  20936. private _emitConstant;
  20937. /** @hidden */
  20938. get _noContextSwitch(): boolean;
  20939. private _emit;
  20940. /** @hidden */
  20941. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  20942. /** @hidden */
  20943. _transmit(effect: Effect, scene: Scene): void;
  20944. protected _buildBlock(state: NodeMaterialBuildState): void;
  20945. protected _dumpPropertiesCode(): string;
  20946. dispose(): void;
  20947. serialize(): any;
  20948. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20949. }
  20950. }
  20951. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  20952. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  20953. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  20954. import { Nullable } from "babylonjs/types";
  20955. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  20956. import { Observable } from "babylonjs/Misc/observable";
  20957. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  20958. /**
  20959. * Enum used to define the compatibility state between two connection points
  20960. */
  20961. export enum NodeMaterialConnectionPointCompatibilityStates {
  20962. /** Points are compatibles */
  20963. Compatible = 0,
  20964. /** Points are incompatible because of their types */
  20965. TypeIncompatible = 1,
  20966. /** Points are incompatible because of their targets (vertex vs fragment) */
  20967. TargetIncompatible = 2
  20968. }
  20969. /**
  20970. * Defines the direction of a connection point
  20971. */
  20972. export enum NodeMaterialConnectionPointDirection {
  20973. /** Input */
  20974. Input = 0,
  20975. /** Output */
  20976. Output = 1
  20977. }
  20978. /**
  20979. * Defines a connection point for a block
  20980. */
  20981. export class NodeMaterialConnectionPoint {
  20982. /** @hidden */
  20983. _ownerBlock: NodeMaterialBlock;
  20984. /** @hidden */
  20985. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  20986. private _endpoints;
  20987. private _associatedVariableName;
  20988. private _direction;
  20989. /** @hidden */
  20990. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20991. /** @hidden */
  20992. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20993. private _type;
  20994. /** @hidden */
  20995. _enforceAssociatedVariableName: boolean;
  20996. /** Gets the direction of the point */
  20997. get direction(): NodeMaterialConnectionPointDirection;
  20998. /** Indicates that this connection point needs dual validation before being connected to another point */
  20999. needDualDirectionValidation: boolean;
  21000. /**
  21001. * Gets or sets the additional types supported by this connection point
  21002. */
  21003. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21004. /**
  21005. * Gets or sets the additional types excluded by this connection point
  21006. */
  21007. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21008. /**
  21009. * Observable triggered when this point is connected
  21010. */
  21011. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  21012. /**
  21013. * Gets or sets the associated variable name in the shader
  21014. */
  21015. get associatedVariableName(): string;
  21016. set associatedVariableName(value: string);
  21017. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  21018. get innerType(): NodeMaterialBlockConnectionPointTypes;
  21019. /**
  21020. * Gets or sets the connection point type (default is float)
  21021. */
  21022. get type(): NodeMaterialBlockConnectionPointTypes;
  21023. set type(value: NodeMaterialBlockConnectionPointTypes);
  21024. /**
  21025. * Gets or sets the connection point name
  21026. */
  21027. name: string;
  21028. /**
  21029. * Gets or sets the connection point name
  21030. */
  21031. displayName: string;
  21032. /**
  21033. * Gets or sets a boolean indicating that this connection point can be omitted
  21034. */
  21035. isOptional: boolean;
  21036. /**
  21037. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  21038. */
  21039. define: string;
  21040. /** @hidden */
  21041. _prioritizeVertex: boolean;
  21042. private _target;
  21043. /** Gets or sets the target of that connection point */
  21044. get target(): NodeMaterialBlockTargets;
  21045. set target(value: NodeMaterialBlockTargets);
  21046. /**
  21047. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  21048. */
  21049. get isConnected(): boolean;
  21050. /**
  21051. * Gets a boolean indicating that the current point is connected to an input block
  21052. */
  21053. get isConnectedToInputBlock(): boolean;
  21054. /**
  21055. * Gets a the connected input block (if any)
  21056. */
  21057. get connectInputBlock(): Nullable<InputBlock>;
  21058. /** Get the other side of the connection (if any) */
  21059. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  21060. /** Get the block that owns this connection point */
  21061. get ownerBlock(): NodeMaterialBlock;
  21062. /** Get the block connected on the other side of this connection (if any) */
  21063. get sourceBlock(): Nullable<NodeMaterialBlock>;
  21064. /** Get the block connected on the endpoints of this connection (if any) */
  21065. get connectedBlocks(): Array<NodeMaterialBlock>;
  21066. /** Gets the list of connected endpoints */
  21067. get endpoints(): NodeMaterialConnectionPoint[];
  21068. /** Gets a boolean indicating if that output point is connected to at least one input */
  21069. get hasEndpoints(): boolean;
  21070. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  21071. get isConnectedInVertexShader(): boolean;
  21072. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  21073. get isConnectedInFragmentShader(): boolean;
  21074. /**
  21075. * Creates a block suitable to be used as an input for this input point.
  21076. * If null is returned, a block based on the point type will be created.
  21077. * @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
  21078. */
  21079. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21080. /**
  21081. * Creates a new connection point
  21082. * @param name defines the connection point name
  21083. * @param ownerBlock defines the block hosting this connection point
  21084. * @param direction defines the direction of the connection point
  21085. */
  21086. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  21087. /**
  21088. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  21089. * @returns the class name
  21090. */
  21091. getClassName(): string;
  21092. /**
  21093. * Gets a boolean indicating if the current point can be connected to another point
  21094. * @param connectionPoint defines the other connection point
  21095. * @returns a boolean
  21096. */
  21097. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  21098. /**
  21099. * Gets a number indicating if the current point can be connected to another point
  21100. * @param connectionPoint defines the other connection point
  21101. * @returns a number defining the compatibility state
  21102. */
  21103. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21104. /**
  21105. * Connect this point to another connection point
  21106. * @param connectionPoint defines the other connection point
  21107. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  21108. * @returns the current connection point
  21109. */
  21110. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  21111. /**
  21112. * Disconnect this point from one of his endpoint
  21113. * @param endpoint defines the other connection point
  21114. * @returns the current connection point
  21115. */
  21116. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  21117. /**
  21118. * Serializes this point in a JSON representation
  21119. * @param isInput defines if the connection point is an input (default is true)
  21120. * @returns the serialized point object
  21121. */
  21122. serialize(isInput?: boolean): any;
  21123. /**
  21124. * Release resources
  21125. */
  21126. dispose(): void;
  21127. }
  21128. }
  21129. declare module "babylonjs/Materials/Node/Enums/nodeMaterialModes" {
  21130. /**
  21131. * Enum used to define the material modes
  21132. */
  21133. export enum NodeMaterialModes {
  21134. /** Regular material */
  21135. Material = 0,
  21136. /** For post process */
  21137. PostProcess = 1,
  21138. /** For particle system */
  21139. Particle = 2
  21140. }
  21141. }
  21142. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  21143. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21144. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21145. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21146. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21147. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21148. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21149. import { Effect } from "babylonjs/Materials/effect";
  21150. import { Mesh } from "babylonjs/Meshes/mesh";
  21151. import { Nullable } from "babylonjs/types";
  21152. import { Texture } from "babylonjs/Materials/Textures/texture";
  21153. import { Scene } from "babylonjs/scene";
  21154. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  21155. /**
  21156. * Block used to read a texture from a sampler
  21157. */
  21158. export class TextureBlock extends NodeMaterialBlock {
  21159. private _defineName;
  21160. private _linearDefineName;
  21161. private _gammaDefineName;
  21162. private _tempTextureRead;
  21163. private _samplerName;
  21164. private _transformedUVName;
  21165. private _textureTransformName;
  21166. private _textureInfoName;
  21167. private _mainUVName;
  21168. private _mainUVDefineName;
  21169. private _fragmentOnly;
  21170. /**
  21171. * Gets or sets the texture associated with the node
  21172. */
  21173. texture: Nullable<Texture>;
  21174. /**
  21175. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21176. */
  21177. convertToGammaSpace: boolean;
  21178. /**
  21179. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21180. */
  21181. convertToLinearSpace: boolean;
  21182. /**
  21183. * Create a new TextureBlock
  21184. * @param name defines the block name
  21185. */
  21186. constructor(name: string, fragmentOnly?: boolean);
  21187. /**
  21188. * Gets the current class name
  21189. * @returns the class name
  21190. */
  21191. getClassName(): string;
  21192. /**
  21193. * Gets the uv input component
  21194. */
  21195. get uv(): NodeMaterialConnectionPoint;
  21196. /**
  21197. * Gets the rgba output component
  21198. */
  21199. get rgba(): NodeMaterialConnectionPoint;
  21200. /**
  21201. * Gets the rgb output component
  21202. */
  21203. get rgb(): NodeMaterialConnectionPoint;
  21204. /**
  21205. * Gets the r output component
  21206. */
  21207. get r(): NodeMaterialConnectionPoint;
  21208. /**
  21209. * Gets the g output component
  21210. */
  21211. get g(): NodeMaterialConnectionPoint;
  21212. /**
  21213. * Gets the b output component
  21214. */
  21215. get b(): NodeMaterialConnectionPoint;
  21216. /**
  21217. * Gets the a output component
  21218. */
  21219. get a(): NodeMaterialConnectionPoint;
  21220. get target(): NodeMaterialBlockTargets;
  21221. autoConfigure(material: NodeMaterial): void;
  21222. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21223. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21224. isReady(): boolean;
  21225. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21226. private get _isMixed();
  21227. private _injectVertexCode;
  21228. private _writeTextureRead;
  21229. private _writeOutput;
  21230. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21231. protected _dumpPropertiesCode(): string;
  21232. serialize(): any;
  21233. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21234. }
  21235. }
  21236. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  21237. /** @hidden */
  21238. export var reflectionFunction: {
  21239. name: string;
  21240. shader: string;
  21241. };
  21242. }
  21243. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock" {
  21244. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21245. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21246. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21247. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21248. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21249. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21250. import { Effect } from "babylonjs/Materials/effect";
  21251. import { Mesh } from "babylonjs/Meshes/mesh";
  21252. import { Nullable } from "babylonjs/types";
  21253. import { Scene } from "babylonjs/scene";
  21254. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  21255. /**
  21256. * Base block used to read a reflection texture from a sampler
  21257. */
  21258. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  21259. /** @hidden */
  21260. _define3DName: string;
  21261. /** @hidden */
  21262. _defineCubicName: string;
  21263. /** @hidden */
  21264. _defineExplicitName: string;
  21265. /** @hidden */
  21266. _defineProjectionName: string;
  21267. /** @hidden */
  21268. _defineLocalCubicName: string;
  21269. /** @hidden */
  21270. _defineSphericalName: string;
  21271. /** @hidden */
  21272. _definePlanarName: string;
  21273. /** @hidden */
  21274. _defineEquirectangularName: string;
  21275. /** @hidden */
  21276. _defineMirroredEquirectangularFixedName: string;
  21277. /** @hidden */
  21278. _defineEquirectangularFixedName: string;
  21279. /** @hidden */
  21280. _defineSkyboxName: string;
  21281. /** @hidden */
  21282. _defineOppositeZ: string;
  21283. /** @hidden */
  21284. _cubeSamplerName: string;
  21285. /** @hidden */
  21286. _2DSamplerName: string;
  21287. protected _positionUVWName: string;
  21288. protected _directionWName: string;
  21289. protected _reflectionVectorName: string;
  21290. /** @hidden */
  21291. _reflectionCoordsName: string;
  21292. /** @hidden */
  21293. _reflectionMatrixName: string;
  21294. protected _reflectionColorName: string;
  21295. /**
  21296. * Gets or sets the texture associated with the node
  21297. */
  21298. texture: Nullable<BaseTexture>;
  21299. /**
  21300. * Create a new ReflectionTextureBaseBlock
  21301. * @param name defines the block name
  21302. */
  21303. constructor(name: string);
  21304. /**
  21305. * Gets the current class name
  21306. * @returns the class name
  21307. */
  21308. getClassName(): string;
  21309. /**
  21310. * Gets the world position input component
  21311. */
  21312. abstract get position(): NodeMaterialConnectionPoint;
  21313. /**
  21314. * Gets the world position input component
  21315. */
  21316. abstract get worldPosition(): NodeMaterialConnectionPoint;
  21317. /**
  21318. * Gets the world normal input component
  21319. */
  21320. abstract get worldNormal(): NodeMaterialConnectionPoint;
  21321. /**
  21322. * Gets the world input component
  21323. */
  21324. abstract get world(): NodeMaterialConnectionPoint;
  21325. /**
  21326. * Gets the camera (or eye) position component
  21327. */
  21328. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  21329. /**
  21330. * Gets the view input component
  21331. */
  21332. abstract get view(): NodeMaterialConnectionPoint;
  21333. protected _getTexture(): Nullable<BaseTexture>;
  21334. autoConfigure(material: NodeMaterial): void;
  21335. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21336. isReady(): boolean;
  21337. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21338. /**
  21339. * Gets the code to inject in the vertex shader
  21340. * @param state current state of the node material building
  21341. * @returns the shader code
  21342. */
  21343. handleVertexSide(state: NodeMaterialBuildState): string;
  21344. /**
  21345. * Handles the inits for the fragment code path
  21346. * @param state node material build state
  21347. */
  21348. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  21349. /**
  21350. * Generates the reflection coords code for the fragment code path
  21351. * @param worldNormalVarName name of the world normal variable
  21352. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  21353. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  21354. * @returns the shader code
  21355. */
  21356. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  21357. /**
  21358. * Generates the reflection color code for the fragment code path
  21359. * @param lodVarName name of the lod variable
  21360. * @param swizzleLookupTexture swizzle to use for the final color variable
  21361. * @returns the shader code
  21362. */
  21363. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  21364. /**
  21365. * Generates the code corresponding to the connected output points
  21366. * @param state node material build state
  21367. * @param varName name of the variable to output
  21368. * @returns the shader code
  21369. */
  21370. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  21371. protected _buildBlock(state: NodeMaterialBuildState): this;
  21372. protected _dumpPropertiesCode(): string;
  21373. serialize(): any;
  21374. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21375. }
  21376. }
  21377. declare module "babylonjs/Materials/Node/nodeMaterialConnectionPointCustomObject" {
  21378. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21379. import { NodeMaterialConnectionPoint, NodeMaterialConnectionPointDirection, NodeMaterialConnectionPointCompatibilityStates } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21380. import { Nullable } from "babylonjs/types";
  21381. /**
  21382. * Defines a connection point to be used for points with a custom object type
  21383. */
  21384. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  21385. private _blockType;
  21386. private _blockName;
  21387. private _nameForCheking?;
  21388. /**
  21389. * Creates a new connection point
  21390. * @param name defines the connection point name
  21391. * @param ownerBlock defines the block hosting this connection point
  21392. * @param direction defines the direction of the connection point
  21393. */
  21394. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  21395. /**
  21396. * Gets a number indicating if the current point can be connected to another point
  21397. * @param connectionPoint defines the other connection point
  21398. * @returns a number defining the compatibility state
  21399. */
  21400. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21401. /**
  21402. * Creates a block suitable to be used as an input for this input point.
  21403. * If null is returned, a block based on the point type will be created.
  21404. * @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
  21405. */
  21406. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21407. }
  21408. }
  21409. declare module "babylonjs/Materials/Node/nodeMaterialDecorator" {
  21410. /**
  21411. * Enum defining the type of properties that can be edited in the property pages in the NME
  21412. */
  21413. export enum PropertyTypeForEdition {
  21414. /** property is a boolean */
  21415. Boolean = 0,
  21416. /** property is a float */
  21417. Float = 1,
  21418. /** property is a Vector2 */
  21419. Vector2 = 2,
  21420. /** property is a list of values */
  21421. List = 3
  21422. }
  21423. /**
  21424. * Interface that defines an option in a variable of type list
  21425. */
  21426. export interface IEditablePropertyListOption {
  21427. /** label of the option */
  21428. "label": string;
  21429. /** value of the option */
  21430. "value": number;
  21431. }
  21432. /**
  21433. * Interface that defines the options available for an editable property
  21434. */
  21435. export interface IEditablePropertyOption {
  21436. /** min value */
  21437. "min"?: number;
  21438. /** max value */
  21439. "max"?: number;
  21440. /** notifiers: indicates which actions to take when the property is changed */
  21441. "notifiers"?: {
  21442. /** the material should be rebuilt */
  21443. "rebuild"?: boolean;
  21444. /** the preview should be updated */
  21445. "update"?: boolean;
  21446. };
  21447. /** list of the options for a variable of type list */
  21448. "options"?: IEditablePropertyListOption[];
  21449. }
  21450. /**
  21451. * Interface that describes an editable property
  21452. */
  21453. export interface IPropertyDescriptionForEdition {
  21454. /** name of the property */
  21455. "propertyName": string;
  21456. /** display name of the property */
  21457. "displayName": string;
  21458. /** type of the property */
  21459. "type": PropertyTypeForEdition;
  21460. /** group of the property - all properties with the same group value will be displayed in a specific section */
  21461. "groupName": string;
  21462. /** options for the property */
  21463. "options": IEditablePropertyOption;
  21464. }
  21465. /**
  21466. * Decorator that flags a property in a node material block as being editable
  21467. */
  21468. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  21469. }
  21470. declare module "babylonjs/Materials/Node/Blocks/PBR/refractionBlock" {
  21471. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21472. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21473. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21474. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21475. import { Nullable } from "babylonjs/types";
  21476. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21477. import { Mesh } from "babylonjs/Meshes/mesh";
  21478. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21479. import { Effect } from "babylonjs/Materials/effect";
  21480. import { Scene } from "babylonjs/scene";
  21481. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21482. /**
  21483. * Block used to implement the refraction part of the sub surface module of the PBR material
  21484. */
  21485. export class RefractionBlock extends NodeMaterialBlock {
  21486. /** @hidden */
  21487. _define3DName: string;
  21488. /** @hidden */
  21489. _refractionMatrixName: string;
  21490. /** @hidden */
  21491. _defineLODRefractionAlpha: string;
  21492. /** @hidden */
  21493. _defineLinearSpecularRefraction: string;
  21494. /** @hidden */
  21495. _defineOppositeZ: string;
  21496. /** @hidden */
  21497. _cubeSamplerName: string;
  21498. /** @hidden */
  21499. _2DSamplerName: string;
  21500. /** @hidden */
  21501. _vRefractionMicrosurfaceInfosName: string;
  21502. /** @hidden */
  21503. _vRefractionInfosName: string;
  21504. private _scene;
  21505. /**
  21506. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21507. * Materials half opaque for instance using refraction could benefit from this control.
  21508. */
  21509. linkRefractionWithTransparency: boolean;
  21510. /**
  21511. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21512. */
  21513. invertRefractionY: boolean;
  21514. /**
  21515. * Gets or sets the texture associated with the node
  21516. */
  21517. texture: Nullable<BaseTexture>;
  21518. /**
  21519. * Create a new RefractionBlock
  21520. * @param name defines the block name
  21521. */
  21522. constructor(name: string);
  21523. /**
  21524. * Gets the current class name
  21525. * @returns the class name
  21526. */
  21527. getClassName(): string;
  21528. /**
  21529. * Gets the intensity input component
  21530. */
  21531. get intensity(): NodeMaterialConnectionPoint;
  21532. /**
  21533. * Gets the index of refraction input component
  21534. */
  21535. get indexOfRefraction(): NodeMaterialConnectionPoint;
  21536. /**
  21537. * Gets the tint at distance input component
  21538. */
  21539. get tintAtDistance(): NodeMaterialConnectionPoint;
  21540. /**
  21541. * Gets the view input component
  21542. */
  21543. get view(): NodeMaterialConnectionPoint;
  21544. /**
  21545. * Gets the refraction object output component
  21546. */
  21547. get refraction(): NodeMaterialConnectionPoint;
  21548. /**
  21549. * Returns true if the block has a texture
  21550. */
  21551. get hasTexture(): boolean;
  21552. protected _getTexture(): Nullable<BaseTexture>;
  21553. autoConfigure(material: NodeMaterial): void;
  21554. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21555. isReady(): boolean;
  21556. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21557. /**
  21558. * Gets the main code of the block (fragment side)
  21559. * @param state current state of the node material building
  21560. * @returns the shader code
  21561. */
  21562. getCode(state: NodeMaterialBuildState): string;
  21563. protected _buildBlock(state: NodeMaterialBuildState): this;
  21564. protected _dumpPropertiesCode(): string;
  21565. serialize(): any;
  21566. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21567. }
  21568. }
  21569. declare module "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock" {
  21570. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21571. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21572. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21573. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21574. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21575. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21576. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21577. import { Nullable } from "babylonjs/types";
  21578. import { Scene } from "babylonjs/scene";
  21579. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  21580. /**
  21581. * Base block used as input for post process
  21582. */
  21583. export class CurrentScreenBlock extends NodeMaterialBlock {
  21584. private _samplerName;
  21585. private _linearDefineName;
  21586. private _gammaDefineName;
  21587. private _mainUVName;
  21588. private _tempTextureRead;
  21589. /**
  21590. * Gets or sets the texture associated with the node
  21591. */
  21592. texture: Nullable<BaseTexture>;
  21593. /**
  21594. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21595. */
  21596. convertToGammaSpace: boolean;
  21597. /**
  21598. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21599. */
  21600. convertToLinearSpace: boolean;
  21601. /**
  21602. * Create a new CurrentScreenBlock
  21603. * @param name defines the block name
  21604. */
  21605. constructor(name: string);
  21606. /**
  21607. * Gets the current class name
  21608. * @returns the class name
  21609. */
  21610. getClassName(): string;
  21611. /**
  21612. * Gets the uv input component
  21613. */
  21614. get uv(): NodeMaterialConnectionPoint;
  21615. /**
  21616. * Gets the rgba output component
  21617. */
  21618. get rgba(): NodeMaterialConnectionPoint;
  21619. /**
  21620. * Gets the rgb output component
  21621. */
  21622. get rgb(): NodeMaterialConnectionPoint;
  21623. /**
  21624. * Gets the r output component
  21625. */
  21626. get r(): NodeMaterialConnectionPoint;
  21627. /**
  21628. * Gets the g output component
  21629. */
  21630. get g(): NodeMaterialConnectionPoint;
  21631. /**
  21632. * Gets the b output component
  21633. */
  21634. get b(): NodeMaterialConnectionPoint;
  21635. /**
  21636. * Gets the a output component
  21637. */
  21638. get a(): NodeMaterialConnectionPoint;
  21639. /**
  21640. * Initialize the block and prepare the context for build
  21641. * @param state defines the state that will be used for the build
  21642. */
  21643. initialize(state: NodeMaterialBuildState): void;
  21644. get target(): NodeMaterialBlockTargets;
  21645. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21646. isReady(): boolean;
  21647. private _injectVertexCode;
  21648. private _writeTextureRead;
  21649. private _writeOutput;
  21650. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21651. serialize(): any;
  21652. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21653. }
  21654. }
  21655. declare module "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock" {
  21656. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21657. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21658. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21659. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21660. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21661. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21662. import { Nullable } from "babylonjs/types";
  21663. import { Scene } from "babylonjs/scene";
  21664. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  21665. /**
  21666. * Base block used for the particle texture
  21667. */
  21668. export class ParticleTextureBlock extends NodeMaterialBlock {
  21669. private _samplerName;
  21670. private _linearDefineName;
  21671. private _gammaDefineName;
  21672. private _tempTextureRead;
  21673. /**
  21674. * Gets or sets the texture associated with the node
  21675. */
  21676. texture: Nullable<BaseTexture>;
  21677. /**
  21678. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21679. */
  21680. convertToGammaSpace: boolean;
  21681. /**
  21682. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21683. */
  21684. convertToLinearSpace: boolean;
  21685. /**
  21686. * Create a new ParticleTextureBlock
  21687. * @param name defines the block name
  21688. */
  21689. constructor(name: string);
  21690. /**
  21691. * Gets the current class name
  21692. * @returns the class name
  21693. */
  21694. getClassName(): string;
  21695. /**
  21696. * Gets the uv input component
  21697. */
  21698. get uv(): NodeMaterialConnectionPoint;
  21699. /**
  21700. * Gets the rgba output component
  21701. */
  21702. get rgba(): NodeMaterialConnectionPoint;
  21703. /**
  21704. * Gets the rgb output component
  21705. */
  21706. get rgb(): NodeMaterialConnectionPoint;
  21707. /**
  21708. * Gets the r output component
  21709. */
  21710. get r(): NodeMaterialConnectionPoint;
  21711. /**
  21712. * Gets the g output component
  21713. */
  21714. get g(): NodeMaterialConnectionPoint;
  21715. /**
  21716. * Gets the b output component
  21717. */
  21718. get b(): NodeMaterialConnectionPoint;
  21719. /**
  21720. * Gets the a output component
  21721. */
  21722. get a(): NodeMaterialConnectionPoint;
  21723. /**
  21724. * Initialize the block and prepare the context for build
  21725. * @param state defines the state that will be used for the build
  21726. */
  21727. initialize(state: NodeMaterialBuildState): void;
  21728. autoConfigure(material: NodeMaterial): void;
  21729. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21730. isReady(): boolean;
  21731. private _writeOutput;
  21732. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21733. serialize(): any;
  21734. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21735. }
  21736. }
  21737. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  21738. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21739. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21740. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  21741. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  21742. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  21743. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  21744. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  21745. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  21746. import { Scene } from "babylonjs/scene";
  21747. /**
  21748. * Class used to store shared data between 2 NodeMaterialBuildState
  21749. */
  21750. export class NodeMaterialBuildStateSharedData {
  21751. /**
  21752. * Gets the list of emitted varyings
  21753. */
  21754. temps: string[];
  21755. /**
  21756. * Gets the list of emitted varyings
  21757. */
  21758. varyings: string[];
  21759. /**
  21760. * Gets the varying declaration string
  21761. */
  21762. varyingDeclaration: string;
  21763. /**
  21764. * Input blocks
  21765. */
  21766. inputBlocks: InputBlock[];
  21767. /**
  21768. * Input blocks
  21769. */
  21770. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  21771. /**
  21772. * Bindable blocks (Blocks that need to set data to the effect)
  21773. */
  21774. bindableBlocks: NodeMaterialBlock[];
  21775. /**
  21776. * List of blocks that can provide a compilation fallback
  21777. */
  21778. blocksWithFallbacks: NodeMaterialBlock[];
  21779. /**
  21780. * List of blocks that can provide a define update
  21781. */
  21782. blocksWithDefines: NodeMaterialBlock[];
  21783. /**
  21784. * List of blocks that can provide a repeatable content
  21785. */
  21786. repeatableContentBlocks: NodeMaterialBlock[];
  21787. /**
  21788. * List of blocks that can provide a dynamic list of uniforms
  21789. */
  21790. dynamicUniformBlocks: NodeMaterialBlock[];
  21791. /**
  21792. * List of blocks that can block the isReady function for the material
  21793. */
  21794. blockingBlocks: NodeMaterialBlock[];
  21795. /**
  21796. * Gets the list of animated inputs
  21797. */
  21798. animatedInputs: InputBlock[];
  21799. /**
  21800. * Build Id used to avoid multiple recompilations
  21801. */
  21802. buildId: number;
  21803. /** List of emitted variables */
  21804. variableNames: {
  21805. [key: string]: number;
  21806. };
  21807. /** List of emitted defines */
  21808. defineNames: {
  21809. [key: string]: number;
  21810. };
  21811. /** Should emit comments? */
  21812. emitComments: boolean;
  21813. /** Emit build activity */
  21814. verbose: boolean;
  21815. /** Gets or sets the hosting scene */
  21816. scene: Scene;
  21817. /**
  21818. * Gets the compilation hints emitted at compilation time
  21819. */
  21820. hints: {
  21821. needWorldViewMatrix: boolean;
  21822. needWorldViewProjectionMatrix: boolean;
  21823. needAlphaBlending: boolean;
  21824. needAlphaTesting: boolean;
  21825. };
  21826. /**
  21827. * List of compilation checks
  21828. */
  21829. checks: {
  21830. emitVertex: boolean;
  21831. emitFragment: boolean;
  21832. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  21833. };
  21834. /**
  21835. * Is vertex program allowed to be empty?
  21836. */
  21837. allowEmptyVertexProgram: boolean;
  21838. /** Creates a new shared data */
  21839. constructor();
  21840. /**
  21841. * Emits console errors and exceptions if there is a failing check
  21842. */
  21843. emitErrors(): void;
  21844. }
  21845. }
  21846. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  21847. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21848. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21849. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  21850. /**
  21851. * Class used to store node based material build state
  21852. */
  21853. export class NodeMaterialBuildState {
  21854. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  21855. supportUniformBuffers: boolean;
  21856. /**
  21857. * Gets the list of emitted attributes
  21858. */
  21859. attributes: string[];
  21860. /**
  21861. * Gets the list of emitted uniforms
  21862. */
  21863. uniforms: string[];
  21864. /**
  21865. * Gets the list of emitted constants
  21866. */
  21867. constants: string[];
  21868. /**
  21869. * Gets the list of emitted samplers
  21870. */
  21871. samplers: string[];
  21872. /**
  21873. * Gets the list of emitted functions
  21874. */
  21875. functions: {
  21876. [key: string]: string;
  21877. };
  21878. /**
  21879. * Gets the list of emitted extensions
  21880. */
  21881. extensions: {
  21882. [key: string]: string;
  21883. };
  21884. /**
  21885. * Gets the target of the compilation state
  21886. */
  21887. target: NodeMaterialBlockTargets;
  21888. /**
  21889. * Gets the list of emitted counters
  21890. */
  21891. counters: {
  21892. [key: string]: number;
  21893. };
  21894. /**
  21895. * Shared data between multiple NodeMaterialBuildState instances
  21896. */
  21897. sharedData: NodeMaterialBuildStateSharedData;
  21898. /** @hidden */
  21899. _vertexState: NodeMaterialBuildState;
  21900. /** @hidden */
  21901. _attributeDeclaration: string;
  21902. /** @hidden */
  21903. _uniformDeclaration: string;
  21904. /** @hidden */
  21905. _constantDeclaration: string;
  21906. /** @hidden */
  21907. _samplerDeclaration: string;
  21908. /** @hidden */
  21909. _varyingTransfer: string;
  21910. /** @hidden */
  21911. _injectAtEnd: string;
  21912. private _repeatableContentAnchorIndex;
  21913. /** @hidden */
  21914. _builtCompilationString: string;
  21915. /**
  21916. * Gets the emitted compilation strings
  21917. */
  21918. compilationString: string;
  21919. /**
  21920. * Finalize the compilation strings
  21921. * @param state defines the current compilation state
  21922. */
  21923. finalize(state: NodeMaterialBuildState): void;
  21924. /** @hidden */
  21925. get _repeatableContentAnchor(): string;
  21926. /** @hidden */
  21927. _getFreeVariableName(prefix: string): string;
  21928. /** @hidden */
  21929. _getFreeDefineName(prefix: string): string;
  21930. /** @hidden */
  21931. _excludeVariableName(name: string): void;
  21932. /** @hidden */
  21933. _emit2DSampler(name: string): void;
  21934. /** @hidden */
  21935. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  21936. /** @hidden */
  21937. _emitExtension(name: string, extension: string, define?: string): void;
  21938. /** @hidden */
  21939. _emitFunction(name: string, code: string, comments: string): void;
  21940. /** @hidden */
  21941. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  21942. replaceStrings?: {
  21943. search: RegExp;
  21944. replace: string;
  21945. }[];
  21946. repeatKey?: string;
  21947. }): string;
  21948. /** @hidden */
  21949. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  21950. repeatKey?: string;
  21951. removeAttributes?: boolean;
  21952. removeUniforms?: boolean;
  21953. removeVaryings?: boolean;
  21954. removeIfDef?: boolean;
  21955. replaceStrings?: {
  21956. search: RegExp;
  21957. replace: string;
  21958. }[];
  21959. }, storeKey?: string): void;
  21960. /** @hidden */
  21961. _registerTempVariable(name: string): boolean;
  21962. /** @hidden */
  21963. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  21964. /** @hidden */
  21965. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  21966. /** @hidden */
  21967. _emitFloat(value: number): string;
  21968. }
  21969. }
  21970. declare module "babylonjs/Misc/uniqueIdGenerator" {
  21971. /**
  21972. * Helper class used to generate session unique ID
  21973. */
  21974. export class UniqueIdGenerator {
  21975. private static _UniqueIdCounter;
  21976. /**
  21977. * Gets an unique (relatively to the current scene) Id
  21978. */
  21979. static get UniqueId(): number;
  21980. }
  21981. }
  21982. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  21983. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21984. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21985. import { Nullable } from "babylonjs/types";
  21986. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21987. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21988. import { Effect } from "babylonjs/Materials/effect";
  21989. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21990. import { Mesh } from "babylonjs/Meshes/mesh";
  21991. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21992. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21993. import { Scene } from "babylonjs/scene";
  21994. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  21995. /**
  21996. * Defines a block that can be used inside a node based material
  21997. */
  21998. export class NodeMaterialBlock {
  21999. private _buildId;
  22000. private _buildTarget;
  22001. private _target;
  22002. private _isFinalMerger;
  22003. private _isInput;
  22004. protected _isUnique: boolean;
  22005. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  22006. inputsAreExclusive: boolean;
  22007. /** @hidden */
  22008. _codeVariableName: string;
  22009. /** @hidden */
  22010. _inputs: NodeMaterialConnectionPoint[];
  22011. /** @hidden */
  22012. _outputs: NodeMaterialConnectionPoint[];
  22013. /** @hidden */
  22014. _preparationId: number;
  22015. /**
  22016. * Gets or sets the name of the block
  22017. */
  22018. name: string;
  22019. /**
  22020. * Gets or sets the unique id of the node
  22021. */
  22022. uniqueId: number;
  22023. /**
  22024. * Gets or sets the comments associated with this block
  22025. */
  22026. comments: string;
  22027. /**
  22028. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  22029. */
  22030. get isUnique(): boolean;
  22031. /**
  22032. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  22033. */
  22034. get isFinalMerger(): boolean;
  22035. /**
  22036. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  22037. */
  22038. get isInput(): boolean;
  22039. /**
  22040. * Gets or sets the build Id
  22041. */
  22042. get buildId(): number;
  22043. set buildId(value: number);
  22044. /**
  22045. * Gets or sets the target of the block
  22046. */
  22047. get target(): NodeMaterialBlockTargets;
  22048. set target(value: NodeMaterialBlockTargets);
  22049. /**
  22050. * Gets the list of input points
  22051. */
  22052. get inputs(): NodeMaterialConnectionPoint[];
  22053. /** Gets the list of output points */
  22054. get outputs(): NodeMaterialConnectionPoint[];
  22055. /**
  22056. * Find an input by its name
  22057. * @param name defines the name of the input to look for
  22058. * @returns the input or null if not found
  22059. */
  22060. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22061. /**
  22062. * Find an output by its name
  22063. * @param name defines the name of the outputto look for
  22064. * @returns the output or null if not found
  22065. */
  22066. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22067. /**
  22068. * Creates a new NodeMaterialBlock
  22069. * @param name defines the block name
  22070. * @param target defines the target of that block (Vertex by default)
  22071. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  22072. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  22073. */
  22074. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  22075. /**
  22076. * Initialize the block and prepare the context for build
  22077. * @param state defines the state that will be used for the build
  22078. */
  22079. initialize(state: NodeMaterialBuildState): void;
  22080. /**
  22081. * Bind data to effect. Will only be called for blocks with isBindable === true
  22082. * @param effect defines the effect to bind data to
  22083. * @param nodeMaterial defines the hosting NodeMaterial
  22084. * @param mesh defines the mesh that will be rendered
  22085. * @param subMesh defines the submesh that will be rendered
  22086. */
  22087. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  22088. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  22089. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  22090. protected _writeFloat(value: number): string;
  22091. /**
  22092. * Gets the current class name e.g. "NodeMaterialBlock"
  22093. * @returns the class name
  22094. */
  22095. getClassName(): string;
  22096. /**
  22097. * Register a new input. Must be called inside a block constructor
  22098. * @param name defines the connection point name
  22099. * @param type defines the connection point type
  22100. * @param isOptional defines a boolean indicating that this input can be omitted
  22101. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22102. * @param point an already created connection point. If not provided, create a new one
  22103. * @returns the current block
  22104. */
  22105. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22106. /**
  22107. * Register a new output. Must be called inside a block constructor
  22108. * @param name defines the connection point name
  22109. * @param type defines the connection point type
  22110. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22111. * @param point an already created connection point. If not provided, create a new one
  22112. * @returns the current block
  22113. */
  22114. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22115. /**
  22116. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  22117. * @param forOutput defines an optional connection point to check compatibility with
  22118. * @returns the first available input or null
  22119. */
  22120. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  22121. /**
  22122. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  22123. * @param forBlock defines an optional block to check compatibility with
  22124. * @returns the first available input or null
  22125. */
  22126. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  22127. /**
  22128. * Gets the sibling of the given output
  22129. * @param current defines the current output
  22130. * @returns the next output in the list or null
  22131. */
  22132. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  22133. /**
  22134. * Connect current block with another block
  22135. * @param other defines the block to connect with
  22136. * @param options define the various options to help pick the right connections
  22137. * @returns the current block
  22138. */
  22139. connectTo(other: NodeMaterialBlock, options?: {
  22140. input?: string;
  22141. output?: string;
  22142. outputSwizzle?: string;
  22143. }): this | undefined;
  22144. protected _buildBlock(state: NodeMaterialBuildState): void;
  22145. /**
  22146. * Add uniforms, samplers and uniform buffers at compilation time
  22147. * @param state defines the state to update
  22148. * @param nodeMaterial defines the node material requesting the update
  22149. * @param defines defines the material defines to update
  22150. * @param uniformBuffers defines the list of uniform buffer names
  22151. */
  22152. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  22153. /**
  22154. * Add potential fallbacks if shader compilation fails
  22155. * @param mesh defines the mesh to be rendered
  22156. * @param fallbacks defines the current prioritized list of fallbacks
  22157. */
  22158. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  22159. /**
  22160. * Initialize defines for shader compilation
  22161. * @param mesh defines the mesh to be rendered
  22162. * @param nodeMaterial defines the node material requesting the update
  22163. * @param defines defines the material defines to update
  22164. * @param useInstances specifies that instances should be used
  22165. */
  22166. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  22167. /**
  22168. * Update defines for shader compilation
  22169. * @param mesh defines the mesh to be rendered
  22170. * @param nodeMaterial defines the node material requesting the update
  22171. * @param defines defines the material defines to update
  22172. * @param useInstances specifies that instances should be used
  22173. * @param subMesh defines which submesh to render
  22174. */
  22175. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22176. /**
  22177. * Lets the block try to connect some inputs automatically
  22178. * @param material defines the hosting NodeMaterial
  22179. */
  22180. autoConfigure(material: NodeMaterial): void;
  22181. /**
  22182. * Function called when a block is declared as repeatable content generator
  22183. * @param vertexShaderState defines the current compilation state for the vertex shader
  22184. * @param fragmentShaderState defines the current compilation state for the fragment shader
  22185. * @param mesh defines the mesh to be rendered
  22186. * @param defines defines the material defines to update
  22187. */
  22188. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  22189. /**
  22190. * Checks if the block is ready
  22191. * @param mesh defines the mesh to be rendered
  22192. * @param nodeMaterial defines the node material requesting the update
  22193. * @param defines defines the material defines to update
  22194. * @param useInstances specifies that instances should be used
  22195. * @returns true if the block is ready
  22196. */
  22197. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  22198. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  22199. private _processBuild;
  22200. /**
  22201. * Compile the current node and generate the shader code
  22202. * @param state defines the current compilation state (uniforms, samplers, current string)
  22203. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  22204. * @returns true if already built
  22205. */
  22206. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  22207. protected _inputRename(name: string): string;
  22208. protected _outputRename(name: string): string;
  22209. protected _dumpPropertiesCode(): string;
  22210. /** @hidden */
  22211. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  22212. /** @hidden */
  22213. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  22214. /**
  22215. * Clone the current block to a new identical block
  22216. * @param scene defines the hosting scene
  22217. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22218. * @returns a copy of the current block
  22219. */
  22220. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  22221. /**
  22222. * Serializes this block in a JSON representation
  22223. * @returns the serialized block object
  22224. */
  22225. serialize(): any;
  22226. /** @hidden */
  22227. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22228. private _deserializePortDisplayNames;
  22229. /**
  22230. * Release resources
  22231. */
  22232. dispose(): void;
  22233. }
  22234. }
  22235. declare module "babylonjs/Materials/pushMaterial" {
  22236. import { Nullable } from "babylonjs/types";
  22237. import { Scene } from "babylonjs/scene";
  22238. import { Matrix } from "babylonjs/Maths/math.vector";
  22239. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22240. import { Mesh } from "babylonjs/Meshes/mesh";
  22241. import { Material } from "babylonjs/Materials/material";
  22242. import { Effect } from "babylonjs/Materials/effect";
  22243. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22244. /**
  22245. * Base class of materials working in push mode in babylon JS
  22246. * @hidden
  22247. */
  22248. export class PushMaterial extends Material {
  22249. protected _activeEffect: Effect;
  22250. protected _normalMatrix: Matrix;
  22251. /**
  22252. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  22253. * This means that the material can keep using a previous shader while a new one is being compiled.
  22254. * This is mostly used when shader parallel compilation is supported (true by default)
  22255. */
  22256. allowShaderHotSwapping: boolean;
  22257. constructor(name: string, scene: Scene);
  22258. getEffect(): Effect;
  22259. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22260. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  22261. /**
  22262. * Binds the given world matrix to the active effect
  22263. *
  22264. * @param world the matrix to bind
  22265. */
  22266. bindOnlyWorldMatrix(world: Matrix): void;
  22267. /**
  22268. * Binds the given normal matrix to the active effect
  22269. *
  22270. * @param normalMatrix the matrix to bind
  22271. */
  22272. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  22273. bind(world: Matrix, mesh?: Mesh): void;
  22274. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  22275. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  22276. }
  22277. }
  22278. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  22279. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22280. /**
  22281. * Root class for all node material optimizers
  22282. */
  22283. export class NodeMaterialOptimizer {
  22284. /**
  22285. * Function used to optimize a NodeMaterial graph
  22286. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  22287. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  22288. */
  22289. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  22290. }
  22291. }
  22292. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  22293. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22294. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22295. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22296. import { Scene } from "babylonjs/scene";
  22297. /**
  22298. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  22299. */
  22300. export class TransformBlock extends NodeMaterialBlock {
  22301. /**
  22302. * Defines the value to use to complement W value to transform it to a Vector4
  22303. */
  22304. complementW: number;
  22305. /**
  22306. * Defines the value to use to complement z value to transform it to a Vector4
  22307. */
  22308. complementZ: number;
  22309. /**
  22310. * Creates a new TransformBlock
  22311. * @param name defines the block name
  22312. */
  22313. constructor(name: string);
  22314. /**
  22315. * Gets the current class name
  22316. * @returns the class name
  22317. */
  22318. getClassName(): string;
  22319. /**
  22320. * Gets the vector input
  22321. */
  22322. get vector(): NodeMaterialConnectionPoint;
  22323. /**
  22324. * Gets the output component
  22325. */
  22326. get output(): NodeMaterialConnectionPoint;
  22327. /**
  22328. * Gets the xyz output component
  22329. */
  22330. get xyz(): NodeMaterialConnectionPoint;
  22331. /**
  22332. * Gets the matrix transform input
  22333. */
  22334. get transform(): NodeMaterialConnectionPoint;
  22335. protected _buildBlock(state: NodeMaterialBuildState): this;
  22336. serialize(): any;
  22337. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22338. protected _dumpPropertiesCode(): string;
  22339. }
  22340. }
  22341. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  22342. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22343. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22344. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22345. /**
  22346. * Block used to output the vertex position
  22347. */
  22348. export class VertexOutputBlock extends NodeMaterialBlock {
  22349. /**
  22350. * Creates a new VertexOutputBlock
  22351. * @param name defines the block name
  22352. */
  22353. constructor(name: string);
  22354. /**
  22355. * Gets the current class name
  22356. * @returns the class name
  22357. */
  22358. getClassName(): string;
  22359. /**
  22360. * Gets the vector input component
  22361. */
  22362. get vector(): NodeMaterialConnectionPoint;
  22363. protected _buildBlock(state: NodeMaterialBuildState): this;
  22364. }
  22365. }
  22366. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  22367. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22368. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22369. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22370. /**
  22371. * Block used to output the final color
  22372. */
  22373. export class FragmentOutputBlock extends NodeMaterialBlock {
  22374. /**
  22375. * Create a new FragmentOutputBlock
  22376. * @param name defines the block name
  22377. */
  22378. constructor(name: string);
  22379. /**
  22380. * Gets the current class name
  22381. * @returns the class name
  22382. */
  22383. getClassName(): string;
  22384. /**
  22385. * Gets the rgba input component
  22386. */
  22387. get rgba(): NodeMaterialConnectionPoint;
  22388. /**
  22389. * Gets the rgb input component
  22390. */
  22391. get rgb(): NodeMaterialConnectionPoint;
  22392. /**
  22393. * Gets the a input component
  22394. */
  22395. get a(): NodeMaterialConnectionPoint;
  22396. protected _buildBlock(state: NodeMaterialBuildState): this;
  22397. }
  22398. }
  22399. declare module "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock" {
  22400. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22401. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22402. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22403. /**
  22404. * Block used for the particle ramp gradient section
  22405. */
  22406. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  22407. /**
  22408. * Create a new ParticleRampGradientBlock
  22409. * @param name defines the block name
  22410. */
  22411. constructor(name: string);
  22412. /**
  22413. * Gets the current class name
  22414. * @returns the class name
  22415. */
  22416. getClassName(): string;
  22417. /**
  22418. * Gets the color input component
  22419. */
  22420. get color(): NodeMaterialConnectionPoint;
  22421. /**
  22422. * Gets the rampColor output component
  22423. */
  22424. get rampColor(): NodeMaterialConnectionPoint;
  22425. /**
  22426. * Initialize the block and prepare the context for build
  22427. * @param state defines the state that will be used for the build
  22428. */
  22429. initialize(state: NodeMaterialBuildState): void;
  22430. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22431. }
  22432. }
  22433. declare module "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock" {
  22434. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22435. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22436. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22437. /**
  22438. * Block used for the particle blend multiply section
  22439. */
  22440. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  22441. /**
  22442. * Create a new ParticleBlendMultiplyBlock
  22443. * @param name defines the block name
  22444. */
  22445. constructor(name: string);
  22446. /**
  22447. * Gets the current class name
  22448. * @returns the class name
  22449. */
  22450. getClassName(): string;
  22451. /**
  22452. * Gets the color input component
  22453. */
  22454. get color(): NodeMaterialConnectionPoint;
  22455. /**
  22456. * Gets the alphaTexture input component
  22457. */
  22458. get alphaTexture(): NodeMaterialConnectionPoint;
  22459. /**
  22460. * Gets the alphaColor input component
  22461. */
  22462. get alphaColor(): NodeMaterialConnectionPoint;
  22463. /**
  22464. * Gets the blendColor output component
  22465. */
  22466. get blendColor(): NodeMaterialConnectionPoint;
  22467. /**
  22468. * Initialize the block and prepare the context for build
  22469. * @param state defines the state that will be used for the build
  22470. */
  22471. initialize(state: NodeMaterialBuildState): void;
  22472. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22473. }
  22474. }
  22475. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  22476. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22477. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22478. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22479. /**
  22480. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  22481. */
  22482. export class VectorMergerBlock extends NodeMaterialBlock {
  22483. /**
  22484. * Create a new VectorMergerBlock
  22485. * @param name defines the block name
  22486. */
  22487. constructor(name: string);
  22488. /**
  22489. * Gets the current class name
  22490. * @returns the class name
  22491. */
  22492. getClassName(): string;
  22493. /**
  22494. * Gets the xyz component (input)
  22495. */
  22496. get xyzIn(): NodeMaterialConnectionPoint;
  22497. /**
  22498. * Gets the xy component (input)
  22499. */
  22500. get xyIn(): NodeMaterialConnectionPoint;
  22501. /**
  22502. * Gets the x component (input)
  22503. */
  22504. get x(): NodeMaterialConnectionPoint;
  22505. /**
  22506. * Gets the y component (input)
  22507. */
  22508. get y(): NodeMaterialConnectionPoint;
  22509. /**
  22510. * Gets the z component (input)
  22511. */
  22512. get z(): NodeMaterialConnectionPoint;
  22513. /**
  22514. * Gets the w component (input)
  22515. */
  22516. get w(): NodeMaterialConnectionPoint;
  22517. /**
  22518. * Gets the xyzw component (output)
  22519. */
  22520. get xyzw(): NodeMaterialConnectionPoint;
  22521. /**
  22522. * Gets the xyz component (output)
  22523. */
  22524. get xyzOut(): NodeMaterialConnectionPoint;
  22525. /**
  22526. * Gets the xy component (output)
  22527. */
  22528. get xyOut(): NodeMaterialConnectionPoint;
  22529. /**
  22530. * Gets the xy component (output)
  22531. * @deprecated Please use xyOut instead.
  22532. */
  22533. get xy(): NodeMaterialConnectionPoint;
  22534. /**
  22535. * Gets the xyz component (output)
  22536. * @deprecated Please use xyzOut instead.
  22537. */
  22538. get xyz(): NodeMaterialConnectionPoint;
  22539. protected _buildBlock(state: NodeMaterialBuildState): this;
  22540. }
  22541. }
  22542. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  22543. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22544. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22545. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22546. import { Vector2 } from "babylonjs/Maths/math.vector";
  22547. import { Scene } from "babylonjs/scene";
  22548. /**
  22549. * Block used to remap a float from a range to a new one
  22550. */
  22551. export class RemapBlock extends NodeMaterialBlock {
  22552. /**
  22553. * Gets or sets the source range
  22554. */
  22555. sourceRange: Vector2;
  22556. /**
  22557. * Gets or sets the target range
  22558. */
  22559. targetRange: Vector2;
  22560. /**
  22561. * Creates a new RemapBlock
  22562. * @param name defines the block name
  22563. */
  22564. constructor(name: string);
  22565. /**
  22566. * Gets the current class name
  22567. * @returns the class name
  22568. */
  22569. getClassName(): string;
  22570. /**
  22571. * Gets the input component
  22572. */
  22573. get input(): NodeMaterialConnectionPoint;
  22574. /**
  22575. * Gets the source min input component
  22576. */
  22577. get sourceMin(): NodeMaterialConnectionPoint;
  22578. /**
  22579. * Gets the source max input component
  22580. */
  22581. get sourceMax(): NodeMaterialConnectionPoint;
  22582. /**
  22583. * Gets the target min input component
  22584. */
  22585. get targetMin(): NodeMaterialConnectionPoint;
  22586. /**
  22587. * Gets the target max input component
  22588. */
  22589. get targetMax(): NodeMaterialConnectionPoint;
  22590. /**
  22591. * Gets the output component
  22592. */
  22593. get output(): NodeMaterialConnectionPoint;
  22594. protected _buildBlock(state: NodeMaterialBuildState): this;
  22595. protected _dumpPropertiesCode(): string;
  22596. serialize(): any;
  22597. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22598. }
  22599. }
  22600. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  22601. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22602. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22603. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22604. /**
  22605. * Block used to multiply 2 values
  22606. */
  22607. export class MultiplyBlock extends NodeMaterialBlock {
  22608. /**
  22609. * Creates a new MultiplyBlock
  22610. * @param name defines the block name
  22611. */
  22612. constructor(name: string);
  22613. /**
  22614. * Gets the current class name
  22615. * @returns the class name
  22616. */
  22617. getClassName(): string;
  22618. /**
  22619. * Gets the left operand input component
  22620. */
  22621. get left(): NodeMaterialConnectionPoint;
  22622. /**
  22623. * Gets the right operand input component
  22624. */
  22625. get right(): NodeMaterialConnectionPoint;
  22626. /**
  22627. * Gets the output component
  22628. */
  22629. get output(): NodeMaterialConnectionPoint;
  22630. protected _buildBlock(state: NodeMaterialBuildState): this;
  22631. }
  22632. }
  22633. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  22634. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22635. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22636. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22637. /**
  22638. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  22639. */
  22640. export class ColorSplitterBlock extends NodeMaterialBlock {
  22641. /**
  22642. * Create a new ColorSplitterBlock
  22643. * @param name defines the block name
  22644. */
  22645. constructor(name: string);
  22646. /**
  22647. * Gets the current class name
  22648. * @returns the class name
  22649. */
  22650. getClassName(): string;
  22651. /**
  22652. * Gets the rgba component (input)
  22653. */
  22654. get rgba(): NodeMaterialConnectionPoint;
  22655. /**
  22656. * Gets the rgb component (input)
  22657. */
  22658. get rgbIn(): NodeMaterialConnectionPoint;
  22659. /**
  22660. * Gets the rgb component (output)
  22661. */
  22662. get rgbOut(): NodeMaterialConnectionPoint;
  22663. /**
  22664. * Gets the r component (output)
  22665. */
  22666. get r(): NodeMaterialConnectionPoint;
  22667. /**
  22668. * Gets the g component (output)
  22669. */
  22670. get g(): NodeMaterialConnectionPoint;
  22671. /**
  22672. * Gets the b component (output)
  22673. */
  22674. get b(): NodeMaterialConnectionPoint;
  22675. /**
  22676. * Gets the a component (output)
  22677. */
  22678. get a(): NodeMaterialConnectionPoint;
  22679. protected _inputRename(name: string): string;
  22680. protected _outputRename(name: string): string;
  22681. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22682. }
  22683. }
  22684. declare module "babylonjs/Materials/Node/nodeMaterial" {
  22685. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22686. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  22687. import { Scene } from "babylonjs/scene";
  22688. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22689. import { Matrix } from "babylonjs/Maths/math.vector";
  22690. import { Mesh } from "babylonjs/Meshes/mesh";
  22691. import { Engine } from "babylonjs/Engines/engine";
  22692. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22693. import { Observable } from "babylonjs/Misc/observable";
  22694. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22695. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22696. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  22697. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  22698. import { Nullable } from "babylonjs/types";
  22699. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  22700. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  22701. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  22702. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  22703. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  22704. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  22705. import { Effect } from "babylonjs/Materials/effect";
  22706. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  22707. import { Camera } from "babylonjs/Cameras/camera";
  22708. import { NodeMaterialModes } from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  22709. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  22710. /**
  22711. * Interface used to configure the node material editor
  22712. */
  22713. export interface INodeMaterialEditorOptions {
  22714. /** Define the URl to load node editor script */
  22715. editorURL?: string;
  22716. }
  22717. /** @hidden */
  22718. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  22719. NORMAL: boolean;
  22720. TANGENT: boolean;
  22721. UV1: boolean;
  22722. /** BONES */
  22723. NUM_BONE_INFLUENCERS: number;
  22724. BonesPerMesh: number;
  22725. BONETEXTURE: boolean;
  22726. /** MORPH TARGETS */
  22727. MORPHTARGETS: boolean;
  22728. MORPHTARGETS_NORMAL: boolean;
  22729. MORPHTARGETS_TANGENT: boolean;
  22730. MORPHTARGETS_UV: boolean;
  22731. NUM_MORPH_INFLUENCERS: number;
  22732. /** IMAGE PROCESSING */
  22733. IMAGEPROCESSING: boolean;
  22734. VIGNETTE: boolean;
  22735. VIGNETTEBLENDMODEMULTIPLY: boolean;
  22736. VIGNETTEBLENDMODEOPAQUE: boolean;
  22737. TONEMAPPING: boolean;
  22738. TONEMAPPING_ACES: boolean;
  22739. CONTRAST: boolean;
  22740. EXPOSURE: boolean;
  22741. COLORCURVES: boolean;
  22742. COLORGRADING: boolean;
  22743. COLORGRADING3D: boolean;
  22744. SAMPLER3DGREENDEPTH: boolean;
  22745. SAMPLER3DBGRMAP: boolean;
  22746. IMAGEPROCESSINGPOSTPROCESS: boolean;
  22747. /** MISC. */
  22748. BUMPDIRECTUV: number;
  22749. constructor();
  22750. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  22751. }
  22752. /**
  22753. * Class used to configure NodeMaterial
  22754. */
  22755. export interface INodeMaterialOptions {
  22756. /**
  22757. * Defines if blocks should emit comments
  22758. */
  22759. emitComments: boolean;
  22760. }
  22761. /**
  22762. * Class used to create a node based material built by assembling shader blocks
  22763. */
  22764. export class NodeMaterial extends PushMaterial {
  22765. private static _BuildIdGenerator;
  22766. private _options;
  22767. private _vertexCompilationState;
  22768. private _fragmentCompilationState;
  22769. private _sharedData;
  22770. private _buildId;
  22771. private _buildWasSuccessful;
  22772. private _cachedWorldViewMatrix;
  22773. private _cachedWorldViewProjectionMatrix;
  22774. private _optimizers;
  22775. private _animationFrame;
  22776. /** Define the Url to load node editor script */
  22777. static EditorURL: string;
  22778. /** Define the Url to load snippets */
  22779. static SnippetUrl: string;
  22780. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  22781. static IgnoreTexturesAtLoadTime: boolean;
  22782. private BJSNODEMATERIALEDITOR;
  22783. /** Get the inspector from bundle or global */
  22784. private _getGlobalNodeMaterialEditor;
  22785. /**
  22786. * Snippet ID if the material was created from the snippet server
  22787. */
  22788. snippetId: string;
  22789. /**
  22790. * Gets or sets data used by visual editor
  22791. * @see https://nme.babylonjs.com
  22792. */
  22793. editorData: any;
  22794. /**
  22795. * 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)
  22796. */
  22797. ignoreAlpha: boolean;
  22798. /**
  22799. * Defines the maximum number of lights that can be used in the material
  22800. */
  22801. maxSimultaneousLights: number;
  22802. /**
  22803. * Observable raised when the material is built
  22804. */
  22805. onBuildObservable: Observable<NodeMaterial>;
  22806. /**
  22807. * Gets or sets the root nodes of the material vertex shader
  22808. */
  22809. _vertexOutputNodes: NodeMaterialBlock[];
  22810. /**
  22811. * Gets or sets the root nodes of the material fragment (pixel) shader
  22812. */
  22813. _fragmentOutputNodes: NodeMaterialBlock[];
  22814. /** Gets or sets options to control the node material overall behavior */
  22815. get options(): INodeMaterialOptions;
  22816. set options(options: INodeMaterialOptions);
  22817. /**
  22818. * Default configuration related to image processing available in the standard Material.
  22819. */
  22820. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22821. /**
  22822. * Gets the image processing configuration used either in this material.
  22823. */
  22824. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22825. /**
  22826. * Sets the Default image processing configuration used either in the this material.
  22827. *
  22828. * If sets to null, the scene one is in use.
  22829. */
  22830. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22831. /**
  22832. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  22833. */
  22834. attachedBlocks: NodeMaterialBlock[];
  22835. /**
  22836. * Specifies the mode of the node material
  22837. * @hidden
  22838. */
  22839. _mode: NodeMaterialModes;
  22840. /**
  22841. * Gets the mode property
  22842. */
  22843. get mode(): NodeMaterialModes;
  22844. /**
  22845. * Create a new node based material
  22846. * @param name defines the material name
  22847. * @param scene defines the hosting scene
  22848. * @param options defines creation option
  22849. */
  22850. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  22851. /**
  22852. * Gets the current class name of the material e.g. "NodeMaterial"
  22853. * @returns the class name
  22854. */
  22855. getClassName(): string;
  22856. /**
  22857. * Keep track of the image processing observer to allow dispose and replace.
  22858. */
  22859. private _imageProcessingObserver;
  22860. /**
  22861. * Attaches a new image processing configuration to the Standard Material.
  22862. * @param configuration
  22863. */
  22864. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22865. /**
  22866. * Get a block by its name
  22867. * @param name defines the name of the block to retrieve
  22868. * @returns the required block or null if not found
  22869. */
  22870. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  22871. /**
  22872. * Get a block by its name
  22873. * @param predicate defines the predicate used to find the good candidate
  22874. * @returns the required block or null if not found
  22875. */
  22876. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  22877. /**
  22878. * Get an input block by its name
  22879. * @param predicate defines the predicate used to find the good candidate
  22880. * @returns the required input block or null if not found
  22881. */
  22882. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  22883. /**
  22884. * Gets the list of input blocks attached to this material
  22885. * @returns an array of InputBlocks
  22886. */
  22887. getInputBlocks(): InputBlock[];
  22888. /**
  22889. * Adds a new optimizer to the list of optimizers
  22890. * @param optimizer defines the optimizers to add
  22891. * @returns the current material
  22892. */
  22893. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22894. /**
  22895. * Remove an optimizer from the list of optimizers
  22896. * @param optimizer defines the optimizers to remove
  22897. * @returns the current material
  22898. */
  22899. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22900. /**
  22901. * Add a new block to the list of output nodes
  22902. * @param node defines the node to add
  22903. * @returns the current material
  22904. */
  22905. addOutputNode(node: NodeMaterialBlock): this;
  22906. /**
  22907. * Remove a block from the list of root nodes
  22908. * @param node defines the node to remove
  22909. * @returns the current material
  22910. */
  22911. removeOutputNode(node: NodeMaterialBlock): this;
  22912. private _addVertexOutputNode;
  22913. private _removeVertexOutputNode;
  22914. private _addFragmentOutputNode;
  22915. private _removeFragmentOutputNode;
  22916. /**
  22917. * Specifies if the material will require alpha blending
  22918. * @returns a boolean specifying if alpha blending is needed
  22919. */
  22920. needAlphaBlending(): boolean;
  22921. /**
  22922. * Specifies if this material should be rendered in alpha test mode
  22923. * @returns a boolean specifying if an alpha test is needed.
  22924. */
  22925. needAlphaTesting(): boolean;
  22926. private _initializeBlock;
  22927. private _resetDualBlocks;
  22928. /**
  22929. * Remove a block from the current node material
  22930. * @param block defines the block to remove
  22931. */
  22932. removeBlock(block: NodeMaterialBlock): void;
  22933. /**
  22934. * Build the material and generates the inner effect
  22935. * @param verbose defines if the build should log activity
  22936. */
  22937. build(verbose?: boolean): void;
  22938. /**
  22939. * Runs an otpimization phase to try to improve the shader code
  22940. */
  22941. optimize(): void;
  22942. private _prepareDefinesForAttributes;
  22943. /**
  22944. * Create a post process from the material
  22945. * @param camera The camera to apply the render pass to.
  22946. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22947. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22948. * @param engine The engine which the post process will be applied. (default: current engine)
  22949. * @param reusable If the post process can be reused on the same frame. (default: false)
  22950. * @param textureType Type of textures used when performing the post process. (default: 0)
  22951. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22952. * @returns the post process created
  22953. */
  22954. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  22955. /**
  22956. * Create the post process effect from the material
  22957. * @param postProcess The post process to create the effect for
  22958. */
  22959. createEffectForPostProcess(postProcess: PostProcess): void;
  22960. private _createEffectOrPostProcess;
  22961. private _createEffectForParticles;
  22962. /**
  22963. * Create the effect to be used as the custom effect for a particle system
  22964. * @param particleSystem Particle system to create the effect for
  22965. * @param onCompiled defines a function to call when the effect creation is successful
  22966. * @param onError defines a function to call when the effect creation has failed
  22967. */
  22968. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22969. private _processDefines;
  22970. /**
  22971. * Get if the submesh is ready to be used and all its information available.
  22972. * Child classes can use it to update shaders
  22973. * @param mesh defines the mesh to check
  22974. * @param subMesh defines which submesh to check
  22975. * @param useInstances specifies that instances should be used
  22976. * @returns a boolean indicating that the submesh is ready or not
  22977. */
  22978. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22979. /**
  22980. * Get a string representing the shaders built by the current node graph
  22981. */
  22982. get compiledShaders(): string;
  22983. /**
  22984. * Binds the world matrix to the material
  22985. * @param world defines the world transformation matrix
  22986. */
  22987. bindOnlyWorldMatrix(world: Matrix): void;
  22988. /**
  22989. * Binds the submesh to this material by preparing the effect and shader to draw
  22990. * @param world defines the world transformation matrix
  22991. * @param mesh defines the mesh containing the submesh
  22992. * @param subMesh defines the submesh to bind the material to
  22993. */
  22994. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22995. /**
  22996. * Gets the active textures from the material
  22997. * @returns an array of textures
  22998. */
  22999. getActiveTextures(): BaseTexture[];
  23000. /**
  23001. * Gets the list of texture blocks
  23002. * @returns an array of texture blocks
  23003. */
  23004. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  23005. /**
  23006. * Specifies if the material uses a texture
  23007. * @param texture defines the texture to check against the material
  23008. * @returns a boolean specifying if the material uses the texture
  23009. */
  23010. hasTexture(texture: BaseTexture): boolean;
  23011. /**
  23012. * Disposes the material
  23013. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23014. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23015. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  23016. */
  23017. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  23018. /** Creates the node editor window. */
  23019. private _createNodeEditor;
  23020. /**
  23021. * Launch the node material editor
  23022. * @param config Define the configuration of the editor
  23023. * @return a promise fulfilled when the node editor is visible
  23024. */
  23025. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  23026. /**
  23027. * Clear the current material
  23028. */
  23029. clear(): void;
  23030. /**
  23031. * Clear the current material and set it to a default state
  23032. */
  23033. setToDefault(): void;
  23034. /**
  23035. * Clear the current material and set it to a default state for post process
  23036. */
  23037. setToDefaultPostProcess(): void;
  23038. /**
  23039. * Clear the current material and set it to a default state for particle
  23040. */
  23041. setToDefaultParticle(): void;
  23042. /**
  23043. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  23044. * @param url defines the url to load from
  23045. * @returns a promise that will fullfil when the material is fully loaded
  23046. */
  23047. loadAsync(url: string): Promise<void>;
  23048. private _gatherBlocks;
  23049. /**
  23050. * Generate a string containing the code declaration required to create an equivalent of this material
  23051. * @returns a string
  23052. */
  23053. generateCode(): string;
  23054. /**
  23055. * Serializes this material in a JSON representation
  23056. * @returns the serialized material object
  23057. */
  23058. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  23059. private _restoreConnections;
  23060. /**
  23061. * Clear the current graph and load a new one from a serialization object
  23062. * @param source defines the JSON representation of the material
  23063. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23064. */
  23065. loadFromSerialization(source: any, rootUrl?: string): void;
  23066. /**
  23067. * Makes a duplicate of the current material.
  23068. * @param name - name to use for the new material.
  23069. */
  23070. clone(name: string): NodeMaterial;
  23071. /**
  23072. * Creates a node material from parsed material data
  23073. * @param source defines the JSON representation of the material
  23074. * @param scene defines the hosting scene
  23075. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23076. * @returns a new node material
  23077. */
  23078. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  23079. /**
  23080. * Creates a node material from a snippet saved in a remote file
  23081. * @param name defines the name of the material to create
  23082. * @param url defines the url to load from
  23083. * @param scene defines the hosting scene
  23084. * @returns a promise that will resolve to the new node material
  23085. */
  23086. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  23087. /**
  23088. * Creates a node material from a snippet saved by the node material editor
  23089. * @param snippetId defines the snippet to load
  23090. * @param scene defines the hosting scene
  23091. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23092. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  23093. * @returns a promise that will resolve to the new node material
  23094. */
  23095. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  23096. /**
  23097. * Creates a new node material set to default basic configuration
  23098. * @param name defines the name of the material
  23099. * @param scene defines the hosting scene
  23100. * @returns a new NodeMaterial
  23101. */
  23102. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  23103. }
  23104. }
  23105. declare module "babylonjs/PostProcesses/postProcess" {
  23106. import { Nullable } from "babylonjs/types";
  23107. import { SmartArray } from "babylonjs/Misc/smartArray";
  23108. import { Observable } from "babylonjs/Misc/observable";
  23109. import { Vector2 } from "babylonjs/Maths/math.vector";
  23110. import { Camera } from "babylonjs/Cameras/camera";
  23111. import { Effect } from "babylonjs/Materials/effect";
  23112. import "babylonjs/Shaders/postprocess.vertex";
  23113. import { IInspectable } from "babylonjs/Misc/iInspectable";
  23114. import { Engine } from "babylonjs/Engines/engine";
  23115. import { Color4 } from "babylonjs/Maths/math.color";
  23116. import "babylonjs/Engines/Extensions/engine.renderTarget";
  23117. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  23118. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23119. /**
  23120. * Size options for a post process
  23121. */
  23122. export type PostProcessOptions = {
  23123. width: number;
  23124. height: number;
  23125. };
  23126. /**
  23127. * PostProcess can be used to apply a shader to a texture after it has been rendered
  23128. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23129. */
  23130. export class PostProcess {
  23131. /** Name of the PostProcess. */
  23132. name: string;
  23133. /**
  23134. * Gets or sets the unique id of the post process
  23135. */
  23136. uniqueId: number;
  23137. /**
  23138. * Width of the texture to apply the post process on
  23139. */
  23140. width: number;
  23141. /**
  23142. * Height of the texture to apply the post process on
  23143. */
  23144. height: number;
  23145. /**
  23146. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  23147. */
  23148. nodeMaterialSource: Nullable<NodeMaterial>;
  23149. /**
  23150. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  23151. * @hidden
  23152. */
  23153. _outputTexture: Nullable<InternalTexture>;
  23154. /**
  23155. * Sampling mode used by the shader
  23156. * See https://doc.babylonjs.com/classes/3.1/texture
  23157. */
  23158. renderTargetSamplingMode: number;
  23159. /**
  23160. * Clear color to use when screen clearing
  23161. */
  23162. clearColor: Color4;
  23163. /**
  23164. * If the buffer needs to be cleared before applying the post process. (default: true)
  23165. * Should be set to false if shader will overwrite all previous pixels.
  23166. */
  23167. autoClear: boolean;
  23168. /**
  23169. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  23170. */
  23171. alphaMode: number;
  23172. /**
  23173. * Sets the setAlphaBlendConstants of the babylon engine
  23174. */
  23175. alphaConstants: Color4;
  23176. /**
  23177. * Animations to be used for the post processing
  23178. */
  23179. animations: import("babylonjs/Animations/animation").Animation[];
  23180. /**
  23181. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  23182. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  23183. */
  23184. enablePixelPerfectMode: boolean;
  23185. /**
  23186. * Force the postprocess to be applied without taking in account viewport
  23187. */
  23188. forceFullscreenViewport: boolean;
  23189. /**
  23190. * List of inspectable custom properties (used by the Inspector)
  23191. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23192. */
  23193. inspectableCustomProperties: IInspectable[];
  23194. /**
  23195. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  23196. *
  23197. * | Value | Type | Description |
  23198. * | ----- | ----------------------------------- | ----------- |
  23199. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  23200. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  23201. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  23202. *
  23203. */
  23204. scaleMode: number;
  23205. /**
  23206. * Force textures to be a power of two (default: false)
  23207. */
  23208. alwaysForcePOT: boolean;
  23209. private _samples;
  23210. /**
  23211. * Number of sample textures (default: 1)
  23212. */
  23213. get samples(): number;
  23214. set samples(n: number);
  23215. /**
  23216. * Modify the scale of the post process to be the same as the viewport (default: false)
  23217. */
  23218. adaptScaleToCurrentViewport: boolean;
  23219. private _camera;
  23220. private _scene;
  23221. private _engine;
  23222. private _options;
  23223. private _reusable;
  23224. private _textureType;
  23225. private _textureFormat;
  23226. /**
  23227. * Smart array of input and output textures for the post process.
  23228. * @hidden
  23229. */
  23230. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  23231. /**
  23232. * The index in _textures that corresponds to the output texture.
  23233. * @hidden
  23234. */
  23235. _currentRenderTextureInd: number;
  23236. private _effect;
  23237. private _samplers;
  23238. private _fragmentUrl;
  23239. private _vertexUrl;
  23240. private _parameters;
  23241. private _scaleRatio;
  23242. protected _indexParameters: any;
  23243. private _shareOutputWithPostProcess;
  23244. private _texelSize;
  23245. private _forcedOutputTexture;
  23246. /**
  23247. * Returns the fragment url or shader name used in the post process.
  23248. * @returns the fragment url or name in the shader store.
  23249. */
  23250. getEffectName(): string;
  23251. /**
  23252. * An event triggered when the postprocess is activated.
  23253. */
  23254. onActivateObservable: Observable<Camera>;
  23255. private _onActivateObserver;
  23256. /**
  23257. * A function that is added to the onActivateObservable
  23258. */
  23259. set onActivate(callback: Nullable<(camera: Camera) => void>);
  23260. /**
  23261. * An event triggered when the postprocess changes its size.
  23262. */
  23263. onSizeChangedObservable: Observable<PostProcess>;
  23264. private _onSizeChangedObserver;
  23265. /**
  23266. * A function that is added to the onSizeChangedObservable
  23267. */
  23268. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  23269. /**
  23270. * An event triggered when the postprocess applies its effect.
  23271. */
  23272. onApplyObservable: Observable<Effect>;
  23273. private _onApplyObserver;
  23274. /**
  23275. * A function that is added to the onApplyObservable
  23276. */
  23277. set onApply(callback: (effect: Effect) => void);
  23278. /**
  23279. * An event triggered before rendering the postprocess
  23280. */
  23281. onBeforeRenderObservable: Observable<Effect>;
  23282. private _onBeforeRenderObserver;
  23283. /**
  23284. * A function that is added to the onBeforeRenderObservable
  23285. */
  23286. set onBeforeRender(callback: (effect: Effect) => void);
  23287. /**
  23288. * An event triggered after rendering the postprocess
  23289. */
  23290. onAfterRenderObservable: Observable<Effect>;
  23291. private _onAfterRenderObserver;
  23292. /**
  23293. * A function that is added to the onAfterRenderObservable
  23294. */
  23295. set onAfterRender(callback: (efect: Effect) => void);
  23296. /**
  23297. * 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
  23298. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  23299. */
  23300. get inputTexture(): InternalTexture;
  23301. set inputTexture(value: InternalTexture);
  23302. /**
  23303. * Gets the camera which post process is applied to.
  23304. * @returns The camera the post process is applied to.
  23305. */
  23306. getCamera(): Camera;
  23307. /**
  23308. * Gets the texel size of the postprocess.
  23309. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  23310. */
  23311. get texelSize(): Vector2;
  23312. /**
  23313. * Creates a new instance PostProcess
  23314. * @param name The name of the PostProcess.
  23315. * @param fragmentUrl The url of the fragment shader to be used.
  23316. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  23317. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  23318. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23319. * @param camera The camera to apply the render pass to.
  23320. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23321. * @param engine The engine which the post process will be applied. (default: current engine)
  23322. * @param reusable If the post process can be reused on the same frame. (default: false)
  23323. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  23324. * @param textureType Type of textures used when performing the post process. (default: 0)
  23325. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  23326. * @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
  23327. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  23328. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23329. */
  23330. constructor(
  23331. /** Name of the PostProcess. */
  23332. 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);
  23333. /**
  23334. * Gets a string idenfifying the name of the class
  23335. * @returns "PostProcess" string
  23336. */
  23337. getClassName(): string;
  23338. /**
  23339. * Gets the engine which this post process belongs to.
  23340. * @returns The engine the post process was enabled with.
  23341. */
  23342. getEngine(): Engine;
  23343. /**
  23344. * The effect that is created when initializing the post process.
  23345. * @returns The created effect corresponding the the postprocess.
  23346. */
  23347. getEffect(): Effect;
  23348. /**
  23349. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  23350. * @param postProcess The post process to share the output with.
  23351. * @returns This post process.
  23352. */
  23353. shareOutputWith(postProcess: PostProcess): PostProcess;
  23354. /**
  23355. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  23356. * This should be called if the post process that shares output with this post process is disabled/disposed.
  23357. */
  23358. useOwnOutput(): void;
  23359. /**
  23360. * Updates the effect with the current post process compile time values and recompiles the shader.
  23361. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23362. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23363. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23364. * @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
  23365. * @param onCompiled Called when the shader has been compiled.
  23366. * @param onError Called if there is an error when compiling a shader.
  23367. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  23368. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  23369. */
  23370. 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;
  23371. /**
  23372. * The post process is reusable if it can be used multiple times within one frame.
  23373. * @returns If the post process is reusable
  23374. */
  23375. isReusable(): boolean;
  23376. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  23377. markTextureDirty(): void;
  23378. /**
  23379. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  23380. * 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.
  23381. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  23382. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  23383. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  23384. * @returns The target texture that was bound to be written to.
  23385. */
  23386. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  23387. /**
  23388. * If the post process is supported.
  23389. */
  23390. get isSupported(): boolean;
  23391. /**
  23392. * The aspect ratio of the output texture.
  23393. */
  23394. get aspectRatio(): number;
  23395. /**
  23396. * Get a value indicating if the post-process is ready to be used
  23397. * @returns true if the post-process is ready (shader is compiled)
  23398. */
  23399. isReady(): boolean;
  23400. /**
  23401. * Binds all textures and uniforms to the shader, this will be run on every pass.
  23402. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  23403. */
  23404. apply(): Nullable<Effect>;
  23405. private _disposeTextures;
  23406. /**
  23407. * Disposes the post process.
  23408. * @param camera The camera to dispose the post process on.
  23409. */
  23410. dispose(camera?: Camera): void;
  23411. }
  23412. }
  23413. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  23414. /** @hidden */
  23415. export var kernelBlurVaryingDeclaration: {
  23416. name: string;
  23417. shader: string;
  23418. };
  23419. }
  23420. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  23421. /** @hidden */
  23422. export var kernelBlurFragment: {
  23423. name: string;
  23424. shader: string;
  23425. };
  23426. }
  23427. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  23428. /** @hidden */
  23429. export var kernelBlurFragment2: {
  23430. name: string;
  23431. shader: string;
  23432. };
  23433. }
  23434. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  23435. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  23436. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  23437. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  23438. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  23439. /** @hidden */
  23440. export var kernelBlurPixelShader: {
  23441. name: string;
  23442. shader: string;
  23443. };
  23444. }
  23445. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  23446. /** @hidden */
  23447. export var kernelBlurVertex: {
  23448. name: string;
  23449. shader: string;
  23450. };
  23451. }
  23452. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  23453. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  23454. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  23455. /** @hidden */
  23456. export var kernelBlurVertexShader: {
  23457. name: string;
  23458. shader: string;
  23459. };
  23460. }
  23461. declare module "babylonjs/PostProcesses/blurPostProcess" {
  23462. import { Vector2 } from "babylonjs/Maths/math.vector";
  23463. import { Nullable } from "babylonjs/types";
  23464. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  23465. import { Camera } from "babylonjs/Cameras/camera";
  23466. import { Effect } from "babylonjs/Materials/effect";
  23467. import { Engine } from "babylonjs/Engines/engine";
  23468. import "babylonjs/Shaders/kernelBlur.fragment";
  23469. import "babylonjs/Shaders/kernelBlur.vertex";
  23470. /**
  23471. * The Blur Post Process which blurs an image based on a kernel and direction.
  23472. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  23473. */
  23474. export class BlurPostProcess extends PostProcess {
  23475. /** The direction in which to blur the image. */
  23476. direction: Vector2;
  23477. private blockCompilation;
  23478. protected _kernel: number;
  23479. protected _idealKernel: number;
  23480. protected _packedFloat: boolean;
  23481. private _staticDefines;
  23482. /**
  23483. * Sets the length in pixels of the blur sample region
  23484. */
  23485. set kernel(v: number);
  23486. /**
  23487. * Gets the length in pixels of the blur sample region
  23488. */
  23489. get kernel(): number;
  23490. /**
  23491. * Sets wether or not the blur needs to unpack/repack floats
  23492. */
  23493. set packedFloat(v: boolean);
  23494. /**
  23495. * Gets wether or not the blur is unpacking/repacking floats
  23496. */
  23497. get packedFloat(): boolean;
  23498. /**
  23499. * Creates a new instance BlurPostProcess
  23500. * @param name The name of the effect.
  23501. * @param direction The direction in which to blur the image.
  23502. * @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.
  23503. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23504. * @param camera The camera to apply the render pass to.
  23505. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23506. * @param engine The engine which the post process will be applied. (default: current engine)
  23507. * @param reusable If the post process can be reused on the same frame. (default: false)
  23508. * @param textureType Type of textures used when performing the post process. (default: 0)
  23509. * @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)
  23510. */
  23511. constructor(name: string,
  23512. /** The direction in which to blur the image. */
  23513. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  23514. /**
  23515. * Updates the effect with the current post process compile time values and recompiles the shader.
  23516. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23517. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23518. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23519. * @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
  23520. * @param onCompiled Called when the shader has been compiled.
  23521. * @param onError Called if there is an error when compiling a shader.
  23522. */
  23523. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23524. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23525. /**
  23526. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  23527. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  23528. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  23529. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  23530. * The gaps between physical kernels are compensated for in the weighting of the samples
  23531. * @param idealKernel Ideal blur kernel.
  23532. * @return Nearest best kernel.
  23533. */
  23534. protected _nearestBestKernel(idealKernel: number): number;
  23535. /**
  23536. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  23537. * @param x The point on the Gaussian distribution to sample.
  23538. * @return the value of the Gaussian function at x.
  23539. */
  23540. protected _gaussianWeight(x: number): number;
  23541. /**
  23542. * Generates a string that can be used as a floating point number in GLSL.
  23543. * @param x Value to print.
  23544. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  23545. * @return GLSL float string.
  23546. */
  23547. protected _glslFloat(x: number, decimalFigures?: number): string;
  23548. }
  23549. }
  23550. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  23551. import { Scene } from "babylonjs/scene";
  23552. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  23553. import { Plane } from "babylonjs/Maths/math.plane";
  23554. /**
  23555. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23556. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23557. * You can then easily use it as a reflectionTexture on a flat surface.
  23558. * In case the surface is not a plane, please consider relying on reflection probes.
  23559. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23560. */
  23561. export class MirrorTexture extends RenderTargetTexture {
  23562. private scene;
  23563. /**
  23564. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  23565. * 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.
  23566. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23567. */
  23568. mirrorPlane: Plane;
  23569. /**
  23570. * Define the blur ratio used to blur the reflection if needed.
  23571. */
  23572. set blurRatio(value: number);
  23573. get blurRatio(): number;
  23574. /**
  23575. * Define the adaptive blur kernel used to blur the reflection if needed.
  23576. * This will autocompute the closest best match for the `blurKernel`
  23577. */
  23578. set adaptiveBlurKernel(value: number);
  23579. /**
  23580. * Define the blur kernel used to blur the reflection if needed.
  23581. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23582. */
  23583. set blurKernel(value: number);
  23584. /**
  23585. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  23586. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23587. */
  23588. set blurKernelX(value: number);
  23589. get blurKernelX(): number;
  23590. /**
  23591. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  23592. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23593. */
  23594. set blurKernelY(value: number);
  23595. get blurKernelY(): number;
  23596. private _autoComputeBlurKernel;
  23597. protected _onRatioRescale(): void;
  23598. private _updateGammaSpace;
  23599. private _imageProcessingConfigChangeObserver;
  23600. private _transformMatrix;
  23601. private _mirrorMatrix;
  23602. private _savedViewMatrix;
  23603. private _blurX;
  23604. private _blurY;
  23605. private _adaptiveBlurKernel;
  23606. private _blurKernelX;
  23607. private _blurKernelY;
  23608. private _blurRatio;
  23609. /**
  23610. * Instantiates a Mirror Texture.
  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. * @param name
  23617. * @param size
  23618. * @param scene
  23619. * @param generateMipMaps
  23620. * @param type
  23621. * @param samplingMode
  23622. * @param generateDepthBuffer
  23623. */
  23624. constructor(name: string, size: number | {
  23625. width: number;
  23626. height: number;
  23627. } | {
  23628. ratio: number;
  23629. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  23630. private _preparePostProcesses;
  23631. /**
  23632. * Clone the mirror texture.
  23633. * @returns the cloned texture
  23634. */
  23635. clone(): MirrorTexture;
  23636. /**
  23637. * Serialize the texture to a JSON representation you could use in Parse later on
  23638. * @returns the serialized JSON representation
  23639. */
  23640. serialize(): any;
  23641. /**
  23642. * Dispose the texture and release its associated resources.
  23643. */
  23644. dispose(): void;
  23645. }
  23646. }
  23647. declare module "babylonjs/Materials/Textures/texture" {
  23648. import { Observable } from "babylonjs/Misc/observable";
  23649. import { Nullable } from "babylonjs/types";
  23650. import { Matrix } from "babylonjs/Maths/math.vector";
  23651. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  23652. import { IInspectable } from "babylonjs/Misc/iInspectable";
  23653. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  23654. import { Scene } from "babylonjs/scene";
  23655. /**
  23656. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23657. * @see http://doc.babylonjs.com/babylon101/materials#texture
  23658. */
  23659. export class Texture extends BaseTexture {
  23660. /**
  23661. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  23662. */
  23663. static SerializeBuffers: boolean;
  23664. /** @hidden */
  23665. static _CubeTextureParser: (jsonTexture: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  23666. /** @hidden */
  23667. static _CreateMirror: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  23668. /** @hidden */
  23669. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  23670. /** nearest is mag = nearest and min = nearest and mip = linear */
  23671. static readonly NEAREST_SAMPLINGMODE: number;
  23672. /** nearest is mag = nearest and min = nearest and mip = linear */
  23673. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  23674. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23675. static readonly BILINEAR_SAMPLINGMODE: number;
  23676. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23677. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  23678. /** Trilinear is mag = linear and min = linear and mip = linear */
  23679. static readonly TRILINEAR_SAMPLINGMODE: number;
  23680. /** Trilinear is mag = linear and min = linear and mip = linear */
  23681. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  23682. /** mag = nearest and min = nearest and mip = nearest */
  23683. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  23684. /** mag = nearest and min = linear and mip = nearest */
  23685. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  23686. /** mag = nearest and min = linear and mip = linear */
  23687. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  23688. /** mag = nearest and min = linear and mip = none */
  23689. static readonly NEAREST_LINEAR: number;
  23690. /** mag = nearest and min = nearest and mip = none */
  23691. static readonly NEAREST_NEAREST: number;
  23692. /** mag = linear and min = nearest and mip = nearest */
  23693. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  23694. /** mag = linear and min = nearest and mip = linear */
  23695. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  23696. /** mag = linear and min = linear and mip = none */
  23697. static readonly LINEAR_LINEAR: number;
  23698. /** mag = linear and min = nearest and mip = none */
  23699. static readonly LINEAR_NEAREST: number;
  23700. /** Explicit coordinates mode */
  23701. static readonly EXPLICIT_MODE: number;
  23702. /** Spherical coordinates mode */
  23703. static readonly SPHERICAL_MODE: number;
  23704. /** Planar coordinates mode */
  23705. static readonly PLANAR_MODE: number;
  23706. /** Cubic coordinates mode */
  23707. static readonly CUBIC_MODE: number;
  23708. /** Projection coordinates mode */
  23709. static readonly PROJECTION_MODE: number;
  23710. /** Inverse Cubic coordinates mode */
  23711. static readonly SKYBOX_MODE: number;
  23712. /** Inverse Cubic coordinates mode */
  23713. static readonly INVCUBIC_MODE: number;
  23714. /** Equirectangular coordinates mode */
  23715. static readonly EQUIRECTANGULAR_MODE: number;
  23716. /** Equirectangular Fixed coordinates mode */
  23717. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  23718. /** Equirectangular Fixed Mirrored coordinates mode */
  23719. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  23720. /** Texture is not repeating outside of 0..1 UVs */
  23721. static readonly CLAMP_ADDRESSMODE: number;
  23722. /** Texture is repeating outside of 0..1 UVs */
  23723. static readonly WRAP_ADDRESSMODE: number;
  23724. /** Texture is repeating and mirrored */
  23725. static readonly MIRROR_ADDRESSMODE: number;
  23726. /**
  23727. * 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
  23728. */
  23729. static UseSerializedUrlIfAny: boolean;
  23730. /**
  23731. * Define the url of the texture.
  23732. */
  23733. url: Nullable<string>;
  23734. /**
  23735. * Define an offset on the texture to offset the u coordinates of the UVs
  23736. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  23737. */
  23738. uOffset: number;
  23739. /**
  23740. * Define an offset on the texture to offset the v coordinates of the UVs
  23741. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  23742. */
  23743. vOffset: number;
  23744. /**
  23745. * Define an offset on the texture to scale the u coordinates of the UVs
  23746. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  23747. */
  23748. uScale: number;
  23749. /**
  23750. * Define an offset on the texture to scale the v coordinates of the UVs
  23751. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  23752. */
  23753. vScale: number;
  23754. /**
  23755. * Define an offset on the texture to rotate around the u coordinates of the UVs
  23756. * @see http://doc.babylonjs.com/how_to/more_materials
  23757. */
  23758. uAng: number;
  23759. /**
  23760. * Define an offset on the texture to rotate around the v coordinates of the UVs
  23761. * @see http://doc.babylonjs.com/how_to/more_materials
  23762. */
  23763. vAng: number;
  23764. /**
  23765. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  23766. * @see http://doc.babylonjs.com/how_to/more_materials
  23767. */
  23768. wAng: number;
  23769. /**
  23770. * Defines the center of rotation (U)
  23771. */
  23772. uRotationCenter: number;
  23773. /**
  23774. * Defines the center of rotation (V)
  23775. */
  23776. vRotationCenter: number;
  23777. /**
  23778. * Defines the center of rotation (W)
  23779. */
  23780. wRotationCenter: number;
  23781. /**
  23782. * Are mip maps generated for this texture or not.
  23783. */
  23784. get noMipmap(): boolean;
  23785. /**
  23786. * List of inspectable custom properties (used by the Inspector)
  23787. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23788. */
  23789. inspectableCustomProperties: Nullable<IInspectable[]>;
  23790. private _noMipmap;
  23791. /** @hidden */
  23792. _invertY: boolean;
  23793. private _rowGenerationMatrix;
  23794. private _cachedTextureMatrix;
  23795. private _projectionModeMatrix;
  23796. private _t0;
  23797. private _t1;
  23798. private _t2;
  23799. private _cachedUOffset;
  23800. private _cachedVOffset;
  23801. private _cachedUScale;
  23802. private _cachedVScale;
  23803. private _cachedUAng;
  23804. private _cachedVAng;
  23805. private _cachedWAng;
  23806. private _cachedProjectionMatrixId;
  23807. private _cachedCoordinatesMode;
  23808. /** @hidden */
  23809. protected _initialSamplingMode: number;
  23810. /** @hidden */
  23811. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  23812. private _deleteBuffer;
  23813. protected _format: Nullable<number>;
  23814. private _delayedOnLoad;
  23815. private _delayedOnError;
  23816. private _mimeType?;
  23817. /**
  23818. * Observable triggered once the texture has been loaded.
  23819. */
  23820. onLoadObservable: Observable<Texture>;
  23821. protected _isBlocking: boolean;
  23822. /**
  23823. * Is the texture preventing material to render while loading.
  23824. * If false, a default texture will be used instead of the loading one during the preparation step.
  23825. */
  23826. set isBlocking(value: boolean);
  23827. get isBlocking(): boolean;
  23828. /**
  23829. * Get the current sampling mode associated with the texture.
  23830. */
  23831. get samplingMode(): number;
  23832. /**
  23833. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  23834. */
  23835. get invertY(): boolean;
  23836. /**
  23837. * Instantiates a new texture.
  23838. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23839. * @see http://doc.babylonjs.com/babylon101/materials#texture
  23840. * @param url defines the url of the picture to load as a texture
  23841. * @param sceneOrEngine defines the scene or engine the texture will belong to
  23842. * @param noMipmap defines if the texture will require mip maps or not
  23843. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  23844. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23845. * @param onLoad defines a callback triggered when the texture has been loaded
  23846. * @param onError defines a callback triggered when an error occurred during the loading session
  23847. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  23848. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  23849. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23850. * @param mimeType defines an optional mime type information
  23851. */
  23852. 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);
  23853. /**
  23854. * Update the url (and optional buffer) of this texture if url was null during construction.
  23855. * @param url the url of the texture
  23856. * @param buffer the buffer of the texture (defaults to null)
  23857. * @param onLoad callback called when the texture is loaded (defaults to null)
  23858. */
  23859. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  23860. /**
  23861. * Finish the loading sequence of a texture flagged as delayed load.
  23862. * @hidden
  23863. */
  23864. delayLoad(): void;
  23865. private _prepareRowForTextureGeneration;
  23866. /**
  23867. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  23868. * @returns the transform matrix of the texture.
  23869. */
  23870. getTextureMatrix(uBase?: number): Matrix;
  23871. /**
  23872. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  23873. * @returns The reflection texture transform
  23874. */
  23875. getReflectionTextureMatrix(): Matrix;
  23876. /**
  23877. * Clones the texture.
  23878. * @returns the cloned texture
  23879. */
  23880. clone(): Texture;
  23881. /**
  23882. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23883. * @returns The JSON representation of the texture
  23884. */
  23885. serialize(): any;
  23886. /**
  23887. * Get the current class name of the texture useful for serialization or dynamic coding.
  23888. * @returns "Texture"
  23889. */
  23890. getClassName(): string;
  23891. /**
  23892. * Dispose the texture and release its associated resources.
  23893. */
  23894. dispose(): void;
  23895. /**
  23896. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  23897. * @param parsedTexture Define the JSON representation of the texture
  23898. * @param scene Define the scene the parsed texture should be instantiated in
  23899. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  23900. * @returns The parsed texture if successful
  23901. */
  23902. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  23903. /**
  23904. * Creates a texture from its base 64 representation.
  23905. * @param data Define the base64 payload without the data: prefix
  23906. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23907. * @param scene Define the scene the texture should belong to
  23908. * @param noMipmap Forces the texture to not create mip map information if true
  23909. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23910. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23911. * @param onLoad define a callback triggered when the texture has been loaded
  23912. * @param onError define a callback triggered when an error occurred during the loading session
  23913. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23914. * @returns the created texture
  23915. */
  23916. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  23917. /**
  23918. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  23919. * @param data Define the base64 payload without the data: prefix
  23920. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23921. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  23922. * @param scene Define the scene the texture should belong to
  23923. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  23924. * @param noMipmap Forces the texture to not create mip map information if true
  23925. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23926. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23927. * @param onLoad define a callback triggered when the texture has been loaded
  23928. * @param onError define a callback triggered when an error occurred during the loading session
  23929. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23930. * @returns the created texture
  23931. */
  23932. 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;
  23933. }
  23934. }
  23935. declare module "babylonjs/PostProcesses/postProcessManager" {
  23936. import { Nullable } from "babylonjs/types";
  23937. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23938. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  23939. import { Scene } from "babylonjs/scene";
  23940. /**
  23941. * PostProcessManager is used to manage one or more post processes or post process pipelines
  23942. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23943. */
  23944. export class PostProcessManager {
  23945. private _scene;
  23946. private _indexBuffer;
  23947. private _vertexBuffers;
  23948. /**
  23949. * Creates a new instance PostProcess
  23950. * @param scene The scene that the post process is associated with.
  23951. */
  23952. constructor(scene: Scene);
  23953. private _prepareBuffers;
  23954. private _buildIndexBuffer;
  23955. /**
  23956. * Rebuilds the vertex buffers of the manager.
  23957. * @hidden
  23958. */
  23959. _rebuild(): void;
  23960. /**
  23961. * Prepares a frame to be run through a post process.
  23962. * @param sourceTexture The input texture to the post procesess. (default: null)
  23963. * @param postProcesses An array of post processes to be run. (default: null)
  23964. * @returns True if the post processes were able to be run.
  23965. * @hidden
  23966. */
  23967. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  23968. /**
  23969. * Manually render a set of post processes to a texture.
  23970. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  23971. * @param postProcesses An array of post processes to be run.
  23972. * @param targetTexture The target texture to render to.
  23973. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  23974. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  23975. * @param lodLevel defines which lod of the texture to render to
  23976. */
  23977. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  23978. /**
  23979. * Finalize the result of the output of the postprocesses.
  23980. * @param doNotPresent If true the result will not be displayed to the screen.
  23981. * @param targetTexture The target texture to render to.
  23982. * @param faceIndex The index of the face to bind the target texture to.
  23983. * @param postProcesses The array of post processes to render.
  23984. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  23985. * @hidden
  23986. */
  23987. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  23988. /**
  23989. * Disposes of the post process manager.
  23990. */
  23991. dispose(): void;
  23992. }
  23993. }
  23994. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  23995. import { Observable } from "babylonjs/Misc/observable";
  23996. import { SmartArray } from "babylonjs/Misc/smartArray";
  23997. import { Nullable, Immutable } from "babylonjs/types";
  23998. import { Camera } from "babylonjs/Cameras/camera";
  23999. import { Scene } from "babylonjs/scene";
  24000. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  24001. import { Color4 } from "babylonjs/Maths/math.color";
  24002. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  24003. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24004. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24005. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  24006. import { Texture } from "babylonjs/Materials/Textures/texture";
  24007. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  24008. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  24009. import "babylonjs/Engines/Extensions/engine.renderTarget";
  24010. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  24011. import { Engine } from "babylonjs/Engines/engine";
  24012. /**
  24013. * This Helps creating a texture that will be created from a camera in your scene.
  24014. * It is basically a dynamic texture that could be used to create special effects for instance.
  24015. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  24016. */
  24017. export class RenderTargetTexture extends Texture {
  24018. isCube: boolean;
  24019. /**
  24020. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  24021. */
  24022. static readonly REFRESHRATE_RENDER_ONCE: number;
  24023. /**
  24024. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  24025. */
  24026. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  24027. /**
  24028. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  24029. * the central point of your effect and can save a lot of performances.
  24030. */
  24031. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  24032. /**
  24033. * Use this predicate to dynamically define the list of mesh you want to render.
  24034. * If set, the renderList property will be overwritten.
  24035. */
  24036. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  24037. private _renderList;
  24038. /**
  24039. * Use this list to define the list of mesh you want to render.
  24040. */
  24041. get renderList(): Nullable<Array<AbstractMesh>>;
  24042. set renderList(value: Nullable<Array<AbstractMesh>>);
  24043. /**
  24044. * Use this function to overload the renderList array at rendering time.
  24045. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  24046. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  24047. * the cube (if the RTT is a cube, else layerOrFace=0).
  24048. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  24049. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  24050. * hold dummy elements!
  24051. */
  24052. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  24053. private _hookArray;
  24054. /**
  24055. * Define if particles should be rendered in your texture.
  24056. */
  24057. renderParticles: boolean;
  24058. /**
  24059. * Define if sprites should be rendered in your texture.
  24060. */
  24061. renderSprites: boolean;
  24062. /**
  24063. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  24064. */
  24065. coordinatesMode: number;
  24066. /**
  24067. * Define the camera used to render the texture.
  24068. */
  24069. activeCamera: Nullable<Camera>;
  24070. /**
  24071. * Override the mesh isReady function with your own one.
  24072. */
  24073. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  24074. /**
  24075. * Override the render function of the texture with your own one.
  24076. */
  24077. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  24078. /**
  24079. * Define if camera post processes should be use while rendering the texture.
  24080. */
  24081. useCameraPostProcesses: boolean;
  24082. /**
  24083. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  24084. */
  24085. ignoreCameraViewport: boolean;
  24086. private _postProcessManager;
  24087. private _postProcesses;
  24088. private _resizeObserver;
  24089. /**
  24090. * An event triggered when the texture is unbind.
  24091. */
  24092. onBeforeBindObservable: Observable<RenderTargetTexture>;
  24093. /**
  24094. * An event triggered when the texture is unbind.
  24095. */
  24096. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  24097. private _onAfterUnbindObserver;
  24098. /**
  24099. * Set a after unbind callback in the texture.
  24100. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  24101. */
  24102. set onAfterUnbind(callback: () => void);
  24103. /**
  24104. * An event triggered before rendering the texture
  24105. */
  24106. onBeforeRenderObservable: Observable<number>;
  24107. private _onBeforeRenderObserver;
  24108. /**
  24109. * Set a before render callback in the texture.
  24110. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  24111. */
  24112. set onBeforeRender(callback: (faceIndex: number) => void);
  24113. /**
  24114. * An event triggered after rendering the texture
  24115. */
  24116. onAfterRenderObservable: Observable<number>;
  24117. private _onAfterRenderObserver;
  24118. /**
  24119. * Set a after render callback in the texture.
  24120. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  24121. */
  24122. set onAfterRender(callback: (faceIndex: number) => void);
  24123. /**
  24124. * An event triggered after the texture clear
  24125. */
  24126. onClearObservable: Observable<Engine>;
  24127. private _onClearObserver;
  24128. /**
  24129. * Set a clear callback in the texture.
  24130. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  24131. */
  24132. set onClear(callback: (Engine: Engine) => void);
  24133. /**
  24134. * An event triggered when the texture is resized.
  24135. */
  24136. onResizeObservable: Observable<RenderTargetTexture>;
  24137. /**
  24138. * Define the clear color of the Render Target if it should be different from the scene.
  24139. */
  24140. clearColor: Color4;
  24141. protected _size: number | {
  24142. width: number;
  24143. height: number;
  24144. layers?: number;
  24145. };
  24146. protected _initialSizeParameter: number | {
  24147. width: number;
  24148. height: number;
  24149. } | {
  24150. ratio: number;
  24151. };
  24152. protected _sizeRatio: Nullable<number>;
  24153. /** @hidden */
  24154. _generateMipMaps: boolean;
  24155. protected _renderingManager: RenderingManager;
  24156. /** @hidden */
  24157. _waitingRenderList: string[];
  24158. protected _doNotChangeAspectRatio: boolean;
  24159. protected _currentRefreshId: number;
  24160. protected _refreshRate: number;
  24161. protected _textureMatrix: Matrix;
  24162. protected _samples: number;
  24163. protected _renderTargetOptions: RenderTargetCreationOptions;
  24164. /**
  24165. * Gets render target creation options that were used.
  24166. */
  24167. get renderTargetOptions(): RenderTargetCreationOptions;
  24168. protected _onRatioRescale(): void;
  24169. /**
  24170. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  24171. * It must define where the camera used to render the texture is set
  24172. */
  24173. boundingBoxPosition: Vector3;
  24174. private _boundingBoxSize;
  24175. /**
  24176. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  24177. * When defined, the cubemap will switch to local mode
  24178. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  24179. * @example https://www.babylonjs-playground.com/#RNASML
  24180. */
  24181. set boundingBoxSize(value: Vector3);
  24182. get boundingBoxSize(): Vector3;
  24183. /**
  24184. * In case the RTT has been created with a depth texture, get the associated
  24185. * depth texture.
  24186. * Otherwise, return null.
  24187. */
  24188. get depthStencilTexture(): Nullable<InternalTexture>;
  24189. /**
  24190. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  24191. * or used a shadow, depth texture...
  24192. * @param name The friendly name of the texture
  24193. * @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)
  24194. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  24195. * @param generateMipMaps True if mip maps need to be generated after render.
  24196. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  24197. * @param type The type of the buffer in the RTT (int, half float, float...)
  24198. * @param isCube True if a cube texture needs to be created
  24199. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  24200. * @param generateDepthBuffer True to generate a depth buffer
  24201. * @param generateStencilBuffer True to generate a stencil buffer
  24202. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  24203. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  24204. * @param delayAllocation if the texture allocation should be delayed (default: false)
  24205. */
  24206. constructor(name: string, size: number | {
  24207. width: number;
  24208. height: number;
  24209. layers?: number;
  24210. } | {
  24211. ratio: number;
  24212. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  24213. /**
  24214. * Creates a depth stencil texture.
  24215. * This is only available in WebGL 2 or with the depth texture extension available.
  24216. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  24217. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  24218. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  24219. */
  24220. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  24221. private _processSizeParameter;
  24222. /**
  24223. * Define the number of samples to use in case of MSAA.
  24224. * It defaults to one meaning no MSAA has been enabled.
  24225. */
  24226. get samples(): number;
  24227. set samples(value: number);
  24228. /**
  24229. * Resets the refresh counter of the texture and start bak from scratch.
  24230. * Could be useful to regenerate the texture if it is setup to render only once.
  24231. */
  24232. resetRefreshCounter(): void;
  24233. /**
  24234. * Define the refresh rate of the texture or the rendering frequency.
  24235. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  24236. */
  24237. get refreshRate(): number;
  24238. set refreshRate(value: number);
  24239. /**
  24240. * Adds a post process to the render target rendering passes.
  24241. * @param postProcess define the post process to add
  24242. */
  24243. addPostProcess(postProcess: PostProcess): void;
  24244. /**
  24245. * Clear all the post processes attached to the render target
  24246. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  24247. */
  24248. clearPostProcesses(dispose?: boolean): void;
  24249. /**
  24250. * Remove one of the post process from the list of attached post processes to the texture
  24251. * @param postProcess define the post process to remove from the list
  24252. */
  24253. removePostProcess(postProcess: PostProcess): void;
  24254. /** @hidden */
  24255. _shouldRender(): boolean;
  24256. /**
  24257. * Gets the actual render size of the texture.
  24258. * @returns the width of the render size
  24259. */
  24260. getRenderSize(): number;
  24261. /**
  24262. * Gets the actual render width of the texture.
  24263. * @returns the width of the render size
  24264. */
  24265. getRenderWidth(): number;
  24266. /**
  24267. * Gets the actual render height of the texture.
  24268. * @returns the height of the render size
  24269. */
  24270. getRenderHeight(): number;
  24271. /**
  24272. * Gets the actual number of layers of the texture.
  24273. * @returns the number of layers
  24274. */
  24275. getRenderLayers(): number;
  24276. /**
  24277. * Get if the texture can be rescaled or not.
  24278. */
  24279. get canRescale(): boolean;
  24280. /**
  24281. * Resize the texture using a ratio.
  24282. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  24283. */
  24284. scale(ratio: number): void;
  24285. /**
  24286. * Get the texture reflection matrix used to rotate/transform the reflection.
  24287. * @returns the reflection matrix
  24288. */
  24289. getReflectionTextureMatrix(): Matrix;
  24290. /**
  24291. * Resize the texture to a new desired size.
  24292. * Be carrefull as it will recreate all the data in the new texture.
  24293. * @param size Define the new size. It can be:
  24294. * - a number for squared texture,
  24295. * - an object containing { width: number, height: number }
  24296. * - or an object containing a ratio { ratio: number }
  24297. */
  24298. resize(size: number | {
  24299. width: number;
  24300. height: number;
  24301. } | {
  24302. ratio: number;
  24303. }): void;
  24304. private _defaultRenderListPrepared;
  24305. /**
  24306. * Renders all the objects from the render list into the texture.
  24307. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  24308. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  24309. */
  24310. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  24311. private _bestReflectionRenderTargetDimension;
  24312. private _prepareRenderingManager;
  24313. /**
  24314. * @hidden
  24315. * @param faceIndex face index to bind to if this is a cubetexture
  24316. * @param layer defines the index of the texture to bind in the array
  24317. */
  24318. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  24319. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  24320. private renderToTarget;
  24321. /**
  24322. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  24323. * This allowed control for front to back rendering or reversly depending of the special needs.
  24324. *
  24325. * @param renderingGroupId The rendering group id corresponding to its index
  24326. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  24327. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  24328. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  24329. */
  24330. 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;
  24331. /**
  24332. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  24333. *
  24334. * @param renderingGroupId The rendering group id corresponding to its index
  24335. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  24336. */
  24337. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  24338. /**
  24339. * Clones the texture.
  24340. * @returns the cloned texture
  24341. */
  24342. clone(): RenderTargetTexture;
  24343. /**
  24344. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  24345. * @returns The JSON representation of the texture
  24346. */
  24347. serialize(): any;
  24348. /**
  24349. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  24350. */
  24351. disposeFramebufferObjects(): void;
  24352. /**
  24353. * Dispose the texture and release its associated resources.
  24354. */
  24355. dispose(): void;
  24356. /** @hidden */
  24357. _rebuild(): void;
  24358. /**
  24359. * Clear the info related to rendering groups preventing retention point in material dispose.
  24360. */
  24361. freeRenderingGroups(): void;
  24362. /**
  24363. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  24364. * @returns the view count
  24365. */
  24366. getViewCount(): number;
  24367. }
  24368. }
  24369. declare module "babylonjs/Misc/guid" {
  24370. /**
  24371. * Class used to manipulate GUIDs
  24372. */
  24373. export class GUID {
  24374. /**
  24375. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  24376. * Be aware Math.random() could cause collisions, but:
  24377. * "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"
  24378. * @returns a pseudo random id
  24379. */
  24380. static RandomId(): string;
  24381. }
  24382. }
  24383. declare module "babylonjs/Materials/shadowDepthWrapper" {
  24384. import { Nullable } from "babylonjs/types";
  24385. import { Scene } from "babylonjs/scene";
  24386. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24387. import { Material } from "babylonjs/Materials/material";
  24388. import { Effect } from "babylonjs/Materials/effect";
  24389. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  24390. /**
  24391. * Options to be used when creating a shadow depth material
  24392. */
  24393. export interface IIOptionShadowDepthMaterial {
  24394. /** Variables in the vertex shader code that need to have their names remapped.
  24395. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  24396. * "var_name" should be either: worldPos or vNormalW
  24397. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  24398. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  24399. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  24400. */
  24401. remappedVariables?: string[];
  24402. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  24403. standalone?: boolean;
  24404. }
  24405. /**
  24406. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  24407. */
  24408. export class ShadowDepthWrapper {
  24409. private _scene;
  24410. private _options?;
  24411. private _baseMaterial;
  24412. private _onEffectCreatedObserver;
  24413. private _subMeshToEffect;
  24414. private _subMeshToDepthEffect;
  24415. private _meshes;
  24416. /** @hidden */
  24417. _matriceNames: any;
  24418. /** Gets the standalone status of the wrapper */
  24419. get standalone(): boolean;
  24420. /** Gets the base material the wrapper is built upon */
  24421. get baseMaterial(): Material;
  24422. /**
  24423. * Instantiate a new shadow depth wrapper.
  24424. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  24425. * generate the shadow depth map. For more information, please refer to the documentation:
  24426. * https://doc.babylonjs.com/babylon101/shadows
  24427. * @param baseMaterial Material to wrap
  24428. * @param scene Define the scene the material belongs to
  24429. * @param options Options used to create the wrapper
  24430. */
  24431. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  24432. /**
  24433. * Gets the effect to use to generate the depth map
  24434. * @param subMesh subMesh to get the effect for
  24435. * @param shadowGenerator shadow generator to get the effect for
  24436. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  24437. */
  24438. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  24439. /**
  24440. * Specifies that the submesh is ready to be used for depth rendering
  24441. * @param subMesh submesh to check
  24442. * @param defines the list of defines to take into account when checking the effect
  24443. * @param shadowGenerator combined with subMesh, it defines the effect to check
  24444. * @param useInstances specifies that instances should be used
  24445. * @returns a boolean indicating that the submesh is ready or not
  24446. */
  24447. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  24448. /**
  24449. * Disposes the resources
  24450. */
  24451. dispose(): void;
  24452. private _makeEffect;
  24453. }
  24454. }
  24455. declare module "babylonjs/Materials/material" {
  24456. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24457. import { SmartArray } from "babylonjs/Misc/smartArray";
  24458. import { Observable } from "babylonjs/Misc/observable";
  24459. import { Nullable } from "babylonjs/types";
  24460. import { Scene } from "babylonjs/scene";
  24461. import { Matrix } from "babylonjs/Maths/math.vector";
  24462. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24463. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24464. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  24465. import { Effect } from "babylonjs/Materials/effect";
  24466. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  24467. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  24468. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  24469. import { IInspectable } from "babylonjs/Misc/iInspectable";
  24470. import { ShadowDepthWrapper } from "babylonjs/Materials/shadowDepthWrapper";
  24471. import { Mesh } from "babylonjs/Meshes/mesh";
  24472. import { Animation } from "babylonjs/Animations/animation";
  24473. /**
  24474. * Options for compiling materials.
  24475. */
  24476. export interface IMaterialCompilationOptions {
  24477. /**
  24478. * Defines whether clip planes are enabled.
  24479. */
  24480. clipPlane: boolean;
  24481. /**
  24482. * Defines whether instances are enabled.
  24483. */
  24484. useInstances: boolean;
  24485. }
  24486. /**
  24487. * Options passed when calling customShaderNameResolve
  24488. */
  24489. export interface ICustomShaderNameResolveOptions {
  24490. /**
  24491. * 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
  24492. */
  24493. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  24494. }
  24495. /**
  24496. * Base class for the main features of a material in Babylon.js
  24497. */
  24498. export class Material implements IAnimatable {
  24499. /**
  24500. * Returns the triangle fill mode
  24501. */
  24502. static readonly TriangleFillMode: number;
  24503. /**
  24504. * Returns the wireframe mode
  24505. */
  24506. static readonly WireFrameFillMode: number;
  24507. /**
  24508. * Returns the point fill mode
  24509. */
  24510. static readonly PointFillMode: number;
  24511. /**
  24512. * Returns the point list draw mode
  24513. */
  24514. static readonly PointListDrawMode: number;
  24515. /**
  24516. * Returns the line list draw mode
  24517. */
  24518. static readonly LineListDrawMode: number;
  24519. /**
  24520. * Returns the line loop draw mode
  24521. */
  24522. static readonly LineLoopDrawMode: number;
  24523. /**
  24524. * Returns the line strip draw mode
  24525. */
  24526. static readonly LineStripDrawMode: number;
  24527. /**
  24528. * Returns the triangle strip draw mode
  24529. */
  24530. static readonly TriangleStripDrawMode: number;
  24531. /**
  24532. * Returns the triangle fan draw mode
  24533. */
  24534. static readonly TriangleFanDrawMode: number;
  24535. /**
  24536. * Stores the clock-wise side orientation
  24537. */
  24538. static readonly ClockWiseSideOrientation: number;
  24539. /**
  24540. * Stores the counter clock-wise side orientation
  24541. */
  24542. static readonly CounterClockWiseSideOrientation: number;
  24543. /**
  24544. * The dirty texture flag value
  24545. */
  24546. static readonly TextureDirtyFlag: number;
  24547. /**
  24548. * The dirty light flag value
  24549. */
  24550. static readonly LightDirtyFlag: number;
  24551. /**
  24552. * The dirty fresnel flag value
  24553. */
  24554. static readonly FresnelDirtyFlag: number;
  24555. /**
  24556. * The dirty attribute flag value
  24557. */
  24558. static readonly AttributesDirtyFlag: number;
  24559. /**
  24560. * The dirty misc flag value
  24561. */
  24562. static readonly MiscDirtyFlag: number;
  24563. /**
  24564. * The all dirty flag value
  24565. */
  24566. static readonly AllDirtyFlag: number;
  24567. /**
  24568. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  24569. */
  24570. static readonly MATERIAL_OPAQUE: number;
  24571. /**
  24572. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  24573. */
  24574. static readonly MATERIAL_ALPHATEST: number;
  24575. /**
  24576. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  24577. */
  24578. static readonly MATERIAL_ALPHABLEND: number;
  24579. /**
  24580. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  24581. * They are also discarded below the alpha cutoff threshold to improve performances.
  24582. */
  24583. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  24584. /**
  24585. * Custom callback helping to override the default shader used in the material.
  24586. */
  24587. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  24588. /**
  24589. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  24590. */
  24591. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  24592. /**
  24593. * The ID of the material
  24594. */
  24595. id: string;
  24596. /**
  24597. * Gets or sets the unique id of the material
  24598. */
  24599. uniqueId: number;
  24600. /**
  24601. * The name of the material
  24602. */
  24603. name: string;
  24604. /**
  24605. * Gets or sets user defined metadata
  24606. */
  24607. metadata: any;
  24608. /**
  24609. * For internal use only. Please do not use.
  24610. */
  24611. reservedDataStore: any;
  24612. /**
  24613. * Specifies if the ready state should be checked on each call
  24614. */
  24615. checkReadyOnEveryCall: boolean;
  24616. /**
  24617. * Specifies if the ready state should be checked once
  24618. */
  24619. checkReadyOnlyOnce: boolean;
  24620. /**
  24621. * The state of the material
  24622. */
  24623. state: string;
  24624. /**
  24625. * The alpha value of the material
  24626. */
  24627. protected _alpha: number;
  24628. /**
  24629. * List of inspectable custom properties (used by the Inspector)
  24630. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24631. */
  24632. inspectableCustomProperties: IInspectable[];
  24633. /**
  24634. * Sets the alpha value of the material
  24635. */
  24636. set alpha(value: number);
  24637. /**
  24638. * Gets the alpha value of the material
  24639. */
  24640. get alpha(): number;
  24641. /**
  24642. * Specifies if back face culling is enabled
  24643. */
  24644. protected _backFaceCulling: boolean;
  24645. /**
  24646. * Sets the back-face culling state
  24647. */
  24648. set backFaceCulling(value: boolean);
  24649. /**
  24650. * Gets the back-face culling state
  24651. */
  24652. get backFaceCulling(): boolean;
  24653. /**
  24654. * Stores the value for side orientation
  24655. */
  24656. sideOrientation: number;
  24657. /**
  24658. * Callback triggered when the material is compiled
  24659. */
  24660. onCompiled: Nullable<(effect: Effect) => void>;
  24661. /**
  24662. * Callback triggered when an error occurs
  24663. */
  24664. onError: Nullable<(effect: Effect, errors: string) => void>;
  24665. /**
  24666. * Callback triggered to get the render target textures
  24667. */
  24668. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  24669. /**
  24670. * Gets a boolean indicating that current material needs to register RTT
  24671. */
  24672. get hasRenderTargetTextures(): boolean;
  24673. /**
  24674. * Specifies if the material should be serialized
  24675. */
  24676. doNotSerialize: boolean;
  24677. /**
  24678. * @hidden
  24679. */
  24680. _storeEffectOnSubMeshes: boolean;
  24681. /**
  24682. * Stores the animations for the material
  24683. */
  24684. animations: Nullable<Array<Animation>>;
  24685. /**
  24686. * An event triggered when the material is disposed
  24687. */
  24688. onDisposeObservable: Observable<Material>;
  24689. /**
  24690. * An observer which watches for dispose events
  24691. */
  24692. private _onDisposeObserver;
  24693. private _onUnBindObservable;
  24694. /**
  24695. * Called during a dispose event
  24696. */
  24697. set onDispose(callback: () => void);
  24698. private _onBindObservable;
  24699. /**
  24700. * An event triggered when the material is bound
  24701. */
  24702. get onBindObservable(): Observable<AbstractMesh>;
  24703. /**
  24704. * An observer which watches for bind events
  24705. */
  24706. private _onBindObserver;
  24707. /**
  24708. * Called during a bind event
  24709. */
  24710. set onBind(callback: (Mesh: AbstractMesh) => void);
  24711. /**
  24712. * An event triggered when the material is unbound
  24713. */
  24714. get onUnBindObservable(): Observable<Material>;
  24715. protected _onEffectCreatedObservable: Nullable<Observable<{
  24716. effect: Effect;
  24717. subMesh: Nullable<SubMesh>;
  24718. }>>;
  24719. /**
  24720. * An event triggered when the effect is (re)created
  24721. */
  24722. get onEffectCreatedObservable(): Observable<{
  24723. effect: Effect;
  24724. subMesh: Nullable<SubMesh>;
  24725. }>;
  24726. /**
  24727. * Stores the value of the alpha mode
  24728. */
  24729. private _alphaMode;
  24730. /**
  24731. * Sets the value of the alpha mode.
  24732. *
  24733. * | Value | Type | Description |
  24734. * | --- | --- | --- |
  24735. * | 0 | ALPHA_DISABLE | |
  24736. * | 1 | ALPHA_ADD | |
  24737. * | 2 | ALPHA_COMBINE | |
  24738. * | 3 | ALPHA_SUBTRACT | |
  24739. * | 4 | ALPHA_MULTIPLY | |
  24740. * | 5 | ALPHA_MAXIMIZED | |
  24741. * | 6 | ALPHA_ONEONE | |
  24742. * | 7 | ALPHA_PREMULTIPLIED | |
  24743. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  24744. * | 9 | ALPHA_INTERPOLATE | |
  24745. * | 10 | ALPHA_SCREENMODE | |
  24746. *
  24747. */
  24748. set alphaMode(value: number);
  24749. /**
  24750. * Gets the value of the alpha mode
  24751. */
  24752. get alphaMode(): number;
  24753. /**
  24754. * Stores the state of the need depth pre-pass value
  24755. */
  24756. private _needDepthPrePass;
  24757. /**
  24758. * Sets the need depth pre-pass value
  24759. */
  24760. set needDepthPrePass(value: boolean);
  24761. /**
  24762. * Gets the depth pre-pass value
  24763. */
  24764. get needDepthPrePass(): boolean;
  24765. /**
  24766. * Specifies if depth writing should be disabled
  24767. */
  24768. disableDepthWrite: boolean;
  24769. /**
  24770. * Specifies if color writing should be disabled
  24771. */
  24772. disableColorWrite: boolean;
  24773. /**
  24774. * Specifies if depth writing should be forced
  24775. */
  24776. forceDepthWrite: boolean;
  24777. /**
  24778. * Specifies the depth function that should be used. 0 means the default engine function
  24779. */
  24780. depthFunction: number;
  24781. /**
  24782. * Specifies if there should be a separate pass for culling
  24783. */
  24784. separateCullingPass: boolean;
  24785. /**
  24786. * Stores the state specifing if fog should be enabled
  24787. */
  24788. private _fogEnabled;
  24789. /**
  24790. * Sets the state for enabling fog
  24791. */
  24792. set fogEnabled(value: boolean);
  24793. /**
  24794. * Gets the value of the fog enabled state
  24795. */
  24796. get fogEnabled(): boolean;
  24797. /**
  24798. * Stores the size of points
  24799. */
  24800. pointSize: number;
  24801. /**
  24802. * Stores the z offset value
  24803. */
  24804. zOffset: number;
  24805. get wireframe(): boolean;
  24806. /**
  24807. * Sets the state of wireframe mode
  24808. */
  24809. set wireframe(value: boolean);
  24810. /**
  24811. * Gets the value specifying if point clouds are enabled
  24812. */
  24813. get pointsCloud(): boolean;
  24814. /**
  24815. * Sets the state of point cloud mode
  24816. */
  24817. set pointsCloud(value: boolean);
  24818. /**
  24819. * Gets the material fill mode
  24820. */
  24821. get fillMode(): number;
  24822. /**
  24823. * Sets the material fill mode
  24824. */
  24825. set fillMode(value: number);
  24826. /**
  24827. * @hidden
  24828. * Stores the effects for the material
  24829. */
  24830. _effect: Nullable<Effect>;
  24831. /**
  24832. * Specifies if uniform buffers should be used
  24833. */
  24834. private _useUBO;
  24835. /**
  24836. * Stores a reference to the scene
  24837. */
  24838. private _scene;
  24839. /**
  24840. * Stores the fill mode state
  24841. */
  24842. private _fillMode;
  24843. /**
  24844. * Specifies if the depth write state should be cached
  24845. */
  24846. private _cachedDepthWriteState;
  24847. /**
  24848. * Specifies if the color write state should be cached
  24849. */
  24850. private _cachedColorWriteState;
  24851. /**
  24852. * Specifies if the depth function state should be cached
  24853. */
  24854. private _cachedDepthFunctionState;
  24855. /**
  24856. * Stores the uniform buffer
  24857. */
  24858. protected _uniformBuffer: UniformBuffer;
  24859. /** @hidden */
  24860. _indexInSceneMaterialArray: number;
  24861. /** @hidden */
  24862. meshMap: Nullable<{
  24863. [id: string]: AbstractMesh | undefined;
  24864. }>;
  24865. /**
  24866. * Creates a material instance
  24867. * @param name defines the name of the material
  24868. * @param scene defines the scene to reference
  24869. * @param doNotAdd specifies if the material should be added to the scene
  24870. */
  24871. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  24872. /**
  24873. * Returns a string representation of the current material
  24874. * @param fullDetails defines a boolean indicating which levels of logging is desired
  24875. * @returns a string with material information
  24876. */
  24877. toString(fullDetails?: boolean): string;
  24878. /**
  24879. * Gets the class name of the material
  24880. * @returns a string with the class name of the material
  24881. */
  24882. getClassName(): string;
  24883. /**
  24884. * Specifies if updates for the material been locked
  24885. */
  24886. get isFrozen(): boolean;
  24887. /**
  24888. * Locks updates for the material
  24889. */
  24890. freeze(): void;
  24891. /**
  24892. * Unlocks updates for the material
  24893. */
  24894. unfreeze(): void;
  24895. /**
  24896. * Specifies if the material is ready to be used
  24897. * @param mesh defines the mesh to check
  24898. * @param useInstances specifies if instances should be used
  24899. * @returns a boolean indicating if the material is ready to be used
  24900. */
  24901. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  24902. /**
  24903. * Specifies that the submesh is ready to be used
  24904. * @param mesh defines the mesh to check
  24905. * @param subMesh defines which submesh to check
  24906. * @param useInstances specifies that instances should be used
  24907. * @returns a boolean indicating that the submesh is ready or not
  24908. */
  24909. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  24910. /**
  24911. * Returns the material effect
  24912. * @returns the effect associated with the material
  24913. */
  24914. getEffect(): Nullable<Effect>;
  24915. /**
  24916. * Returns the current scene
  24917. * @returns a Scene
  24918. */
  24919. getScene(): Scene;
  24920. /**
  24921. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  24922. */
  24923. protected _forceAlphaTest: boolean;
  24924. /**
  24925. * The transparency mode of the material.
  24926. */
  24927. protected _transparencyMode: Nullable<number>;
  24928. /**
  24929. * Gets the current transparency mode.
  24930. */
  24931. get transparencyMode(): Nullable<number>;
  24932. /**
  24933. * Sets the transparency mode of the material.
  24934. *
  24935. * | Value | Type | Description |
  24936. * | ----- | ----------------------------------- | ----------- |
  24937. * | 0 | OPAQUE | |
  24938. * | 1 | ALPHATEST | |
  24939. * | 2 | ALPHABLEND | |
  24940. * | 3 | ALPHATESTANDBLEND | |
  24941. *
  24942. */
  24943. set transparencyMode(value: Nullable<number>);
  24944. /**
  24945. * Returns true if alpha blending should be disabled.
  24946. */
  24947. protected get _disableAlphaBlending(): boolean;
  24948. /**
  24949. * Specifies whether or not this material should be rendered in alpha blend mode.
  24950. * @returns a boolean specifying if alpha blending is needed
  24951. */
  24952. needAlphaBlending(): boolean;
  24953. /**
  24954. * Specifies if the mesh will require alpha blending
  24955. * @param mesh defines the mesh to check
  24956. * @returns a boolean specifying if alpha blending is needed for the mesh
  24957. */
  24958. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  24959. /**
  24960. * Specifies whether or not this material should be rendered in alpha test mode.
  24961. * @returns a boolean specifying if an alpha test is needed.
  24962. */
  24963. needAlphaTesting(): boolean;
  24964. /**
  24965. * Specifies if material alpha testing should be turned on for the mesh
  24966. * @param mesh defines the mesh to check
  24967. */
  24968. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  24969. /**
  24970. * Gets the texture used for the alpha test
  24971. * @returns the texture to use for alpha testing
  24972. */
  24973. getAlphaTestTexture(): Nullable<BaseTexture>;
  24974. /**
  24975. * Marks the material to indicate that it needs to be re-calculated
  24976. */
  24977. markDirty(): void;
  24978. /** @hidden */
  24979. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  24980. /**
  24981. * Binds the material to the mesh
  24982. * @param world defines the world transformation matrix
  24983. * @param mesh defines the mesh to bind the material to
  24984. */
  24985. bind(world: Matrix, mesh?: Mesh): void;
  24986. /**
  24987. * Binds the submesh to the material
  24988. * @param world defines the world transformation matrix
  24989. * @param mesh defines the mesh containing the submesh
  24990. * @param subMesh defines the submesh to bind the material to
  24991. */
  24992. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  24993. /**
  24994. * Binds the world matrix to the material
  24995. * @param world defines the world transformation matrix
  24996. */
  24997. bindOnlyWorldMatrix(world: Matrix): void;
  24998. /**
  24999. * Binds the scene's uniform buffer to the effect.
  25000. * @param effect defines the effect to bind to the scene uniform buffer
  25001. * @param sceneUbo defines the uniform buffer storing scene data
  25002. */
  25003. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  25004. /**
  25005. * Binds the view matrix to the effect
  25006. * @param effect defines the effect to bind the view matrix to
  25007. */
  25008. bindView(effect: Effect): void;
  25009. /**
  25010. * Binds the view projection matrix to the effect
  25011. * @param effect defines the effect to bind the view projection matrix to
  25012. */
  25013. bindViewProjection(effect: Effect): void;
  25014. /**
  25015. * Processes to execute after binding the material to a mesh
  25016. * @param mesh defines the rendered mesh
  25017. */
  25018. protected _afterBind(mesh?: Mesh): void;
  25019. /**
  25020. * Unbinds the material from the mesh
  25021. */
  25022. unbind(): void;
  25023. /**
  25024. * Gets the active textures from the material
  25025. * @returns an array of textures
  25026. */
  25027. getActiveTextures(): BaseTexture[];
  25028. /**
  25029. * Specifies if the material uses a texture
  25030. * @param texture defines the texture to check against the material
  25031. * @returns a boolean specifying if the material uses the texture
  25032. */
  25033. hasTexture(texture: BaseTexture): boolean;
  25034. /**
  25035. * Makes a duplicate of the material, and gives it a new name
  25036. * @param name defines the new name for the duplicated material
  25037. * @returns the cloned material
  25038. */
  25039. clone(name: string): Nullable<Material>;
  25040. /**
  25041. * Gets the meshes bound to the material
  25042. * @returns an array of meshes bound to the material
  25043. */
  25044. getBindedMeshes(): AbstractMesh[];
  25045. /**
  25046. * Force shader compilation
  25047. * @param mesh defines the mesh associated with this material
  25048. * @param onCompiled defines a function to execute once the material is compiled
  25049. * @param options defines the options to configure the compilation
  25050. * @param onError defines a function to execute if the material fails compiling
  25051. */
  25052. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  25053. /**
  25054. * Force shader compilation
  25055. * @param mesh defines the mesh that will use this material
  25056. * @param options defines additional options for compiling the shaders
  25057. * @returns a promise that resolves when the compilation completes
  25058. */
  25059. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  25060. private static readonly _AllDirtyCallBack;
  25061. private static readonly _ImageProcessingDirtyCallBack;
  25062. private static readonly _TextureDirtyCallBack;
  25063. private static readonly _FresnelDirtyCallBack;
  25064. private static readonly _MiscDirtyCallBack;
  25065. private static readonly _LightsDirtyCallBack;
  25066. private static readonly _AttributeDirtyCallBack;
  25067. private static _FresnelAndMiscDirtyCallBack;
  25068. private static _TextureAndMiscDirtyCallBack;
  25069. private static readonly _DirtyCallbackArray;
  25070. private static readonly _RunDirtyCallBacks;
  25071. /**
  25072. * Marks a define in the material to indicate that it needs to be re-computed
  25073. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  25074. */
  25075. markAsDirty(flag: number): void;
  25076. /**
  25077. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  25078. * @param func defines a function which checks material defines against the submeshes
  25079. */
  25080. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  25081. /**
  25082. * Indicates that we need to re-calculated for all submeshes
  25083. */
  25084. protected _markAllSubMeshesAsAllDirty(): void;
  25085. /**
  25086. * Indicates that image processing needs to be re-calculated for all submeshes
  25087. */
  25088. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  25089. /**
  25090. * Indicates that textures need to be re-calculated for all submeshes
  25091. */
  25092. protected _markAllSubMeshesAsTexturesDirty(): void;
  25093. /**
  25094. * Indicates that fresnel needs to be re-calculated for all submeshes
  25095. */
  25096. protected _markAllSubMeshesAsFresnelDirty(): void;
  25097. /**
  25098. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  25099. */
  25100. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  25101. /**
  25102. * Indicates that lights need to be re-calculated for all submeshes
  25103. */
  25104. protected _markAllSubMeshesAsLightsDirty(): void;
  25105. /**
  25106. * Indicates that attributes need to be re-calculated for all submeshes
  25107. */
  25108. protected _markAllSubMeshesAsAttributesDirty(): void;
  25109. /**
  25110. * Indicates that misc needs to be re-calculated for all submeshes
  25111. */
  25112. protected _markAllSubMeshesAsMiscDirty(): void;
  25113. /**
  25114. * Indicates that textures and misc need to be re-calculated for all submeshes
  25115. */
  25116. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  25117. /**
  25118. * Disposes the material
  25119. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  25120. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  25121. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  25122. */
  25123. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  25124. /** @hidden */
  25125. private releaseVertexArrayObject;
  25126. /**
  25127. * Serializes this material
  25128. * @returns the serialized material object
  25129. */
  25130. serialize(): any;
  25131. /**
  25132. * Creates a material from parsed material data
  25133. * @param parsedMaterial defines parsed material data
  25134. * @param scene defines the hosting scene
  25135. * @param rootUrl defines the root URL to use to load textures
  25136. * @returns a new material
  25137. */
  25138. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  25139. }
  25140. }
  25141. declare module "babylonjs/Materials/multiMaterial" {
  25142. import { Nullable } from "babylonjs/types";
  25143. import { Scene } from "babylonjs/scene";
  25144. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25145. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25146. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25147. import { Material } from "babylonjs/Materials/material";
  25148. /**
  25149. * A multi-material is used to apply different materials to different parts of the same object without the need of
  25150. * separate meshes. This can be use to improve performances.
  25151. * @see http://doc.babylonjs.com/how_to/multi_materials
  25152. */
  25153. export class MultiMaterial extends Material {
  25154. private _subMaterials;
  25155. /**
  25156. * Gets or Sets the list of Materials used within the multi material.
  25157. * They need to be ordered according to the submeshes order in the associated mesh
  25158. */
  25159. get subMaterials(): Nullable<Material>[];
  25160. set subMaterials(value: Nullable<Material>[]);
  25161. /**
  25162. * Function used to align with Node.getChildren()
  25163. * @returns the list of Materials used within the multi material
  25164. */
  25165. getChildren(): Nullable<Material>[];
  25166. /**
  25167. * Instantiates a new Multi Material
  25168. * A multi-material is used to apply different materials to different parts of the same object without the need of
  25169. * separate meshes. This can be use to improve performances.
  25170. * @see http://doc.babylonjs.com/how_to/multi_materials
  25171. * @param name Define the name in the scene
  25172. * @param scene Define the scene the material belongs to
  25173. */
  25174. constructor(name: string, scene: Scene);
  25175. private _hookArray;
  25176. /**
  25177. * Get one of the submaterial by its index in the submaterials array
  25178. * @param index The index to look the sub material at
  25179. * @returns The Material if the index has been defined
  25180. */
  25181. getSubMaterial(index: number): Nullable<Material>;
  25182. /**
  25183. * Get the list of active textures for the whole sub materials list.
  25184. * @returns All the textures that will be used during the rendering
  25185. */
  25186. getActiveTextures(): BaseTexture[];
  25187. /**
  25188. * Gets the current class name of the material e.g. "MultiMaterial"
  25189. * Mainly use in serialization.
  25190. * @returns the class name
  25191. */
  25192. getClassName(): string;
  25193. /**
  25194. * Checks if the material is ready to render the requested sub mesh
  25195. * @param mesh Define the mesh the submesh belongs to
  25196. * @param subMesh Define the sub mesh to look readyness for
  25197. * @param useInstances Define whether or not the material is used with instances
  25198. * @returns true if ready, otherwise false
  25199. */
  25200. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  25201. /**
  25202. * Clones the current material and its related sub materials
  25203. * @param name Define the name of the newly cloned material
  25204. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  25205. * @returns the cloned material
  25206. */
  25207. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  25208. /**
  25209. * Serializes the materials into a JSON representation.
  25210. * @returns the JSON representation
  25211. */
  25212. serialize(): any;
  25213. /**
  25214. * Dispose the material and release its associated resources
  25215. * @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)
  25216. * @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)
  25217. * @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)
  25218. */
  25219. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  25220. /**
  25221. * Creates a MultiMaterial from parsed MultiMaterial data.
  25222. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  25223. * @param scene defines the hosting scene
  25224. * @returns a new MultiMaterial
  25225. */
  25226. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  25227. }
  25228. }
  25229. declare module "babylonjs/Meshes/subMesh" {
  25230. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  25231. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  25232. import { Engine } from "babylonjs/Engines/engine";
  25233. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  25234. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  25235. import { Effect } from "babylonjs/Materials/effect";
  25236. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  25237. import { Plane } from "babylonjs/Maths/math.plane";
  25238. import { Collider } from "babylonjs/Collisions/collider";
  25239. import { Material } from "babylonjs/Materials/material";
  25240. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  25241. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25242. import { Mesh } from "babylonjs/Meshes/mesh";
  25243. import { Ray } from "babylonjs/Culling/ray";
  25244. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  25245. /**
  25246. * Defines a subdivision inside a mesh
  25247. */
  25248. export class SubMesh implements ICullable {
  25249. /** the material index to use */
  25250. materialIndex: number;
  25251. /** vertex index start */
  25252. verticesStart: number;
  25253. /** vertices count */
  25254. verticesCount: number;
  25255. /** index start */
  25256. indexStart: number;
  25257. /** indices count */
  25258. indexCount: number;
  25259. /** @hidden */
  25260. _materialDefines: Nullable<MaterialDefines>;
  25261. /** @hidden */
  25262. _materialEffect: Nullable<Effect>;
  25263. /** @hidden */
  25264. _effectOverride: Nullable<Effect>;
  25265. /**
  25266. * Gets material defines used by the effect associated to the sub mesh
  25267. */
  25268. get materialDefines(): Nullable<MaterialDefines>;
  25269. /**
  25270. * Sets material defines used by the effect associated to the sub mesh
  25271. */
  25272. set materialDefines(defines: Nullable<MaterialDefines>);
  25273. /**
  25274. * Gets associated effect
  25275. */
  25276. get effect(): Nullable<Effect>;
  25277. /**
  25278. * Sets associated effect (effect used to render this submesh)
  25279. * @param effect defines the effect to associate with
  25280. * @param defines defines the set of defines used to compile this effect
  25281. */
  25282. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  25283. /** @hidden */
  25284. _linesIndexCount: number;
  25285. private _mesh;
  25286. private _renderingMesh;
  25287. private _boundingInfo;
  25288. private _linesIndexBuffer;
  25289. /** @hidden */
  25290. _lastColliderWorldVertices: Nullable<Vector3[]>;
  25291. /** @hidden */
  25292. _trianglePlanes: Plane[];
  25293. /** @hidden */
  25294. _lastColliderTransformMatrix: Nullable<Matrix>;
  25295. /** @hidden */
  25296. _renderId: number;
  25297. /** @hidden */
  25298. _alphaIndex: number;
  25299. /** @hidden */
  25300. _distanceToCamera: number;
  25301. /** @hidden */
  25302. _id: number;
  25303. private _currentMaterial;
  25304. /**
  25305. * Add a new submesh to a mesh
  25306. * @param materialIndex defines the material index to use
  25307. * @param verticesStart defines vertex index start
  25308. * @param verticesCount defines vertices count
  25309. * @param indexStart defines index start
  25310. * @param indexCount defines indices count
  25311. * @param mesh defines the parent mesh
  25312. * @param renderingMesh defines an optional rendering mesh
  25313. * @param createBoundingBox defines if bounding box should be created for this submesh
  25314. * @returns the new submesh
  25315. */
  25316. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  25317. /**
  25318. * Creates a new submesh
  25319. * @param materialIndex defines the material index to use
  25320. * @param verticesStart defines vertex index start
  25321. * @param verticesCount defines vertices count
  25322. * @param indexStart defines index start
  25323. * @param indexCount defines indices count
  25324. * @param mesh defines the parent mesh
  25325. * @param renderingMesh defines an optional rendering mesh
  25326. * @param createBoundingBox defines if bounding box should be created for this submesh
  25327. */
  25328. constructor(
  25329. /** the material index to use */
  25330. materialIndex: number,
  25331. /** vertex index start */
  25332. verticesStart: number,
  25333. /** vertices count */
  25334. verticesCount: number,
  25335. /** index start */
  25336. indexStart: number,
  25337. /** indices count */
  25338. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  25339. /**
  25340. * Returns true if this submesh covers the entire parent mesh
  25341. * @ignorenaming
  25342. */
  25343. get IsGlobal(): boolean;
  25344. /**
  25345. * Returns the submesh BoudingInfo object
  25346. * @returns current bounding info (or mesh's one if the submesh is global)
  25347. */
  25348. getBoundingInfo(): BoundingInfo;
  25349. /**
  25350. * Sets the submesh BoundingInfo
  25351. * @param boundingInfo defines the new bounding info to use
  25352. * @returns the SubMesh
  25353. */
  25354. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  25355. /**
  25356. * Returns the mesh of the current submesh
  25357. * @return the parent mesh
  25358. */
  25359. getMesh(): AbstractMesh;
  25360. /**
  25361. * Returns the rendering mesh of the submesh
  25362. * @returns the rendering mesh (could be different from parent mesh)
  25363. */
  25364. getRenderingMesh(): Mesh;
  25365. /**
  25366. * Returns the replacement mesh of the submesh
  25367. * @returns the replacement mesh (could be different from parent mesh)
  25368. */
  25369. getReplacementMesh(): Nullable<AbstractMesh>;
  25370. /**
  25371. * Returns the effective mesh of the submesh
  25372. * @returns the effective mesh (could be different from parent mesh)
  25373. */
  25374. getEffectiveMesh(): AbstractMesh;
  25375. /**
  25376. * Returns the submesh material
  25377. * @returns null or the current material
  25378. */
  25379. getMaterial(): Nullable<Material>;
  25380. /**
  25381. * Sets a new updated BoundingInfo object to the submesh
  25382. * @param data defines an optional position array to use to determine the bounding info
  25383. * @returns the SubMesh
  25384. */
  25385. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  25386. /** @hidden */
  25387. _checkCollision(collider: Collider): boolean;
  25388. /**
  25389. * Updates the submesh BoundingInfo
  25390. * @param world defines the world matrix to use to update the bounding info
  25391. * @returns the submesh
  25392. */
  25393. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  25394. /**
  25395. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  25396. * @param frustumPlanes defines the frustum planes
  25397. * @returns true if the submesh is intersecting with the frustum
  25398. */
  25399. isInFrustum(frustumPlanes: Plane[]): boolean;
  25400. /**
  25401. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  25402. * @param frustumPlanes defines the frustum planes
  25403. * @returns true if the submesh is inside the frustum
  25404. */
  25405. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25406. /**
  25407. * Renders the submesh
  25408. * @param enableAlphaMode defines if alpha needs to be used
  25409. * @returns the submesh
  25410. */
  25411. render(enableAlphaMode: boolean): SubMesh;
  25412. /**
  25413. * @hidden
  25414. */
  25415. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  25416. /**
  25417. * Checks if the submesh intersects with a ray
  25418. * @param ray defines the ray to test
  25419. * @returns true is the passed ray intersects the submesh bounding box
  25420. */
  25421. canIntersects(ray: Ray): boolean;
  25422. /**
  25423. * Intersects current submesh with a ray
  25424. * @param ray defines the ray to test
  25425. * @param positions defines mesh's positions array
  25426. * @param indices defines mesh's indices array
  25427. * @param fastCheck defines if the first intersection will be used (and not the closest)
  25428. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25429. * @returns intersection info or null if no intersection
  25430. */
  25431. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  25432. /** @hidden */
  25433. private _intersectLines;
  25434. /** @hidden */
  25435. private _intersectUnIndexedLines;
  25436. /** @hidden */
  25437. private _intersectTriangles;
  25438. /** @hidden */
  25439. private _intersectUnIndexedTriangles;
  25440. /** @hidden */
  25441. _rebuild(): void;
  25442. /**
  25443. * Creates a new submesh from the passed mesh
  25444. * @param newMesh defines the new hosting mesh
  25445. * @param newRenderingMesh defines an optional rendering mesh
  25446. * @returns the new submesh
  25447. */
  25448. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  25449. /**
  25450. * Release associated resources
  25451. */
  25452. dispose(): void;
  25453. /**
  25454. * Gets the class name
  25455. * @returns the string "SubMesh".
  25456. */
  25457. getClassName(): string;
  25458. /**
  25459. * Creates a new submesh from indices data
  25460. * @param materialIndex the index of the main mesh material
  25461. * @param startIndex the index where to start the copy in the mesh indices array
  25462. * @param indexCount the number of indices to copy then from the startIndex
  25463. * @param mesh the main mesh to create the submesh from
  25464. * @param renderingMesh the optional rendering mesh
  25465. * @returns a new submesh
  25466. */
  25467. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  25468. }
  25469. }
  25470. declare module "babylonjs/Loading/sceneLoaderFlags" {
  25471. /**
  25472. * Class used to represent data loading progression
  25473. */
  25474. export class SceneLoaderFlags {
  25475. private static _ForceFullSceneLoadingForIncremental;
  25476. private static _ShowLoadingScreen;
  25477. private static _CleanBoneMatrixWeights;
  25478. private static _loggingLevel;
  25479. /**
  25480. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  25481. */
  25482. static get ForceFullSceneLoadingForIncremental(): boolean;
  25483. static set ForceFullSceneLoadingForIncremental(value: boolean);
  25484. /**
  25485. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  25486. */
  25487. static get ShowLoadingScreen(): boolean;
  25488. static set ShowLoadingScreen(value: boolean);
  25489. /**
  25490. * Defines the current logging level (while loading the scene)
  25491. * @ignorenaming
  25492. */
  25493. static get loggingLevel(): number;
  25494. static set loggingLevel(value: number);
  25495. /**
  25496. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  25497. */
  25498. static get CleanBoneMatrixWeights(): boolean;
  25499. static set CleanBoneMatrixWeights(value: boolean);
  25500. }
  25501. }
  25502. declare module "babylonjs/Meshes/geometry" {
  25503. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  25504. import { Scene } from "babylonjs/scene";
  25505. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  25506. import { Engine } from "babylonjs/Engines/engine";
  25507. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  25508. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  25509. import { Effect } from "babylonjs/Materials/effect";
  25510. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  25511. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  25512. import { Mesh } from "babylonjs/Meshes/mesh";
  25513. /**
  25514. * Class used to store geometry data (vertex buffers + index buffer)
  25515. */
  25516. export class Geometry implements IGetSetVerticesData {
  25517. /**
  25518. * Gets or sets the ID of the geometry
  25519. */
  25520. id: string;
  25521. /**
  25522. * Gets or sets the unique ID of the geometry
  25523. */
  25524. uniqueId: number;
  25525. /**
  25526. * Gets the delay loading state of the geometry (none by default which means not delayed)
  25527. */
  25528. delayLoadState: number;
  25529. /**
  25530. * Gets the file containing the data to load when running in delay load state
  25531. */
  25532. delayLoadingFile: Nullable<string>;
  25533. /**
  25534. * Callback called when the geometry is updated
  25535. */
  25536. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  25537. private _scene;
  25538. private _engine;
  25539. private _meshes;
  25540. private _totalVertices;
  25541. /** @hidden */
  25542. _indices: IndicesArray;
  25543. /** @hidden */
  25544. _vertexBuffers: {
  25545. [key: string]: VertexBuffer;
  25546. };
  25547. private _isDisposed;
  25548. private _extend;
  25549. private _boundingBias;
  25550. /** @hidden */
  25551. _delayInfo: Array<string>;
  25552. private _indexBuffer;
  25553. private _indexBufferIsUpdatable;
  25554. /** @hidden */
  25555. _boundingInfo: Nullable<BoundingInfo>;
  25556. /** @hidden */
  25557. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  25558. /** @hidden */
  25559. _softwareSkinningFrameId: number;
  25560. private _vertexArrayObjects;
  25561. private _updatable;
  25562. /** @hidden */
  25563. _positions: Nullable<Vector3[]>;
  25564. /**
  25565. * 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
  25566. */
  25567. get boundingBias(): Vector2;
  25568. /**
  25569. * 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
  25570. */
  25571. set boundingBias(value: Vector2);
  25572. /**
  25573. * Static function used to attach a new empty geometry to a mesh
  25574. * @param mesh defines the mesh to attach the geometry to
  25575. * @returns the new Geometry
  25576. */
  25577. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  25578. /** Get the list of meshes using this geometry */
  25579. get meshes(): Mesh[];
  25580. /**
  25581. * Creates a new geometry
  25582. * @param id defines the unique ID
  25583. * @param scene defines the hosting scene
  25584. * @param vertexData defines the VertexData used to get geometry data
  25585. * @param updatable defines if geometry must be updatable (false by default)
  25586. * @param mesh defines the mesh that will be associated with the geometry
  25587. */
  25588. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  25589. /**
  25590. * Gets the current extend of the geometry
  25591. */
  25592. get extend(): {
  25593. minimum: Vector3;
  25594. maximum: Vector3;
  25595. };
  25596. /**
  25597. * Gets the hosting scene
  25598. * @returns the hosting Scene
  25599. */
  25600. getScene(): Scene;
  25601. /**
  25602. * Gets the hosting engine
  25603. * @returns the hosting Engine
  25604. */
  25605. getEngine(): Engine;
  25606. /**
  25607. * Defines if the geometry is ready to use
  25608. * @returns true if the geometry is ready to be used
  25609. */
  25610. isReady(): boolean;
  25611. /**
  25612. * Gets a value indicating that the geometry should not be serialized
  25613. */
  25614. get doNotSerialize(): boolean;
  25615. /** @hidden */
  25616. _rebuild(): void;
  25617. /**
  25618. * Affects all geometry data in one call
  25619. * @param vertexData defines the geometry data
  25620. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  25621. */
  25622. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  25623. /**
  25624. * Set specific vertex data
  25625. * @param kind defines the data kind (Position, normal, etc...)
  25626. * @param data defines the vertex data to use
  25627. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25628. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25629. */
  25630. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  25631. /**
  25632. * Removes a specific vertex data
  25633. * @param kind defines the data kind (Position, normal, etc...)
  25634. */
  25635. removeVerticesData(kind: string): void;
  25636. /**
  25637. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  25638. * @param buffer defines the vertex buffer to use
  25639. * @param totalVertices defines the total number of vertices for position kind (could be null)
  25640. */
  25641. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  25642. /**
  25643. * Update a specific vertex buffer
  25644. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  25645. * It will do nothing if the buffer is not updatable
  25646. * @param kind defines the data kind (Position, normal, etc...)
  25647. * @param data defines the data to use
  25648. * @param offset defines the offset in the target buffer where to store the data
  25649. * @param useBytes set to true if the offset is in bytes
  25650. */
  25651. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  25652. /**
  25653. * Update a specific vertex buffer
  25654. * This function will create a new buffer if the current one is not updatable
  25655. * @param kind defines the data kind (Position, normal, etc...)
  25656. * @param data defines the data to use
  25657. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  25658. */
  25659. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  25660. private _updateBoundingInfo;
  25661. /** @hidden */
  25662. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  25663. /**
  25664. * Gets total number of vertices
  25665. * @returns the total number of vertices
  25666. */
  25667. getTotalVertices(): number;
  25668. /**
  25669. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25670. * @param kind defines the data kind (Position, normal, etc...)
  25671. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25672. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25673. * @returns a float array containing vertex data
  25674. */
  25675. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25676. /**
  25677. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  25678. * @param kind defines the data kind (Position, normal, etc...)
  25679. * @returns true if the vertex buffer with the specified kind is updatable
  25680. */
  25681. isVertexBufferUpdatable(kind: string): boolean;
  25682. /**
  25683. * Gets a specific vertex buffer
  25684. * @param kind defines the data kind (Position, normal, etc...)
  25685. * @returns a VertexBuffer
  25686. */
  25687. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25688. /**
  25689. * Returns all vertex buffers
  25690. * @return an object holding all vertex buffers indexed by kind
  25691. */
  25692. getVertexBuffers(): Nullable<{
  25693. [key: string]: VertexBuffer;
  25694. }>;
  25695. /**
  25696. * Gets a boolean indicating if specific vertex buffer is present
  25697. * @param kind defines the data kind (Position, normal, etc...)
  25698. * @returns true if data is present
  25699. */
  25700. isVerticesDataPresent(kind: string): boolean;
  25701. /**
  25702. * Gets a list of all attached data kinds (Position, normal, etc...)
  25703. * @returns a list of string containing all kinds
  25704. */
  25705. getVerticesDataKinds(): string[];
  25706. /**
  25707. * Update index buffer
  25708. * @param indices defines the indices to store in the index buffer
  25709. * @param offset defines the offset in the target buffer where to store the data
  25710. * @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)
  25711. */
  25712. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  25713. /**
  25714. * Creates a new index buffer
  25715. * @param indices defines the indices to store in the index buffer
  25716. * @param totalVertices defines the total number of vertices (could be null)
  25717. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25718. */
  25719. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  25720. /**
  25721. * Return the total number of indices
  25722. * @returns the total number of indices
  25723. */
  25724. getTotalIndices(): number;
  25725. /**
  25726. * Gets the index buffer array
  25727. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25728. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25729. * @returns the index buffer array
  25730. */
  25731. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25732. /**
  25733. * Gets the index buffer
  25734. * @return the index buffer
  25735. */
  25736. getIndexBuffer(): Nullable<DataBuffer>;
  25737. /** @hidden */
  25738. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  25739. /**
  25740. * Release the associated resources for a specific mesh
  25741. * @param mesh defines the source mesh
  25742. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  25743. */
  25744. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  25745. /**
  25746. * Apply current geometry to a given mesh
  25747. * @param mesh defines the mesh to apply geometry to
  25748. */
  25749. applyToMesh(mesh: Mesh): void;
  25750. private _updateExtend;
  25751. private _applyToMesh;
  25752. private notifyUpdate;
  25753. /**
  25754. * Load the geometry if it was flagged as delay loaded
  25755. * @param scene defines the hosting scene
  25756. * @param onLoaded defines a callback called when the geometry is loaded
  25757. */
  25758. load(scene: Scene, onLoaded?: () => void): void;
  25759. private _queueLoad;
  25760. /**
  25761. * Invert the geometry to move from a right handed system to a left handed one.
  25762. */
  25763. toLeftHanded(): void;
  25764. /** @hidden */
  25765. _resetPointsArrayCache(): void;
  25766. /** @hidden */
  25767. _generatePointsArray(): boolean;
  25768. /**
  25769. * Gets a value indicating if the geometry is disposed
  25770. * @returns true if the geometry was disposed
  25771. */
  25772. isDisposed(): boolean;
  25773. private _disposeVertexArrayObjects;
  25774. /**
  25775. * Free all associated resources
  25776. */
  25777. dispose(): void;
  25778. /**
  25779. * Clone the current geometry into a new geometry
  25780. * @param id defines the unique ID of the new geometry
  25781. * @returns a new geometry object
  25782. */
  25783. copy(id: string): Geometry;
  25784. /**
  25785. * Serialize the current geometry info (and not the vertices data) into a JSON object
  25786. * @return a JSON representation of the current geometry data (without the vertices data)
  25787. */
  25788. serialize(): any;
  25789. private toNumberArray;
  25790. /**
  25791. * Serialize all vertices data into a JSON oject
  25792. * @returns a JSON representation of the current geometry data
  25793. */
  25794. serializeVerticeData(): any;
  25795. /**
  25796. * Extracts a clone of a mesh geometry
  25797. * @param mesh defines the source mesh
  25798. * @param id defines the unique ID of the new geometry object
  25799. * @returns the new geometry object
  25800. */
  25801. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  25802. /**
  25803. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  25804. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  25805. * Be aware Math.random() could cause collisions, but:
  25806. * "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"
  25807. * @returns a string containing a new GUID
  25808. */
  25809. static RandomId(): string;
  25810. /** @hidden */
  25811. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  25812. private static _CleanMatricesWeights;
  25813. /**
  25814. * Create a new geometry from persisted data (Using .babylon file format)
  25815. * @param parsedVertexData defines the persisted data
  25816. * @param scene defines the hosting scene
  25817. * @param rootUrl defines the root url to use to load assets (like delayed data)
  25818. * @returns the new geometry object
  25819. */
  25820. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  25821. }
  25822. }
  25823. declare module "babylonjs/Meshes/mesh.vertexData" {
  25824. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  25825. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  25826. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  25827. import { Geometry } from "babylonjs/Meshes/geometry";
  25828. import { Mesh } from "babylonjs/Meshes/mesh";
  25829. /**
  25830. * Define an interface for all classes that will get and set the data on vertices
  25831. */
  25832. export interface IGetSetVerticesData {
  25833. /**
  25834. * Gets a boolean indicating if specific vertex data is present
  25835. * @param kind defines the vertex data kind to use
  25836. * @returns true is data kind is present
  25837. */
  25838. isVerticesDataPresent(kind: string): boolean;
  25839. /**
  25840. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25841. * @param kind defines the data kind (Position, normal, etc...)
  25842. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25843. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25844. * @returns a float array containing vertex data
  25845. */
  25846. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25847. /**
  25848. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25849. * @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.
  25850. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25851. * @returns the indices array or an empty array if the mesh has no geometry
  25852. */
  25853. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25854. /**
  25855. * Set specific vertex data
  25856. * @param kind defines the data kind (Position, normal, etc...)
  25857. * @param data defines the vertex data to use
  25858. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25859. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25860. */
  25861. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  25862. /**
  25863. * Update a specific associated vertex buffer
  25864. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25865. * - VertexBuffer.PositionKind
  25866. * - VertexBuffer.UVKind
  25867. * - VertexBuffer.UV2Kind
  25868. * - VertexBuffer.UV3Kind
  25869. * - VertexBuffer.UV4Kind
  25870. * - VertexBuffer.UV5Kind
  25871. * - VertexBuffer.UV6Kind
  25872. * - VertexBuffer.ColorKind
  25873. * - VertexBuffer.MatricesIndicesKind
  25874. * - VertexBuffer.MatricesIndicesExtraKind
  25875. * - VertexBuffer.MatricesWeightsKind
  25876. * - VertexBuffer.MatricesWeightsExtraKind
  25877. * @param data defines the data source
  25878. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25879. * @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)
  25880. */
  25881. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  25882. /**
  25883. * Creates a new index buffer
  25884. * @param indices defines the indices to store in the index buffer
  25885. * @param totalVertices defines the total number of vertices (could be null)
  25886. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25887. */
  25888. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  25889. }
  25890. /**
  25891. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  25892. */
  25893. export class VertexData {
  25894. /**
  25895. * Mesh side orientation : usually the external or front surface
  25896. */
  25897. static readonly FRONTSIDE: number;
  25898. /**
  25899. * Mesh side orientation : usually the internal or back surface
  25900. */
  25901. static readonly BACKSIDE: number;
  25902. /**
  25903. * Mesh side orientation : both internal and external or front and back surfaces
  25904. */
  25905. static readonly DOUBLESIDE: number;
  25906. /**
  25907. * Mesh side orientation : by default, `FRONTSIDE`
  25908. */
  25909. static readonly DEFAULTSIDE: number;
  25910. /**
  25911. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  25912. */
  25913. positions: Nullable<FloatArray>;
  25914. /**
  25915. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  25916. */
  25917. normals: Nullable<FloatArray>;
  25918. /**
  25919. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  25920. */
  25921. tangents: Nullable<FloatArray>;
  25922. /**
  25923. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25924. */
  25925. uvs: Nullable<FloatArray>;
  25926. /**
  25927. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25928. */
  25929. uvs2: Nullable<FloatArray>;
  25930. /**
  25931. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25932. */
  25933. uvs3: Nullable<FloatArray>;
  25934. /**
  25935. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25936. */
  25937. uvs4: Nullable<FloatArray>;
  25938. /**
  25939. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25940. */
  25941. uvs5: Nullable<FloatArray>;
  25942. /**
  25943. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25944. */
  25945. uvs6: Nullable<FloatArray>;
  25946. /**
  25947. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  25948. */
  25949. colors: Nullable<FloatArray>;
  25950. /**
  25951. * 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).
  25952. */
  25953. matricesIndices: Nullable<FloatArray>;
  25954. /**
  25955. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  25956. */
  25957. matricesWeights: Nullable<FloatArray>;
  25958. /**
  25959. * An array extending the number of possible indices
  25960. */
  25961. matricesIndicesExtra: Nullable<FloatArray>;
  25962. /**
  25963. * An array extending the number of possible weights when the number of indices is extended
  25964. */
  25965. matricesWeightsExtra: Nullable<FloatArray>;
  25966. /**
  25967. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  25968. */
  25969. indices: Nullable<IndicesArray>;
  25970. /**
  25971. * Uses the passed data array to set the set the values for the specified kind of data
  25972. * @param data a linear array of floating numbers
  25973. * @param kind the type of data that is being set, eg positions, colors etc
  25974. */
  25975. set(data: FloatArray, kind: string): void;
  25976. /**
  25977. * Associates the vertexData to the passed Mesh.
  25978. * Sets it as updatable or not (default `false`)
  25979. * @param mesh the mesh the vertexData is applied to
  25980. * @param updatable when used and having the value true allows new data to update the vertexData
  25981. * @returns the VertexData
  25982. */
  25983. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  25984. /**
  25985. * Associates the vertexData to the passed Geometry.
  25986. * Sets it as updatable or not (default `false`)
  25987. * @param geometry the geometry the vertexData is applied to
  25988. * @param updatable when used and having the value true allows new data to update the vertexData
  25989. * @returns VertexData
  25990. */
  25991. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  25992. /**
  25993. * Updates the associated mesh
  25994. * @param mesh the mesh to be updated
  25995. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  25996. * @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
  25997. * @returns VertexData
  25998. */
  25999. updateMesh(mesh: Mesh): VertexData;
  26000. /**
  26001. * Updates the associated geometry
  26002. * @param geometry the geometry to be updated
  26003. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  26004. * @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
  26005. * @returns VertexData.
  26006. */
  26007. updateGeometry(geometry: Geometry): VertexData;
  26008. private _applyTo;
  26009. private _update;
  26010. /**
  26011. * Transforms each position and each normal of the vertexData according to the passed Matrix
  26012. * @param matrix the transforming matrix
  26013. * @returns the VertexData
  26014. */
  26015. transform(matrix: Matrix): VertexData;
  26016. /**
  26017. * Merges the passed VertexData into the current one
  26018. * @param other the VertexData to be merged into the current one
  26019. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  26020. * @returns the modified VertexData
  26021. */
  26022. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  26023. private _mergeElement;
  26024. private _validate;
  26025. /**
  26026. * Serializes the VertexData
  26027. * @returns a serialized object
  26028. */
  26029. serialize(): any;
  26030. /**
  26031. * Extracts the vertexData from a mesh
  26032. * @param mesh the mesh from which to extract the VertexData
  26033. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  26034. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  26035. * @returns the object VertexData associated to the passed mesh
  26036. */
  26037. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  26038. /**
  26039. * Extracts the vertexData from the geometry
  26040. * @param geometry the geometry from which to extract the VertexData
  26041. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  26042. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  26043. * @returns the object VertexData associated to the passed mesh
  26044. */
  26045. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  26046. private static _ExtractFrom;
  26047. /**
  26048. * Creates the VertexData for a Ribbon
  26049. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  26050. * * pathArray array of paths, each of which an array of successive Vector3
  26051. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  26052. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  26053. * * 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
  26054. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26055. * * 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)
  26056. * * 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)
  26057. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  26058. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  26059. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  26060. * @returns the VertexData of the ribbon
  26061. */
  26062. static CreateRibbon(options: {
  26063. pathArray: Vector3[][];
  26064. closeArray?: boolean;
  26065. closePath?: boolean;
  26066. offset?: number;
  26067. sideOrientation?: number;
  26068. frontUVs?: Vector4;
  26069. backUVs?: Vector4;
  26070. invertUV?: boolean;
  26071. uvs?: Vector2[];
  26072. colors?: Color4[];
  26073. }): VertexData;
  26074. /**
  26075. * Creates the VertexData for a box
  26076. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26077. * * size sets the width, height and depth of the box to the value of size, optional default 1
  26078. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  26079. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  26080. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  26081. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  26082. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  26083. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26084. * * 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)
  26085. * * 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)
  26086. * @returns the VertexData of the box
  26087. */
  26088. static CreateBox(options: {
  26089. size?: number;
  26090. width?: number;
  26091. height?: number;
  26092. depth?: number;
  26093. faceUV?: Vector4[];
  26094. faceColors?: Color4[];
  26095. sideOrientation?: number;
  26096. frontUVs?: Vector4;
  26097. backUVs?: Vector4;
  26098. }): VertexData;
  26099. /**
  26100. * Creates the VertexData for a tiled box
  26101. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26102. * * faceTiles sets the pattern, tile size and number of tiles for a face
  26103. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  26104. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  26105. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26106. * @returns the VertexData of the box
  26107. */
  26108. static CreateTiledBox(options: {
  26109. pattern?: number;
  26110. width?: number;
  26111. height?: number;
  26112. depth?: number;
  26113. tileSize?: number;
  26114. tileWidth?: number;
  26115. tileHeight?: number;
  26116. alignHorizontal?: number;
  26117. alignVertical?: number;
  26118. faceUV?: Vector4[];
  26119. faceColors?: Color4[];
  26120. sideOrientation?: number;
  26121. }): VertexData;
  26122. /**
  26123. * Creates the VertexData for a tiled plane
  26124. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26125. * * pattern a limited pattern arrangement depending on the number
  26126. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  26127. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  26128. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  26129. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26130. * * 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)
  26131. * * 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)
  26132. * @returns the VertexData of the tiled plane
  26133. */
  26134. static CreateTiledPlane(options: {
  26135. pattern?: number;
  26136. tileSize?: number;
  26137. tileWidth?: number;
  26138. tileHeight?: number;
  26139. size?: number;
  26140. width?: number;
  26141. height?: number;
  26142. alignHorizontal?: number;
  26143. alignVertical?: number;
  26144. sideOrientation?: number;
  26145. frontUVs?: Vector4;
  26146. backUVs?: Vector4;
  26147. }): VertexData;
  26148. /**
  26149. * Creates the VertexData for an ellipsoid, defaults to a sphere
  26150. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26151. * * segments sets the number of horizontal strips optional, default 32
  26152. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  26153. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  26154. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  26155. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  26156. * * 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
  26157. * * 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
  26158. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26159. * * 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)
  26160. * * 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)
  26161. * @returns the VertexData of the ellipsoid
  26162. */
  26163. static CreateSphere(options: {
  26164. segments?: number;
  26165. diameter?: number;
  26166. diameterX?: number;
  26167. diameterY?: number;
  26168. diameterZ?: number;
  26169. arc?: number;
  26170. slice?: number;
  26171. sideOrientation?: number;
  26172. frontUVs?: Vector4;
  26173. backUVs?: Vector4;
  26174. }): VertexData;
  26175. /**
  26176. * Creates the VertexData for a cylinder, cone or prism
  26177. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26178. * * height sets the height (y direction) of the cylinder, optional, default 2
  26179. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  26180. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  26181. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  26182. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  26183. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  26184. * * 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
  26185. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26186. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26187. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  26188. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  26189. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26190. * * 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)
  26191. * * 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)
  26192. * @returns the VertexData of the cylinder, cone or prism
  26193. */
  26194. static CreateCylinder(options: {
  26195. height?: number;
  26196. diameterTop?: number;
  26197. diameterBottom?: number;
  26198. diameter?: number;
  26199. tessellation?: number;
  26200. subdivisions?: number;
  26201. arc?: number;
  26202. faceColors?: Color4[];
  26203. faceUV?: Vector4[];
  26204. hasRings?: boolean;
  26205. enclose?: boolean;
  26206. sideOrientation?: number;
  26207. frontUVs?: Vector4;
  26208. backUVs?: Vector4;
  26209. }): VertexData;
  26210. /**
  26211. * Creates the VertexData for a torus
  26212. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26213. * * diameter the diameter of the torus, optional default 1
  26214. * * thickness the diameter of the tube forming the torus, optional default 0.5
  26215. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  26216. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26217. * * 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)
  26218. * * 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)
  26219. * @returns the VertexData of the torus
  26220. */
  26221. static CreateTorus(options: {
  26222. diameter?: number;
  26223. thickness?: number;
  26224. tessellation?: number;
  26225. sideOrientation?: number;
  26226. frontUVs?: Vector4;
  26227. backUVs?: Vector4;
  26228. }): VertexData;
  26229. /**
  26230. * Creates the VertexData of the LineSystem
  26231. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  26232. * - lines an array of lines, each line being an array of successive Vector3
  26233. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  26234. * @returns the VertexData of the LineSystem
  26235. */
  26236. static CreateLineSystem(options: {
  26237. lines: Vector3[][];
  26238. colors?: Nullable<Color4[][]>;
  26239. }): VertexData;
  26240. /**
  26241. * Create the VertexData for a DashedLines
  26242. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  26243. * - points an array successive Vector3
  26244. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  26245. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  26246. * - dashNb the intended total number of dashes, optional, default 200
  26247. * @returns the VertexData for the DashedLines
  26248. */
  26249. static CreateDashedLines(options: {
  26250. points: Vector3[];
  26251. dashSize?: number;
  26252. gapSize?: number;
  26253. dashNb?: number;
  26254. }): VertexData;
  26255. /**
  26256. * Creates the VertexData for a Ground
  26257. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  26258. * - width the width (x direction) of the ground, optional, default 1
  26259. * - height the height (z direction) of the ground, optional, default 1
  26260. * - subdivisions the number of subdivisions per side, optional, default 1
  26261. * @returns the VertexData of the Ground
  26262. */
  26263. static CreateGround(options: {
  26264. width?: number;
  26265. height?: number;
  26266. subdivisions?: number;
  26267. subdivisionsX?: number;
  26268. subdivisionsY?: number;
  26269. }): VertexData;
  26270. /**
  26271. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  26272. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  26273. * * xmin the ground minimum X coordinate, optional, default -1
  26274. * * zmin the ground minimum Z coordinate, optional, default -1
  26275. * * xmax the ground maximum X coordinate, optional, default 1
  26276. * * zmax the ground maximum Z coordinate, optional, default 1
  26277. * * 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}
  26278. * * 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}
  26279. * @returns the VertexData of the TiledGround
  26280. */
  26281. static CreateTiledGround(options: {
  26282. xmin: number;
  26283. zmin: number;
  26284. xmax: number;
  26285. zmax: number;
  26286. subdivisions?: {
  26287. w: number;
  26288. h: number;
  26289. };
  26290. precision?: {
  26291. w: number;
  26292. h: number;
  26293. };
  26294. }): VertexData;
  26295. /**
  26296. * Creates the VertexData of the Ground designed from a heightmap
  26297. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  26298. * * width the width (x direction) of the ground
  26299. * * height the height (z direction) of the ground
  26300. * * subdivisions the number of subdivisions per side
  26301. * * minHeight the minimum altitude on the ground, optional, default 0
  26302. * * maxHeight the maximum altitude on the ground, optional default 1
  26303. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  26304. * * buffer the array holding the image color data
  26305. * * bufferWidth the width of image
  26306. * * bufferHeight the height of image
  26307. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  26308. * @returns the VertexData of the Ground designed from a heightmap
  26309. */
  26310. static CreateGroundFromHeightMap(options: {
  26311. width: number;
  26312. height: number;
  26313. subdivisions: number;
  26314. minHeight: number;
  26315. maxHeight: number;
  26316. colorFilter: Color3;
  26317. buffer: Uint8Array;
  26318. bufferWidth: number;
  26319. bufferHeight: number;
  26320. alphaFilter: number;
  26321. }): VertexData;
  26322. /**
  26323. * Creates the VertexData for a Plane
  26324. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  26325. * * size sets the width and height of the plane to the value of size, optional default 1
  26326. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  26327. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  26328. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26329. * * 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)
  26330. * * 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)
  26331. * @returns the VertexData of the box
  26332. */
  26333. static CreatePlane(options: {
  26334. size?: number;
  26335. width?: number;
  26336. height?: number;
  26337. sideOrientation?: number;
  26338. frontUVs?: Vector4;
  26339. backUVs?: Vector4;
  26340. }): VertexData;
  26341. /**
  26342. * Creates the VertexData of the Disc or regular Polygon
  26343. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  26344. * * radius the radius of the disc, optional default 0.5
  26345. * * tessellation the number of polygon sides, optional, default 64
  26346. * * 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
  26347. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26348. * * 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)
  26349. * * 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)
  26350. * @returns the VertexData of the box
  26351. */
  26352. static CreateDisc(options: {
  26353. radius?: number;
  26354. tessellation?: number;
  26355. arc?: number;
  26356. sideOrientation?: number;
  26357. frontUVs?: Vector4;
  26358. backUVs?: Vector4;
  26359. }): VertexData;
  26360. /**
  26361. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  26362. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  26363. * @param polygon a mesh built from polygonTriangulation.build()
  26364. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26365. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26366. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26367. * @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)
  26368. * @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)
  26369. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  26370. * @returns the VertexData of the Polygon
  26371. */
  26372. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  26373. /**
  26374. * Creates the VertexData of the IcoSphere
  26375. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  26376. * * radius the radius of the IcoSphere, optional default 1
  26377. * * radiusX allows stretching in the x direction, optional, default radius
  26378. * * radiusY allows stretching in the y direction, optional, default radius
  26379. * * radiusZ allows stretching in the z direction, optional, default radius
  26380. * * flat when true creates a flat shaded mesh, optional, default true
  26381. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  26382. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26383. * * 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)
  26384. * * 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)
  26385. * @returns the VertexData of the IcoSphere
  26386. */
  26387. static CreateIcoSphere(options: {
  26388. radius?: number;
  26389. radiusX?: number;
  26390. radiusY?: number;
  26391. radiusZ?: number;
  26392. flat?: boolean;
  26393. subdivisions?: number;
  26394. sideOrientation?: number;
  26395. frontUVs?: Vector4;
  26396. backUVs?: Vector4;
  26397. }): VertexData;
  26398. /**
  26399. * Creates the VertexData for a Polyhedron
  26400. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  26401. * * type provided types are:
  26402. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  26403. * * 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)
  26404. * * size the size of the IcoSphere, optional default 1
  26405. * * sizeX allows stretching in the x direction, optional, default size
  26406. * * sizeY allows stretching in the y direction, optional, default size
  26407. * * sizeZ allows stretching in the z direction, optional, default size
  26408. * * 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
  26409. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26410. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26411. * * flat when true creates a flat shaded mesh, optional, default true
  26412. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  26413. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26414. * * 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)
  26415. * * 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)
  26416. * @returns the VertexData of the Polyhedron
  26417. */
  26418. static CreatePolyhedron(options: {
  26419. type?: number;
  26420. size?: number;
  26421. sizeX?: number;
  26422. sizeY?: number;
  26423. sizeZ?: number;
  26424. custom?: any;
  26425. faceUV?: Vector4[];
  26426. faceColors?: Color4[];
  26427. flat?: boolean;
  26428. sideOrientation?: number;
  26429. frontUVs?: Vector4;
  26430. backUVs?: Vector4;
  26431. }): VertexData;
  26432. /**
  26433. * Creates the VertexData for a TorusKnot
  26434. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  26435. * * radius the radius of the torus knot, optional, default 2
  26436. * * tube the thickness of the tube, optional, default 0.5
  26437. * * radialSegments the number of sides on each tube segments, optional, default 32
  26438. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  26439. * * p the number of windings around the z axis, optional, default 2
  26440. * * q the number of windings around the x axis, optional, default 3
  26441. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26442. * * 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)
  26443. * * 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)
  26444. * @returns the VertexData of the Torus Knot
  26445. */
  26446. static CreateTorusKnot(options: {
  26447. radius?: number;
  26448. tube?: number;
  26449. radialSegments?: number;
  26450. tubularSegments?: number;
  26451. p?: number;
  26452. q?: number;
  26453. sideOrientation?: number;
  26454. frontUVs?: Vector4;
  26455. backUVs?: Vector4;
  26456. }): VertexData;
  26457. /**
  26458. * Compute normals for given positions and indices
  26459. * @param positions an array of vertex positions, [...., x, y, z, ......]
  26460. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  26461. * @param normals an array of vertex normals, [...., x, y, z, ......]
  26462. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  26463. * * facetNormals : optional array of facet normals (vector3)
  26464. * * facetPositions : optional array of facet positions (vector3)
  26465. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  26466. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  26467. * * bInfo : optional bounding info, required for facetPartitioning computation
  26468. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  26469. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  26470. * * useRightHandedSystem: optional boolean to for right handed system computation
  26471. * * depthSort : optional boolean to enable the facet depth sort computation
  26472. * * distanceTo : optional Vector3 to compute the facet depth from this location
  26473. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  26474. */
  26475. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  26476. facetNormals?: any;
  26477. facetPositions?: any;
  26478. facetPartitioning?: any;
  26479. ratio?: number;
  26480. bInfo?: any;
  26481. bbSize?: Vector3;
  26482. subDiv?: any;
  26483. useRightHandedSystem?: boolean;
  26484. depthSort?: boolean;
  26485. distanceTo?: Vector3;
  26486. depthSortedFacets?: any;
  26487. }): void;
  26488. /** @hidden */
  26489. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  26490. /**
  26491. * Applies VertexData created from the imported parameters to the geometry
  26492. * @param parsedVertexData the parsed data from an imported file
  26493. * @param geometry the geometry to apply the VertexData to
  26494. */
  26495. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  26496. }
  26497. }
  26498. declare module "babylonjs/Morph/morphTarget" {
  26499. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  26500. import { Observable } from "babylonjs/Misc/observable";
  26501. import { Nullable, FloatArray } from "babylonjs/types";
  26502. import { Scene } from "babylonjs/scene";
  26503. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26504. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  26505. /**
  26506. * Defines a target to use with MorphTargetManager
  26507. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26508. */
  26509. export class MorphTarget implements IAnimatable {
  26510. /** defines the name of the target */
  26511. name: string;
  26512. /**
  26513. * Gets or sets the list of animations
  26514. */
  26515. animations: import("babylonjs/Animations/animation").Animation[];
  26516. private _scene;
  26517. private _positions;
  26518. private _normals;
  26519. private _tangents;
  26520. private _uvs;
  26521. private _influence;
  26522. private _uniqueId;
  26523. /**
  26524. * Observable raised when the influence changes
  26525. */
  26526. onInfluenceChanged: Observable<boolean>;
  26527. /** @hidden */
  26528. _onDataLayoutChanged: Observable<void>;
  26529. /**
  26530. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  26531. */
  26532. get influence(): number;
  26533. set influence(influence: number);
  26534. /**
  26535. * Gets or sets the id of the morph Target
  26536. */
  26537. id: string;
  26538. private _animationPropertiesOverride;
  26539. /**
  26540. * Gets or sets the animation properties override
  26541. */
  26542. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  26543. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  26544. /**
  26545. * Creates a new MorphTarget
  26546. * @param name defines the name of the target
  26547. * @param influence defines the influence to use
  26548. * @param scene defines the scene the morphtarget belongs to
  26549. */
  26550. constructor(
  26551. /** defines the name of the target */
  26552. name: string, influence?: number, scene?: Nullable<Scene>);
  26553. /**
  26554. * Gets the unique ID of this manager
  26555. */
  26556. get uniqueId(): number;
  26557. /**
  26558. * Gets a boolean defining if the target contains position data
  26559. */
  26560. get hasPositions(): boolean;
  26561. /**
  26562. * Gets a boolean defining if the target contains normal data
  26563. */
  26564. get hasNormals(): boolean;
  26565. /**
  26566. * Gets a boolean defining if the target contains tangent data
  26567. */
  26568. get hasTangents(): boolean;
  26569. /**
  26570. * Gets a boolean defining if the target contains texture coordinates data
  26571. */
  26572. get hasUVs(): boolean;
  26573. /**
  26574. * Affects position data to this target
  26575. * @param data defines the position data to use
  26576. */
  26577. setPositions(data: Nullable<FloatArray>): void;
  26578. /**
  26579. * Gets the position data stored in this target
  26580. * @returns a FloatArray containing the position data (or null if not present)
  26581. */
  26582. getPositions(): Nullable<FloatArray>;
  26583. /**
  26584. * Affects normal data to this target
  26585. * @param data defines the normal data to use
  26586. */
  26587. setNormals(data: Nullable<FloatArray>): void;
  26588. /**
  26589. * Gets the normal data stored in this target
  26590. * @returns a FloatArray containing the normal data (or null if not present)
  26591. */
  26592. getNormals(): Nullable<FloatArray>;
  26593. /**
  26594. * Affects tangent data to this target
  26595. * @param data defines the tangent data to use
  26596. */
  26597. setTangents(data: Nullable<FloatArray>): void;
  26598. /**
  26599. * Gets the tangent data stored in this target
  26600. * @returns a FloatArray containing the tangent data (or null if not present)
  26601. */
  26602. getTangents(): Nullable<FloatArray>;
  26603. /**
  26604. * Affects texture coordinates data to this target
  26605. * @param data defines the texture coordinates data to use
  26606. */
  26607. setUVs(data: Nullable<FloatArray>): void;
  26608. /**
  26609. * Gets the texture coordinates data stored in this target
  26610. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  26611. */
  26612. getUVs(): Nullable<FloatArray>;
  26613. /**
  26614. * Clone the current target
  26615. * @returns a new MorphTarget
  26616. */
  26617. clone(): MorphTarget;
  26618. /**
  26619. * Serializes the current target into a Serialization object
  26620. * @returns the serialized object
  26621. */
  26622. serialize(): any;
  26623. /**
  26624. * Returns the string "MorphTarget"
  26625. * @returns "MorphTarget"
  26626. */
  26627. getClassName(): string;
  26628. /**
  26629. * Creates a new target from serialized data
  26630. * @param serializationObject defines the serialized data to use
  26631. * @returns a new MorphTarget
  26632. */
  26633. static Parse(serializationObject: any): MorphTarget;
  26634. /**
  26635. * Creates a MorphTarget from mesh data
  26636. * @param mesh defines the source mesh
  26637. * @param name defines the name to use for the new target
  26638. * @param influence defines the influence to attach to the target
  26639. * @returns a new MorphTarget
  26640. */
  26641. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  26642. }
  26643. }
  26644. declare module "babylonjs/Morph/morphTargetManager" {
  26645. import { Nullable } from "babylonjs/types";
  26646. import { Scene } from "babylonjs/scene";
  26647. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  26648. /**
  26649. * This class is used to deform meshes using morphing between different targets
  26650. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26651. */
  26652. export class MorphTargetManager {
  26653. private _targets;
  26654. private _targetInfluenceChangedObservers;
  26655. private _targetDataLayoutChangedObservers;
  26656. private _activeTargets;
  26657. private _scene;
  26658. private _influences;
  26659. private _supportsNormals;
  26660. private _supportsTangents;
  26661. private _supportsUVs;
  26662. private _vertexCount;
  26663. private _uniqueId;
  26664. private _tempInfluences;
  26665. /**
  26666. * Gets or sets a boolean indicating if normals must be morphed
  26667. */
  26668. enableNormalMorphing: boolean;
  26669. /**
  26670. * Gets or sets a boolean indicating if tangents must be morphed
  26671. */
  26672. enableTangentMorphing: boolean;
  26673. /**
  26674. * Gets or sets a boolean indicating if UV must be morphed
  26675. */
  26676. enableUVMorphing: boolean;
  26677. /**
  26678. * Creates a new MorphTargetManager
  26679. * @param scene defines the current scene
  26680. */
  26681. constructor(scene?: Nullable<Scene>);
  26682. /**
  26683. * Gets the unique ID of this manager
  26684. */
  26685. get uniqueId(): number;
  26686. /**
  26687. * Gets the number of vertices handled by this manager
  26688. */
  26689. get vertexCount(): number;
  26690. /**
  26691. * Gets a boolean indicating if this manager supports morphing of normals
  26692. */
  26693. get supportsNormals(): boolean;
  26694. /**
  26695. * Gets a boolean indicating if this manager supports morphing of tangents
  26696. */
  26697. get supportsTangents(): boolean;
  26698. /**
  26699. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  26700. */
  26701. get supportsUVs(): boolean;
  26702. /**
  26703. * Gets the number of targets stored in this manager
  26704. */
  26705. get numTargets(): number;
  26706. /**
  26707. * Gets the number of influencers (ie. the number of targets with influences > 0)
  26708. */
  26709. get numInfluencers(): number;
  26710. /**
  26711. * Gets the list of influences (one per target)
  26712. */
  26713. get influences(): Float32Array;
  26714. /**
  26715. * Gets the active target at specified index. An active target is a target with an influence > 0
  26716. * @param index defines the index to check
  26717. * @returns the requested target
  26718. */
  26719. getActiveTarget(index: number): MorphTarget;
  26720. /**
  26721. * Gets the target at specified index
  26722. * @param index defines the index to check
  26723. * @returns the requested target
  26724. */
  26725. getTarget(index: number): MorphTarget;
  26726. /**
  26727. * Add a new target to this manager
  26728. * @param target defines the target to add
  26729. */
  26730. addTarget(target: MorphTarget): void;
  26731. /**
  26732. * Removes a target from the manager
  26733. * @param target defines the target to remove
  26734. */
  26735. removeTarget(target: MorphTarget): void;
  26736. /**
  26737. * Clone the current manager
  26738. * @returns a new MorphTargetManager
  26739. */
  26740. clone(): MorphTargetManager;
  26741. /**
  26742. * Serializes the current manager into a Serialization object
  26743. * @returns the serialized object
  26744. */
  26745. serialize(): any;
  26746. private _syncActiveTargets;
  26747. /**
  26748. * Syncrhonize the targets with all the meshes using this morph target manager
  26749. */
  26750. synchronize(): void;
  26751. /**
  26752. * Creates a new MorphTargetManager from serialized data
  26753. * @param serializationObject defines the serialized data
  26754. * @param scene defines the hosting scene
  26755. * @returns the new MorphTargetManager
  26756. */
  26757. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  26758. }
  26759. }
  26760. declare module "babylonjs/Meshes/meshLODLevel" {
  26761. import { Mesh } from "babylonjs/Meshes/mesh";
  26762. import { Nullable } from "babylonjs/types";
  26763. /**
  26764. * Class used to represent a specific level of detail of a mesh
  26765. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  26766. */
  26767. export class MeshLODLevel {
  26768. /** Defines the distance where this level should start being displayed */
  26769. distance: number;
  26770. /** Defines the mesh to use to render this level */
  26771. mesh: Nullable<Mesh>;
  26772. /**
  26773. * Creates a new LOD level
  26774. * @param distance defines the distance where this level should star being displayed
  26775. * @param mesh defines the mesh to use to render this level
  26776. */
  26777. constructor(
  26778. /** Defines the distance where this level should start being displayed */
  26779. distance: number,
  26780. /** Defines the mesh to use to render this level */
  26781. mesh: Nullable<Mesh>);
  26782. }
  26783. }
  26784. declare module "babylonjs/Meshes/groundMesh" {
  26785. import { Scene } from "babylonjs/scene";
  26786. import { Vector3 } from "babylonjs/Maths/math.vector";
  26787. import { Mesh } from "babylonjs/Meshes/mesh";
  26788. /**
  26789. * Mesh representing the gorund
  26790. */
  26791. export class GroundMesh extends Mesh {
  26792. /** If octree should be generated */
  26793. generateOctree: boolean;
  26794. private _heightQuads;
  26795. /** @hidden */
  26796. _subdivisionsX: number;
  26797. /** @hidden */
  26798. _subdivisionsY: number;
  26799. /** @hidden */
  26800. _width: number;
  26801. /** @hidden */
  26802. _height: number;
  26803. /** @hidden */
  26804. _minX: number;
  26805. /** @hidden */
  26806. _maxX: number;
  26807. /** @hidden */
  26808. _minZ: number;
  26809. /** @hidden */
  26810. _maxZ: number;
  26811. constructor(name: string, scene: Scene);
  26812. /**
  26813. * "GroundMesh"
  26814. * @returns "GroundMesh"
  26815. */
  26816. getClassName(): string;
  26817. /**
  26818. * The minimum of x and y subdivisions
  26819. */
  26820. get subdivisions(): number;
  26821. /**
  26822. * X subdivisions
  26823. */
  26824. get subdivisionsX(): number;
  26825. /**
  26826. * Y subdivisions
  26827. */
  26828. get subdivisionsY(): number;
  26829. /**
  26830. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  26831. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  26832. * @param chunksCount the number of subdivisions for x and y
  26833. * @param octreeBlocksSize (Default: 32)
  26834. */
  26835. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  26836. /**
  26837. * Returns a height (y) value in the Worl system :
  26838. * the ground altitude at the coordinates (x, z) expressed in the World system.
  26839. * @param x x coordinate
  26840. * @param z z coordinate
  26841. * @returns the ground y position if (x, z) are outside the ground surface.
  26842. */
  26843. getHeightAtCoordinates(x: number, z: number): number;
  26844. /**
  26845. * Returns a normalized vector (Vector3) orthogonal to the ground
  26846. * at the ground coordinates (x, z) expressed in the World system.
  26847. * @param x x coordinate
  26848. * @param z z coordinate
  26849. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  26850. */
  26851. getNormalAtCoordinates(x: number, z: number): Vector3;
  26852. /**
  26853. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  26854. * at the ground coordinates (x, z) expressed in the World system.
  26855. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  26856. * @param x x coordinate
  26857. * @param z z coordinate
  26858. * @param ref vector to store the result
  26859. * @returns the GroundMesh.
  26860. */
  26861. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  26862. /**
  26863. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  26864. * if the ground has been updated.
  26865. * This can be used in the render loop.
  26866. * @returns the GroundMesh.
  26867. */
  26868. updateCoordinateHeights(): GroundMesh;
  26869. private _getFacetAt;
  26870. private _initHeightQuads;
  26871. private _computeHeightQuads;
  26872. /**
  26873. * Serializes this ground mesh
  26874. * @param serializationObject object to write serialization to
  26875. */
  26876. serialize(serializationObject: any): void;
  26877. /**
  26878. * Parses a serialized ground mesh
  26879. * @param parsedMesh the serialized mesh
  26880. * @param scene the scene to create the ground mesh in
  26881. * @returns the created ground mesh
  26882. */
  26883. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  26884. }
  26885. }
  26886. declare module "babylonjs/Physics/physicsJoint" {
  26887. import { Vector3 } from "babylonjs/Maths/math.vector";
  26888. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  26889. /**
  26890. * Interface for Physics-Joint data
  26891. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26892. */
  26893. export interface PhysicsJointData {
  26894. /**
  26895. * The main pivot of the joint
  26896. */
  26897. mainPivot?: Vector3;
  26898. /**
  26899. * The connected pivot of the joint
  26900. */
  26901. connectedPivot?: Vector3;
  26902. /**
  26903. * The main axis of the joint
  26904. */
  26905. mainAxis?: Vector3;
  26906. /**
  26907. * The connected axis of the joint
  26908. */
  26909. connectedAxis?: Vector3;
  26910. /**
  26911. * The collision of the joint
  26912. */
  26913. collision?: boolean;
  26914. /**
  26915. * Native Oimo/Cannon/Energy data
  26916. */
  26917. nativeParams?: any;
  26918. }
  26919. /**
  26920. * This is a holder class for the physics joint created by the physics plugin
  26921. * It holds a set of functions to control the underlying joint
  26922. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26923. */
  26924. export class PhysicsJoint {
  26925. /**
  26926. * The type of the physics joint
  26927. */
  26928. type: number;
  26929. /**
  26930. * The data for the physics joint
  26931. */
  26932. jointData: PhysicsJointData;
  26933. private _physicsJoint;
  26934. protected _physicsPlugin: IPhysicsEnginePlugin;
  26935. /**
  26936. * Initializes the physics joint
  26937. * @param type The type of the physics joint
  26938. * @param jointData The data for the physics joint
  26939. */
  26940. constructor(
  26941. /**
  26942. * The type of the physics joint
  26943. */
  26944. type: number,
  26945. /**
  26946. * The data for the physics joint
  26947. */
  26948. jointData: PhysicsJointData);
  26949. /**
  26950. * Gets the physics joint
  26951. */
  26952. get physicsJoint(): any;
  26953. /**
  26954. * Sets the physics joint
  26955. */
  26956. set physicsJoint(newJoint: any);
  26957. /**
  26958. * Sets the physics plugin
  26959. */
  26960. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  26961. /**
  26962. * Execute a function that is physics-plugin specific.
  26963. * @param {Function} func the function that will be executed.
  26964. * It accepts two parameters: the physics world and the physics joint
  26965. */
  26966. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  26967. /**
  26968. * Distance-Joint type
  26969. */
  26970. static DistanceJoint: number;
  26971. /**
  26972. * Hinge-Joint type
  26973. */
  26974. static HingeJoint: number;
  26975. /**
  26976. * Ball-and-Socket joint type
  26977. */
  26978. static BallAndSocketJoint: number;
  26979. /**
  26980. * Wheel-Joint type
  26981. */
  26982. static WheelJoint: number;
  26983. /**
  26984. * Slider-Joint type
  26985. */
  26986. static SliderJoint: number;
  26987. /**
  26988. * Prismatic-Joint type
  26989. */
  26990. static PrismaticJoint: number;
  26991. /**
  26992. * Universal-Joint type
  26993. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  26994. */
  26995. static UniversalJoint: number;
  26996. /**
  26997. * Hinge-Joint 2 type
  26998. */
  26999. static Hinge2Joint: number;
  27000. /**
  27001. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  27002. */
  27003. static PointToPointJoint: number;
  27004. /**
  27005. * Spring-Joint type
  27006. */
  27007. static SpringJoint: number;
  27008. /**
  27009. * Lock-Joint type
  27010. */
  27011. static LockJoint: number;
  27012. }
  27013. /**
  27014. * A class representing a physics distance joint
  27015. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27016. */
  27017. export class DistanceJoint extends PhysicsJoint {
  27018. /**
  27019. *
  27020. * @param jointData The data for the Distance-Joint
  27021. */
  27022. constructor(jointData: DistanceJointData);
  27023. /**
  27024. * Update the predefined distance.
  27025. * @param maxDistance The maximum preferred distance
  27026. * @param minDistance The minimum preferred distance
  27027. */
  27028. updateDistance(maxDistance: number, minDistance?: number): void;
  27029. }
  27030. /**
  27031. * Represents a Motor-Enabled Joint
  27032. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27033. */
  27034. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  27035. /**
  27036. * Initializes the Motor-Enabled Joint
  27037. * @param type The type of the joint
  27038. * @param jointData The physica joint data for the joint
  27039. */
  27040. constructor(type: number, jointData: PhysicsJointData);
  27041. /**
  27042. * Set the motor values.
  27043. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27044. * @param force the force to apply
  27045. * @param maxForce max force for this motor.
  27046. */
  27047. setMotor(force?: number, maxForce?: number): void;
  27048. /**
  27049. * Set the motor's limits.
  27050. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27051. * @param upperLimit The upper limit of the motor
  27052. * @param lowerLimit The lower limit of the motor
  27053. */
  27054. setLimit(upperLimit: number, lowerLimit?: number): void;
  27055. }
  27056. /**
  27057. * This class represents a single physics Hinge-Joint
  27058. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27059. */
  27060. export class HingeJoint extends MotorEnabledJoint {
  27061. /**
  27062. * Initializes the Hinge-Joint
  27063. * @param jointData The joint data for the Hinge-Joint
  27064. */
  27065. constructor(jointData: PhysicsJointData);
  27066. /**
  27067. * Set the motor values.
  27068. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27069. * @param {number} force the force to apply
  27070. * @param {number} maxForce max force for this motor.
  27071. */
  27072. setMotor(force?: number, maxForce?: number): void;
  27073. /**
  27074. * Set the motor's limits.
  27075. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27076. * @param upperLimit The upper limit of the motor
  27077. * @param lowerLimit The lower limit of the motor
  27078. */
  27079. setLimit(upperLimit: number, lowerLimit?: number): void;
  27080. }
  27081. /**
  27082. * This class represents a dual hinge physics joint (same as wheel joint)
  27083. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27084. */
  27085. export class Hinge2Joint extends MotorEnabledJoint {
  27086. /**
  27087. * Initializes the Hinge2-Joint
  27088. * @param jointData The joint data for the Hinge2-Joint
  27089. */
  27090. constructor(jointData: PhysicsJointData);
  27091. /**
  27092. * Set the motor values.
  27093. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27094. * @param {number} targetSpeed the speed the motor is to reach
  27095. * @param {number} maxForce max force for this motor.
  27096. * @param {motorIndex} the motor's index, 0 or 1.
  27097. */
  27098. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  27099. /**
  27100. * Set the motor limits.
  27101. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27102. * @param {number} upperLimit the upper limit
  27103. * @param {number} lowerLimit lower limit
  27104. * @param {motorIndex} the motor's index, 0 or 1.
  27105. */
  27106. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27107. }
  27108. /**
  27109. * Interface for a motor enabled joint
  27110. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27111. */
  27112. export interface IMotorEnabledJoint {
  27113. /**
  27114. * Physics joint
  27115. */
  27116. physicsJoint: any;
  27117. /**
  27118. * Sets the motor of the motor-enabled joint
  27119. * @param force The force of the motor
  27120. * @param maxForce The maximum force of the motor
  27121. * @param motorIndex The index of the motor
  27122. */
  27123. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  27124. /**
  27125. * Sets the limit of the motor
  27126. * @param upperLimit The upper limit of the motor
  27127. * @param lowerLimit The lower limit of the motor
  27128. * @param motorIndex The index of the motor
  27129. */
  27130. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27131. }
  27132. /**
  27133. * Joint data for a Distance-Joint
  27134. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27135. */
  27136. export interface DistanceJointData extends PhysicsJointData {
  27137. /**
  27138. * Max distance the 2 joint objects can be apart
  27139. */
  27140. maxDistance: number;
  27141. }
  27142. /**
  27143. * Joint data from a spring joint
  27144. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27145. */
  27146. export interface SpringJointData extends PhysicsJointData {
  27147. /**
  27148. * Length of the spring
  27149. */
  27150. length: number;
  27151. /**
  27152. * Stiffness of the spring
  27153. */
  27154. stiffness: number;
  27155. /**
  27156. * Damping of the spring
  27157. */
  27158. damping: number;
  27159. /** this callback will be called when applying the force to the impostors. */
  27160. forceApplicationCallback: () => void;
  27161. }
  27162. }
  27163. declare module "babylonjs/Physics/physicsRaycastResult" {
  27164. import { Vector3 } from "babylonjs/Maths/math.vector";
  27165. /**
  27166. * Holds the data for the raycast result
  27167. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27168. */
  27169. export class PhysicsRaycastResult {
  27170. private _hasHit;
  27171. private _hitDistance;
  27172. private _hitNormalWorld;
  27173. private _hitPointWorld;
  27174. private _rayFromWorld;
  27175. private _rayToWorld;
  27176. /**
  27177. * Gets if there was a hit
  27178. */
  27179. get hasHit(): boolean;
  27180. /**
  27181. * Gets the distance from the hit
  27182. */
  27183. get hitDistance(): number;
  27184. /**
  27185. * Gets the hit normal/direction in the world
  27186. */
  27187. get hitNormalWorld(): Vector3;
  27188. /**
  27189. * Gets the hit point in the world
  27190. */
  27191. get hitPointWorld(): Vector3;
  27192. /**
  27193. * Gets the ray "start point" of the ray in the world
  27194. */
  27195. get rayFromWorld(): Vector3;
  27196. /**
  27197. * Gets the ray "end point" of the ray in the world
  27198. */
  27199. get rayToWorld(): Vector3;
  27200. /**
  27201. * Sets the hit data (normal & point in world space)
  27202. * @param hitNormalWorld defines the normal in world space
  27203. * @param hitPointWorld defines the point in world space
  27204. */
  27205. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  27206. /**
  27207. * Sets the distance from the start point to the hit point
  27208. * @param distance
  27209. */
  27210. setHitDistance(distance: number): void;
  27211. /**
  27212. * Calculates the distance manually
  27213. */
  27214. calculateHitDistance(): void;
  27215. /**
  27216. * Resets all the values to default
  27217. * @param from The from point on world space
  27218. * @param to The to point on world space
  27219. */
  27220. reset(from?: Vector3, to?: Vector3): void;
  27221. }
  27222. /**
  27223. * Interface for the size containing width and height
  27224. */
  27225. interface IXYZ {
  27226. /**
  27227. * X
  27228. */
  27229. x: number;
  27230. /**
  27231. * Y
  27232. */
  27233. y: number;
  27234. /**
  27235. * Z
  27236. */
  27237. z: number;
  27238. }
  27239. }
  27240. declare module "babylonjs/Physics/IPhysicsEngine" {
  27241. import { Nullable } from "babylonjs/types";
  27242. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  27243. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27244. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  27245. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  27246. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  27247. /**
  27248. * Interface used to describe a physics joint
  27249. */
  27250. export interface PhysicsImpostorJoint {
  27251. /** Defines the main impostor to which the joint is linked */
  27252. mainImpostor: PhysicsImpostor;
  27253. /** Defines the impostor that is connected to the main impostor using this joint */
  27254. connectedImpostor: PhysicsImpostor;
  27255. /** Defines the joint itself */
  27256. joint: PhysicsJoint;
  27257. }
  27258. /** @hidden */
  27259. export interface IPhysicsEnginePlugin {
  27260. world: any;
  27261. name: string;
  27262. setGravity(gravity: Vector3): void;
  27263. setTimeStep(timeStep: number): void;
  27264. getTimeStep(): number;
  27265. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  27266. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27267. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27268. generatePhysicsBody(impostor: PhysicsImpostor): void;
  27269. removePhysicsBody(impostor: PhysicsImpostor): void;
  27270. generateJoint(joint: PhysicsImpostorJoint): void;
  27271. removeJoint(joint: PhysicsImpostorJoint): void;
  27272. isSupported(): boolean;
  27273. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  27274. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  27275. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  27276. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  27277. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27278. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27279. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  27280. getBodyMass(impostor: PhysicsImpostor): number;
  27281. getBodyFriction(impostor: PhysicsImpostor): number;
  27282. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  27283. getBodyRestitution(impostor: PhysicsImpostor): number;
  27284. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  27285. getBodyPressure?(impostor: PhysicsImpostor): number;
  27286. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  27287. getBodyStiffness?(impostor: PhysicsImpostor): number;
  27288. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  27289. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  27290. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  27291. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  27292. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  27293. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  27294. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  27295. sleepBody(impostor: PhysicsImpostor): void;
  27296. wakeUpBody(impostor: PhysicsImpostor): void;
  27297. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  27298. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  27299. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  27300. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27301. getRadius(impostor: PhysicsImpostor): number;
  27302. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  27303. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  27304. dispose(): void;
  27305. }
  27306. /**
  27307. * Interface used to define a physics engine
  27308. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  27309. */
  27310. export interface IPhysicsEngine {
  27311. /**
  27312. * Gets the gravity vector used by the simulation
  27313. */
  27314. gravity: Vector3;
  27315. /**
  27316. * Sets the gravity vector used by the simulation
  27317. * @param gravity defines the gravity vector to use
  27318. */
  27319. setGravity(gravity: Vector3): void;
  27320. /**
  27321. * Set the time step of the physics engine.
  27322. * Default is 1/60.
  27323. * To slow it down, enter 1/600 for example.
  27324. * To speed it up, 1/30
  27325. * @param newTimeStep the new timestep to apply to this world.
  27326. */
  27327. setTimeStep(newTimeStep: number): void;
  27328. /**
  27329. * Get the time step of the physics engine.
  27330. * @returns the current time step
  27331. */
  27332. getTimeStep(): number;
  27333. /**
  27334. * Set the sub time step of the physics engine.
  27335. * Default is 0 meaning there is no sub steps
  27336. * To increase physics resolution precision, set a small value (like 1 ms)
  27337. * @param subTimeStep defines the new sub timestep used for physics resolution.
  27338. */
  27339. setSubTimeStep(subTimeStep: number): void;
  27340. /**
  27341. * Get the sub time step of the physics engine.
  27342. * @returns the current sub time step
  27343. */
  27344. getSubTimeStep(): number;
  27345. /**
  27346. * Release all resources
  27347. */
  27348. dispose(): void;
  27349. /**
  27350. * Gets the name of the current physics plugin
  27351. * @returns the name of the plugin
  27352. */
  27353. getPhysicsPluginName(): string;
  27354. /**
  27355. * Adding a new impostor for the impostor tracking.
  27356. * This will be done by the impostor itself.
  27357. * @param impostor the impostor to add
  27358. */
  27359. addImpostor(impostor: PhysicsImpostor): void;
  27360. /**
  27361. * Remove an impostor from the engine.
  27362. * This impostor and its mesh will not longer be updated by the physics engine.
  27363. * @param impostor the impostor to remove
  27364. */
  27365. removeImpostor(impostor: PhysicsImpostor): void;
  27366. /**
  27367. * Add a joint to the physics engine
  27368. * @param mainImpostor defines the main impostor to which the joint is added.
  27369. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  27370. * @param joint defines the joint that will connect both impostors.
  27371. */
  27372. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  27373. /**
  27374. * Removes a joint from the simulation
  27375. * @param mainImpostor defines the impostor used with the joint
  27376. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  27377. * @param joint defines the joint to remove
  27378. */
  27379. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  27380. /**
  27381. * Gets the current plugin used to run the simulation
  27382. * @returns current plugin
  27383. */
  27384. getPhysicsPlugin(): IPhysicsEnginePlugin;
  27385. /**
  27386. * Gets the list of physic impostors
  27387. * @returns an array of PhysicsImpostor
  27388. */
  27389. getImpostors(): Array<PhysicsImpostor>;
  27390. /**
  27391. * Gets the impostor for a physics enabled object
  27392. * @param object defines the object impersonated by the impostor
  27393. * @returns the PhysicsImpostor or null if not found
  27394. */
  27395. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27396. /**
  27397. * Gets the impostor for a physics body object
  27398. * @param body defines physics body used by the impostor
  27399. * @returns the PhysicsImpostor or null if not found
  27400. */
  27401. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  27402. /**
  27403. * Does a raycast in the physics world
  27404. * @param from when should the ray start?
  27405. * @param to when should the ray end?
  27406. * @returns PhysicsRaycastResult
  27407. */
  27408. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  27409. /**
  27410. * Called by the scene. No need to call it.
  27411. * @param delta defines the timespam between frames
  27412. */
  27413. _step(delta: number): void;
  27414. }
  27415. }
  27416. declare module "babylonjs/Physics/physicsImpostor" {
  27417. import { Nullable, IndicesArray } from "babylonjs/types";
  27418. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  27419. import { TransformNode } from "babylonjs/Meshes/transformNode";
  27420. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27421. import { Scene } from "babylonjs/scene";
  27422. import { Bone } from "babylonjs/Bones/bone";
  27423. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  27424. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  27425. import { Space } from "babylonjs/Maths/math.axis";
  27426. /**
  27427. * The interface for the physics imposter parameters
  27428. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27429. */
  27430. export interface PhysicsImpostorParameters {
  27431. /**
  27432. * The mass of the physics imposter
  27433. */
  27434. mass: number;
  27435. /**
  27436. * The friction of the physics imposter
  27437. */
  27438. friction?: number;
  27439. /**
  27440. * The coefficient of restitution of the physics imposter
  27441. */
  27442. restitution?: number;
  27443. /**
  27444. * The native options of the physics imposter
  27445. */
  27446. nativeOptions?: any;
  27447. /**
  27448. * Specifies if the parent should be ignored
  27449. */
  27450. ignoreParent?: boolean;
  27451. /**
  27452. * Specifies if bi-directional transformations should be disabled
  27453. */
  27454. disableBidirectionalTransformation?: boolean;
  27455. /**
  27456. * The pressure inside the physics imposter, soft object only
  27457. */
  27458. pressure?: number;
  27459. /**
  27460. * The stiffness the physics imposter, soft object only
  27461. */
  27462. stiffness?: number;
  27463. /**
  27464. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  27465. */
  27466. velocityIterations?: number;
  27467. /**
  27468. * The number of iterations used in maintaining consistent vertex positions, soft object only
  27469. */
  27470. positionIterations?: number;
  27471. /**
  27472. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  27473. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  27474. * Add to fix multiple points
  27475. */
  27476. fixedPoints?: number;
  27477. /**
  27478. * The collision margin around a soft object
  27479. */
  27480. margin?: number;
  27481. /**
  27482. * The collision margin around a soft object
  27483. */
  27484. damping?: number;
  27485. /**
  27486. * The path for a rope based on an extrusion
  27487. */
  27488. path?: any;
  27489. /**
  27490. * The shape of an extrusion used for a rope based on an extrusion
  27491. */
  27492. shape?: any;
  27493. }
  27494. /**
  27495. * Interface for a physics-enabled object
  27496. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27497. */
  27498. export interface IPhysicsEnabledObject {
  27499. /**
  27500. * The position of the physics-enabled object
  27501. */
  27502. position: Vector3;
  27503. /**
  27504. * The rotation of the physics-enabled object
  27505. */
  27506. rotationQuaternion: Nullable<Quaternion>;
  27507. /**
  27508. * The scale of the physics-enabled object
  27509. */
  27510. scaling: Vector3;
  27511. /**
  27512. * The rotation of the physics-enabled object
  27513. */
  27514. rotation?: Vector3;
  27515. /**
  27516. * The parent of the physics-enabled object
  27517. */
  27518. parent?: any;
  27519. /**
  27520. * The bounding info of the physics-enabled object
  27521. * @returns The bounding info of the physics-enabled object
  27522. */
  27523. getBoundingInfo(): BoundingInfo;
  27524. /**
  27525. * Computes the world matrix
  27526. * @param force Specifies if the world matrix should be computed by force
  27527. * @returns A world matrix
  27528. */
  27529. computeWorldMatrix(force: boolean): Matrix;
  27530. /**
  27531. * Gets the world matrix
  27532. * @returns A world matrix
  27533. */
  27534. getWorldMatrix?(): Matrix;
  27535. /**
  27536. * Gets the child meshes
  27537. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  27538. * @returns An array of abstract meshes
  27539. */
  27540. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  27541. /**
  27542. * Gets the vertex data
  27543. * @param kind The type of vertex data
  27544. * @returns A nullable array of numbers, or a float32 array
  27545. */
  27546. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  27547. /**
  27548. * Gets the indices from the mesh
  27549. * @returns A nullable array of index arrays
  27550. */
  27551. getIndices?(): Nullable<IndicesArray>;
  27552. /**
  27553. * Gets the scene from the mesh
  27554. * @returns the indices array or null
  27555. */
  27556. getScene?(): Scene;
  27557. /**
  27558. * Gets the absolute position from the mesh
  27559. * @returns the absolute position
  27560. */
  27561. getAbsolutePosition(): Vector3;
  27562. /**
  27563. * Gets the absolute pivot point from the mesh
  27564. * @returns the absolute pivot point
  27565. */
  27566. getAbsolutePivotPoint(): Vector3;
  27567. /**
  27568. * Rotates the mesh
  27569. * @param axis The axis of rotation
  27570. * @param amount The amount of rotation
  27571. * @param space The space of the rotation
  27572. * @returns The rotation transform node
  27573. */
  27574. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  27575. /**
  27576. * Translates the mesh
  27577. * @param axis The axis of translation
  27578. * @param distance The distance of translation
  27579. * @param space The space of the translation
  27580. * @returns The transform node
  27581. */
  27582. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  27583. /**
  27584. * Sets the absolute position of the mesh
  27585. * @param absolutePosition The absolute position of the mesh
  27586. * @returns The transform node
  27587. */
  27588. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  27589. /**
  27590. * Gets the class name of the mesh
  27591. * @returns The class name
  27592. */
  27593. getClassName(): string;
  27594. }
  27595. /**
  27596. * Represents a physics imposter
  27597. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27598. */
  27599. export class PhysicsImpostor {
  27600. /**
  27601. * The physics-enabled object used as the physics imposter
  27602. */
  27603. object: IPhysicsEnabledObject;
  27604. /**
  27605. * The type of the physics imposter
  27606. */
  27607. type: number;
  27608. private _options;
  27609. private _scene?;
  27610. /**
  27611. * The default object size of the imposter
  27612. */
  27613. static DEFAULT_OBJECT_SIZE: Vector3;
  27614. /**
  27615. * The identity quaternion of the imposter
  27616. */
  27617. static IDENTITY_QUATERNION: Quaternion;
  27618. /** @hidden */
  27619. _pluginData: any;
  27620. private _physicsEngine;
  27621. private _physicsBody;
  27622. private _bodyUpdateRequired;
  27623. private _onBeforePhysicsStepCallbacks;
  27624. private _onAfterPhysicsStepCallbacks;
  27625. /** @hidden */
  27626. _onPhysicsCollideCallbacks: Array<{
  27627. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  27628. otherImpostors: Array<PhysicsImpostor>;
  27629. }>;
  27630. private _deltaPosition;
  27631. private _deltaRotation;
  27632. private _deltaRotationConjugated;
  27633. /** @hidden */
  27634. _isFromLine: boolean;
  27635. private _parent;
  27636. private _isDisposed;
  27637. private static _tmpVecs;
  27638. private static _tmpQuat;
  27639. /**
  27640. * Specifies if the physics imposter is disposed
  27641. */
  27642. get isDisposed(): boolean;
  27643. /**
  27644. * Gets the mass of the physics imposter
  27645. */
  27646. get mass(): number;
  27647. set mass(value: number);
  27648. /**
  27649. * Gets the coefficient of friction
  27650. */
  27651. get friction(): number;
  27652. /**
  27653. * Sets the coefficient of friction
  27654. */
  27655. set friction(value: number);
  27656. /**
  27657. * Gets the coefficient of restitution
  27658. */
  27659. get restitution(): number;
  27660. /**
  27661. * Sets the coefficient of restitution
  27662. */
  27663. set restitution(value: number);
  27664. /**
  27665. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  27666. */
  27667. get pressure(): number;
  27668. /**
  27669. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  27670. */
  27671. set pressure(value: number);
  27672. /**
  27673. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  27674. */
  27675. get stiffness(): number;
  27676. /**
  27677. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  27678. */
  27679. set stiffness(value: number);
  27680. /**
  27681. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  27682. */
  27683. get velocityIterations(): number;
  27684. /**
  27685. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  27686. */
  27687. set velocityIterations(value: number);
  27688. /**
  27689. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  27690. */
  27691. get positionIterations(): number;
  27692. /**
  27693. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  27694. */
  27695. set positionIterations(value: number);
  27696. /**
  27697. * The unique id of the physics imposter
  27698. * set by the physics engine when adding this impostor to the array
  27699. */
  27700. uniqueId: number;
  27701. /**
  27702. * @hidden
  27703. */
  27704. soft: boolean;
  27705. /**
  27706. * @hidden
  27707. */
  27708. segments: number;
  27709. private _joints;
  27710. /**
  27711. * Initializes the physics imposter
  27712. * @param object The physics-enabled object used as the physics imposter
  27713. * @param type The type of the physics imposter
  27714. * @param _options The options for the physics imposter
  27715. * @param _scene The Babylon scene
  27716. */
  27717. constructor(
  27718. /**
  27719. * The physics-enabled object used as the physics imposter
  27720. */
  27721. object: IPhysicsEnabledObject,
  27722. /**
  27723. * The type of the physics imposter
  27724. */
  27725. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  27726. /**
  27727. * This function will completly initialize this impostor.
  27728. * It will create a new body - but only if this mesh has no parent.
  27729. * If it has, this impostor will not be used other than to define the impostor
  27730. * of the child mesh.
  27731. * @hidden
  27732. */
  27733. _init(): void;
  27734. private _getPhysicsParent;
  27735. /**
  27736. * Should a new body be generated.
  27737. * @returns boolean specifying if body initialization is required
  27738. */
  27739. isBodyInitRequired(): boolean;
  27740. /**
  27741. * Sets the updated scaling
  27742. * @param updated Specifies if the scaling is updated
  27743. */
  27744. setScalingUpdated(): void;
  27745. /**
  27746. * Force a regeneration of this or the parent's impostor's body.
  27747. * Use under cautious - This will remove all joints already implemented.
  27748. */
  27749. forceUpdate(): void;
  27750. /**
  27751. * Gets the body that holds this impostor. Either its own, or its parent.
  27752. */
  27753. get physicsBody(): any;
  27754. /**
  27755. * Get the parent of the physics imposter
  27756. * @returns Physics imposter or null
  27757. */
  27758. get parent(): Nullable<PhysicsImpostor>;
  27759. /**
  27760. * Sets the parent of the physics imposter
  27761. */
  27762. set parent(value: Nullable<PhysicsImpostor>);
  27763. /**
  27764. * Set the physics body. Used mainly by the physics engine/plugin
  27765. */
  27766. set physicsBody(physicsBody: any);
  27767. /**
  27768. * Resets the update flags
  27769. */
  27770. resetUpdateFlags(): void;
  27771. /**
  27772. * Gets the object extend size
  27773. * @returns the object extend size
  27774. */
  27775. getObjectExtendSize(): Vector3;
  27776. /**
  27777. * Gets the object center
  27778. * @returns The object center
  27779. */
  27780. getObjectCenter(): Vector3;
  27781. /**
  27782. * Get a specific parameter from the options parameters
  27783. * @param paramName The object parameter name
  27784. * @returns The object parameter
  27785. */
  27786. getParam(paramName: string): any;
  27787. /**
  27788. * Sets a specific parameter in the options given to the physics plugin
  27789. * @param paramName The parameter name
  27790. * @param value The value of the parameter
  27791. */
  27792. setParam(paramName: string, value: number): void;
  27793. /**
  27794. * Specifically change the body's mass option. Won't recreate the physics body object
  27795. * @param mass The mass of the physics imposter
  27796. */
  27797. setMass(mass: number): void;
  27798. /**
  27799. * Gets the linear velocity
  27800. * @returns linear velocity or null
  27801. */
  27802. getLinearVelocity(): Nullable<Vector3>;
  27803. /**
  27804. * Sets the linear velocity
  27805. * @param velocity linear velocity or null
  27806. */
  27807. setLinearVelocity(velocity: Nullable<Vector3>): void;
  27808. /**
  27809. * Gets the angular velocity
  27810. * @returns angular velocity or null
  27811. */
  27812. getAngularVelocity(): Nullable<Vector3>;
  27813. /**
  27814. * Sets the angular velocity
  27815. * @param velocity The velocity or null
  27816. */
  27817. setAngularVelocity(velocity: Nullable<Vector3>): void;
  27818. /**
  27819. * Execute a function with the physics plugin native code
  27820. * Provide a function the will have two variables - the world object and the physics body object
  27821. * @param func The function to execute with the physics plugin native code
  27822. */
  27823. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  27824. /**
  27825. * Register a function that will be executed before the physics world is stepping forward
  27826. * @param func The function to execute before the physics world is stepped forward
  27827. */
  27828. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27829. /**
  27830. * Unregister a function that will be executed before the physics world is stepping forward
  27831. * @param func The function to execute before the physics world is stepped forward
  27832. */
  27833. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27834. /**
  27835. * Register a function that will be executed after the physics step
  27836. * @param func The function to execute after physics step
  27837. */
  27838. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27839. /**
  27840. * Unregisters a function that will be executed after the physics step
  27841. * @param func The function to execute after physics step
  27842. */
  27843. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27844. /**
  27845. * register a function that will be executed when this impostor collides against a different body
  27846. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  27847. * @param func Callback that is executed on collision
  27848. */
  27849. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  27850. /**
  27851. * Unregisters the physics imposter on contact
  27852. * @param collideAgainst The physics object to collide against
  27853. * @param func Callback to execute on collision
  27854. */
  27855. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  27856. private _tmpQuat;
  27857. private _tmpQuat2;
  27858. /**
  27859. * Get the parent rotation
  27860. * @returns The parent rotation
  27861. */
  27862. getParentsRotation(): Quaternion;
  27863. /**
  27864. * this function is executed by the physics engine.
  27865. */
  27866. beforeStep: () => void;
  27867. /**
  27868. * this function is executed by the physics engine
  27869. */
  27870. afterStep: () => void;
  27871. /**
  27872. * Legacy collision detection event support
  27873. */
  27874. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  27875. /**
  27876. * event and body object due to cannon's event-based architecture.
  27877. */
  27878. onCollide: (e: {
  27879. body: any;
  27880. }) => void;
  27881. /**
  27882. * Apply a force
  27883. * @param force The force to apply
  27884. * @param contactPoint The contact point for the force
  27885. * @returns The physics imposter
  27886. */
  27887. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27888. /**
  27889. * Apply an impulse
  27890. * @param force The impulse force
  27891. * @param contactPoint The contact point for the impulse force
  27892. * @returns The physics imposter
  27893. */
  27894. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27895. /**
  27896. * A help function to create a joint
  27897. * @param otherImpostor A physics imposter used to create a joint
  27898. * @param jointType The type of joint
  27899. * @param jointData The data for the joint
  27900. * @returns The physics imposter
  27901. */
  27902. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  27903. /**
  27904. * Add a joint to this impostor with a different impostor
  27905. * @param otherImpostor A physics imposter used to add a joint
  27906. * @param joint The joint to add
  27907. * @returns The physics imposter
  27908. */
  27909. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  27910. /**
  27911. * Add an anchor to a cloth impostor
  27912. * @param otherImpostor rigid impostor to anchor to
  27913. * @param width ratio across width from 0 to 1
  27914. * @param height ratio up height from 0 to 1
  27915. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  27916. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  27917. * @returns impostor the soft imposter
  27918. */
  27919. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  27920. /**
  27921. * Add a hook to a rope impostor
  27922. * @param otherImpostor rigid impostor to anchor to
  27923. * @param length ratio across rope from 0 to 1
  27924. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  27925. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  27926. * @returns impostor the rope imposter
  27927. */
  27928. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  27929. /**
  27930. * Will keep this body still, in a sleep mode.
  27931. * @returns the physics imposter
  27932. */
  27933. sleep(): PhysicsImpostor;
  27934. /**
  27935. * Wake the body up.
  27936. * @returns The physics imposter
  27937. */
  27938. wakeUp(): PhysicsImpostor;
  27939. /**
  27940. * Clones the physics imposter
  27941. * @param newObject The physics imposter clones to this physics-enabled object
  27942. * @returns A nullable physics imposter
  27943. */
  27944. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27945. /**
  27946. * Disposes the physics imposter
  27947. */
  27948. dispose(): void;
  27949. /**
  27950. * Sets the delta position
  27951. * @param position The delta position amount
  27952. */
  27953. setDeltaPosition(position: Vector3): void;
  27954. /**
  27955. * Sets the delta rotation
  27956. * @param rotation The delta rotation amount
  27957. */
  27958. setDeltaRotation(rotation: Quaternion): void;
  27959. /**
  27960. * Gets the box size of the physics imposter and stores the result in the input parameter
  27961. * @param result Stores the box size
  27962. * @returns The physics imposter
  27963. */
  27964. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  27965. /**
  27966. * Gets the radius of the physics imposter
  27967. * @returns Radius of the physics imposter
  27968. */
  27969. getRadius(): number;
  27970. /**
  27971. * Sync a bone with this impostor
  27972. * @param bone The bone to sync to the impostor.
  27973. * @param boneMesh The mesh that the bone is influencing.
  27974. * @param jointPivot The pivot of the joint / bone in local space.
  27975. * @param distToJoint Optional distance from the impostor to the joint.
  27976. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27977. */
  27978. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  27979. /**
  27980. * Sync impostor to a bone
  27981. * @param bone The bone that the impostor will be synced to.
  27982. * @param boneMesh The mesh that the bone is influencing.
  27983. * @param jointPivot The pivot of the joint / bone in local space.
  27984. * @param distToJoint Optional distance from the impostor to the joint.
  27985. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27986. * @param boneAxis Optional vector3 axis the bone is aligned with
  27987. */
  27988. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  27989. /**
  27990. * No-Imposter type
  27991. */
  27992. static NoImpostor: number;
  27993. /**
  27994. * Sphere-Imposter type
  27995. */
  27996. static SphereImpostor: number;
  27997. /**
  27998. * Box-Imposter type
  27999. */
  28000. static BoxImpostor: number;
  28001. /**
  28002. * Plane-Imposter type
  28003. */
  28004. static PlaneImpostor: number;
  28005. /**
  28006. * Mesh-imposter type
  28007. */
  28008. static MeshImpostor: number;
  28009. /**
  28010. * Capsule-Impostor type (Ammo.js plugin only)
  28011. */
  28012. static CapsuleImpostor: number;
  28013. /**
  28014. * Cylinder-Imposter type
  28015. */
  28016. static CylinderImpostor: number;
  28017. /**
  28018. * Particle-Imposter type
  28019. */
  28020. static ParticleImpostor: number;
  28021. /**
  28022. * Heightmap-Imposter type
  28023. */
  28024. static HeightmapImpostor: number;
  28025. /**
  28026. * ConvexHull-Impostor type (Ammo.js plugin only)
  28027. */
  28028. static ConvexHullImpostor: number;
  28029. /**
  28030. * Custom-Imposter type (Ammo.js plugin only)
  28031. */
  28032. static CustomImpostor: number;
  28033. /**
  28034. * Rope-Imposter type
  28035. */
  28036. static RopeImpostor: number;
  28037. /**
  28038. * Cloth-Imposter type
  28039. */
  28040. static ClothImpostor: number;
  28041. /**
  28042. * Softbody-Imposter type
  28043. */
  28044. static SoftbodyImpostor: number;
  28045. }
  28046. }
  28047. declare module "babylonjs/Meshes/mesh" {
  28048. import { Observable } from "babylonjs/Misc/observable";
  28049. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28050. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  28051. import { Camera } from "babylonjs/Cameras/camera";
  28052. import { Scene } from "babylonjs/scene";
  28053. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  28054. import { Color4 } from "babylonjs/Maths/math.color";
  28055. import { Engine } from "babylonjs/Engines/engine";
  28056. import { Node } from "babylonjs/node";
  28057. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  28058. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  28059. import { Buffer } from "babylonjs/Meshes/buffer";
  28060. import { Geometry } from "babylonjs/Meshes/geometry";
  28061. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28062. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28063. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  28064. import { Effect } from "babylonjs/Materials/effect";
  28065. import { Material } from "babylonjs/Materials/material";
  28066. import { Skeleton } from "babylonjs/Bones/skeleton";
  28067. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  28068. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  28069. import { Path3D } from "babylonjs/Maths/math.path";
  28070. import { Plane } from "babylonjs/Maths/math.plane";
  28071. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28072. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  28073. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  28074. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  28075. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  28076. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  28077. /**
  28078. * @hidden
  28079. **/
  28080. export class _CreationDataStorage {
  28081. closePath?: boolean;
  28082. closeArray?: boolean;
  28083. idx: number[];
  28084. dashSize: number;
  28085. gapSize: number;
  28086. path3D: Path3D;
  28087. pathArray: Vector3[][];
  28088. arc: number;
  28089. radius: number;
  28090. cap: number;
  28091. tessellation: number;
  28092. }
  28093. /**
  28094. * @hidden
  28095. **/
  28096. class _InstanceDataStorage {
  28097. visibleInstances: any;
  28098. batchCache: _InstancesBatch;
  28099. instancesBufferSize: number;
  28100. instancesBuffer: Nullable<Buffer>;
  28101. instancesData: Float32Array;
  28102. overridenInstanceCount: number;
  28103. isFrozen: boolean;
  28104. previousBatch: Nullable<_InstancesBatch>;
  28105. hardwareInstancedRendering: boolean;
  28106. sideOrientation: number;
  28107. manualUpdate: boolean;
  28108. }
  28109. /**
  28110. * @hidden
  28111. **/
  28112. export class _InstancesBatch {
  28113. mustReturn: boolean;
  28114. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  28115. renderSelf: boolean[];
  28116. hardwareInstancedRendering: boolean[];
  28117. }
  28118. /**
  28119. * @hidden
  28120. **/
  28121. class _ThinInstanceDataStorage {
  28122. instancesCount: number;
  28123. matrixBuffer: Nullable<Buffer>;
  28124. matrixBufferSize: number;
  28125. matrixData: Nullable<Float32Array>;
  28126. boundingVectors: Array<Vector3>;
  28127. }
  28128. /**
  28129. * Class used to represent renderable models
  28130. */
  28131. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  28132. /**
  28133. * Mesh side orientation : usually the external or front surface
  28134. */
  28135. static readonly FRONTSIDE: number;
  28136. /**
  28137. * Mesh side orientation : usually the internal or back surface
  28138. */
  28139. static readonly BACKSIDE: number;
  28140. /**
  28141. * Mesh side orientation : both internal and external or front and back surfaces
  28142. */
  28143. static readonly DOUBLESIDE: number;
  28144. /**
  28145. * Mesh side orientation : by default, `FRONTSIDE`
  28146. */
  28147. static readonly DEFAULTSIDE: number;
  28148. /**
  28149. * Mesh cap setting : no cap
  28150. */
  28151. static readonly NO_CAP: number;
  28152. /**
  28153. * Mesh cap setting : one cap at the beginning of the mesh
  28154. */
  28155. static readonly CAP_START: number;
  28156. /**
  28157. * Mesh cap setting : one cap at the end of the mesh
  28158. */
  28159. static readonly CAP_END: number;
  28160. /**
  28161. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  28162. */
  28163. static readonly CAP_ALL: number;
  28164. /**
  28165. * Mesh pattern setting : no flip or rotate
  28166. */
  28167. static readonly NO_FLIP: number;
  28168. /**
  28169. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  28170. */
  28171. static readonly FLIP_TILE: number;
  28172. /**
  28173. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  28174. */
  28175. static readonly ROTATE_TILE: number;
  28176. /**
  28177. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  28178. */
  28179. static readonly FLIP_ROW: number;
  28180. /**
  28181. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  28182. */
  28183. static readonly ROTATE_ROW: number;
  28184. /**
  28185. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  28186. */
  28187. static readonly FLIP_N_ROTATE_TILE: number;
  28188. /**
  28189. * Mesh pattern setting : rotate pattern and rotate
  28190. */
  28191. static readonly FLIP_N_ROTATE_ROW: number;
  28192. /**
  28193. * Mesh tile positioning : part tiles same on left/right or top/bottom
  28194. */
  28195. static readonly CENTER: number;
  28196. /**
  28197. * Mesh tile positioning : part tiles on left
  28198. */
  28199. static readonly LEFT: number;
  28200. /**
  28201. * Mesh tile positioning : part tiles on right
  28202. */
  28203. static readonly RIGHT: number;
  28204. /**
  28205. * Mesh tile positioning : part tiles on top
  28206. */
  28207. static readonly TOP: number;
  28208. /**
  28209. * Mesh tile positioning : part tiles on bottom
  28210. */
  28211. static readonly BOTTOM: number;
  28212. /**
  28213. * Gets the default side orientation.
  28214. * @param orientation the orientation to value to attempt to get
  28215. * @returns the default orientation
  28216. * @hidden
  28217. */
  28218. static _GetDefaultSideOrientation(orientation?: number): number;
  28219. private _internalMeshDataInfo;
  28220. /**
  28221. * An event triggered before rendering the mesh
  28222. */
  28223. get onBeforeRenderObservable(): Observable<Mesh>;
  28224. /**
  28225. * An event triggered before binding the mesh
  28226. */
  28227. get onBeforeBindObservable(): Observable<Mesh>;
  28228. /**
  28229. * An event triggered after rendering the mesh
  28230. */
  28231. get onAfterRenderObservable(): Observable<Mesh>;
  28232. /**
  28233. * An event triggered before drawing the mesh
  28234. */
  28235. get onBeforeDrawObservable(): Observable<Mesh>;
  28236. private _onBeforeDrawObserver;
  28237. /**
  28238. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  28239. */
  28240. set onBeforeDraw(callback: () => void);
  28241. get hasInstances(): boolean;
  28242. get hasThinInstances(): boolean;
  28243. /**
  28244. * Gets the delay loading state of the mesh (when delay loading is turned on)
  28245. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  28246. */
  28247. delayLoadState: number;
  28248. /**
  28249. * Gets the list of instances created from this mesh
  28250. * it is not supposed to be modified manually.
  28251. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  28252. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  28253. */
  28254. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  28255. /**
  28256. * Gets the file containing delay loading data for this mesh
  28257. */
  28258. delayLoadingFile: string;
  28259. /** @hidden */
  28260. _binaryInfo: any;
  28261. /**
  28262. * User defined function used to change how LOD level selection is done
  28263. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  28264. */
  28265. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  28266. /**
  28267. * Gets or sets the morph target manager
  28268. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  28269. */
  28270. get morphTargetManager(): Nullable<MorphTargetManager>;
  28271. set morphTargetManager(value: Nullable<MorphTargetManager>);
  28272. /** @hidden */
  28273. _creationDataStorage: Nullable<_CreationDataStorage>;
  28274. /** @hidden */
  28275. _geometry: Nullable<Geometry>;
  28276. /** @hidden */
  28277. _delayInfo: Array<string>;
  28278. /** @hidden */
  28279. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  28280. /** @hidden */
  28281. _instanceDataStorage: _InstanceDataStorage;
  28282. /** @hidden */
  28283. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  28284. private _effectiveMaterial;
  28285. /** @hidden */
  28286. _shouldGenerateFlatShading: boolean;
  28287. /** @hidden */
  28288. _originalBuilderSideOrientation: number;
  28289. /**
  28290. * Use this property to change the original side orientation defined at construction time
  28291. */
  28292. overrideMaterialSideOrientation: Nullable<number>;
  28293. /**
  28294. * Gets the source mesh (the one used to clone this one from)
  28295. */
  28296. get source(): Nullable<Mesh>;
  28297. /**
  28298. * Gets or sets a boolean indicating that this mesh does not use index buffer
  28299. */
  28300. get isUnIndexed(): boolean;
  28301. set isUnIndexed(value: boolean);
  28302. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  28303. get worldMatrixInstancedBuffer(): Float32Array;
  28304. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  28305. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  28306. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  28307. /**
  28308. * @constructor
  28309. * @param name The value used by scene.getMeshByName() to do a lookup.
  28310. * @param scene The scene to add this mesh to.
  28311. * @param parent The parent of this mesh, if it has one
  28312. * @param source An optional Mesh from which geometry is shared, cloned.
  28313. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  28314. * When false, achieved by calling a clone(), also passing False.
  28315. * This will make creation of children, recursive.
  28316. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  28317. */
  28318. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  28319. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  28320. doNotInstantiate: boolean;
  28321. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  28322. /**
  28323. * Gets the class name
  28324. * @returns the string "Mesh".
  28325. */
  28326. getClassName(): string;
  28327. /** @hidden */
  28328. get _isMesh(): boolean;
  28329. /**
  28330. * Returns a description of this mesh
  28331. * @param fullDetails define if full details about this mesh must be used
  28332. * @returns a descriptive string representing this mesh
  28333. */
  28334. toString(fullDetails?: boolean): string;
  28335. /** @hidden */
  28336. _unBindEffect(): void;
  28337. /**
  28338. * Gets a boolean indicating if this mesh has LOD
  28339. */
  28340. get hasLODLevels(): boolean;
  28341. /**
  28342. * Gets the list of MeshLODLevel associated with the current mesh
  28343. * @returns an array of MeshLODLevel
  28344. */
  28345. getLODLevels(): MeshLODLevel[];
  28346. private _sortLODLevels;
  28347. /**
  28348. * Add a mesh as LOD level triggered at the given distance.
  28349. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28350. * @param distance The distance from the center of the object to show this level
  28351. * @param mesh The mesh to be added as LOD level (can be null)
  28352. * @return This mesh (for chaining)
  28353. */
  28354. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  28355. /**
  28356. * Returns the LOD level mesh at the passed distance or null if not found.
  28357. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28358. * @param distance The distance from the center of the object to show this level
  28359. * @returns a Mesh or `null`
  28360. */
  28361. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  28362. /**
  28363. * Remove a mesh from the LOD array
  28364. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28365. * @param mesh defines the mesh to be removed
  28366. * @return This mesh (for chaining)
  28367. */
  28368. removeLODLevel(mesh: Mesh): Mesh;
  28369. /**
  28370. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  28371. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28372. * @param camera defines the camera to use to compute distance
  28373. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  28374. * @return This mesh (for chaining)
  28375. */
  28376. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  28377. /**
  28378. * Gets the mesh internal Geometry object
  28379. */
  28380. get geometry(): Nullable<Geometry>;
  28381. /**
  28382. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  28383. * @returns the total number of vertices
  28384. */
  28385. getTotalVertices(): number;
  28386. /**
  28387. * Returns the content of an associated vertex buffer
  28388. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28389. * - VertexBuffer.PositionKind
  28390. * - VertexBuffer.UVKind
  28391. * - VertexBuffer.UV2Kind
  28392. * - VertexBuffer.UV3Kind
  28393. * - VertexBuffer.UV4Kind
  28394. * - VertexBuffer.UV5Kind
  28395. * - VertexBuffer.UV6Kind
  28396. * - VertexBuffer.ColorKind
  28397. * - VertexBuffer.MatricesIndicesKind
  28398. * - VertexBuffer.MatricesIndicesExtraKind
  28399. * - VertexBuffer.MatricesWeightsKind
  28400. * - VertexBuffer.MatricesWeightsExtraKind
  28401. * @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
  28402. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  28403. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  28404. */
  28405. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  28406. /**
  28407. * Returns the mesh VertexBuffer object from the requested `kind`
  28408. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28409. * - VertexBuffer.PositionKind
  28410. * - VertexBuffer.NormalKind
  28411. * - VertexBuffer.UVKind
  28412. * - VertexBuffer.UV2Kind
  28413. * - VertexBuffer.UV3Kind
  28414. * - VertexBuffer.UV4Kind
  28415. * - VertexBuffer.UV5Kind
  28416. * - VertexBuffer.UV6Kind
  28417. * - VertexBuffer.ColorKind
  28418. * - VertexBuffer.MatricesIndicesKind
  28419. * - VertexBuffer.MatricesIndicesExtraKind
  28420. * - VertexBuffer.MatricesWeightsKind
  28421. * - VertexBuffer.MatricesWeightsExtraKind
  28422. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  28423. */
  28424. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  28425. /**
  28426. * Tests if a specific vertex buffer is associated with this mesh
  28427. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  28428. * - VertexBuffer.PositionKind
  28429. * - VertexBuffer.NormalKind
  28430. * - VertexBuffer.UVKind
  28431. * - VertexBuffer.UV2Kind
  28432. * - VertexBuffer.UV3Kind
  28433. * - VertexBuffer.UV4Kind
  28434. * - VertexBuffer.UV5Kind
  28435. * - VertexBuffer.UV6Kind
  28436. * - VertexBuffer.ColorKind
  28437. * - VertexBuffer.MatricesIndicesKind
  28438. * - VertexBuffer.MatricesIndicesExtraKind
  28439. * - VertexBuffer.MatricesWeightsKind
  28440. * - VertexBuffer.MatricesWeightsExtraKind
  28441. * @returns a boolean
  28442. */
  28443. isVerticesDataPresent(kind: string): boolean;
  28444. /**
  28445. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  28446. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  28447. * - VertexBuffer.PositionKind
  28448. * - VertexBuffer.UVKind
  28449. * - VertexBuffer.UV2Kind
  28450. * - VertexBuffer.UV3Kind
  28451. * - VertexBuffer.UV4Kind
  28452. * - VertexBuffer.UV5Kind
  28453. * - VertexBuffer.UV6Kind
  28454. * - VertexBuffer.ColorKind
  28455. * - VertexBuffer.MatricesIndicesKind
  28456. * - VertexBuffer.MatricesIndicesExtraKind
  28457. * - VertexBuffer.MatricesWeightsKind
  28458. * - VertexBuffer.MatricesWeightsExtraKind
  28459. * @returns a boolean
  28460. */
  28461. isVertexBufferUpdatable(kind: string): boolean;
  28462. /**
  28463. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  28464. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28465. * - VertexBuffer.PositionKind
  28466. * - VertexBuffer.NormalKind
  28467. * - VertexBuffer.UVKind
  28468. * - VertexBuffer.UV2Kind
  28469. * - VertexBuffer.UV3Kind
  28470. * - VertexBuffer.UV4Kind
  28471. * - VertexBuffer.UV5Kind
  28472. * - VertexBuffer.UV6Kind
  28473. * - VertexBuffer.ColorKind
  28474. * - VertexBuffer.MatricesIndicesKind
  28475. * - VertexBuffer.MatricesIndicesExtraKind
  28476. * - VertexBuffer.MatricesWeightsKind
  28477. * - VertexBuffer.MatricesWeightsExtraKind
  28478. * @returns an array of strings
  28479. */
  28480. getVerticesDataKinds(): string[];
  28481. /**
  28482. * Returns a positive integer : the total number of indices in this mesh geometry.
  28483. * @returns the numner of indices or zero if the mesh has no geometry.
  28484. */
  28485. getTotalIndices(): number;
  28486. /**
  28487. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  28488. * @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.
  28489. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  28490. * @returns the indices array or an empty array if the mesh has no geometry
  28491. */
  28492. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  28493. get isBlocked(): boolean;
  28494. /**
  28495. * Determine if the current mesh is ready to be rendered
  28496. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28497. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  28498. * @returns true if all associated assets are ready (material, textures, shaders)
  28499. */
  28500. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  28501. /**
  28502. * 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.
  28503. */
  28504. get areNormalsFrozen(): boolean;
  28505. /**
  28506. * 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.
  28507. * @returns the current mesh
  28508. */
  28509. freezeNormals(): Mesh;
  28510. /**
  28511. * 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
  28512. * @returns the current mesh
  28513. */
  28514. unfreezeNormals(): Mesh;
  28515. /**
  28516. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  28517. */
  28518. set overridenInstanceCount(count: number);
  28519. /** @hidden */
  28520. _preActivate(): Mesh;
  28521. /** @hidden */
  28522. _preActivateForIntermediateRendering(renderId: number): Mesh;
  28523. /** @hidden */
  28524. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  28525. protected _afterComputeWorldMatrix(): void;
  28526. /**
  28527. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28528. * This means the mesh underlying bounding box and sphere are recomputed.
  28529. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28530. * @returns the current mesh
  28531. */
  28532. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  28533. /** @hidden */
  28534. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  28535. /**
  28536. * This function will subdivide the mesh into multiple submeshes
  28537. * @param count defines the expected number of submeshes
  28538. */
  28539. subdivide(count: number): void;
  28540. /**
  28541. * Copy a FloatArray into a specific associated vertex buffer
  28542. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  28543. * - VertexBuffer.PositionKind
  28544. * - VertexBuffer.UVKind
  28545. * - VertexBuffer.UV2Kind
  28546. * - VertexBuffer.UV3Kind
  28547. * - VertexBuffer.UV4Kind
  28548. * - VertexBuffer.UV5Kind
  28549. * - VertexBuffer.UV6Kind
  28550. * - VertexBuffer.ColorKind
  28551. * - VertexBuffer.MatricesIndicesKind
  28552. * - VertexBuffer.MatricesIndicesExtraKind
  28553. * - VertexBuffer.MatricesWeightsKind
  28554. * - VertexBuffer.MatricesWeightsExtraKind
  28555. * @param data defines the data source
  28556. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  28557. * @param stride defines the data stride size (can be null)
  28558. * @returns the current mesh
  28559. */
  28560. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28561. /**
  28562. * Delete a vertex buffer associated with this mesh
  28563. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  28564. * - VertexBuffer.PositionKind
  28565. * - VertexBuffer.UVKind
  28566. * - VertexBuffer.UV2Kind
  28567. * - VertexBuffer.UV3Kind
  28568. * - VertexBuffer.UV4Kind
  28569. * - VertexBuffer.UV5Kind
  28570. * - VertexBuffer.UV6Kind
  28571. * - VertexBuffer.ColorKind
  28572. * - VertexBuffer.MatricesIndicesKind
  28573. * - VertexBuffer.MatricesIndicesExtraKind
  28574. * - VertexBuffer.MatricesWeightsKind
  28575. * - VertexBuffer.MatricesWeightsExtraKind
  28576. */
  28577. removeVerticesData(kind: string): void;
  28578. /**
  28579. * Flags an associated vertex buffer as updatable
  28580. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  28581. * - VertexBuffer.PositionKind
  28582. * - VertexBuffer.UVKind
  28583. * - VertexBuffer.UV2Kind
  28584. * - VertexBuffer.UV3Kind
  28585. * - VertexBuffer.UV4Kind
  28586. * - VertexBuffer.UV5Kind
  28587. * - VertexBuffer.UV6Kind
  28588. * - VertexBuffer.ColorKind
  28589. * - VertexBuffer.MatricesIndicesKind
  28590. * - VertexBuffer.MatricesIndicesExtraKind
  28591. * - VertexBuffer.MatricesWeightsKind
  28592. * - VertexBuffer.MatricesWeightsExtraKind
  28593. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  28594. */
  28595. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  28596. /**
  28597. * Sets the mesh global Vertex Buffer
  28598. * @param buffer defines the buffer to use
  28599. * @returns the current mesh
  28600. */
  28601. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  28602. /**
  28603. * Update a specific associated vertex buffer
  28604. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  28605. * - VertexBuffer.PositionKind
  28606. * - VertexBuffer.UVKind
  28607. * - VertexBuffer.UV2Kind
  28608. * - VertexBuffer.UV3Kind
  28609. * - VertexBuffer.UV4Kind
  28610. * - VertexBuffer.UV5Kind
  28611. * - VertexBuffer.UV6Kind
  28612. * - VertexBuffer.ColorKind
  28613. * - VertexBuffer.MatricesIndicesKind
  28614. * - VertexBuffer.MatricesIndicesExtraKind
  28615. * - VertexBuffer.MatricesWeightsKind
  28616. * - VertexBuffer.MatricesWeightsExtraKind
  28617. * @param data defines the data source
  28618. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  28619. * @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)
  28620. * @returns the current mesh
  28621. */
  28622. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28623. /**
  28624. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  28625. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  28626. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  28627. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  28628. * @returns the current mesh
  28629. */
  28630. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  28631. /**
  28632. * Creates a un-shared specific occurence of the geometry for the mesh.
  28633. * @returns the current mesh
  28634. */
  28635. makeGeometryUnique(): Mesh;
  28636. /**
  28637. * Set the index buffer of this mesh
  28638. * @param indices defines the source data
  28639. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  28640. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  28641. * @returns the current mesh
  28642. */
  28643. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  28644. /**
  28645. * Update the current index buffer
  28646. * @param indices defines the source data
  28647. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28648. * @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)
  28649. * @returns the current mesh
  28650. */
  28651. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28652. /**
  28653. * Invert the geometry to move from a right handed system to a left handed one.
  28654. * @returns the current mesh
  28655. */
  28656. toLeftHanded(): Mesh;
  28657. /** @hidden */
  28658. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  28659. /** @hidden */
  28660. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  28661. /**
  28662. * Registers for this mesh a javascript function called just before the rendering process
  28663. * @param func defines the function to call before rendering this mesh
  28664. * @returns the current mesh
  28665. */
  28666. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  28667. /**
  28668. * Disposes a previously registered javascript function called before the rendering
  28669. * @param func defines the function to remove
  28670. * @returns the current mesh
  28671. */
  28672. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  28673. /**
  28674. * Registers for this mesh a javascript function called just after the rendering is complete
  28675. * @param func defines the function to call after rendering this mesh
  28676. * @returns the current mesh
  28677. */
  28678. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  28679. /**
  28680. * Disposes a previously registered javascript function called after the rendering.
  28681. * @param func defines the function to remove
  28682. * @returns the current mesh
  28683. */
  28684. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  28685. /** @hidden */
  28686. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  28687. /** @hidden */
  28688. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  28689. /** @hidden */
  28690. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  28691. /** @hidden */
  28692. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  28693. /** @hidden */
  28694. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  28695. /** @hidden */
  28696. _rebuild(): void;
  28697. /** @hidden */
  28698. _freeze(): void;
  28699. /** @hidden */
  28700. _unFreeze(): void;
  28701. /**
  28702. * 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
  28703. * @param subMesh defines the subMesh to render
  28704. * @param enableAlphaMode defines if alpha mode can be changed
  28705. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  28706. * @returns the current mesh
  28707. */
  28708. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  28709. private _onBeforeDraw;
  28710. /**
  28711. * Renormalize the mesh and patch it up if there are no weights
  28712. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  28713. * However in the case of zero weights then we set just a single influence to 1.
  28714. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  28715. */
  28716. cleanMatrixWeights(): void;
  28717. private normalizeSkinFourWeights;
  28718. private normalizeSkinWeightsAndExtra;
  28719. /**
  28720. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  28721. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  28722. * the user know there was an issue with importing the mesh
  28723. * @returns a validation object with skinned, valid and report string
  28724. */
  28725. validateSkinning(): {
  28726. skinned: boolean;
  28727. valid: boolean;
  28728. report: string;
  28729. };
  28730. /** @hidden */
  28731. _checkDelayState(): Mesh;
  28732. private _queueLoad;
  28733. /**
  28734. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28735. * A mesh is in the frustum if its bounding box intersects the frustum
  28736. * @param frustumPlanes defines the frustum to test
  28737. * @returns true if the mesh is in the frustum planes
  28738. */
  28739. isInFrustum(frustumPlanes: Plane[]): boolean;
  28740. /**
  28741. * Sets the mesh material by the material or multiMaterial `id` property
  28742. * @param id is a string identifying the material or the multiMaterial
  28743. * @returns the current mesh
  28744. */
  28745. setMaterialByID(id: string): Mesh;
  28746. /**
  28747. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  28748. * @returns an array of IAnimatable
  28749. */
  28750. getAnimatables(): IAnimatable[];
  28751. /**
  28752. * Modifies the mesh geometry according to the passed transformation matrix.
  28753. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  28754. * The mesh normals are modified using the same transformation.
  28755. * Note that, under the hood, this method sets a new VertexBuffer each call.
  28756. * @param transform defines the transform matrix to use
  28757. * @see http://doc.babylonjs.com/resources/baking_transformations
  28758. * @returns the current mesh
  28759. */
  28760. bakeTransformIntoVertices(transform: Matrix): Mesh;
  28761. /**
  28762. * Modifies the mesh geometry according to its own current World Matrix.
  28763. * The mesh World Matrix is then reset.
  28764. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  28765. * Note that, under the hood, this method sets a new VertexBuffer each call.
  28766. * @see http://doc.babylonjs.com/resources/baking_transformations
  28767. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  28768. * @returns the current mesh
  28769. */
  28770. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  28771. /** @hidden */
  28772. get _positions(): Nullable<Vector3[]>;
  28773. /** @hidden */
  28774. _resetPointsArrayCache(): Mesh;
  28775. /** @hidden */
  28776. _generatePointsArray(): boolean;
  28777. /**
  28778. * Returns a new Mesh object generated from the current mesh properties.
  28779. * This method must not get confused with createInstance()
  28780. * @param name is a string, the name given to the new mesh
  28781. * @param newParent can be any Node object (default `null`)
  28782. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  28783. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  28784. * @returns a new mesh
  28785. */
  28786. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  28787. /**
  28788. * Releases resources associated with this mesh.
  28789. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28790. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28791. */
  28792. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28793. /** @hidden */
  28794. _disposeInstanceSpecificData(): void;
  28795. /** @hidden */
  28796. _disposeThinInstanceSpecificData(): void;
  28797. /**
  28798. * Modifies the mesh geometry according to a displacement map.
  28799. * 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.
  28800. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  28801. * @param url is a string, the URL from the image file is to be downloaded.
  28802. * @param minHeight is the lower limit of the displacement.
  28803. * @param maxHeight is the upper limit of the displacement.
  28804. * @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.
  28805. * @param uvOffset is an optional vector2 used to offset UV.
  28806. * @param uvScale is an optional vector2 used to scale UV.
  28807. * @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.
  28808. * @returns the Mesh.
  28809. */
  28810. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  28811. /**
  28812. * Modifies the mesh geometry according to a displacementMap buffer.
  28813. * 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.
  28814. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  28815. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  28816. * @param heightMapWidth is the width of the buffer image.
  28817. * @param heightMapHeight is the height of the buffer image.
  28818. * @param minHeight is the lower limit of the displacement.
  28819. * @param maxHeight is the upper limit of the displacement.
  28820. * @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.
  28821. * @param uvOffset is an optional vector2 used to offset UV.
  28822. * @param uvScale is an optional vector2 used to scale UV.
  28823. * @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.
  28824. * @returns the Mesh.
  28825. */
  28826. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  28827. /**
  28828. * Modify the mesh to get a flat shading rendering.
  28829. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  28830. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  28831. * @returns current mesh
  28832. */
  28833. convertToFlatShadedMesh(): Mesh;
  28834. /**
  28835. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  28836. * In other words, more vertices, no more indices and a single bigger VBO.
  28837. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  28838. * @returns current mesh
  28839. */
  28840. convertToUnIndexedMesh(): Mesh;
  28841. /**
  28842. * Inverses facet orientations.
  28843. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28844. * @param flipNormals will also inverts the normals
  28845. * @returns current mesh
  28846. */
  28847. flipFaces(flipNormals?: boolean): Mesh;
  28848. /**
  28849. * Increase the number of facets and hence vertices in a mesh
  28850. * Vertex normals are interpolated from existing vertex normals
  28851. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28852. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  28853. */
  28854. increaseVertices(numberPerEdge: number): void;
  28855. /**
  28856. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  28857. * This will undo any application of covertToFlatShadedMesh
  28858. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28859. */
  28860. forceSharedVertices(): void;
  28861. /** @hidden */
  28862. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  28863. /** @hidden */
  28864. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  28865. /**
  28866. * Creates a new InstancedMesh object from the mesh model.
  28867. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  28868. * @param name defines the name of the new instance
  28869. * @returns a new InstancedMesh
  28870. */
  28871. createInstance(name: string): InstancedMesh;
  28872. /**
  28873. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  28874. * After this call, all the mesh instances have the same submeshes than the current mesh.
  28875. * @returns the current mesh
  28876. */
  28877. synchronizeInstances(): Mesh;
  28878. /**
  28879. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  28880. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  28881. * This should be used together with the simplification to avoid disappearing triangles.
  28882. * @param successCallback an optional success callback to be called after the optimization finished.
  28883. * @returns the current mesh
  28884. */
  28885. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  28886. /**
  28887. * Serialize current mesh
  28888. * @param serializationObject defines the object which will receive the serialization data
  28889. */
  28890. serialize(serializationObject: any): void;
  28891. /** @hidden */
  28892. _syncGeometryWithMorphTargetManager(): void;
  28893. /** @hidden */
  28894. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  28895. /**
  28896. * Returns a new Mesh object parsed from the source provided.
  28897. * @param parsedMesh is the source
  28898. * @param scene defines the hosting scene
  28899. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  28900. * @returns a new Mesh
  28901. */
  28902. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  28903. /**
  28904. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  28905. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  28906. * @param name defines the name of the mesh to create
  28907. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  28908. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  28909. * @param closePath creates a seam between the first and the last points of each path of the path array
  28910. * @param offset is taken in account only if the `pathArray` is containing a single path
  28911. * @param scene defines the hosting scene
  28912. * @param updatable defines if the mesh must be flagged as updatable
  28913. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28914. * @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)
  28915. * @returns a new Mesh
  28916. */
  28917. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28918. /**
  28919. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  28920. * @param name defines the name of the mesh to create
  28921. * @param radius sets the radius size (float) of the polygon (default 0.5)
  28922. * @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
  28923. * @param scene defines the hosting scene
  28924. * @param updatable defines if the mesh must be flagged as updatable
  28925. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28926. * @returns a new Mesh
  28927. */
  28928. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  28929. /**
  28930. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  28931. * @param name defines the name of the mesh to create
  28932. * @param size sets the size (float) of each box side (default 1)
  28933. * @param scene defines the hosting scene
  28934. * @param updatable defines if the mesh must be flagged as updatable
  28935. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28936. * @returns a new Mesh
  28937. */
  28938. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  28939. /**
  28940. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  28941. * @param name defines the name of the mesh to create
  28942. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  28943. * @param diameter sets the diameter size (float) of the sphere (default 1)
  28944. * @param scene defines the hosting scene
  28945. * @param updatable defines if the mesh must be flagged as updatable
  28946. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28947. * @returns a new Mesh
  28948. */
  28949. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28950. /**
  28951. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  28952. * @param name defines the name of the mesh to create
  28953. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  28954. * @param diameter sets the diameter size (float) of the sphere (default 1)
  28955. * @param scene defines the hosting scene
  28956. * @returns a new Mesh
  28957. */
  28958. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  28959. /**
  28960. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  28961. * @param name defines the name of the mesh to create
  28962. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  28963. * @param diameterTop set the top cap diameter (floats, default 1)
  28964. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  28965. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  28966. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  28967. * @param scene defines the hosting scene
  28968. * @param updatable defines if the mesh must be flagged as updatable
  28969. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28970. * @returns a new Mesh
  28971. */
  28972. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  28973. /**
  28974. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  28975. * @param name defines the name of the mesh to create
  28976. * @param diameter sets the diameter size (float) of the torus (default 1)
  28977. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  28978. * @param tessellation sets the number of torus sides (postive integer, default 16)
  28979. * @param scene defines the hosting scene
  28980. * @param updatable defines if the mesh must be flagged as updatable
  28981. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28982. * @returns a new Mesh
  28983. */
  28984. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28985. /**
  28986. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  28987. * @param name defines the name of the mesh to create
  28988. * @param radius sets the global radius size (float) of the torus knot (default 2)
  28989. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  28990. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  28991. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  28992. * @param p the number of windings on X axis (positive integers, default 2)
  28993. * @param q the number of windings on Y axis (positive integers, default 3)
  28994. * @param scene defines the hosting scene
  28995. * @param updatable defines if the mesh must be flagged as updatable
  28996. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28997. * @returns a new Mesh
  28998. */
  28999. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29000. /**
  29001. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  29002. * @param name defines the name of the mesh to create
  29003. * @param points is an array successive Vector3
  29004. * @param scene defines the hosting scene
  29005. * @param updatable defines if the mesh must be flagged as updatable
  29006. * @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).
  29007. * @returns a new Mesh
  29008. */
  29009. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  29010. /**
  29011. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  29012. * @param name defines the name of the mesh to create
  29013. * @param points is an array successive Vector3
  29014. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  29015. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  29016. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  29017. * @param scene defines the hosting scene
  29018. * @param updatable defines if the mesh must be flagged as updatable
  29019. * @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)
  29020. * @returns a new Mesh
  29021. */
  29022. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  29023. /**
  29024. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  29025. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  29026. * 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.
  29027. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29028. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  29029. * Remember you can only change the shape positions, not their number when updating a polygon.
  29030. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  29031. * @param name defines the name of the mesh to create
  29032. * @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
  29033. * @param scene defines the hosting scene
  29034. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  29035. * @param updatable defines if the mesh must be flagged as updatable
  29036. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29037. * @param earcutInjection can be used to inject your own earcut reference
  29038. * @returns a new Mesh
  29039. */
  29040. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  29041. /**
  29042. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  29043. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  29044. * @param name defines the name of the mesh to create
  29045. * @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
  29046. * @param depth defines the height of extrusion
  29047. * @param scene defines the hosting scene
  29048. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  29049. * @param updatable defines if the mesh must be flagged as updatable
  29050. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29051. * @param earcutInjection can be used to inject your own earcut reference
  29052. * @returns a new Mesh
  29053. */
  29054. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  29055. /**
  29056. * Creates an extruded shape mesh.
  29057. * 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
  29058. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  29059. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  29060. * @param name defines the name of the mesh to create
  29061. * @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
  29062. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  29063. * @param scale is the value to scale the shape
  29064. * @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
  29065. * @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
  29066. * @param scene defines the hosting scene
  29067. * @param updatable defines if the mesh must be flagged as updatable
  29068. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29069. * @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)
  29070. * @returns a new Mesh
  29071. */
  29072. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29073. /**
  29074. * Creates an custom extruded shape mesh.
  29075. * The custom extrusion is a parametric shape.
  29076. * It has no predefined shape. Its final shape will depend on the input parameters.
  29077. * Please consider using the same method from the MeshBuilder class instead
  29078. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  29079. * @param name defines the name of the mesh to create
  29080. * @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
  29081. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  29082. * @param scaleFunction is a custom Javascript function called on each path point
  29083. * @param rotationFunction is a custom Javascript function called on each path point
  29084. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  29085. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  29086. * @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
  29087. * @param scene defines the hosting scene
  29088. * @param updatable defines if the mesh must be flagged as updatable
  29089. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29090. * @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)
  29091. * @returns a new Mesh
  29092. */
  29093. 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;
  29094. /**
  29095. * Creates lathe mesh.
  29096. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  29097. * Please consider using the same method from the MeshBuilder class instead
  29098. * @param name defines the name of the mesh to create
  29099. * @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
  29100. * @param radius is the radius value of the lathe
  29101. * @param tessellation is the side number of the lathe.
  29102. * @param scene defines the hosting scene
  29103. * @param updatable defines if the mesh must be flagged as updatable
  29104. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29105. * @returns a new Mesh
  29106. */
  29107. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29108. /**
  29109. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  29110. * @param name defines the name of the mesh to create
  29111. * @param size sets the size (float) of both sides of the plane at once (default 1)
  29112. * @param scene defines the hosting scene
  29113. * @param updatable defines if the mesh must be flagged as updatable
  29114. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29115. * @returns a new Mesh
  29116. */
  29117. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29118. /**
  29119. * Creates a ground mesh.
  29120. * Please consider using the same method from the MeshBuilder class instead
  29121. * @param name defines the name of the mesh to create
  29122. * @param width set the width of the ground
  29123. * @param height set the height of the ground
  29124. * @param subdivisions sets the number of subdivisions per side
  29125. * @param scene defines the hosting scene
  29126. * @param updatable defines if the mesh must be flagged as updatable
  29127. * @returns a new Mesh
  29128. */
  29129. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  29130. /**
  29131. * Creates a tiled ground mesh.
  29132. * Please consider using the same method from the MeshBuilder class instead
  29133. * @param name defines the name of the mesh to create
  29134. * @param xmin set the ground minimum X coordinate
  29135. * @param zmin set the ground minimum Y coordinate
  29136. * @param xmax set the ground maximum X coordinate
  29137. * @param zmax set the ground maximum Z coordinate
  29138. * @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
  29139. * @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
  29140. * @param scene defines the hosting scene
  29141. * @param updatable defines if the mesh must be flagged as updatable
  29142. * @returns a new Mesh
  29143. */
  29144. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  29145. w: number;
  29146. h: number;
  29147. }, precision: {
  29148. w: number;
  29149. h: number;
  29150. }, scene: Scene, updatable?: boolean): Mesh;
  29151. /**
  29152. * Creates a ground mesh from a height map.
  29153. * Please consider using the same method from the MeshBuilder class instead
  29154. * @see http://doc.babylonjs.com/babylon101/height_map
  29155. * @param name defines the name of the mesh to create
  29156. * @param url sets the URL of the height map image resource
  29157. * @param width set the ground width size
  29158. * @param height set the ground height size
  29159. * @param subdivisions sets the number of subdivision per side
  29160. * @param minHeight is the minimum altitude on the ground
  29161. * @param maxHeight is the maximum altitude on the ground
  29162. * @param scene defines the hosting scene
  29163. * @param updatable defines if the mesh must be flagged as updatable
  29164. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  29165. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  29166. * @returns a new Mesh
  29167. */
  29168. 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;
  29169. /**
  29170. * Creates a tube mesh.
  29171. * The tube is a parametric shape.
  29172. * It has no predefined shape. Its final shape will depend on the input parameters.
  29173. * Please consider using the same method from the MeshBuilder class instead
  29174. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  29175. * @param name defines the name of the mesh to create
  29176. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  29177. * @param radius sets the tube radius size
  29178. * @param tessellation is the number of sides on the tubular surface
  29179. * @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
  29180. * @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
  29181. * @param scene defines the hosting scene
  29182. * @param updatable defines if the mesh must be flagged as updatable
  29183. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29184. * @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)
  29185. * @returns a new Mesh
  29186. */
  29187. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  29188. (i: number, distance: number): number;
  29189. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29190. /**
  29191. * Creates a polyhedron mesh.
  29192. * Please consider using the same method from the MeshBuilder class instead.
  29193. * * 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
  29194. * * The parameter `size` (positive float, default 1) sets the polygon size
  29195. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  29196. * * 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`
  29197. * * 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
  29198. * * 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)`)
  29199. * * 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
  29200. * * 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
  29201. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29202. * * If you create a double-sided mesh, you can choose what parts of 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
  29203. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29204. * @param name defines the name of the mesh to create
  29205. * @param options defines the options used to create the mesh
  29206. * @param scene defines the hosting scene
  29207. * @returns a new Mesh
  29208. */
  29209. static CreatePolyhedron(name: string, options: {
  29210. type?: number;
  29211. size?: number;
  29212. sizeX?: number;
  29213. sizeY?: number;
  29214. sizeZ?: number;
  29215. custom?: any;
  29216. faceUV?: Vector4[];
  29217. faceColors?: Color4[];
  29218. updatable?: boolean;
  29219. sideOrientation?: number;
  29220. }, scene: Scene): Mesh;
  29221. /**
  29222. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  29223. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  29224. * * 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`)
  29225. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  29226. * * 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
  29227. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29228. * * If you create a double-sided mesh, you can choose what parts of 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
  29229. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29230. * @param name defines the name of the mesh
  29231. * @param options defines the options used to create the mesh
  29232. * @param scene defines the hosting scene
  29233. * @returns a new Mesh
  29234. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  29235. */
  29236. static CreateIcoSphere(name: string, options: {
  29237. radius?: number;
  29238. flat?: boolean;
  29239. subdivisions?: number;
  29240. sideOrientation?: number;
  29241. updatable?: boolean;
  29242. }, scene: Scene): Mesh;
  29243. /**
  29244. * Creates a decal mesh.
  29245. * Please consider using the same method from the MeshBuilder class instead.
  29246. * A decal is a mesh usually applied as a model onto the surface of another mesh
  29247. * @param name defines the name of the mesh
  29248. * @param sourceMesh defines the mesh receiving the decal
  29249. * @param position sets the position of the decal in world coordinates
  29250. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  29251. * @param size sets the decal scaling
  29252. * @param angle sets the angle to rotate the decal
  29253. * @returns a new Mesh
  29254. */
  29255. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  29256. /**
  29257. * Prepare internal position array for software CPU skinning
  29258. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  29259. */
  29260. setPositionsForCPUSkinning(): Float32Array;
  29261. /**
  29262. * Prepare internal normal array for software CPU skinning
  29263. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  29264. */
  29265. setNormalsForCPUSkinning(): Float32Array;
  29266. /**
  29267. * Updates the vertex buffer by applying transformation from the bones
  29268. * @param skeleton defines the skeleton to apply to current mesh
  29269. * @returns the current mesh
  29270. */
  29271. applySkeleton(skeleton: Skeleton): Mesh;
  29272. /**
  29273. * 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
  29274. * @param meshes defines the list of meshes to scan
  29275. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  29276. */
  29277. static MinMax(meshes: AbstractMesh[]): {
  29278. min: Vector3;
  29279. max: Vector3;
  29280. };
  29281. /**
  29282. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  29283. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  29284. * @returns a vector3
  29285. */
  29286. static Center(meshesOrMinMaxVector: {
  29287. min: Vector3;
  29288. max: Vector3;
  29289. } | AbstractMesh[]): Vector3;
  29290. /**
  29291. * Merge the array of meshes into a single mesh for performance reasons.
  29292. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  29293. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  29294. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  29295. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  29296. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  29297. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  29298. * @returns a new mesh
  29299. */
  29300. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  29301. /** @hidden */
  29302. addInstance(instance: InstancedMesh): void;
  29303. /** @hidden */
  29304. removeInstance(instance: InstancedMesh): void;
  29305. }
  29306. }
  29307. declare module "babylonjs/Cameras/camera" {
  29308. import { SmartArray } from "babylonjs/Misc/smartArray";
  29309. import { Observable } from "babylonjs/Misc/observable";
  29310. import { Nullable } from "babylonjs/types";
  29311. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  29312. import { Scene } from "babylonjs/scene";
  29313. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  29314. import { Node } from "babylonjs/node";
  29315. import { Mesh } from "babylonjs/Meshes/mesh";
  29316. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29317. import { ICullable } from "babylonjs/Culling/boundingInfo";
  29318. import { Viewport } from "babylonjs/Maths/math.viewport";
  29319. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29320. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29321. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  29322. import { Ray } from "babylonjs/Culling/ray";
  29323. /**
  29324. * This is the base class of all the camera used in the application.
  29325. * @see http://doc.babylonjs.com/features/cameras
  29326. */
  29327. export class Camera extends Node {
  29328. /** @hidden */
  29329. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  29330. /**
  29331. * This is the default projection mode used by the cameras.
  29332. * It helps recreating a feeling of perspective and better appreciate depth.
  29333. * This is the best way to simulate real life cameras.
  29334. */
  29335. static readonly PERSPECTIVE_CAMERA: number;
  29336. /**
  29337. * This helps creating camera with an orthographic mode.
  29338. * 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.
  29339. */
  29340. static readonly ORTHOGRAPHIC_CAMERA: number;
  29341. /**
  29342. * This is the default FOV mode for perspective cameras.
  29343. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  29344. */
  29345. static readonly FOVMODE_VERTICAL_FIXED: number;
  29346. /**
  29347. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  29348. */
  29349. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  29350. /**
  29351. * This specifies ther is no need for a camera rig.
  29352. * Basically only one eye is rendered corresponding to the camera.
  29353. */
  29354. static readonly RIG_MODE_NONE: number;
  29355. /**
  29356. * Simulates a camera Rig with one blue eye and one red eye.
  29357. * This can be use with 3d blue and red glasses.
  29358. */
  29359. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  29360. /**
  29361. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  29362. */
  29363. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  29364. /**
  29365. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  29366. */
  29367. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  29368. /**
  29369. * Defines that both eyes of the camera will be rendered over under each other.
  29370. */
  29371. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  29372. /**
  29373. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  29374. */
  29375. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  29376. /**
  29377. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  29378. */
  29379. static readonly RIG_MODE_VR: number;
  29380. /**
  29381. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  29382. */
  29383. static readonly RIG_MODE_WEBVR: number;
  29384. /**
  29385. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  29386. */
  29387. static readonly RIG_MODE_CUSTOM: number;
  29388. /**
  29389. * Defines if by default attaching controls should prevent the default javascript event to continue.
  29390. */
  29391. static ForceAttachControlToAlwaysPreventDefault: boolean;
  29392. /**
  29393. * Define the input manager associated with the camera.
  29394. */
  29395. inputs: CameraInputsManager<Camera>;
  29396. /** @hidden */
  29397. _position: Vector3;
  29398. /**
  29399. * Define the current local position of the camera in the scene
  29400. */
  29401. get position(): Vector3;
  29402. set position(newPosition: Vector3);
  29403. /**
  29404. * The vector the camera should consider as up.
  29405. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  29406. */
  29407. upVector: Vector3;
  29408. /**
  29409. * Define the current limit on the left side for an orthographic camera
  29410. * In scene unit
  29411. */
  29412. orthoLeft: Nullable<number>;
  29413. /**
  29414. * Define the current limit on the right side for an orthographic camera
  29415. * In scene unit
  29416. */
  29417. orthoRight: Nullable<number>;
  29418. /**
  29419. * Define the current limit on the bottom side for an orthographic camera
  29420. * In scene unit
  29421. */
  29422. orthoBottom: Nullable<number>;
  29423. /**
  29424. * Define the current limit on the top side for an orthographic camera
  29425. * In scene unit
  29426. */
  29427. orthoTop: Nullable<number>;
  29428. /**
  29429. * Field Of View is set in Radians. (default is 0.8)
  29430. */
  29431. fov: number;
  29432. /**
  29433. * Define the minimum distance the camera can see from.
  29434. * This is important to note that the depth buffer are not infinite and the closer it starts
  29435. * the more your scene might encounter depth fighting issue.
  29436. */
  29437. minZ: number;
  29438. /**
  29439. * Define the maximum distance the camera can see to.
  29440. * This is important to note that the depth buffer are not infinite and the further it end
  29441. * the more your scene might encounter depth fighting issue.
  29442. */
  29443. maxZ: number;
  29444. /**
  29445. * Define the default inertia of the camera.
  29446. * This helps giving a smooth feeling to the camera movement.
  29447. */
  29448. inertia: number;
  29449. /**
  29450. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  29451. */
  29452. mode: number;
  29453. /**
  29454. * Define whether the camera is intermediate.
  29455. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  29456. */
  29457. isIntermediate: boolean;
  29458. /**
  29459. * Define the viewport of the camera.
  29460. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  29461. */
  29462. viewport: Viewport;
  29463. /**
  29464. * Restricts the camera to viewing objects with the same layerMask.
  29465. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  29466. */
  29467. layerMask: number;
  29468. /**
  29469. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  29470. */
  29471. fovMode: number;
  29472. /**
  29473. * Rig mode of the camera.
  29474. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  29475. * This is normally controlled byt the camera themselves as internal use.
  29476. */
  29477. cameraRigMode: number;
  29478. /**
  29479. * Defines the distance between both "eyes" in case of a RIG
  29480. */
  29481. interaxialDistance: number;
  29482. /**
  29483. * Defines if stereoscopic rendering is done side by side or over under.
  29484. */
  29485. isStereoscopicSideBySide: boolean;
  29486. /**
  29487. * 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
  29488. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  29489. * else in the scene. (Eg. security camera)
  29490. *
  29491. * 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)
  29492. */
  29493. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  29494. /**
  29495. * When set, the camera will render to this render target instead of the default canvas
  29496. *
  29497. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  29498. */
  29499. outputRenderTarget: Nullable<RenderTargetTexture>;
  29500. /**
  29501. * Observable triggered when the camera view matrix has changed.
  29502. */
  29503. onViewMatrixChangedObservable: Observable<Camera>;
  29504. /**
  29505. * Observable triggered when the camera Projection matrix has changed.
  29506. */
  29507. onProjectionMatrixChangedObservable: Observable<Camera>;
  29508. /**
  29509. * Observable triggered when the inputs have been processed.
  29510. */
  29511. onAfterCheckInputsObservable: Observable<Camera>;
  29512. /**
  29513. * Observable triggered when reset has been called and applied to the camera.
  29514. */
  29515. onRestoreStateObservable: Observable<Camera>;
  29516. /**
  29517. * Is this camera a part of a rig system?
  29518. */
  29519. isRigCamera: boolean;
  29520. /**
  29521. * If isRigCamera set to true this will be set with the parent camera.
  29522. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  29523. */
  29524. rigParent?: Camera;
  29525. /** @hidden */
  29526. _cameraRigParams: any;
  29527. /** @hidden */
  29528. _rigCameras: Camera[];
  29529. /** @hidden */
  29530. _rigPostProcess: Nullable<PostProcess>;
  29531. protected _webvrViewMatrix: Matrix;
  29532. /** @hidden */
  29533. _skipRendering: boolean;
  29534. /** @hidden */
  29535. _projectionMatrix: Matrix;
  29536. /** @hidden */
  29537. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  29538. /** @hidden */
  29539. _activeMeshes: SmartArray<AbstractMesh>;
  29540. protected _globalPosition: Vector3;
  29541. /** @hidden */
  29542. _computedViewMatrix: Matrix;
  29543. private _doNotComputeProjectionMatrix;
  29544. private _transformMatrix;
  29545. private _frustumPlanes;
  29546. private _refreshFrustumPlanes;
  29547. private _storedFov;
  29548. private _stateStored;
  29549. /**
  29550. * Instantiates a new camera object.
  29551. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  29552. * @see http://doc.babylonjs.com/features/cameras
  29553. * @param name Defines the name of the camera in the scene
  29554. * @param position Defines the position of the camera
  29555. * @param scene Defines the scene the camera belongs too
  29556. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  29557. */
  29558. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  29559. /**
  29560. * Store current camera state (fov, position, etc..)
  29561. * @returns the camera
  29562. */
  29563. storeState(): Camera;
  29564. /**
  29565. * Restores the camera state values if it has been stored. You must call storeState() first
  29566. */
  29567. protected _restoreStateValues(): boolean;
  29568. /**
  29569. * Restored camera state. You must call storeState() first.
  29570. * @returns true if restored and false otherwise
  29571. */
  29572. restoreState(): boolean;
  29573. /**
  29574. * Gets the class name of the camera.
  29575. * @returns the class name
  29576. */
  29577. getClassName(): string;
  29578. /** @hidden */
  29579. readonly _isCamera: boolean;
  29580. /**
  29581. * Gets a string representation of the camera useful for debug purpose.
  29582. * @param fullDetails Defines that a more verboe level of logging is required
  29583. * @returns the string representation
  29584. */
  29585. toString(fullDetails?: boolean): string;
  29586. /**
  29587. * Gets the current world space position of the camera.
  29588. */
  29589. get globalPosition(): Vector3;
  29590. /**
  29591. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  29592. * @returns the active meshe list
  29593. */
  29594. getActiveMeshes(): SmartArray<AbstractMesh>;
  29595. /**
  29596. * Check whether a mesh is part of the current active mesh list of the camera
  29597. * @param mesh Defines the mesh to check
  29598. * @returns true if active, false otherwise
  29599. */
  29600. isActiveMesh(mesh: Mesh): boolean;
  29601. /**
  29602. * Is this camera ready to be used/rendered
  29603. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  29604. * @return true if the camera is ready
  29605. */
  29606. isReady(completeCheck?: boolean): boolean;
  29607. /** @hidden */
  29608. _initCache(): void;
  29609. /** @hidden */
  29610. _updateCache(ignoreParentClass?: boolean): void;
  29611. /** @hidden */
  29612. _isSynchronized(): boolean;
  29613. /** @hidden */
  29614. _isSynchronizedViewMatrix(): boolean;
  29615. /** @hidden */
  29616. _isSynchronizedProjectionMatrix(): boolean;
  29617. /**
  29618. * Attach the input controls to a specific dom element to get the input from.
  29619. * @param element Defines the element the controls should be listened from
  29620. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  29621. */
  29622. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29623. /**
  29624. * Detach the current controls from the specified dom element.
  29625. * @param element Defines the element to stop listening the inputs from
  29626. */
  29627. detachControl(element: HTMLElement): void;
  29628. /**
  29629. * Update the camera state according to the different inputs gathered during the frame.
  29630. */
  29631. update(): void;
  29632. /** @hidden */
  29633. _checkInputs(): void;
  29634. /** @hidden */
  29635. get rigCameras(): Camera[];
  29636. /**
  29637. * Gets the post process used by the rig cameras
  29638. */
  29639. get rigPostProcess(): Nullable<PostProcess>;
  29640. /**
  29641. * Internal, gets the first post proces.
  29642. * @returns the first post process to be run on this camera.
  29643. */
  29644. _getFirstPostProcess(): Nullable<PostProcess>;
  29645. private _cascadePostProcessesToRigCams;
  29646. /**
  29647. * Attach a post process to the camera.
  29648. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29649. * @param postProcess The post process to attach to the camera
  29650. * @param insertAt The position of the post process in case several of them are in use in the scene
  29651. * @returns the position the post process has been inserted at
  29652. */
  29653. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  29654. /**
  29655. * Detach a post process to the camera.
  29656. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29657. * @param postProcess The post process to detach from the camera
  29658. */
  29659. detachPostProcess(postProcess: PostProcess): void;
  29660. /**
  29661. * Gets the current world matrix of the camera
  29662. */
  29663. getWorldMatrix(): Matrix;
  29664. /** @hidden */
  29665. _getViewMatrix(): Matrix;
  29666. /**
  29667. * Gets the current view matrix of the camera.
  29668. * @param force forces the camera to recompute the matrix without looking at the cached state
  29669. * @returns the view matrix
  29670. */
  29671. getViewMatrix(force?: boolean): Matrix;
  29672. /**
  29673. * Freeze the projection matrix.
  29674. * It will prevent the cache check of the camera projection compute and can speed up perf
  29675. * if no parameter of the camera are meant to change
  29676. * @param projection Defines manually a projection if necessary
  29677. */
  29678. freezeProjectionMatrix(projection?: Matrix): void;
  29679. /**
  29680. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  29681. */
  29682. unfreezeProjectionMatrix(): void;
  29683. /**
  29684. * Gets the current projection matrix of the camera.
  29685. * @param force forces the camera to recompute the matrix without looking at the cached state
  29686. * @returns the projection matrix
  29687. */
  29688. getProjectionMatrix(force?: boolean): Matrix;
  29689. /**
  29690. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  29691. * @returns a Matrix
  29692. */
  29693. getTransformationMatrix(): Matrix;
  29694. private _updateFrustumPlanes;
  29695. /**
  29696. * Checks if a cullable object (mesh...) is in the camera frustum
  29697. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  29698. * @param target The object to check
  29699. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  29700. * @returns true if the object is in frustum otherwise false
  29701. */
  29702. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  29703. /**
  29704. * Checks if a cullable object (mesh...) is in the camera frustum
  29705. * Unlike isInFrustum this cheks the full bounding box
  29706. * @param target The object to check
  29707. * @returns true if the object is in frustum otherwise false
  29708. */
  29709. isCompletelyInFrustum(target: ICullable): boolean;
  29710. /**
  29711. * Gets a ray in the forward direction from the camera.
  29712. * @param length Defines the length of the ray to create
  29713. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  29714. * @param origin Defines the start point of the ray which defaults to the camera position
  29715. * @returns the forward ray
  29716. */
  29717. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  29718. /**
  29719. * Releases resources associated with this node.
  29720. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29721. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29722. */
  29723. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29724. /** @hidden */
  29725. _isLeftCamera: boolean;
  29726. /**
  29727. * Gets the left camera of a rig setup in case of Rigged Camera
  29728. */
  29729. get isLeftCamera(): boolean;
  29730. /** @hidden */
  29731. _isRightCamera: boolean;
  29732. /**
  29733. * Gets the right camera of a rig setup in case of Rigged Camera
  29734. */
  29735. get isRightCamera(): boolean;
  29736. /**
  29737. * Gets the left camera of a rig setup in case of Rigged Camera
  29738. */
  29739. get leftCamera(): Nullable<FreeCamera>;
  29740. /**
  29741. * Gets the right camera of a rig setup in case of Rigged Camera
  29742. */
  29743. get rightCamera(): Nullable<FreeCamera>;
  29744. /**
  29745. * Gets the left camera target of a rig setup in case of Rigged Camera
  29746. * @returns the target position
  29747. */
  29748. getLeftTarget(): Nullable<Vector3>;
  29749. /**
  29750. * Gets the right camera target of a rig setup in case of Rigged Camera
  29751. * @returns the target position
  29752. */
  29753. getRightTarget(): Nullable<Vector3>;
  29754. /**
  29755. * @hidden
  29756. */
  29757. setCameraRigMode(mode: number, rigParams: any): void;
  29758. /** @hidden */
  29759. static _setStereoscopicRigMode(camera: Camera): void;
  29760. /** @hidden */
  29761. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  29762. /** @hidden */
  29763. static _setVRRigMode(camera: Camera, rigParams: any): void;
  29764. /** @hidden */
  29765. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  29766. /** @hidden */
  29767. _getVRProjectionMatrix(): Matrix;
  29768. protected _updateCameraRotationMatrix(): void;
  29769. protected _updateWebVRCameraRotationMatrix(): void;
  29770. /**
  29771. * This function MUST be overwritten by the different WebVR cameras available.
  29772. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29773. * @hidden
  29774. */
  29775. _getWebVRProjectionMatrix(): Matrix;
  29776. /**
  29777. * This function MUST be overwritten by the different WebVR cameras available.
  29778. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29779. * @hidden
  29780. */
  29781. _getWebVRViewMatrix(): Matrix;
  29782. /** @hidden */
  29783. setCameraRigParameter(name: string, value: any): void;
  29784. /**
  29785. * needs to be overridden by children so sub has required properties to be copied
  29786. * @hidden
  29787. */
  29788. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  29789. /**
  29790. * May need to be overridden by children
  29791. * @hidden
  29792. */
  29793. _updateRigCameras(): void;
  29794. /** @hidden */
  29795. _setupInputs(): void;
  29796. /**
  29797. * Serialiaze the camera setup to a json represention
  29798. * @returns the JSON representation
  29799. */
  29800. serialize(): any;
  29801. /**
  29802. * Clones the current camera.
  29803. * @param name The cloned camera name
  29804. * @returns the cloned camera
  29805. */
  29806. clone(name: string): Camera;
  29807. /**
  29808. * Gets the direction of the camera relative to a given local axis.
  29809. * @param localAxis Defines the reference axis to provide a relative direction.
  29810. * @return the direction
  29811. */
  29812. getDirection(localAxis: Vector3): Vector3;
  29813. /**
  29814. * Returns the current camera absolute rotation
  29815. */
  29816. get absoluteRotation(): Quaternion;
  29817. /**
  29818. * Gets the direction of the camera relative to a given local axis into a passed vector.
  29819. * @param localAxis Defines the reference axis to provide a relative direction.
  29820. * @param result Defines the vector to store the result in
  29821. */
  29822. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  29823. /**
  29824. * Gets a camera constructor for a given camera type
  29825. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  29826. * @param name The name of the camera the result will be able to instantiate
  29827. * @param scene The scene the result will construct the camera in
  29828. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  29829. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  29830. * @returns a factory method to construc the camera
  29831. */
  29832. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  29833. /**
  29834. * Compute the world matrix of the camera.
  29835. * @returns the camera world matrix
  29836. */
  29837. computeWorldMatrix(): Matrix;
  29838. /**
  29839. * Parse a JSON and creates the camera from the parsed information
  29840. * @param parsedCamera The JSON to parse
  29841. * @param scene The scene to instantiate the camera in
  29842. * @returns the newly constructed camera
  29843. */
  29844. static Parse(parsedCamera: any, scene: Scene): Camera;
  29845. }
  29846. }
  29847. declare module "babylonjs/Meshes/Builders/discBuilder" {
  29848. import { Nullable } from "babylonjs/types";
  29849. import { Scene } from "babylonjs/scene";
  29850. import { Vector4 } from "babylonjs/Maths/math.vector";
  29851. import { Mesh } from "babylonjs/Meshes/mesh";
  29852. /**
  29853. * Class containing static functions to help procedurally build meshes
  29854. */
  29855. export class DiscBuilder {
  29856. /**
  29857. * Creates a plane polygonal mesh. By default, this is a disc
  29858. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  29859. * * 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
  29860. * * 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
  29861. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  29862. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  29863. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29864. * @param name defines the name of the mesh
  29865. * @param options defines the options used to create the mesh
  29866. * @param scene defines the hosting scene
  29867. * @returns the plane polygonal mesh
  29868. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  29869. */
  29870. static CreateDisc(name: string, options: {
  29871. radius?: number;
  29872. tessellation?: number;
  29873. arc?: number;
  29874. updatable?: boolean;
  29875. sideOrientation?: number;
  29876. frontUVs?: Vector4;
  29877. backUVs?: Vector4;
  29878. }, scene?: Nullable<Scene>): Mesh;
  29879. }
  29880. }
  29881. declare module "babylonjs/Materials/fresnelParameters" {
  29882. import { DeepImmutable } from "babylonjs/types";
  29883. import { Color3 } from "babylonjs/Maths/math.color";
  29884. /**
  29885. * Options to be used when creating a FresnelParameters.
  29886. */
  29887. export type IFresnelParametersCreationOptions = {
  29888. /**
  29889. * Define the color used on edges (grazing angle)
  29890. */
  29891. leftColor?: Color3;
  29892. /**
  29893. * Define the color used on center
  29894. */
  29895. rightColor?: Color3;
  29896. /**
  29897. * Define bias applied to computed fresnel term
  29898. */
  29899. bias?: number;
  29900. /**
  29901. * Defined the power exponent applied to fresnel term
  29902. */
  29903. power?: number;
  29904. /**
  29905. * Define if the fresnel effect is enable or not.
  29906. */
  29907. isEnabled?: boolean;
  29908. };
  29909. /**
  29910. * Serialized format for FresnelParameters.
  29911. */
  29912. export type IFresnelParametersSerialized = {
  29913. /**
  29914. * Define the color used on edges (grazing angle) [as an array]
  29915. */
  29916. leftColor: number[];
  29917. /**
  29918. * Define the color used on center [as an array]
  29919. */
  29920. rightColor: number[];
  29921. /**
  29922. * Define bias applied to computed fresnel term
  29923. */
  29924. bias: number;
  29925. /**
  29926. * Defined the power exponent applied to fresnel term
  29927. */
  29928. power?: number;
  29929. /**
  29930. * Define if the fresnel effect is enable or not.
  29931. */
  29932. isEnabled: boolean;
  29933. };
  29934. /**
  29935. * This represents all the required information to add a fresnel effect on a material:
  29936. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29937. */
  29938. export class FresnelParameters {
  29939. private _isEnabled;
  29940. /**
  29941. * Define if the fresnel effect is enable or not.
  29942. */
  29943. get isEnabled(): boolean;
  29944. set isEnabled(value: boolean);
  29945. /**
  29946. * Define the color used on edges (grazing angle)
  29947. */
  29948. leftColor: Color3;
  29949. /**
  29950. * Define the color used on center
  29951. */
  29952. rightColor: Color3;
  29953. /**
  29954. * Define bias applied to computed fresnel term
  29955. */
  29956. bias: number;
  29957. /**
  29958. * Defined the power exponent applied to fresnel term
  29959. */
  29960. power: number;
  29961. /**
  29962. * Creates a new FresnelParameters object.
  29963. *
  29964. * @param options provide your own settings to optionally to override defaults
  29965. */
  29966. constructor(options?: IFresnelParametersCreationOptions);
  29967. /**
  29968. * Clones the current fresnel and its valuues
  29969. * @returns a clone fresnel configuration
  29970. */
  29971. clone(): FresnelParameters;
  29972. /**
  29973. * Determines equality between FresnelParameters objects
  29974. * @param otherFresnelParameters defines the second operand
  29975. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  29976. */
  29977. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  29978. /**
  29979. * Serializes the current fresnel parameters to a JSON representation.
  29980. * @return the JSON serialization
  29981. */
  29982. serialize(): IFresnelParametersSerialized;
  29983. /**
  29984. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  29985. * @param parsedFresnelParameters Define the JSON representation
  29986. * @returns the parsed parameters
  29987. */
  29988. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  29989. }
  29990. }
  29991. declare module "babylonjs/Materials/materialFlags" {
  29992. /**
  29993. * This groups all the flags used to control the materials channel.
  29994. */
  29995. export class MaterialFlags {
  29996. private static _DiffuseTextureEnabled;
  29997. /**
  29998. * Are diffuse textures enabled in the application.
  29999. */
  30000. static get DiffuseTextureEnabled(): boolean;
  30001. static set DiffuseTextureEnabled(value: boolean);
  30002. private static _AmbientTextureEnabled;
  30003. /**
  30004. * Are ambient textures enabled in the application.
  30005. */
  30006. static get AmbientTextureEnabled(): boolean;
  30007. static set AmbientTextureEnabled(value: boolean);
  30008. private static _OpacityTextureEnabled;
  30009. /**
  30010. * Are opacity textures enabled in the application.
  30011. */
  30012. static get OpacityTextureEnabled(): boolean;
  30013. static set OpacityTextureEnabled(value: boolean);
  30014. private static _ReflectionTextureEnabled;
  30015. /**
  30016. * Are reflection textures enabled in the application.
  30017. */
  30018. static get ReflectionTextureEnabled(): boolean;
  30019. static set ReflectionTextureEnabled(value: boolean);
  30020. private static _EmissiveTextureEnabled;
  30021. /**
  30022. * Are emissive textures enabled in the application.
  30023. */
  30024. static get EmissiveTextureEnabled(): boolean;
  30025. static set EmissiveTextureEnabled(value: boolean);
  30026. private static _SpecularTextureEnabled;
  30027. /**
  30028. * Are specular textures enabled in the application.
  30029. */
  30030. static get SpecularTextureEnabled(): boolean;
  30031. static set SpecularTextureEnabled(value: boolean);
  30032. private static _BumpTextureEnabled;
  30033. /**
  30034. * Are bump textures enabled in the application.
  30035. */
  30036. static get BumpTextureEnabled(): boolean;
  30037. static set BumpTextureEnabled(value: boolean);
  30038. private static _LightmapTextureEnabled;
  30039. /**
  30040. * Are lightmap textures enabled in the application.
  30041. */
  30042. static get LightmapTextureEnabled(): boolean;
  30043. static set LightmapTextureEnabled(value: boolean);
  30044. private static _RefractionTextureEnabled;
  30045. /**
  30046. * Are refraction textures enabled in the application.
  30047. */
  30048. static get RefractionTextureEnabled(): boolean;
  30049. static set RefractionTextureEnabled(value: boolean);
  30050. private static _ColorGradingTextureEnabled;
  30051. /**
  30052. * Are color grading textures enabled in the application.
  30053. */
  30054. static get ColorGradingTextureEnabled(): boolean;
  30055. static set ColorGradingTextureEnabled(value: boolean);
  30056. private static _FresnelEnabled;
  30057. /**
  30058. * Are fresnels enabled in the application.
  30059. */
  30060. static get FresnelEnabled(): boolean;
  30061. static set FresnelEnabled(value: boolean);
  30062. private static _ClearCoatTextureEnabled;
  30063. /**
  30064. * Are clear coat textures enabled in the application.
  30065. */
  30066. static get ClearCoatTextureEnabled(): boolean;
  30067. static set ClearCoatTextureEnabled(value: boolean);
  30068. private static _ClearCoatBumpTextureEnabled;
  30069. /**
  30070. * Are clear coat bump textures enabled in the application.
  30071. */
  30072. static get ClearCoatBumpTextureEnabled(): boolean;
  30073. static set ClearCoatBumpTextureEnabled(value: boolean);
  30074. private static _ClearCoatTintTextureEnabled;
  30075. /**
  30076. * Are clear coat tint textures enabled in the application.
  30077. */
  30078. static get ClearCoatTintTextureEnabled(): boolean;
  30079. static set ClearCoatTintTextureEnabled(value: boolean);
  30080. private static _SheenTextureEnabled;
  30081. /**
  30082. * Are sheen textures enabled in the application.
  30083. */
  30084. static get SheenTextureEnabled(): boolean;
  30085. static set SheenTextureEnabled(value: boolean);
  30086. private static _AnisotropicTextureEnabled;
  30087. /**
  30088. * Are anisotropic textures enabled in the application.
  30089. */
  30090. static get AnisotropicTextureEnabled(): boolean;
  30091. static set AnisotropicTextureEnabled(value: boolean);
  30092. private static _ThicknessTextureEnabled;
  30093. /**
  30094. * Are thickness textures enabled in the application.
  30095. */
  30096. static get ThicknessTextureEnabled(): boolean;
  30097. static set ThicknessTextureEnabled(value: boolean);
  30098. }
  30099. }
  30100. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  30101. /** @hidden */
  30102. export var defaultFragmentDeclaration: {
  30103. name: string;
  30104. shader: string;
  30105. };
  30106. }
  30107. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  30108. /** @hidden */
  30109. export var defaultUboDeclaration: {
  30110. name: string;
  30111. shader: string;
  30112. };
  30113. }
  30114. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  30115. /** @hidden */
  30116. export var lightFragmentDeclaration: {
  30117. name: string;
  30118. shader: string;
  30119. };
  30120. }
  30121. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  30122. /** @hidden */
  30123. export var lightUboDeclaration: {
  30124. name: string;
  30125. shader: string;
  30126. };
  30127. }
  30128. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  30129. /** @hidden */
  30130. export var lightsFragmentFunctions: {
  30131. name: string;
  30132. shader: string;
  30133. };
  30134. }
  30135. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  30136. /** @hidden */
  30137. export var shadowsFragmentFunctions: {
  30138. name: string;
  30139. shader: string;
  30140. };
  30141. }
  30142. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  30143. /** @hidden */
  30144. export var fresnelFunction: {
  30145. name: string;
  30146. shader: string;
  30147. };
  30148. }
  30149. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions" {
  30150. /** @hidden */
  30151. export var bumpFragmentMainFunctions: {
  30152. name: string;
  30153. shader: string;
  30154. };
  30155. }
  30156. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  30157. /** @hidden */
  30158. export var bumpFragmentFunctions: {
  30159. name: string;
  30160. shader: string;
  30161. };
  30162. }
  30163. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  30164. /** @hidden */
  30165. export var logDepthDeclaration: {
  30166. name: string;
  30167. shader: string;
  30168. };
  30169. }
  30170. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  30171. /** @hidden */
  30172. export var bumpFragment: {
  30173. name: string;
  30174. shader: string;
  30175. };
  30176. }
  30177. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  30178. /** @hidden */
  30179. export var depthPrePass: {
  30180. name: string;
  30181. shader: string;
  30182. };
  30183. }
  30184. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  30185. /** @hidden */
  30186. export var lightFragment: {
  30187. name: string;
  30188. shader: string;
  30189. };
  30190. }
  30191. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  30192. /** @hidden */
  30193. export var logDepthFragment: {
  30194. name: string;
  30195. shader: string;
  30196. };
  30197. }
  30198. declare module "babylonjs/Shaders/default.fragment" {
  30199. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  30200. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  30201. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  30202. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  30203. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  30204. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  30205. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  30206. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  30207. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  30208. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  30209. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  30210. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  30211. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  30212. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  30213. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  30214. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  30215. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  30216. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  30217. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  30218. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  30219. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  30220. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  30221. /** @hidden */
  30222. export var defaultPixelShader: {
  30223. name: string;
  30224. shader: string;
  30225. };
  30226. }
  30227. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  30228. /** @hidden */
  30229. export var defaultVertexDeclaration: {
  30230. name: string;
  30231. shader: string;
  30232. };
  30233. }
  30234. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  30235. /** @hidden */
  30236. export var bumpVertexDeclaration: {
  30237. name: string;
  30238. shader: string;
  30239. };
  30240. }
  30241. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  30242. /** @hidden */
  30243. export var bumpVertex: {
  30244. name: string;
  30245. shader: string;
  30246. };
  30247. }
  30248. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  30249. /** @hidden */
  30250. export var fogVertex: {
  30251. name: string;
  30252. shader: string;
  30253. };
  30254. }
  30255. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  30256. /** @hidden */
  30257. export var shadowsVertex: {
  30258. name: string;
  30259. shader: string;
  30260. };
  30261. }
  30262. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  30263. /** @hidden */
  30264. export var pointCloudVertex: {
  30265. name: string;
  30266. shader: string;
  30267. };
  30268. }
  30269. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  30270. /** @hidden */
  30271. export var logDepthVertex: {
  30272. name: string;
  30273. shader: string;
  30274. };
  30275. }
  30276. declare module "babylonjs/Shaders/default.vertex" {
  30277. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  30278. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  30279. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  30280. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  30281. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  30282. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  30283. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  30284. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  30285. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  30286. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  30287. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  30288. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  30289. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  30290. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  30291. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  30292. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  30293. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  30294. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  30295. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  30296. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  30297. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  30298. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  30299. /** @hidden */
  30300. export var defaultVertexShader: {
  30301. name: string;
  30302. shader: string;
  30303. };
  30304. }
  30305. declare module "babylonjs/Materials/standardMaterial" {
  30306. import { SmartArray } from "babylonjs/Misc/smartArray";
  30307. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30308. import { Nullable } from "babylonjs/types";
  30309. import { Scene } from "babylonjs/scene";
  30310. import { Matrix } from "babylonjs/Maths/math.vector";
  30311. import { Color3 } from "babylonjs/Maths/math.color";
  30312. import { SubMesh } from "babylonjs/Meshes/subMesh";
  30313. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30314. import { Mesh } from "babylonjs/Meshes/mesh";
  30315. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  30316. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  30317. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  30318. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30319. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  30320. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30321. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30322. import "babylonjs/Shaders/default.fragment";
  30323. import "babylonjs/Shaders/default.vertex";
  30324. /** @hidden */
  30325. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  30326. MAINUV1: boolean;
  30327. MAINUV2: boolean;
  30328. DIFFUSE: boolean;
  30329. DIFFUSEDIRECTUV: number;
  30330. AMBIENT: boolean;
  30331. AMBIENTDIRECTUV: number;
  30332. OPACITY: boolean;
  30333. OPACITYDIRECTUV: number;
  30334. OPACITYRGB: boolean;
  30335. REFLECTION: boolean;
  30336. EMISSIVE: boolean;
  30337. EMISSIVEDIRECTUV: number;
  30338. SPECULAR: boolean;
  30339. SPECULARDIRECTUV: number;
  30340. BUMP: boolean;
  30341. BUMPDIRECTUV: number;
  30342. PARALLAX: boolean;
  30343. PARALLAXOCCLUSION: boolean;
  30344. SPECULAROVERALPHA: boolean;
  30345. CLIPPLANE: boolean;
  30346. CLIPPLANE2: boolean;
  30347. CLIPPLANE3: boolean;
  30348. CLIPPLANE4: boolean;
  30349. CLIPPLANE5: boolean;
  30350. CLIPPLANE6: boolean;
  30351. ALPHATEST: boolean;
  30352. DEPTHPREPASS: boolean;
  30353. ALPHAFROMDIFFUSE: boolean;
  30354. POINTSIZE: boolean;
  30355. FOG: boolean;
  30356. SPECULARTERM: boolean;
  30357. DIFFUSEFRESNEL: boolean;
  30358. OPACITYFRESNEL: boolean;
  30359. REFLECTIONFRESNEL: boolean;
  30360. REFRACTIONFRESNEL: boolean;
  30361. EMISSIVEFRESNEL: boolean;
  30362. FRESNEL: boolean;
  30363. NORMAL: boolean;
  30364. UV1: boolean;
  30365. UV2: boolean;
  30366. VERTEXCOLOR: boolean;
  30367. VERTEXALPHA: boolean;
  30368. NUM_BONE_INFLUENCERS: number;
  30369. BonesPerMesh: number;
  30370. BONETEXTURE: boolean;
  30371. INSTANCES: boolean;
  30372. THIN_INSTANCES: boolean;
  30373. GLOSSINESS: boolean;
  30374. ROUGHNESS: boolean;
  30375. EMISSIVEASILLUMINATION: boolean;
  30376. LINKEMISSIVEWITHDIFFUSE: boolean;
  30377. REFLECTIONFRESNELFROMSPECULAR: boolean;
  30378. LIGHTMAP: boolean;
  30379. LIGHTMAPDIRECTUV: number;
  30380. OBJECTSPACE_NORMALMAP: boolean;
  30381. USELIGHTMAPASSHADOWMAP: boolean;
  30382. REFLECTIONMAP_3D: boolean;
  30383. REFLECTIONMAP_SPHERICAL: boolean;
  30384. REFLECTIONMAP_PLANAR: boolean;
  30385. REFLECTIONMAP_CUBIC: boolean;
  30386. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  30387. REFLECTIONMAP_PROJECTION: boolean;
  30388. REFLECTIONMAP_SKYBOX: boolean;
  30389. REFLECTIONMAP_EXPLICIT: boolean;
  30390. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  30391. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  30392. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  30393. INVERTCUBICMAP: boolean;
  30394. LOGARITHMICDEPTH: boolean;
  30395. REFRACTION: boolean;
  30396. REFRACTIONMAP_3D: boolean;
  30397. REFLECTIONOVERALPHA: boolean;
  30398. TWOSIDEDLIGHTING: boolean;
  30399. SHADOWFLOAT: boolean;
  30400. MORPHTARGETS: boolean;
  30401. MORPHTARGETS_NORMAL: boolean;
  30402. MORPHTARGETS_TANGENT: boolean;
  30403. MORPHTARGETS_UV: boolean;
  30404. NUM_MORPH_INFLUENCERS: number;
  30405. NONUNIFORMSCALING: boolean;
  30406. PREMULTIPLYALPHA: boolean;
  30407. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  30408. ALPHABLEND: boolean;
  30409. RGBDLIGHTMAP: boolean;
  30410. RGBDREFLECTION: boolean;
  30411. RGBDREFRACTION: boolean;
  30412. IMAGEPROCESSING: boolean;
  30413. VIGNETTE: boolean;
  30414. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30415. VIGNETTEBLENDMODEOPAQUE: boolean;
  30416. TONEMAPPING: boolean;
  30417. TONEMAPPING_ACES: boolean;
  30418. CONTRAST: boolean;
  30419. COLORCURVES: boolean;
  30420. COLORGRADING: boolean;
  30421. COLORGRADING3D: boolean;
  30422. SAMPLER3DGREENDEPTH: boolean;
  30423. SAMPLER3DBGRMAP: boolean;
  30424. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30425. MULTIVIEW: boolean;
  30426. /**
  30427. * If the reflection texture on this material is in linear color space
  30428. * @hidden
  30429. */
  30430. IS_REFLECTION_LINEAR: boolean;
  30431. /**
  30432. * If the refraction texture on this material is in linear color space
  30433. * @hidden
  30434. */
  30435. IS_REFRACTION_LINEAR: boolean;
  30436. EXPOSURE: boolean;
  30437. constructor();
  30438. setReflectionMode(modeToEnable: string): void;
  30439. }
  30440. /**
  30441. * This is the default material used in Babylon. It is the best trade off between quality
  30442. * and performances.
  30443. * @see http://doc.babylonjs.com/babylon101/materials
  30444. */
  30445. export class StandardMaterial extends PushMaterial {
  30446. private _diffuseTexture;
  30447. /**
  30448. * The basic texture of the material as viewed under a light.
  30449. */
  30450. diffuseTexture: Nullable<BaseTexture>;
  30451. private _ambientTexture;
  30452. /**
  30453. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  30454. */
  30455. ambientTexture: Nullable<BaseTexture>;
  30456. private _opacityTexture;
  30457. /**
  30458. * Define the transparency of the material from a texture.
  30459. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  30460. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  30461. */
  30462. opacityTexture: Nullable<BaseTexture>;
  30463. private _reflectionTexture;
  30464. /**
  30465. * Define the texture used to display the reflection.
  30466. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30467. */
  30468. reflectionTexture: Nullable<BaseTexture>;
  30469. private _emissiveTexture;
  30470. /**
  30471. * Define texture of the material as if self lit.
  30472. * This will be mixed in the final result even in the absence of light.
  30473. */
  30474. emissiveTexture: Nullable<BaseTexture>;
  30475. private _specularTexture;
  30476. /**
  30477. * Define how the color and intensity of the highlight given by the light in the material.
  30478. */
  30479. specularTexture: Nullable<BaseTexture>;
  30480. private _bumpTexture;
  30481. /**
  30482. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  30483. * 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.
  30484. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  30485. */
  30486. bumpTexture: Nullable<BaseTexture>;
  30487. private _lightmapTexture;
  30488. /**
  30489. * Complex lighting can be computationally expensive to compute at runtime.
  30490. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  30491. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  30492. */
  30493. lightmapTexture: Nullable<BaseTexture>;
  30494. private _refractionTexture;
  30495. /**
  30496. * Define the texture used to display the refraction.
  30497. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30498. */
  30499. refractionTexture: Nullable<BaseTexture>;
  30500. /**
  30501. * The color of the material lit by the environmental background lighting.
  30502. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  30503. */
  30504. ambientColor: Color3;
  30505. /**
  30506. * The basic color of the material as viewed under a light.
  30507. */
  30508. diffuseColor: Color3;
  30509. /**
  30510. * Define how the color and intensity of the highlight given by the light in the material.
  30511. */
  30512. specularColor: Color3;
  30513. /**
  30514. * Define the color of the material as if self lit.
  30515. * This will be mixed in the final result even in the absence of light.
  30516. */
  30517. emissiveColor: Color3;
  30518. /**
  30519. * Defines how sharp are the highlights in the material.
  30520. * The bigger the value the sharper giving a more glossy feeling to the result.
  30521. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  30522. */
  30523. specularPower: number;
  30524. private _useAlphaFromDiffuseTexture;
  30525. /**
  30526. * Does the transparency come from the diffuse texture alpha channel.
  30527. */
  30528. useAlphaFromDiffuseTexture: boolean;
  30529. private _useEmissiveAsIllumination;
  30530. /**
  30531. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  30532. */
  30533. useEmissiveAsIllumination: boolean;
  30534. private _linkEmissiveWithDiffuse;
  30535. /**
  30536. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  30537. * the emissive level when the final color is close to one.
  30538. */
  30539. linkEmissiveWithDiffuse: boolean;
  30540. private _useSpecularOverAlpha;
  30541. /**
  30542. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  30543. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  30544. */
  30545. useSpecularOverAlpha: boolean;
  30546. private _useReflectionOverAlpha;
  30547. /**
  30548. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  30549. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  30550. */
  30551. useReflectionOverAlpha: boolean;
  30552. private _disableLighting;
  30553. /**
  30554. * Does lights from the scene impacts this material.
  30555. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  30556. */
  30557. disableLighting: boolean;
  30558. private _useObjectSpaceNormalMap;
  30559. /**
  30560. * Allows using an object space normal map (instead of tangent space).
  30561. */
  30562. useObjectSpaceNormalMap: boolean;
  30563. private _useParallax;
  30564. /**
  30565. * Is parallax enabled or not.
  30566. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  30567. */
  30568. useParallax: boolean;
  30569. private _useParallaxOcclusion;
  30570. /**
  30571. * Is parallax occlusion enabled or not.
  30572. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  30573. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  30574. */
  30575. useParallaxOcclusion: boolean;
  30576. /**
  30577. * 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.
  30578. */
  30579. parallaxScaleBias: number;
  30580. private _roughness;
  30581. /**
  30582. * Helps to define how blurry the reflections should appears in the material.
  30583. */
  30584. roughness: number;
  30585. /**
  30586. * In case of refraction, define the value of the index of refraction.
  30587. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30588. */
  30589. indexOfRefraction: number;
  30590. /**
  30591. * Invert the refraction texture alongside the y axis.
  30592. * It can be useful with procedural textures or probe for instance.
  30593. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30594. */
  30595. invertRefractionY: boolean;
  30596. /**
  30597. * Defines the alpha limits in alpha test mode.
  30598. */
  30599. alphaCutOff: number;
  30600. private _useLightmapAsShadowmap;
  30601. /**
  30602. * In case of light mapping, define whether the map contains light or shadow informations.
  30603. */
  30604. useLightmapAsShadowmap: boolean;
  30605. private _diffuseFresnelParameters;
  30606. /**
  30607. * Define the diffuse fresnel parameters of the material.
  30608. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30609. */
  30610. diffuseFresnelParameters: FresnelParameters;
  30611. private _opacityFresnelParameters;
  30612. /**
  30613. * Define the opacity fresnel parameters of the material.
  30614. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30615. */
  30616. opacityFresnelParameters: FresnelParameters;
  30617. private _reflectionFresnelParameters;
  30618. /**
  30619. * Define the reflection fresnel parameters of the material.
  30620. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30621. */
  30622. reflectionFresnelParameters: FresnelParameters;
  30623. private _refractionFresnelParameters;
  30624. /**
  30625. * Define the refraction fresnel parameters of the material.
  30626. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30627. */
  30628. refractionFresnelParameters: FresnelParameters;
  30629. private _emissiveFresnelParameters;
  30630. /**
  30631. * Define the emissive fresnel parameters of the material.
  30632. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30633. */
  30634. emissiveFresnelParameters: FresnelParameters;
  30635. private _useReflectionFresnelFromSpecular;
  30636. /**
  30637. * If true automatically deducts the fresnels values from the material specularity.
  30638. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30639. */
  30640. useReflectionFresnelFromSpecular: boolean;
  30641. private _useGlossinessFromSpecularMapAlpha;
  30642. /**
  30643. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  30644. */
  30645. useGlossinessFromSpecularMapAlpha: boolean;
  30646. private _maxSimultaneousLights;
  30647. /**
  30648. * Defines the maximum number of lights that can be used in the material
  30649. */
  30650. maxSimultaneousLights: number;
  30651. private _invertNormalMapX;
  30652. /**
  30653. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  30654. */
  30655. invertNormalMapX: boolean;
  30656. private _invertNormalMapY;
  30657. /**
  30658. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  30659. */
  30660. invertNormalMapY: boolean;
  30661. private _twoSidedLighting;
  30662. /**
  30663. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  30664. */
  30665. twoSidedLighting: boolean;
  30666. /**
  30667. * Default configuration related to image processing available in the standard Material.
  30668. */
  30669. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  30670. /**
  30671. * Gets the image processing configuration used either in this material.
  30672. */
  30673. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  30674. /**
  30675. * Sets the Default image processing configuration used either in the this material.
  30676. *
  30677. * If sets to null, the scene one is in use.
  30678. */
  30679. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  30680. /**
  30681. * Keep track of the image processing observer to allow dispose and replace.
  30682. */
  30683. private _imageProcessingObserver;
  30684. /**
  30685. * Attaches a new image processing configuration to the Standard Material.
  30686. * @param configuration
  30687. */
  30688. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  30689. /**
  30690. * Gets wether the color curves effect is enabled.
  30691. */
  30692. get cameraColorCurvesEnabled(): boolean;
  30693. /**
  30694. * Sets wether the color curves effect is enabled.
  30695. */
  30696. set cameraColorCurvesEnabled(value: boolean);
  30697. /**
  30698. * Gets wether the color grading effect is enabled.
  30699. */
  30700. get cameraColorGradingEnabled(): boolean;
  30701. /**
  30702. * Gets wether the color grading effect is enabled.
  30703. */
  30704. set cameraColorGradingEnabled(value: boolean);
  30705. /**
  30706. * Gets wether tonemapping is enabled or not.
  30707. */
  30708. get cameraToneMappingEnabled(): boolean;
  30709. /**
  30710. * Sets wether tonemapping is enabled or not
  30711. */
  30712. set cameraToneMappingEnabled(value: boolean);
  30713. /**
  30714. * The camera exposure used on this material.
  30715. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30716. * This corresponds to a photographic exposure.
  30717. */
  30718. get cameraExposure(): number;
  30719. /**
  30720. * The camera exposure used on this material.
  30721. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30722. * This corresponds to a photographic exposure.
  30723. */
  30724. set cameraExposure(value: number);
  30725. /**
  30726. * Gets The camera contrast used on this material.
  30727. */
  30728. get cameraContrast(): number;
  30729. /**
  30730. * Sets The camera contrast used on this material.
  30731. */
  30732. set cameraContrast(value: number);
  30733. /**
  30734. * Gets the Color Grading 2D Lookup Texture.
  30735. */
  30736. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  30737. /**
  30738. * Sets the Color Grading 2D Lookup Texture.
  30739. */
  30740. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  30741. /**
  30742. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30743. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30744. * 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;
  30745. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30746. */
  30747. get cameraColorCurves(): Nullable<ColorCurves>;
  30748. /**
  30749. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30750. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30751. * 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;
  30752. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30753. */
  30754. set cameraColorCurves(value: Nullable<ColorCurves>);
  30755. protected _renderTargets: SmartArray<RenderTargetTexture>;
  30756. protected _worldViewProjectionMatrix: Matrix;
  30757. protected _globalAmbientColor: Color3;
  30758. protected _useLogarithmicDepth: boolean;
  30759. protected _rebuildInParallel: boolean;
  30760. /**
  30761. * Instantiates a new standard material.
  30762. * This is the default material used in Babylon. It is the best trade off between quality
  30763. * and performances.
  30764. * @see http://doc.babylonjs.com/babylon101/materials
  30765. * @param name Define the name of the material in the scene
  30766. * @param scene Define the scene the material belong to
  30767. */
  30768. constructor(name: string, scene: Scene);
  30769. /**
  30770. * Gets a boolean indicating that current material needs to register RTT
  30771. */
  30772. get hasRenderTargetTextures(): boolean;
  30773. /**
  30774. * Gets the current class name of the material e.g. "StandardMaterial"
  30775. * Mainly use in serialization.
  30776. * @returns the class name
  30777. */
  30778. getClassName(): string;
  30779. /**
  30780. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  30781. * You can try switching to logarithmic depth.
  30782. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  30783. */
  30784. get useLogarithmicDepth(): boolean;
  30785. set useLogarithmicDepth(value: boolean);
  30786. /**
  30787. * Specifies if the material will require alpha blending
  30788. * @returns a boolean specifying if alpha blending is needed
  30789. */
  30790. needAlphaBlending(): boolean;
  30791. /**
  30792. * Specifies if this material should be rendered in alpha test mode
  30793. * @returns a boolean specifying if an alpha test is needed.
  30794. */
  30795. needAlphaTesting(): boolean;
  30796. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  30797. /**
  30798. * Get the texture used for alpha test purpose.
  30799. * @returns the diffuse texture in case of the standard material.
  30800. */
  30801. getAlphaTestTexture(): Nullable<BaseTexture>;
  30802. /**
  30803. * Get if the submesh is ready to be used and all its information available.
  30804. * Child classes can use it to update shaders
  30805. * @param mesh defines the mesh to check
  30806. * @param subMesh defines which submesh to check
  30807. * @param useInstances specifies that instances should be used
  30808. * @returns a boolean indicating that the submesh is ready or not
  30809. */
  30810. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30811. /**
  30812. * Builds the material UBO layouts.
  30813. * Used internally during the effect preparation.
  30814. */
  30815. buildUniformLayout(): void;
  30816. /**
  30817. * Unbinds the material from the mesh
  30818. */
  30819. unbind(): void;
  30820. /**
  30821. * Binds the submesh to this material by preparing the effect and shader to draw
  30822. * @param world defines the world transformation matrix
  30823. * @param mesh defines the mesh containing the submesh
  30824. * @param subMesh defines the submesh to bind the material to
  30825. */
  30826. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  30827. /**
  30828. * Get the list of animatables in the material.
  30829. * @returns the list of animatables object used in the material
  30830. */
  30831. getAnimatables(): IAnimatable[];
  30832. /**
  30833. * Gets the active textures from the material
  30834. * @returns an array of textures
  30835. */
  30836. getActiveTextures(): BaseTexture[];
  30837. /**
  30838. * Specifies if the material uses a texture
  30839. * @param texture defines the texture to check against the material
  30840. * @returns a boolean specifying if the material uses the texture
  30841. */
  30842. hasTexture(texture: BaseTexture): boolean;
  30843. /**
  30844. * Disposes the material
  30845. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  30846. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  30847. */
  30848. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  30849. /**
  30850. * Makes a duplicate of the material, and gives it a new name
  30851. * @param name defines the new name for the duplicated material
  30852. * @returns the cloned material
  30853. */
  30854. clone(name: string): StandardMaterial;
  30855. /**
  30856. * Serializes this material in a JSON representation
  30857. * @returns the serialized material object
  30858. */
  30859. serialize(): any;
  30860. /**
  30861. * Creates a standard material from parsed material data
  30862. * @param source defines the JSON representation of the material
  30863. * @param scene defines the hosting scene
  30864. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  30865. * @returns a new standard material
  30866. */
  30867. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  30868. /**
  30869. * Are diffuse textures enabled in the application.
  30870. */
  30871. static get DiffuseTextureEnabled(): boolean;
  30872. static set DiffuseTextureEnabled(value: boolean);
  30873. /**
  30874. * Are ambient textures enabled in the application.
  30875. */
  30876. static get AmbientTextureEnabled(): boolean;
  30877. static set AmbientTextureEnabled(value: boolean);
  30878. /**
  30879. * Are opacity textures enabled in the application.
  30880. */
  30881. static get OpacityTextureEnabled(): boolean;
  30882. static set OpacityTextureEnabled(value: boolean);
  30883. /**
  30884. * Are reflection textures enabled in the application.
  30885. */
  30886. static get ReflectionTextureEnabled(): boolean;
  30887. static set ReflectionTextureEnabled(value: boolean);
  30888. /**
  30889. * Are emissive textures enabled in the application.
  30890. */
  30891. static get EmissiveTextureEnabled(): boolean;
  30892. static set EmissiveTextureEnabled(value: boolean);
  30893. /**
  30894. * Are specular textures enabled in the application.
  30895. */
  30896. static get SpecularTextureEnabled(): boolean;
  30897. static set SpecularTextureEnabled(value: boolean);
  30898. /**
  30899. * Are bump textures enabled in the application.
  30900. */
  30901. static get BumpTextureEnabled(): boolean;
  30902. static set BumpTextureEnabled(value: boolean);
  30903. /**
  30904. * Are lightmap textures enabled in the application.
  30905. */
  30906. static get LightmapTextureEnabled(): boolean;
  30907. static set LightmapTextureEnabled(value: boolean);
  30908. /**
  30909. * Are refraction textures enabled in the application.
  30910. */
  30911. static get RefractionTextureEnabled(): boolean;
  30912. static set RefractionTextureEnabled(value: boolean);
  30913. /**
  30914. * Are color grading textures enabled in the application.
  30915. */
  30916. static get ColorGradingTextureEnabled(): boolean;
  30917. static set ColorGradingTextureEnabled(value: boolean);
  30918. /**
  30919. * Are fresnels enabled in the application.
  30920. */
  30921. static get FresnelEnabled(): boolean;
  30922. static set FresnelEnabled(value: boolean);
  30923. }
  30924. }
  30925. declare module "babylonjs/Particles/solidParticleSystem" {
  30926. import { Nullable } from "babylonjs/types";
  30927. import { Mesh } from "babylonjs/Meshes/mesh";
  30928. import { Scene, IDisposable } from "babylonjs/scene";
  30929. import { DepthSortedParticle, SolidParticle, SolidParticleVertex } from "babylonjs/Particles/solidParticle";
  30930. import { Material } from "babylonjs/Materials/material";
  30931. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  30932. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  30933. /**
  30934. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  30935. *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.
  30936. * The SPS is also a particle system. It provides some methods to manage the particles.
  30937. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  30938. *
  30939. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  30940. */
  30941. export class SolidParticleSystem implements IDisposable {
  30942. /**
  30943. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  30944. * Example : var p = SPS.particles[i];
  30945. */
  30946. particles: SolidParticle[];
  30947. /**
  30948. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  30949. */
  30950. nbParticles: number;
  30951. /**
  30952. * If the particles must ever face the camera (default false). Useful for planar particles.
  30953. */
  30954. billboard: boolean;
  30955. /**
  30956. * Recompute normals when adding a shape
  30957. */
  30958. recomputeNormals: boolean;
  30959. /**
  30960. * This a counter ofr your own usage. It's not set by any SPS functions.
  30961. */
  30962. counter: number;
  30963. /**
  30964. * The SPS name. This name is also given to the underlying mesh.
  30965. */
  30966. name: string;
  30967. /**
  30968. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  30969. */
  30970. mesh: Mesh;
  30971. /**
  30972. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  30973. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  30974. */
  30975. vars: any;
  30976. /**
  30977. * This array is populated when the SPS is set as 'pickable'.
  30978. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  30979. * Each element of this array is an object `{idx: int, faceId: int}`.
  30980. * `idx` is the picked particle index in the `SPS.particles` array
  30981. * `faceId` is the picked face index counted within this particle.
  30982. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  30983. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  30984. * Use the method SPS.pickedParticle(pickingInfo) instead.
  30985. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  30986. */
  30987. pickedParticles: {
  30988. idx: number;
  30989. faceId: number;
  30990. }[];
  30991. /**
  30992. * This array is populated when the SPS is set as 'pickable'
  30993. * Each key of this array is a submesh index.
  30994. * Each element of this array is a second array defined like this :
  30995. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  30996. * Each element of this second array is an object `{idx: int, faceId: int}`.
  30997. * `idx` is the picked particle index in the `SPS.particles` array
  30998. * `faceId` is the picked face index counted within this particle.
  30999. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  31000. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  31001. */
  31002. pickedBySubMesh: {
  31003. idx: number;
  31004. faceId: number;
  31005. }[][];
  31006. /**
  31007. * This array is populated when `enableDepthSort` is set to true.
  31008. * Each element of this array is an instance of the class DepthSortedParticle.
  31009. */
  31010. depthSortedParticles: DepthSortedParticle[];
  31011. /**
  31012. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  31013. * @hidden
  31014. */
  31015. _bSphereOnly: boolean;
  31016. /**
  31017. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  31018. * @hidden
  31019. */
  31020. _bSphereRadiusFactor: number;
  31021. private _scene;
  31022. private _positions;
  31023. private _indices;
  31024. private _normals;
  31025. private _colors;
  31026. private _uvs;
  31027. private _indices32;
  31028. private _positions32;
  31029. private _normals32;
  31030. private _fixedNormal32;
  31031. private _colors32;
  31032. private _uvs32;
  31033. private _index;
  31034. private _updatable;
  31035. private _pickable;
  31036. private _isVisibilityBoxLocked;
  31037. private _alwaysVisible;
  31038. private _depthSort;
  31039. private _expandable;
  31040. private _shapeCounter;
  31041. private _copy;
  31042. private _color;
  31043. private _computeParticleColor;
  31044. private _computeParticleTexture;
  31045. private _computeParticleRotation;
  31046. private _computeParticleVertex;
  31047. private _computeBoundingBox;
  31048. private _depthSortParticles;
  31049. private _camera;
  31050. private _mustUnrotateFixedNormals;
  31051. private _particlesIntersect;
  31052. private _needs32Bits;
  31053. private _isNotBuilt;
  31054. private _lastParticleId;
  31055. private _idxOfId;
  31056. private _multimaterialEnabled;
  31057. private _useModelMaterial;
  31058. private _indicesByMaterial;
  31059. private _materialIndexes;
  31060. private _depthSortFunction;
  31061. private _materialSortFunction;
  31062. private _materials;
  31063. private _multimaterial;
  31064. private _materialIndexesById;
  31065. private _defaultMaterial;
  31066. private _autoUpdateSubMeshes;
  31067. private _tmpVertex;
  31068. /**
  31069. * Creates a SPS (Solid Particle System) object.
  31070. * @param name (String) is the SPS name, this will be the underlying mesh name.
  31071. * @param scene (Scene) is the scene in which the SPS is added.
  31072. * @param options defines the options of the sps e.g.
  31073. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  31074. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  31075. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  31076. * * 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.
  31077. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  31078. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  31079. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  31080. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  31081. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  31082. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  31083. */
  31084. constructor(name: string, scene: Scene, options?: {
  31085. updatable?: boolean;
  31086. isPickable?: boolean;
  31087. enableDepthSort?: boolean;
  31088. particleIntersection?: boolean;
  31089. boundingSphereOnly?: boolean;
  31090. bSphereRadiusFactor?: number;
  31091. expandable?: boolean;
  31092. useModelMaterial?: boolean;
  31093. enableMultiMaterial?: boolean;
  31094. });
  31095. /**
  31096. * Builds the SPS underlying mesh. Returns a standard Mesh.
  31097. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  31098. * @returns the created mesh
  31099. */
  31100. buildMesh(): Mesh;
  31101. /**
  31102. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  31103. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  31104. * Thus the particles generated from `digest()` have their property `position` set yet.
  31105. * @param mesh ( Mesh ) is the mesh to be digested
  31106. * @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
  31107. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  31108. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  31109. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  31110. * @returns the current SPS
  31111. */
  31112. digest(mesh: Mesh, options?: {
  31113. facetNb?: number;
  31114. number?: number;
  31115. delta?: number;
  31116. storage?: [];
  31117. }): SolidParticleSystem;
  31118. /**
  31119. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  31120. * @hidden
  31121. */
  31122. private _unrotateFixedNormals;
  31123. /**
  31124. * Resets the temporary working copy particle
  31125. * @hidden
  31126. */
  31127. private _resetCopy;
  31128. /**
  31129. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  31130. * @param p the current index in the positions array to be updated
  31131. * @param ind the current index in the indices array
  31132. * @param shape a Vector3 array, the shape geometry
  31133. * @param positions the positions array to be updated
  31134. * @param meshInd the shape indices array
  31135. * @param indices the indices array to be updated
  31136. * @param meshUV the shape uv array
  31137. * @param uvs the uv array to be updated
  31138. * @param meshCol the shape color array
  31139. * @param colors the color array to be updated
  31140. * @param meshNor the shape normals array
  31141. * @param normals the normals array to be updated
  31142. * @param idx the particle index
  31143. * @param idxInShape the particle index in its shape
  31144. * @param options the addShape() method passed options
  31145. * @model the particle model
  31146. * @hidden
  31147. */
  31148. private _meshBuilder;
  31149. /**
  31150. * Returns a shape Vector3 array from positions float array
  31151. * @param positions float array
  31152. * @returns a vector3 array
  31153. * @hidden
  31154. */
  31155. private _posToShape;
  31156. /**
  31157. * Returns a shapeUV array from a float uvs (array deep copy)
  31158. * @param uvs as a float array
  31159. * @returns a shapeUV array
  31160. * @hidden
  31161. */
  31162. private _uvsToShapeUV;
  31163. /**
  31164. * Adds a new particle object in the particles array
  31165. * @param idx particle index in particles array
  31166. * @param id particle id
  31167. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  31168. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  31169. * @param model particle ModelShape object
  31170. * @param shapeId model shape identifier
  31171. * @param idxInShape index of the particle in the current model
  31172. * @param bInfo model bounding info object
  31173. * @param storage target storage array, if any
  31174. * @hidden
  31175. */
  31176. private _addParticle;
  31177. /**
  31178. * Adds some particles to the SPS from the model shape. Returns the shape id.
  31179. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  31180. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  31181. * @param nb (positive integer) the number of particles to be created from this model
  31182. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  31183. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  31184. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  31185. * @returns the number of shapes in the system
  31186. */
  31187. addShape(mesh: Mesh, nb: number, options?: {
  31188. positionFunction?: any;
  31189. vertexFunction?: any;
  31190. storage?: [];
  31191. }): number;
  31192. /**
  31193. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  31194. * @hidden
  31195. */
  31196. private _rebuildParticle;
  31197. /**
  31198. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  31199. * @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.
  31200. * @returns the SPS.
  31201. */
  31202. rebuildMesh(reset?: boolean): SolidParticleSystem;
  31203. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  31204. * Returns an array with the removed particles.
  31205. * 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.
  31206. * The SPS can't be empty so at least one particle needs to remain in place.
  31207. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  31208. * @param start index of the first particle to remove
  31209. * @param end index of the last particle to remove (included)
  31210. * @returns an array populated with the removed particles
  31211. */
  31212. removeParticles(start: number, end: number): SolidParticle[];
  31213. /**
  31214. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  31215. * @param solidParticleArray an array populated with Solid Particles objects
  31216. * @returns the SPS
  31217. */
  31218. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  31219. /**
  31220. * Creates a new particle and modifies the SPS mesh geometry :
  31221. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  31222. * - calls _addParticle() to populate the particle array
  31223. * factorized code from addShape() and insertParticlesFromArray()
  31224. * @param idx particle index in the particles array
  31225. * @param i particle index in its shape
  31226. * @param modelShape particle ModelShape object
  31227. * @param shape shape vertex array
  31228. * @param meshInd shape indices array
  31229. * @param meshUV shape uv array
  31230. * @param meshCol shape color array
  31231. * @param meshNor shape normals array
  31232. * @param bbInfo shape bounding info
  31233. * @param storage target particle storage
  31234. * @options addShape() passed options
  31235. * @hidden
  31236. */
  31237. private _insertNewParticle;
  31238. /**
  31239. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  31240. * This method calls `updateParticle()` for each particle of the SPS.
  31241. * For an animated SPS, it is usually called within the render loop.
  31242. * 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.
  31243. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  31244. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  31245. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  31246. * @returns the SPS.
  31247. */
  31248. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  31249. /**
  31250. * Disposes the SPS.
  31251. */
  31252. dispose(): void;
  31253. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  31254. * idx is the particle index in the SPS
  31255. * faceId is the picked face index counted within this particle.
  31256. * Returns null if the pickInfo can't identify a picked particle.
  31257. * @param pickingInfo (PickingInfo object)
  31258. * @returns {idx: number, faceId: number} or null
  31259. */
  31260. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  31261. idx: number;
  31262. faceId: number;
  31263. }>;
  31264. /**
  31265. * Returns a SolidParticle object from its identifier : particle.id
  31266. * @param id (integer) the particle Id
  31267. * @returns the searched particle or null if not found in the SPS.
  31268. */
  31269. getParticleById(id: number): Nullable<SolidParticle>;
  31270. /**
  31271. * Returns a new array populated with the particles having the passed shapeId.
  31272. * @param shapeId (integer) the shape identifier
  31273. * @returns a new solid particle array
  31274. */
  31275. getParticlesByShapeId(shapeId: number): SolidParticle[];
  31276. /**
  31277. * Populates the passed array "ref" with the particles having the passed shapeId.
  31278. * @param shapeId the shape identifier
  31279. * @returns the SPS
  31280. * @param ref
  31281. */
  31282. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  31283. /**
  31284. * Computes the required SubMeshes according the materials assigned to the particles.
  31285. * @returns the solid particle system.
  31286. * Does nothing if called before the SPS mesh is built.
  31287. */
  31288. computeSubMeshes(): SolidParticleSystem;
  31289. /**
  31290. * Sorts the solid particles by material when MultiMaterial is enabled.
  31291. * Updates the indices32 array.
  31292. * Updates the indicesByMaterial array.
  31293. * Updates the mesh indices array.
  31294. * @returns the SPS
  31295. * @hidden
  31296. */
  31297. private _sortParticlesByMaterial;
  31298. /**
  31299. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  31300. * @hidden
  31301. */
  31302. private _setMaterialIndexesById;
  31303. /**
  31304. * Returns an array with unique values of Materials from the passed array
  31305. * @param array the material array to be checked and filtered
  31306. * @hidden
  31307. */
  31308. private _filterUniqueMaterialId;
  31309. /**
  31310. * Sets a new Standard Material as _defaultMaterial if not already set.
  31311. * @hidden
  31312. */
  31313. private _setDefaultMaterial;
  31314. /**
  31315. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  31316. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31317. * @returns the SPS.
  31318. */
  31319. refreshVisibleSize(): SolidParticleSystem;
  31320. /**
  31321. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  31322. * @param size the size (float) of the visibility box
  31323. * note : this doesn't lock the SPS mesh bounding box.
  31324. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31325. */
  31326. setVisibilityBox(size: number): void;
  31327. /**
  31328. * Gets whether the SPS as always visible or not
  31329. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31330. */
  31331. get isAlwaysVisible(): boolean;
  31332. /**
  31333. * Sets the SPS as always visible or not
  31334. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31335. */
  31336. set isAlwaysVisible(val: boolean);
  31337. /**
  31338. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31339. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31340. */
  31341. set isVisibilityBoxLocked(val: boolean);
  31342. /**
  31343. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31344. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31345. */
  31346. get isVisibilityBoxLocked(): boolean;
  31347. /**
  31348. * Tells to `setParticles()` to compute the particle rotations or not.
  31349. * Default value : true. The SPS is faster when it's set to false.
  31350. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31351. */
  31352. set computeParticleRotation(val: boolean);
  31353. /**
  31354. * Tells to `setParticles()` to compute the particle colors or not.
  31355. * Default value : true. The SPS is faster when it's set to false.
  31356. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31357. */
  31358. set computeParticleColor(val: boolean);
  31359. set computeParticleTexture(val: boolean);
  31360. /**
  31361. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  31362. * Default value : false. The SPS is faster when it's set to false.
  31363. * Note : the particle custom vertex positions aren't stored values.
  31364. */
  31365. set computeParticleVertex(val: boolean);
  31366. /**
  31367. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  31368. */
  31369. set computeBoundingBox(val: boolean);
  31370. /**
  31371. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  31372. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31373. * Default : `true`
  31374. */
  31375. set depthSortParticles(val: boolean);
  31376. /**
  31377. * Gets if `setParticles()` computes the particle rotations or not.
  31378. * Default value : true. The SPS is faster when it's set to false.
  31379. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31380. */
  31381. get computeParticleRotation(): boolean;
  31382. /**
  31383. * Gets if `setParticles()` computes the particle colors or not.
  31384. * Default value : true. The SPS is faster when it's set to false.
  31385. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31386. */
  31387. get computeParticleColor(): boolean;
  31388. /**
  31389. * Gets if `setParticles()` computes the particle textures or not.
  31390. * Default value : true. The SPS is faster when it's set to false.
  31391. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  31392. */
  31393. get computeParticleTexture(): boolean;
  31394. /**
  31395. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  31396. * Default value : false. The SPS is faster when it's set to false.
  31397. * Note : the particle custom vertex positions aren't stored values.
  31398. */
  31399. get computeParticleVertex(): boolean;
  31400. /**
  31401. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  31402. */
  31403. get computeBoundingBox(): boolean;
  31404. /**
  31405. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  31406. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31407. * Default : `true`
  31408. */
  31409. get depthSortParticles(): boolean;
  31410. /**
  31411. * Gets if the SPS is created as expandable at construction time.
  31412. * Default : `false`
  31413. */
  31414. get expandable(): boolean;
  31415. /**
  31416. * Gets if the SPS supports the Multi Materials
  31417. */
  31418. get multimaterialEnabled(): boolean;
  31419. /**
  31420. * Gets if the SPS uses the model materials for its own multimaterial.
  31421. */
  31422. get useModelMaterial(): boolean;
  31423. /**
  31424. * The SPS used material array.
  31425. */
  31426. get materials(): Material[];
  31427. /**
  31428. * Sets the SPS MultiMaterial from the passed materials.
  31429. * Note : the passed array is internally copied and not used then by reference.
  31430. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  31431. */
  31432. setMultiMaterial(materials: Material[]): void;
  31433. /**
  31434. * The SPS computed multimaterial object
  31435. */
  31436. get multimaterial(): MultiMaterial;
  31437. set multimaterial(mm: MultiMaterial);
  31438. /**
  31439. * If the subMeshes must be updated on the next call to setParticles()
  31440. */
  31441. get autoUpdateSubMeshes(): boolean;
  31442. set autoUpdateSubMeshes(val: boolean);
  31443. /**
  31444. * This function does nothing. It may be overwritten to set all the particle first values.
  31445. * The SPS doesn't call this function, you may have to call it by your own.
  31446. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31447. */
  31448. initParticles(): void;
  31449. /**
  31450. * This function does nothing. It may be overwritten to recycle a particle.
  31451. * The SPS doesn't call this function, you may have to call it by your own.
  31452. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31453. * @param particle The particle to recycle
  31454. * @returns the recycled particle
  31455. */
  31456. recycleParticle(particle: SolidParticle): SolidParticle;
  31457. /**
  31458. * Updates a particle : this function should be overwritten by the user.
  31459. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  31460. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31461. * @example : just set a particle position or velocity and recycle conditions
  31462. * @param particle The particle to update
  31463. * @returns the updated particle
  31464. */
  31465. updateParticle(particle: SolidParticle): SolidParticle;
  31466. /**
  31467. * Updates a vertex of a particle : it can be overwritten by the user.
  31468. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  31469. * @param particle the current particle
  31470. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  31471. * @param pt the index of the current vertex in the particle shape
  31472. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  31473. * @example : just set a vertex particle position or color
  31474. * @returns the sps
  31475. */
  31476. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  31477. /**
  31478. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  31479. * This does nothing and may be overwritten by the user.
  31480. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31481. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31482. * @param update the boolean update value actually passed to setParticles()
  31483. */
  31484. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31485. /**
  31486. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  31487. * This will be passed three parameters.
  31488. * This does nothing and may be overwritten by the user.
  31489. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31490. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31491. * @param update the boolean update value actually passed to setParticles()
  31492. */
  31493. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31494. }
  31495. }
  31496. declare module "babylonjs/Particles/solidParticle" {
  31497. import { Nullable } from "babylonjs/types";
  31498. import { Vector3, Matrix, Quaternion, Vector4, Vector2 } from "babylonjs/Maths/math.vector";
  31499. import { Color4 } from "babylonjs/Maths/math.color";
  31500. import { Mesh } from "babylonjs/Meshes/mesh";
  31501. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  31502. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  31503. import { Plane } from "babylonjs/Maths/math.plane";
  31504. import { Material } from "babylonjs/Materials/material";
  31505. /**
  31506. * Represents one particle of a solid particle system.
  31507. */
  31508. export class SolidParticle {
  31509. /**
  31510. * particle global index
  31511. */
  31512. idx: number;
  31513. /**
  31514. * particle identifier
  31515. */
  31516. id: number;
  31517. /**
  31518. * The color of the particle
  31519. */
  31520. color: Nullable<Color4>;
  31521. /**
  31522. * The world space position of the particle.
  31523. */
  31524. position: Vector3;
  31525. /**
  31526. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  31527. */
  31528. rotation: Vector3;
  31529. /**
  31530. * The world space rotation quaternion of the particle.
  31531. */
  31532. rotationQuaternion: Nullable<Quaternion>;
  31533. /**
  31534. * The scaling of the particle.
  31535. */
  31536. scaling: Vector3;
  31537. /**
  31538. * The uvs of the particle.
  31539. */
  31540. uvs: Vector4;
  31541. /**
  31542. * The current speed of the particle.
  31543. */
  31544. velocity: Vector3;
  31545. /**
  31546. * The pivot point in the particle local space.
  31547. */
  31548. pivot: Vector3;
  31549. /**
  31550. * Must the particle be translated from its pivot point in its local space ?
  31551. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  31552. * Default : false
  31553. */
  31554. translateFromPivot: boolean;
  31555. /**
  31556. * Is the particle active or not ?
  31557. */
  31558. alive: boolean;
  31559. /**
  31560. * Is the particle visible or not ?
  31561. */
  31562. isVisible: boolean;
  31563. /**
  31564. * Index of this particle in the global "positions" array (Internal use)
  31565. * @hidden
  31566. */
  31567. _pos: number;
  31568. /**
  31569. * @hidden Index of this particle in the global "indices" array (Internal use)
  31570. */
  31571. _ind: number;
  31572. /**
  31573. * @hidden ModelShape of this particle (Internal use)
  31574. */
  31575. _model: ModelShape;
  31576. /**
  31577. * ModelShape id of this particle
  31578. */
  31579. shapeId: number;
  31580. /**
  31581. * Index of the particle in its shape id
  31582. */
  31583. idxInShape: number;
  31584. /**
  31585. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  31586. */
  31587. _modelBoundingInfo: BoundingInfo;
  31588. /**
  31589. * @hidden Particle BoundingInfo object (Internal use)
  31590. */
  31591. _boundingInfo: BoundingInfo;
  31592. /**
  31593. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  31594. */
  31595. _sps: SolidParticleSystem;
  31596. /**
  31597. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  31598. */
  31599. _stillInvisible: boolean;
  31600. /**
  31601. * @hidden Last computed particle rotation matrix
  31602. */
  31603. _rotationMatrix: number[];
  31604. /**
  31605. * Parent particle Id, if any.
  31606. * Default null.
  31607. */
  31608. parentId: Nullable<number>;
  31609. /**
  31610. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  31611. */
  31612. materialIndex: Nullable<number>;
  31613. /**
  31614. * Custom object or properties.
  31615. */
  31616. props: Nullable<any>;
  31617. /**
  31618. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  31619. * The possible values are :
  31620. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  31621. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31622. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  31623. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  31624. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31625. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  31626. * */
  31627. cullingStrategy: number;
  31628. /**
  31629. * @hidden Internal global position in the SPS.
  31630. */
  31631. _globalPosition: Vector3;
  31632. /**
  31633. * Creates a Solid Particle object.
  31634. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  31635. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  31636. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  31637. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  31638. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  31639. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  31640. * @param shapeId (integer) is the model shape identifier in the SPS.
  31641. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  31642. * @param sps defines the sps it is associated to
  31643. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  31644. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  31645. */
  31646. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  31647. /**
  31648. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  31649. * @param target the particle target
  31650. * @returns the current particle
  31651. */
  31652. copyToRef(target: SolidParticle): SolidParticle;
  31653. /**
  31654. * Legacy support, changed scale to scaling
  31655. */
  31656. get scale(): Vector3;
  31657. /**
  31658. * Legacy support, changed scale to scaling
  31659. */
  31660. set scale(scale: Vector3);
  31661. /**
  31662. * Legacy support, changed quaternion to rotationQuaternion
  31663. */
  31664. get quaternion(): Nullable<Quaternion>;
  31665. /**
  31666. * Legacy support, changed quaternion to rotationQuaternion
  31667. */
  31668. set quaternion(q: Nullable<Quaternion>);
  31669. /**
  31670. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  31671. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  31672. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  31673. * @returns true if it intersects
  31674. */
  31675. intersectsMesh(target: Mesh | SolidParticle): boolean;
  31676. /**
  31677. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  31678. * A particle is in the frustum if its bounding box intersects the frustum
  31679. * @param frustumPlanes defines the frustum to test
  31680. * @returns true if the particle is in the frustum planes
  31681. */
  31682. isInFrustum(frustumPlanes: Plane[]): boolean;
  31683. /**
  31684. * get the rotation matrix of the particle
  31685. * @hidden
  31686. */
  31687. getRotationMatrix(m: Matrix): void;
  31688. }
  31689. /**
  31690. * Represents the shape of the model used by one particle of a solid particle system.
  31691. * SPS internal tool, don't use it manually.
  31692. */
  31693. export class ModelShape {
  31694. /**
  31695. * The shape id
  31696. * @hidden
  31697. */
  31698. shapeID: number;
  31699. /**
  31700. * flat array of model positions (internal use)
  31701. * @hidden
  31702. */
  31703. _shape: Vector3[];
  31704. /**
  31705. * flat array of model UVs (internal use)
  31706. * @hidden
  31707. */
  31708. _shapeUV: number[];
  31709. /**
  31710. * color array of the model
  31711. * @hidden
  31712. */
  31713. _shapeColors: number[];
  31714. /**
  31715. * indices array of the model
  31716. * @hidden
  31717. */
  31718. _indices: number[];
  31719. /**
  31720. * normals array of the model
  31721. * @hidden
  31722. */
  31723. _normals: number[];
  31724. /**
  31725. * length of the shape in the model indices array (internal use)
  31726. * @hidden
  31727. */
  31728. _indicesLength: number;
  31729. /**
  31730. * Custom position function (internal use)
  31731. * @hidden
  31732. */
  31733. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  31734. /**
  31735. * Custom vertex function (internal use)
  31736. * @hidden
  31737. */
  31738. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  31739. /**
  31740. * Model material (internal use)
  31741. * @hidden
  31742. */
  31743. _material: Nullable<Material>;
  31744. /**
  31745. * 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.
  31746. * SPS internal tool, don't use it manually.
  31747. * @hidden
  31748. */
  31749. 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>);
  31750. }
  31751. /**
  31752. * Represents a Depth Sorted Particle in the solid particle system.
  31753. * @hidden
  31754. */
  31755. export class DepthSortedParticle {
  31756. /**
  31757. * Particle index
  31758. */
  31759. idx: number;
  31760. /**
  31761. * Index of the particle in the "indices" array
  31762. */
  31763. ind: number;
  31764. /**
  31765. * Length of the particle shape in the "indices" array
  31766. */
  31767. indicesLength: number;
  31768. /**
  31769. * Squared distance from the particle to the camera
  31770. */
  31771. sqDistance: number;
  31772. /**
  31773. * Material index when used with MultiMaterials
  31774. */
  31775. materialIndex: number;
  31776. /**
  31777. * Creates a new sorted particle
  31778. * @param materialIndex
  31779. */
  31780. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  31781. }
  31782. /**
  31783. * Represents a solid particle vertex
  31784. */
  31785. export class SolidParticleVertex {
  31786. /**
  31787. * Vertex position
  31788. */
  31789. position: Vector3;
  31790. /**
  31791. * Vertex color
  31792. */
  31793. color: Color4;
  31794. /**
  31795. * Vertex UV
  31796. */
  31797. uv: Vector2;
  31798. /**
  31799. * Creates a new solid particle vertex
  31800. */
  31801. constructor();
  31802. /** Vertex x coordinate */
  31803. get x(): number;
  31804. set x(val: number);
  31805. /** Vertex y coordinate */
  31806. get y(): number;
  31807. set y(val: number);
  31808. /** Vertex z coordinate */
  31809. get z(): number;
  31810. set z(val: number);
  31811. }
  31812. }
  31813. declare module "babylonjs/Collisions/meshCollisionData" {
  31814. import { Collider } from "babylonjs/Collisions/collider";
  31815. import { Vector3 } from "babylonjs/Maths/math.vector";
  31816. import { Nullable } from "babylonjs/types";
  31817. import { Observer } from "babylonjs/Misc/observable";
  31818. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31819. /**
  31820. * @hidden
  31821. */
  31822. export class _MeshCollisionData {
  31823. _checkCollisions: boolean;
  31824. _collisionMask: number;
  31825. _collisionGroup: number;
  31826. _surroundingMeshes: Nullable<AbstractMesh[]>;
  31827. _collider: Nullable<Collider>;
  31828. _oldPositionForCollisions: Vector3;
  31829. _diffPositionForCollisions: Vector3;
  31830. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  31831. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  31832. }
  31833. }
  31834. declare module "babylonjs/Meshes/abstractMesh" {
  31835. import { Observable } from "babylonjs/Misc/observable";
  31836. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  31837. import { Camera } from "babylonjs/Cameras/camera";
  31838. import { Scene, IDisposable } from "babylonjs/scene";
  31839. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  31840. import { Node } from "babylonjs/node";
  31841. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  31842. import { TransformNode } from "babylonjs/Meshes/transformNode";
  31843. import { SubMesh } from "babylonjs/Meshes/subMesh";
  31844. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  31845. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  31846. import { Material } from "babylonjs/Materials/material";
  31847. import { Light } from "babylonjs/Lights/light";
  31848. import { Skeleton } from "babylonjs/Bones/skeleton";
  31849. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  31850. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  31851. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  31852. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  31853. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  31854. import { Plane } from "babylonjs/Maths/math.plane";
  31855. import { Ray } from "babylonjs/Culling/ray";
  31856. import { Collider } from "babylonjs/Collisions/collider";
  31857. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  31858. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  31859. /** @hidden */
  31860. class _FacetDataStorage {
  31861. facetPositions: Vector3[];
  31862. facetNormals: Vector3[];
  31863. facetPartitioning: number[][];
  31864. facetNb: number;
  31865. partitioningSubdivisions: number;
  31866. partitioningBBoxRatio: number;
  31867. facetDataEnabled: boolean;
  31868. facetParameters: any;
  31869. bbSize: Vector3;
  31870. subDiv: {
  31871. max: number;
  31872. X: number;
  31873. Y: number;
  31874. Z: number;
  31875. };
  31876. facetDepthSort: boolean;
  31877. facetDepthSortEnabled: boolean;
  31878. depthSortedIndices: IndicesArray;
  31879. depthSortedFacets: {
  31880. ind: number;
  31881. sqDistance: number;
  31882. }[];
  31883. facetDepthSortFunction: (f1: {
  31884. ind: number;
  31885. sqDistance: number;
  31886. }, f2: {
  31887. ind: number;
  31888. sqDistance: number;
  31889. }) => number;
  31890. facetDepthSortFrom: Vector3;
  31891. facetDepthSortOrigin: Vector3;
  31892. invertedMatrix: Matrix;
  31893. }
  31894. /**
  31895. * @hidden
  31896. **/
  31897. class _InternalAbstractMeshDataInfo {
  31898. _hasVertexAlpha: boolean;
  31899. _useVertexColors: boolean;
  31900. _numBoneInfluencers: number;
  31901. _applyFog: boolean;
  31902. _receiveShadows: boolean;
  31903. _facetData: _FacetDataStorage;
  31904. _visibility: number;
  31905. _skeleton: Nullable<Skeleton>;
  31906. _layerMask: number;
  31907. _computeBonesUsingShaders: boolean;
  31908. _isActive: boolean;
  31909. _onlyForInstances: boolean;
  31910. _isActiveIntermediate: boolean;
  31911. _onlyForInstancesIntermediate: boolean;
  31912. _actAsRegularMesh: boolean;
  31913. }
  31914. /**
  31915. * Class used to store all common mesh properties
  31916. */
  31917. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  31918. /** No occlusion */
  31919. static OCCLUSION_TYPE_NONE: number;
  31920. /** Occlusion set to optimisitic */
  31921. static OCCLUSION_TYPE_OPTIMISTIC: number;
  31922. /** Occlusion set to strict */
  31923. static OCCLUSION_TYPE_STRICT: number;
  31924. /** Use an accurante occlusion algorithm */
  31925. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  31926. /** Use a conservative occlusion algorithm */
  31927. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  31928. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  31929. * Test order :
  31930. * Is the bounding sphere outside the frustum ?
  31931. * If not, are the bounding box vertices outside the frustum ?
  31932. * It not, then the cullable object is in the frustum.
  31933. */
  31934. static readonly CULLINGSTRATEGY_STANDARD: number;
  31935. /** Culling strategy : Bounding Sphere Only.
  31936. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  31937. * It's also less accurate than the standard because some not visible objects can still be selected.
  31938. * Test : is the bounding sphere outside the frustum ?
  31939. * If not, then the cullable object is in the frustum.
  31940. */
  31941. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  31942. /** Culling strategy : Optimistic Inclusion.
  31943. * This in an inclusion test first, then the standard exclusion test.
  31944. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  31945. * 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.
  31946. * Anyway, it's as accurate as the standard strategy.
  31947. * Test :
  31948. * Is the cullable object bounding sphere center in the frustum ?
  31949. * If not, apply the default culling strategy.
  31950. */
  31951. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  31952. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  31953. * This in an inclusion test first, then the bounding sphere only exclusion test.
  31954. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  31955. * 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.
  31956. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  31957. * Test :
  31958. * Is the cullable object bounding sphere center in the frustum ?
  31959. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  31960. */
  31961. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  31962. /**
  31963. * No billboard
  31964. */
  31965. static get BILLBOARDMODE_NONE(): number;
  31966. /** Billboard on X axis */
  31967. static get BILLBOARDMODE_X(): number;
  31968. /** Billboard on Y axis */
  31969. static get BILLBOARDMODE_Y(): number;
  31970. /** Billboard on Z axis */
  31971. static get BILLBOARDMODE_Z(): number;
  31972. /** Billboard on all axes */
  31973. static get BILLBOARDMODE_ALL(): number;
  31974. /** Billboard on using position instead of orientation */
  31975. static get BILLBOARDMODE_USE_POSITION(): number;
  31976. /** @hidden */
  31977. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  31978. /**
  31979. * The culling strategy to use to check whether the mesh must be rendered or not.
  31980. * This value can be changed at any time and will be used on the next render mesh selection.
  31981. * The possible values are :
  31982. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  31983. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31984. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  31985. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  31986. * Please read each static variable documentation to get details about the culling process.
  31987. * */
  31988. cullingStrategy: number;
  31989. /**
  31990. * Gets the number of facets in the mesh
  31991. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  31992. */
  31993. get facetNb(): number;
  31994. /**
  31995. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  31996. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  31997. */
  31998. get partitioningSubdivisions(): number;
  31999. set partitioningSubdivisions(nb: number);
  32000. /**
  32001. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  32002. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  32003. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  32004. */
  32005. get partitioningBBoxRatio(): number;
  32006. set partitioningBBoxRatio(ratio: number);
  32007. /**
  32008. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  32009. * Works only for updatable meshes.
  32010. * Doesn't work with multi-materials
  32011. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  32012. */
  32013. get mustDepthSortFacets(): boolean;
  32014. set mustDepthSortFacets(sort: boolean);
  32015. /**
  32016. * The location (Vector3) where the facet depth sort must be computed from.
  32017. * By default, the active camera position.
  32018. * Used only when facet depth sort is enabled
  32019. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  32020. */
  32021. get facetDepthSortFrom(): Vector3;
  32022. set facetDepthSortFrom(location: Vector3);
  32023. /**
  32024. * gets a boolean indicating if facetData is enabled
  32025. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  32026. */
  32027. get isFacetDataEnabled(): boolean;
  32028. /** @hidden */
  32029. _updateNonUniformScalingState(value: boolean): boolean;
  32030. /**
  32031. * An event triggered when this mesh collides with another one
  32032. */
  32033. onCollideObservable: Observable<AbstractMesh>;
  32034. /** Set a function to call when this mesh collides with another one */
  32035. set onCollide(callback: () => void);
  32036. /**
  32037. * An event triggered when the collision's position changes
  32038. */
  32039. onCollisionPositionChangeObservable: Observable<Vector3>;
  32040. /** Set a function to call when the collision's position changes */
  32041. set onCollisionPositionChange(callback: () => void);
  32042. /**
  32043. * An event triggered when material is changed
  32044. */
  32045. onMaterialChangedObservable: Observable<AbstractMesh>;
  32046. /**
  32047. * Gets or sets the orientation for POV movement & rotation
  32048. */
  32049. definedFacingForward: boolean;
  32050. /** @hidden */
  32051. _occlusionQuery: Nullable<WebGLQuery>;
  32052. /** @hidden */
  32053. _renderingGroup: Nullable<RenderingGroup>;
  32054. /**
  32055. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  32056. */
  32057. get visibility(): number;
  32058. /**
  32059. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  32060. */
  32061. set visibility(value: number);
  32062. /** Gets or sets the alpha index used to sort transparent meshes
  32063. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  32064. */
  32065. alphaIndex: number;
  32066. /**
  32067. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  32068. */
  32069. isVisible: boolean;
  32070. /**
  32071. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  32072. */
  32073. isPickable: boolean;
  32074. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  32075. showSubMeshesBoundingBox: boolean;
  32076. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  32077. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  32078. */
  32079. isBlocker: boolean;
  32080. /**
  32081. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  32082. */
  32083. enablePointerMoveEvents: boolean;
  32084. /**
  32085. * Specifies the rendering group id for this mesh (0 by default)
  32086. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  32087. */
  32088. renderingGroupId: number;
  32089. private _material;
  32090. /** Gets or sets current material */
  32091. get material(): Nullable<Material>;
  32092. set material(value: Nullable<Material>);
  32093. /**
  32094. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  32095. * @see http://doc.babylonjs.com/babylon101/shadows
  32096. */
  32097. get receiveShadows(): boolean;
  32098. set receiveShadows(value: boolean);
  32099. /** Defines color to use when rendering outline */
  32100. outlineColor: Color3;
  32101. /** Define width to use when rendering outline */
  32102. outlineWidth: number;
  32103. /** Defines color to use when rendering overlay */
  32104. overlayColor: Color3;
  32105. /** Defines alpha to use when rendering overlay */
  32106. overlayAlpha: number;
  32107. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  32108. get hasVertexAlpha(): boolean;
  32109. set hasVertexAlpha(value: boolean);
  32110. /** 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) */
  32111. get useVertexColors(): boolean;
  32112. set useVertexColors(value: boolean);
  32113. /**
  32114. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  32115. */
  32116. get computeBonesUsingShaders(): boolean;
  32117. set computeBonesUsingShaders(value: boolean);
  32118. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  32119. get numBoneInfluencers(): number;
  32120. set numBoneInfluencers(value: number);
  32121. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  32122. get applyFog(): boolean;
  32123. set applyFog(value: boolean);
  32124. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  32125. useOctreeForRenderingSelection: boolean;
  32126. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  32127. useOctreeForPicking: boolean;
  32128. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  32129. useOctreeForCollisions: boolean;
  32130. /**
  32131. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  32132. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  32133. */
  32134. get layerMask(): number;
  32135. set layerMask(value: number);
  32136. /**
  32137. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  32138. */
  32139. alwaysSelectAsActiveMesh: boolean;
  32140. /**
  32141. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  32142. */
  32143. doNotSyncBoundingInfo: boolean;
  32144. /**
  32145. * Gets or sets the current action manager
  32146. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32147. */
  32148. actionManager: Nullable<AbstractActionManager>;
  32149. private _meshCollisionData;
  32150. /**
  32151. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  32152. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32153. */
  32154. ellipsoid: Vector3;
  32155. /**
  32156. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  32157. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32158. */
  32159. ellipsoidOffset: Vector3;
  32160. /**
  32161. * Gets or sets a collision mask used to mask collisions (default is -1).
  32162. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  32163. */
  32164. get collisionMask(): number;
  32165. set collisionMask(mask: number);
  32166. /**
  32167. * Gets or sets the current collision group mask (-1 by default).
  32168. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  32169. */
  32170. get collisionGroup(): number;
  32171. set collisionGroup(mask: number);
  32172. /**
  32173. * Gets or sets current surrounding meshes (null by default).
  32174. *
  32175. * By default collision detection is tested against every mesh in the scene.
  32176. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  32177. * meshes will be tested for the collision.
  32178. *
  32179. * Note: if set to an empty array no collision will happen when this mesh is moved.
  32180. */
  32181. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  32182. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  32183. /**
  32184. * Defines edge width used when edgesRenderer is enabled
  32185. * @see https://www.babylonjs-playground.com/#10OJSG#13
  32186. */
  32187. edgesWidth: number;
  32188. /**
  32189. * Defines edge color used when edgesRenderer is enabled
  32190. * @see https://www.babylonjs-playground.com/#10OJSG#13
  32191. */
  32192. edgesColor: Color4;
  32193. /** @hidden */
  32194. _edgesRenderer: Nullable<IEdgesRenderer>;
  32195. /** @hidden */
  32196. _masterMesh: Nullable<AbstractMesh>;
  32197. /** @hidden */
  32198. _boundingInfo: Nullable<BoundingInfo>;
  32199. /** @hidden */
  32200. _renderId: number;
  32201. /**
  32202. * Gets or sets the list of subMeshes
  32203. * @see http://doc.babylonjs.com/how_to/multi_materials
  32204. */
  32205. subMeshes: SubMesh[];
  32206. /** @hidden */
  32207. _intersectionsInProgress: AbstractMesh[];
  32208. /** @hidden */
  32209. _unIndexed: boolean;
  32210. /** @hidden */
  32211. _lightSources: Light[];
  32212. /** Gets the list of lights affecting that mesh */
  32213. get lightSources(): Light[];
  32214. /** @hidden */
  32215. get _positions(): Nullable<Vector3[]>;
  32216. /** @hidden */
  32217. _waitingData: {
  32218. lods: Nullable<any>;
  32219. actions: Nullable<any>;
  32220. freezeWorldMatrix: Nullable<boolean>;
  32221. };
  32222. /** @hidden */
  32223. _bonesTransformMatrices: Nullable<Float32Array>;
  32224. /** @hidden */
  32225. _transformMatrixTexture: Nullable<RawTexture>;
  32226. /**
  32227. * Gets or sets a skeleton to apply skining transformations
  32228. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  32229. */
  32230. set skeleton(value: Nullable<Skeleton>);
  32231. get skeleton(): Nullable<Skeleton>;
  32232. /**
  32233. * An event triggered when the mesh is rebuilt.
  32234. */
  32235. onRebuildObservable: Observable<AbstractMesh>;
  32236. /**
  32237. * Creates a new AbstractMesh
  32238. * @param name defines the name of the mesh
  32239. * @param scene defines the hosting scene
  32240. */
  32241. constructor(name: string, scene?: Nullable<Scene>);
  32242. /**
  32243. * Returns the string "AbstractMesh"
  32244. * @returns "AbstractMesh"
  32245. */
  32246. getClassName(): string;
  32247. /**
  32248. * Gets a string representation of the current mesh
  32249. * @param fullDetails defines a boolean indicating if full details must be included
  32250. * @returns a string representation of the current mesh
  32251. */
  32252. toString(fullDetails?: boolean): string;
  32253. /**
  32254. * @hidden
  32255. */
  32256. protected _getEffectiveParent(): Nullable<Node>;
  32257. /** @hidden */
  32258. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  32259. /** @hidden */
  32260. _rebuild(): void;
  32261. /** @hidden */
  32262. _resyncLightSources(): void;
  32263. /** @hidden */
  32264. _resyncLightSource(light: Light): void;
  32265. /** @hidden */
  32266. _unBindEffect(): void;
  32267. /** @hidden */
  32268. _removeLightSource(light: Light, dispose: boolean): void;
  32269. private _markSubMeshesAsDirty;
  32270. /** @hidden */
  32271. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  32272. /** @hidden */
  32273. _markSubMeshesAsAttributesDirty(): void;
  32274. /** @hidden */
  32275. _markSubMeshesAsMiscDirty(): void;
  32276. /**
  32277. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  32278. */
  32279. get scaling(): Vector3;
  32280. set scaling(newScaling: Vector3);
  32281. /**
  32282. * Returns true if the mesh is blocked. Implemented by child classes
  32283. */
  32284. get isBlocked(): boolean;
  32285. /**
  32286. * Returns the mesh itself by default. Implemented by child classes
  32287. * @param camera defines the camera to use to pick the right LOD level
  32288. * @returns the currentAbstractMesh
  32289. */
  32290. getLOD(camera: Camera): Nullable<AbstractMesh>;
  32291. /**
  32292. * Returns 0 by default. Implemented by child classes
  32293. * @returns an integer
  32294. */
  32295. getTotalVertices(): number;
  32296. /**
  32297. * Returns a positive integer : the total number of indices in this mesh geometry.
  32298. * @returns the numner of indices or zero if the mesh has no geometry.
  32299. */
  32300. getTotalIndices(): number;
  32301. /**
  32302. * Returns null by default. Implemented by child classes
  32303. * @returns null
  32304. */
  32305. getIndices(): Nullable<IndicesArray>;
  32306. /**
  32307. * Returns the array of the requested vertex data kind. Implemented by child classes
  32308. * @param kind defines the vertex data kind to use
  32309. * @returns null
  32310. */
  32311. getVerticesData(kind: string): Nullable<FloatArray>;
  32312. /**
  32313. * Sets the vertex data of the mesh geometry for the requested `kind`.
  32314. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  32315. * Note that a new underlying VertexBuffer object is created each call.
  32316. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  32317. * @param kind defines vertex data kind:
  32318. * * VertexBuffer.PositionKind
  32319. * * VertexBuffer.UVKind
  32320. * * VertexBuffer.UV2Kind
  32321. * * VertexBuffer.UV3Kind
  32322. * * VertexBuffer.UV4Kind
  32323. * * VertexBuffer.UV5Kind
  32324. * * VertexBuffer.UV6Kind
  32325. * * VertexBuffer.ColorKind
  32326. * * VertexBuffer.MatricesIndicesKind
  32327. * * VertexBuffer.MatricesIndicesExtraKind
  32328. * * VertexBuffer.MatricesWeightsKind
  32329. * * VertexBuffer.MatricesWeightsExtraKind
  32330. * @param data defines the data source
  32331. * @param updatable defines if the data must be flagged as updatable (or static)
  32332. * @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
  32333. * @returns the current mesh
  32334. */
  32335. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  32336. /**
  32337. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  32338. * If the mesh has no geometry, it is simply returned as it is.
  32339. * @param kind defines vertex data kind:
  32340. * * VertexBuffer.PositionKind
  32341. * * VertexBuffer.UVKind
  32342. * * VertexBuffer.UV2Kind
  32343. * * VertexBuffer.UV3Kind
  32344. * * VertexBuffer.UV4Kind
  32345. * * VertexBuffer.UV5Kind
  32346. * * VertexBuffer.UV6Kind
  32347. * * VertexBuffer.ColorKind
  32348. * * VertexBuffer.MatricesIndicesKind
  32349. * * VertexBuffer.MatricesIndicesExtraKind
  32350. * * VertexBuffer.MatricesWeightsKind
  32351. * * VertexBuffer.MatricesWeightsExtraKind
  32352. * @param data defines the data source
  32353. * @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
  32354. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  32355. * @returns the current mesh
  32356. */
  32357. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  32358. /**
  32359. * Sets the mesh indices,
  32360. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  32361. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  32362. * @param totalVertices Defines the total number of vertices
  32363. * @returns the current mesh
  32364. */
  32365. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  32366. /**
  32367. * Gets a boolean indicating if specific vertex data is present
  32368. * @param kind defines the vertex data kind to use
  32369. * @returns true is data kind is present
  32370. */
  32371. isVerticesDataPresent(kind: string): boolean;
  32372. /**
  32373. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  32374. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  32375. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  32376. * @returns a BoundingInfo
  32377. */
  32378. getBoundingInfo(): BoundingInfo;
  32379. /**
  32380. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  32381. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  32382. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  32383. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  32384. * @returns the current mesh
  32385. */
  32386. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  32387. /**
  32388. * Overwrite the current bounding info
  32389. * @param boundingInfo defines the new bounding info
  32390. * @returns the current mesh
  32391. */
  32392. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  32393. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  32394. get useBones(): boolean;
  32395. /** @hidden */
  32396. _preActivate(): void;
  32397. /** @hidden */
  32398. _preActivateForIntermediateRendering(renderId: number): void;
  32399. /** @hidden */
  32400. _activate(renderId: number, intermediateRendering: boolean): boolean;
  32401. /** @hidden */
  32402. _postActivate(): void;
  32403. /** @hidden */
  32404. _freeze(): void;
  32405. /** @hidden */
  32406. _unFreeze(): void;
  32407. /**
  32408. * Gets the current world matrix
  32409. * @returns a Matrix
  32410. */
  32411. getWorldMatrix(): Matrix;
  32412. /** @hidden */
  32413. _getWorldMatrixDeterminant(): number;
  32414. /**
  32415. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  32416. */
  32417. get isAnInstance(): boolean;
  32418. /**
  32419. * Gets a boolean indicating if this mesh has instances
  32420. */
  32421. get hasInstances(): boolean;
  32422. /**
  32423. * Gets a boolean indicating if this mesh has thin instances
  32424. */
  32425. get hasThinInstances(): boolean;
  32426. /**
  32427. * Perform relative position change from the point of view of behind the front of the mesh.
  32428. * This is performed taking into account the meshes current rotation, so you do not have to care.
  32429. * Supports definition of mesh facing forward or backward
  32430. * @param amountRight defines the distance on the right axis
  32431. * @param amountUp defines the distance on the up axis
  32432. * @param amountForward defines the distance on the forward axis
  32433. * @returns the current mesh
  32434. */
  32435. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  32436. /**
  32437. * Calculate relative position change from the point of view of behind the front of the mesh.
  32438. * This is performed taking into account the meshes current rotation, so you do not have to care.
  32439. * Supports definition of mesh facing forward or backward
  32440. * @param amountRight defines the distance on the right axis
  32441. * @param amountUp defines the distance on the up axis
  32442. * @param amountForward defines the distance on the forward axis
  32443. * @returns the new displacement vector
  32444. */
  32445. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  32446. /**
  32447. * Perform relative rotation change from the point of view of behind the front of the mesh.
  32448. * Supports definition of mesh facing forward or backward
  32449. * @param flipBack defines the flip
  32450. * @param twirlClockwise defines the twirl
  32451. * @param tiltRight defines the tilt
  32452. * @returns the current mesh
  32453. */
  32454. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  32455. /**
  32456. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  32457. * Supports definition of mesh facing forward or backward.
  32458. * @param flipBack defines the flip
  32459. * @param twirlClockwise defines the twirl
  32460. * @param tiltRight defines the tilt
  32461. * @returns the new rotation vector
  32462. */
  32463. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  32464. /**
  32465. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  32466. * This means the mesh underlying bounding box and sphere are recomputed.
  32467. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  32468. * @returns the current mesh
  32469. */
  32470. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  32471. /** @hidden */
  32472. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  32473. /** @hidden */
  32474. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  32475. /** @hidden */
  32476. _updateBoundingInfo(): AbstractMesh;
  32477. /** @hidden */
  32478. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  32479. /** @hidden */
  32480. protected _afterComputeWorldMatrix(): void;
  32481. /** @hidden */
  32482. get _effectiveMesh(): AbstractMesh;
  32483. /**
  32484. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  32485. * A mesh is in the frustum if its bounding box intersects the frustum
  32486. * @param frustumPlanes defines the frustum to test
  32487. * @returns true if the mesh is in the frustum planes
  32488. */
  32489. isInFrustum(frustumPlanes: Plane[]): boolean;
  32490. /**
  32491. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  32492. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  32493. * @param frustumPlanes defines the frustum to test
  32494. * @returns true if the mesh is completely in the frustum planes
  32495. */
  32496. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  32497. /**
  32498. * True if the mesh intersects another mesh or a SolidParticle object
  32499. * @param mesh defines a target mesh or SolidParticle to test
  32500. * @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)
  32501. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  32502. * @returns true if there is an intersection
  32503. */
  32504. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  32505. /**
  32506. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  32507. * @param point defines the point to test
  32508. * @returns true if there is an intersection
  32509. */
  32510. intersectsPoint(point: Vector3): boolean;
  32511. /**
  32512. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  32513. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32514. */
  32515. get checkCollisions(): boolean;
  32516. set checkCollisions(collisionEnabled: boolean);
  32517. /**
  32518. * Gets Collider object used to compute collisions (not physics)
  32519. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32520. */
  32521. get collider(): Nullable<Collider>;
  32522. /**
  32523. * Move the mesh using collision engine
  32524. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32525. * @param displacement defines the requested displacement vector
  32526. * @returns the current mesh
  32527. */
  32528. moveWithCollisions(displacement: Vector3): AbstractMesh;
  32529. private _onCollisionPositionChange;
  32530. /** @hidden */
  32531. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  32532. /** @hidden */
  32533. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  32534. /** @hidden */
  32535. _checkCollision(collider: Collider): AbstractMesh;
  32536. /** @hidden */
  32537. _generatePointsArray(): boolean;
  32538. /**
  32539. * Checks if the passed Ray intersects with the mesh
  32540. * @param ray defines the ray to use
  32541. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  32542. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32543. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  32544. * @returns the picking info
  32545. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  32546. */
  32547. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  32548. /**
  32549. * Clones the current mesh
  32550. * @param name defines the mesh name
  32551. * @param newParent defines the new mesh parent
  32552. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  32553. * @returns the new mesh
  32554. */
  32555. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  32556. /**
  32557. * Disposes all the submeshes of the current meshnp
  32558. * @returns the current mesh
  32559. */
  32560. releaseSubMeshes(): AbstractMesh;
  32561. /**
  32562. * Releases resources associated with this abstract mesh.
  32563. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  32564. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  32565. */
  32566. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  32567. /**
  32568. * Adds the passed mesh as a child to the current mesh
  32569. * @param mesh defines the child mesh
  32570. * @returns the current mesh
  32571. */
  32572. addChild(mesh: AbstractMesh): AbstractMesh;
  32573. /**
  32574. * Removes the passed mesh from the current mesh children list
  32575. * @param mesh defines the child mesh
  32576. * @returns the current mesh
  32577. */
  32578. removeChild(mesh: AbstractMesh): AbstractMesh;
  32579. /** @hidden */
  32580. private _initFacetData;
  32581. /**
  32582. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  32583. * This method can be called within the render loop.
  32584. * 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
  32585. * @returns the current mesh
  32586. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32587. */
  32588. updateFacetData(): AbstractMesh;
  32589. /**
  32590. * Returns the facetLocalNormals array.
  32591. * The normals are expressed in the mesh local spac
  32592. * @returns an array of Vector3
  32593. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32594. */
  32595. getFacetLocalNormals(): Vector3[];
  32596. /**
  32597. * Returns the facetLocalPositions array.
  32598. * The facet positions are expressed in the mesh local space
  32599. * @returns an array of Vector3
  32600. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32601. */
  32602. getFacetLocalPositions(): Vector3[];
  32603. /**
  32604. * Returns the facetLocalPartioning array
  32605. * @returns an array of array of numbers
  32606. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32607. */
  32608. getFacetLocalPartitioning(): number[][];
  32609. /**
  32610. * Returns the i-th facet position in the world system.
  32611. * This method allocates a new Vector3 per call
  32612. * @param i defines the facet index
  32613. * @returns a new Vector3
  32614. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32615. */
  32616. getFacetPosition(i: number): Vector3;
  32617. /**
  32618. * Sets the reference Vector3 with the i-th facet position in the world system
  32619. * @param i defines the facet index
  32620. * @param ref defines the target vector
  32621. * @returns the current mesh
  32622. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32623. */
  32624. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  32625. /**
  32626. * Returns the i-th facet normal in the world system.
  32627. * This method allocates a new Vector3 per call
  32628. * @param i defines the facet index
  32629. * @returns a new Vector3
  32630. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32631. */
  32632. getFacetNormal(i: number): Vector3;
  32633. /**
  32634. * Sets the reference Vector3 with the i-th facet normal in the world system
  32635. * @param i defines the facet index
  32636. * @param ref defines the target vector
  32637. * @returns the current mesh
  32638. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32639. */
  32640. getFacetNormalToRef(i: number, ref: Vector3): this;
  32641. /**
  32642. * 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)
  32643. * @param x defines x coordinate
  32644. * @param y defines y coordinate
  32645. * @param z defines z coordinate
  32646. * @returns the array of facet indexes
  32647. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32648. */
  32649. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  32650. /**
  32651. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  32652. * @param projected sets as the (x,y,z) world projection on the facet
  32653. * @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
  32654. * @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
  32655. * @param x defines x coordinate
  32656. * @param y defines y coordinate
  32657. * @param z defines z coordinate
  32658. * @returns the face index if found (or null instead)
  32659. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32660. */
  32661. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  32662. /**
  32663. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  32664. * @param projected sets as the (x,y,z) local projection on the facet
  32665. * @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
  32666. * @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
  32667. * @param x defines x coordinate
  32668. * @param y defines y coordinate
  32669. * @param z defines z coordinate
  32670. * @returns the face index if found (or null instead)
  32671. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32672. */
  32673. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  32674. /**
  32675. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  32676. * @returns the parameters
  32677. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32678. */
  32679. getFacetDataParameters(): any;
  32680. /**
  32681. * Disables the feature FacetData and frees the related memory
  32682. * @returns the current mesh
  32683. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32684. */
  32685. disableFacetData(): AbstractMesh;
  32686. /**
  32687. * Updates the AbstractMesh indices array
  32688. * @param indices defines the data source
  32689. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  32690. * @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)
  32691. * @returns the current mesh
  32692. */
  32693. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  32694. /**
  32695. * Creates new normals data for the mesh
  32696. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  32697. * @returns the current mesh
  32698. */
  32699. createNormals(updatable: boolean): AbstractMesh;
  32700. /**
  32701. * Align the mesh with a normal
  32702. * @param normal defines the normal to use
  32703. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  32704. * @returns the current mesh
  32705. */
  32706. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  32707. /** @hidden */
  32708. _checkOcclusionQuery(): boolean;
  32709. /**
  32710. * Disables the mesh edge rendering mode
  32711. * @returns the currentAbstractMesh
  32712. */
  32713. disableEdgesRendering(): AbstractMesh;
  32714. /**
  32715. * Enables the edge rendering mode on the mesh.
  32716. * This mode makes the mesh edges visible
  32717. * @param epsilon defines the maximal distance between two angles to detect a face
  32718. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  32719. * @returns the currentAbstractMesh
  32720. * @see https://www.babylonjs-playground.com/#19O9TU#0
  32721. */
  32722. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  32723. }
  32724. }
  32725. declare module "babylonjs/Actions/actionEvent" {
  32726. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32727. import { Nullable } from "babylonjs/types";
  32728. import { Sprite } from "babylonjs/Sprites/sprite";
  32729. import { Scene } from "babylonjs/scene";
  32730. import { Vector2 } from "babylonjs/Maths/math.vector";
  32731. /**
  32732. * Interface used to define ActionEvent
  32733. */
  32734. export interface IActionEvent {
  32735. /** The mesh or sprite that triggered the action */
  32736. source: any;
  32737. /** The X mouse cursor position at the time of the event */
  32738. pointerX: number;
  32739. /** The Y mouse cursor position at the time of the event */
  32740. pointerY: number;
  32741. /** The mesh that is currently pointed at (can be null) */
  32742. meshUnderPointer: Nullable<AbstractMesh>;
  32743. /** the original (browser) event that triggered the ActionEvent */
  32744. sourceEvent?: any;
  32745. /** additional data for the event */
  32746. additionalData?: any;
  32747. }
  32748. /**
  32749. * ActionEvent is the event being sent when an action is triggered.
  32750. */
  32751. export class ActionEvent implements IActionEvent {
  32752. /** The mesh or sprite that triggered the action */
  32753. source: any;
  32754. /** The X mouse cursor position at the time of the event */
  32755. pointerX: number;
  32756. /** The Y mouse cursor position at the time of the event */
  32757. pointerY: number;
  32758. /** The mesh that is currently pointed at (can be null) */
  32759. meshUnderPointer: Nullable<AbstractMesh>;
  32760. /** the original (browser) event that triggered the ActionEvent */
  32761. sourceEvent?: any;
  32762. /** additional data for the event */
  32763. additionalData?: any;
  32764. /**
  32765. * Creates a new ActionEvent
  32766. * @param source The mesh or sprite that triggered the action
  32767. * @param pointerX The X mouse cursor position at the time of the event
  32768. * @param pointerY The Y mouse cursor position at the time of the event
  32769. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  32770. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  32771. * @param additionalData additional data for the event
  32772. */
  32773. constructor(
  32774. /** The mesh or sprite that triggered the action */
  32775. source: any,
  32776. /** The X mouse cursor position at the time of the event */
  32777. pointerX: number,
  32778. /** The Y mouse cursor position at the time of the event */
  32779. pointerY: number,
  32780. /** The mesh that is currently pointed at (can be null) */
  32781. meshUnderPointer: Nullable<AbstractMesh>,
  32782. /** the original (browser) event that triggered the ActionEvent */
  32783. sourceEvent?: any,
  32784. /** additional data for the event */
  32785. additionalData?: any);
  32786. /**
  32787. * Helper function to auto-create an ActionEvent from a source mesh.
  32788. * @param source The source mesh that triggered the event
  32789. * @param evt The original (browser) event
  32790. * @param additionalData additional data for the event
  32791. * @returns the new ActionEvent
  32792. */
  32793. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  32794. /**
  32795. * Helper function to auto-create an ActionEvent from a source sprite
  32796. * @param source The source sprite that triggered the event
  32797. * @param scene Scene associated with the sprite
  32798. * @param evt The original (browser) event
  32799. * @param additionalData additional data for the event
  32800. * @returns the new ActionEvent
  32801. */
  32802. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  32803. /**
  32804. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  32805. * @param scene the scene where the event occurred
  32806. * @param evt The original (browser) event
  32807. * @returns the new ActionEvent
  32808. */
  32809. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  32810. /**
  32811. * Helper function to auto-create an ActionEvent from a primitive
  32812. * @param prim defines the target primitive
  32813. * @param pointerPos defines the pointer position
  32814. * @param evt The original (browser) event
  32815. * @param additionalData additional data for the event
  32816. * @returns the new ActionEvent
  32817. */
  32818. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  32819. }
  32820. }
  32821. declare module "babylonjs/Actions/abstractActionManager" {
  32822. import { IDisposable } from "babylonjs/scene";
  32823. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  32824. import { IAction } from "babylonjs/Actions/action";
  32825. import { Nullable } from "babylonjs/types";
  32826. /**
  32827. * Abstract class used to decouple action Manager from scene and meshes.
  32828. * Do not instantiate.
  32829. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32830. */
  32831. export abstract class AbstractActionManager implements IDisposable {
  32832. /** Gets the list of active triggers */
  32833. static Triggers: {
  32834. [key: string]: number;
  32835. };
  32836. /** Gets the cursor to use when hovering items */
  32837. hoverCursor: string;
  32838. /** Gets the list of actions */
  32839. actions: IAction[];
  32840. /**
  32841. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  32842. */
  32843. isRecursive: boolean;
  32844. /**
  32845. * Releases all associated resources
  32846. */
  32847. abstract dispose(): void;
  32848. /**
  32849. * Does this action manager has pointer triggers
  32850. */
  32851. abstract get hasPointerTriggers(): boolean;
  32852. /**
  32853. * Does this action manager has pick triggers
  32854. */
  32855. abstract get hasPickTriggers(): boolean;
  32856. /**
  32857. * Process a specific trigger
  32858. * @param trigger defines the trigger to process
  32859. * @param evt defines the event details to be processed
  32860. */
  32861. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  32862. /**
  32863. * Does this action manager handles actions of any of the given triggers
  32864. * @param triggers defines the triggers to be tested
  32865. * @return a boolean indicating whether one (or more) of the triggers is handled
  32866. */
  32867. abstract hasSpecificTriggers(triggers: number[]): boolean;
  32868. /**
  32869. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  32870. * speed.
  32871. * @param triggerA defines the trigger to be tested
  32872. * @param triggerB defines the trigger to be tested
  32873. * @return a boolean indicating whether one (or more) of the triggers is handled
  32874. */
  32875. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  32876. /**
  32877. * Does this action manager handles actions of a given trigger
  32878. * @param trigger defines the trigger to be tested
  32879. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  32880. * @return whether the trigger is handled
  32881. */
  32882. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  32883. /**
  32884. * Serialize this manager to a JSON object
  32885. * @param name defines the property name to store this manager
  32886. * @returns a JSON representation of this manager
  32887. */
  32888. abstract serialize(name: string): any;
  32889. /**
  32890. * Registers an action to this action manager
  32891. * @param action defines the action to be registered
  32892. * @return the action amended (prepared) after registration
  32893. */
  32894. abstract registerAction(action: IAction): Nullable<IAction>;
  32895. /**
  32896. * Unregisters an action to this action manager
  32897. * @param action defines the action to be unregistered
  32898. * @return a boolean indicating whether the action has been unregistered
  32899. */
  32900. abstract unregisterAction(action: IAction): Boolean;
  32901. /**
  32902. * Does exist one action manager with at least one trigger
  32903. **/
  32904. static get HasTriggers(): boolean;
  32905. /**
  32906. * Does exist one action manager with at least one pick trigger
  32907. **/
  32908. static get HasPickTriggers(): boolean;
  32909. /**
  32910. * Does exist one action manager that handles actions of a given trigger
  32911. * @param trigger defines the trigger to be tested
  32912. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  32913. **/
  32914. static HasSpecificTrigger(trigger: number): boolean;
  32915. }
  32916. }
  32917. declare module "babylonjs/node" {
  32918. import { Scene } from "babylonjs/scene";
  32919. import { Nullable } from "babylonjs/types";
  32920. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  32921. import { Engine } from "babylonjs/Engines/engine";
  32922. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  32923. import { Observable } from "babylonjs/Misc/observable";
  32924. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  32925. import { IInspectable } from "babylonjs/Misc/iInspectable";
  32926. import { Animatable } from "babylonjs/Animations/animatable";
  32927. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  32928. import { Animation } from "babylonjs/Animations/animation";
  32929. import { AnimationRange } from "babylonjs/Animations/animationRange";
  32930. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32931. /**
  32932. * Defines how a node can be built from a string name.
  32933. */
  32934. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  32935. /**
  32936. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  32937. */
  32938. export class Node implements IBehaviorAware<Node> {
  32939. /** @hidden */
  32940. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  32941. private static _NodeConstructors;
  32942. /**
  32943. * Add a new node constructor
  32944. * @param type defines the type name of the node to construct
  32945. * @param constructorFunc defines the constructor function
  32946. */
  32947. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  32948. /**
  32949. * Returns a node constructor based on type name
  32950. * @param type defines the type name
  32951. * @param name defines the new node name
  32952. * @param scene defines the hosting scene
  32953. * @param options defines optional options to transmit to constructors
  32954. * @returns the new constructor or null
  32955. */
  32956. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  32957. /**
  32958. * Gets or sets the name of the node
  32959. */
  32960. name: string;
  32961. /**
  32962. * Gets or sets the id of the node
  32963. */
  32964. id: string;
  32965. /**
  32966. * Gets or sets the unique id of the node
  32967. */
  32968. uniqueId: number;
  32969. /**
  32970. * Gets or sets a string used to store user defined state for the node
  32971. */
  32972. state: string;
  32973. /**
  32974. * Gets or sets an object used to store user defined information for the node
  32975. */
  32976. metadata: any;
  32977. /**
  32978. * For internal use only. Please do not use.
  32979. */
  32980. reservedDataStore: any;
  32981. /**
  32982. * List of inspectable custom properties (used by the Inspector)
  32983. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  32984. */
  32985. inspectableCustomProperties: IInspectable[];
  32986. private _doNotSerialize;
  32987. /**
  32988. * Gets or sets a boolean used to define if the node must be serialized
  32989. */
  32990. get doNotSerialize(): boolean;
  32991. set doNotSerialize(value: boolean);
  32992. /** @hidden */
  32993. _isDisposed: boolean;
  32994. /**
  32995. * Gets a list of Animations associated with the node
  32996. */
  32997. animations: import("babylonjs/Animations/animation").Animation[];
  32998. protected _ranges: {
  32999. [name: string]: Nullable<AnimationRange>;
  33000. };
  33001. /**
  33002. * Callback raised when the node is ready to be used
  33003. */
  33004. onReady: Nullable<(node: Node) => void>;
  33005. private _isEnabled;
  33006. private _isParentEnabled;
  33007. private _isReady;
  33008. /** @hidden */
  33009. _currentRenderId: number;
  33010. private _parentUpdateId;
  33011. /** @hidden */
  33012. _childUpdateId: number;
  33013. /** @hidden */
  33014. _waitingParentId: Nullable<string>;
  33015. /** @hidden */
  33016. _scene: Scene;
  33017. /** @hidden */
  33018. _cache: any;
  33019. private _parentNode;
  33020. private _children;
  33021. /** @hidden */
  33022. _worldMatrix: Matrix;
  33023. /** @hidden */
  33024. _worldMatrixDeterminant: number;
  33025. /** @hidden */
  33026. _worldMatrixDeterminantIsDirty: boolean;
  33027. /** @hidden */
  33028. private _sceneRootNodesIndex;
  33029. /**
  33030. * Gets a boolean indicating if the node has been disposed
  33031. * @returns true if the node was disposed
  33032. */
  33033. isDisposed(): boolean;
  33034. /**
  33035. * Gets or sets the parent of the node (without keeping the current position in the scene)
  33036. * @see https://doc.babylonjs.com/how_to/parenting
  33037. */
  33038. set parent(parent: Nullable<Node>);
  33039. get parent(): Nullable<Node>;
  33040. /** @hidden */
  33041. _addToSceneRootNodes(): void;
  33042. /** @hidden */
  33043. _removeFromSceneRootNodes(): void;
  33044. private _animationPropertiesOverride;
  33045. /**
  33046. * Gets or sets the animation properties override
  33047. */
  33048. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  33049. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  33050. /**
  33051. * Gets a string idenfifying the name of the class
  33052. * @returns "Node" string
  33053. */
  33054. getClassName(): string;
  33055. /** @hidden */
  33056. readonly _isNode: boolean;
  33057. /**
  33058. * An event triggered when the mesh is disposed
  33059. */
  33060. onDisposeObservable: Observable<Node>;
  33061. private _onDisposeObserver;
  33062. /**
  33063. * Sets a callback that will be raised when the node will be disposed
  33064. */
  33065. set onDispose(callback: () => void);
  33066. /**
  33067. * Creates a new Node
  33068. * @param name the name and id to be given to this node
  33069. * @param scene the scene this node will be added to
  33070. */
  33071. constructor(name: string, scene?: Nullable<Scene>);
  33072. /**
  33073. * Gets the scene of the node
  33074. * @returns a scene
  33075. */
  33076. getScene(): Scene;
  33077. /**
  33078. * Gets the engine of the node
  33079. * @returns a Engine
  33080. */
  33081. getEngine(): Engine;
  33082. private _behaviors;
  33083. /**
  33084. * Attach a behavior to the node
  33085. * @see http://doc.babylonjs.com/features/behaviour
  33086. * @param behavior defines the behavior to attach
  33087. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  33088. * @returns the current Node
  33089. */
  33090. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  33091. /**
  33092. * Remove an attached behavior
  33093. * @see http://doc.babylonjs.com/features/behaviour
  33094. * @param behavior defines the behavior to attach
  33095. * @returns the current Node
  33096. */
  33097. removeBehavior(behavior: Behavior<Node>): Node;
  33098. /**
  33099. * Gets the list of attached behaviors
  33100. * @see http://doc.babylonjs.com/features/behaviour
  33101. */
  33102. get behaviors(): Behavior<Node>[];
  33103. /**
  33104. * Gets an attached behavior by name
  33105. * @param name defines the name of the behavior to look for
  33106. * @see http://doc.babylonjs.com/features/behaviour
  33107. * @returns null if behavior was not found else the requested behavior
  33108. */
  33109. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  33110. /**
  33111. * Returns the latest update of the World matrix
  33112. * @returns a Matrix
  33113. */
  33114. getWorldMatrix(): Matrix;
  33115. /** @hidden */
  33116. _getWorldMatrixDeterminant(): number;
  33117. /**
  33118. * Returns directly the latest state of the mesh World matrix.
  33119. * A Matrix is returned.
  33120. */
  33121. get worldMatrixFromCache(): Matrix;
  33122. /** @hidden */
  33123. _initCache(): void;
  33124. /** @hidden */
  33125. updateCache(force?: boolean): void;
  33126. /** @hidden */
  33127. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  33128. /** @hidden */
  33129. _updateCache(ignoreParentClass?: boolean): void;
  33130. /** @hidden */
  33131. _isSynchronized(): boolean;
  33132. /** @hidden */
  33133. _markSyncedWithParent(): void;
  33134. /** @hidden */
  33135. isSynchronizedWithParent(): boolean;
  33136. /** @hidden */
  33137. isSynchronized(): boolean;
  33138. /**
  33139. * Is this node ready to be used/rendered
  33140. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  33141. * @return true if the node is ready
  33142. */
  33143. isReady(completeCheck?: boolean): boolean;
  33144. /**
  33145. * Is this node enabled?
  33146. * 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
  33147. * @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
  33148. * @return whether this node (and its parent) is enabled
  33149. */
  33150. isEnabled(checkAncestors?: boolean): boolean;
  33151. /** @hidden */
  33152. protected _syncParentEnabledState(): void;
  33153. /**
  33154. * Set the enabled state of this node
  33155. * @param value defines the new enabled state
  33156. */
  33157. setEnabled(value: boolean): void;
  33158. /**
  33159. * Is this node a descendant of the given node?
  33160. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  33161. * @param ancestor defines the parent node to inspect
  33162. * @returns a boolean indicating if this node is a descendant of the given node
  33163. */
  33164. isDescendantOf(ancestor: Node): boolean;
  33165. /** @hidden */
  33166. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  33167. /**
  33168. * Will return all nodes that have this node as ascendant
  33169. * @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
  33170. * @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
  33171. * @return all children nodes of all types
  33172. */
  33173. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  33174. /**
  33175. * Get all child-meshes of this node
  33176. * @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)
  33177. * @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
  33178. * @returns an array of AbstractMesh
  33179. */
  33180. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  33181. /**
  33182. * Get all direct children of this node
  33183. * @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
  33184. * @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)
  33185. * @returns an array of Node
  33186. */
  33187. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  33188. /** @hidden */
  33189. _setReady(state: boolean): void;
  33190. /**
  33191. * Get an animation by name
  33192. * @param name defines the name of the animation to look for
  33193. * @returns null if not found else the requested animation
  33194. */
  33195. getAnimationByName(name: string): Nullable<Animation>;
  33196. /**
  33197. * Creates an animation range for this node
  33198. * @param name defines the name of the range
  33199. * @param from defines the starting key
  33200. * @param to defines the end key
  33201. */
  33202. createAnimationRange(name: string, from: number, to: number): void;
  33203. /**
  33204. * Delete a specific animation range
  33205. * @param name defines the name of the range to delete
  33206. * @param deleteFrames defines if animation frames from the range must be deleted as well
  33207. */
  33208. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  33209. /**
  33210. * Get an animation range by name
  33211. * @param name defines the name of the animation range to look for
  33212. * @returns null if not found else the requested animation range
  33213. */
  33214. getAnimationRange(name: string): Nullable<AnimationRange>;
  33215. /**
  33216. * Gets the list of all animation ranges defined on this node
  33217. * @returns an array
  33218. */
  33219. getAnimationRanges(): Nullable<AnimationRange>[];
  33220. /**
  33221. * Will start the animation sequence
  33222. * @param name defines the range frames for animation sequence
  33223. * @param loop defines if the animation should loop (false by default)
  33224. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  33225. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  33226. * @returns the object created for this animation. If range does not exist, it will return null
  33227. */
  33228. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  33229. /**
  33230. * Serialize animation ranges into a JSON compatible object
  33231. * @returns serialization object
  33232. */
  33233. serializeAnimationRanges(): any;
  33234. /**
  33235. * Computes the world matrix of the node
  33236. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  33237. * @returns the world matrix
  33238. */
  33239. computeWorldMatrix(force?: boolean): Matrix;
  33240. /**
  33241. * Releases resources associated with this node.
  33242. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33243. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33244. */
  33245. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33246. /**
  33247. * Parse animation range data from a serialization object and store them into a given node
  33248. * @param node defines where to store the animation ranges
  33249. * @param parsedNode defines the serialization object to read data from
  33250. * @param scene defines the hosting scene
  33251. */
  33252. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  33253. /**
  33254. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  33255. * @param includeDescendants Include bounding info from descendants as well (true by default)
  33256. * @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
  33257. * @returns the new bounding vectors
  33258. */
  33259. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  33260. min: Vector3;
  33261. max: Vector3;
  33262. };
  33263. }
  33264. }
  33265. declare module "babylonjs/Animations/animation" {
  33266. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  33267. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  33268. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  33269. import { Nullable } from "babylonjs/types";
  33270. import { Scene } from "babylonjs/scene";
  33271. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  33272. import { AnimationRange } from "babylonjs/Animations/animationRange";
  33273. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  33274. import { Node } from "babylonjs/node";
  33275. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33276. import { Size } from "babylonjs/Maths/math.size";
  33277. import { Animatable } from "babylonjs/Animations/animatable";
  33278. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  33279. /**
  33280. * @hidden
  33281. */
  33282. export class _IAnimationState {
  33283. key: number;
  33284. repeatCount: number;
  33285. workValue?: any;
  33286. loopMode?: number;
  33287. offsetValue?: any;
  33288. highLimitValue?: any;
  33289. }
  33290. /**
  33291. * Class used to store any kind of animation
  33292. */
  33293. export class Animation {
  33294. /**Name of the animation */
  33295. name: string;
  33296. /**Property to animate */
  33297. targetProperty: string;
  33298. /**The frames per second of the animation */
  33299. framePerSecond: number;
  33300. /**The data type of the animation */
  33301. dataType: number;
  33302. /**The loop mode of the animation */
  33303. loopMode?: number | undefined;
  33304. /**Specifies if blending should be enabled */
  33305. enableBlending?: boolean | undefined;
  33306. /**
  33307. * Use matrix interpolation instead of using direct key value when animating matrices
  33308. */
  33309. static AllowMatricesInterpolation: boolean;
  33310. /**
  33311. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  33312. */
  33313. static AllowMatrixDecomposeForInterpolation: boolean;
  33314. /**
  33315. * Stores the key frames of the animation
  33316. */
  33317. private _keys;
  33318. /**
  33319. * Stores the easing function of the animation
  33320. */
  33321. private _easingFunction;
  33322. /**
  33323. * @hidden Internal use only
  33324. */
  33325. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  33326. /**
  33327. * The set of event that will be linked to this animation
  33328. */
  33329. private _events;
  33330. /**
  33331. * Stores an array of target property paths
  33332. */
  33333. targetPropertyPath: string[];
  33334. /**
  33335. * Stores the blending speed of the animation
  33336. */
  33337. blendingSpeed: number;
  33338. /**
  33339. * Stores the animation ranges for the animation
  33340. */
  33341. private _ranges;
  33342. /**
  33343. * @hidden Internal use
  33344. */
  33345. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  33346. /**
  33347. * Sets up an animation
  33348. * @param property The property to animate
  33349. * @param animationType The animation type to apply
  33350. * @param framePerSecond The frames per second of the animation
  33351. * @param easingFunction The easing function used in the animation
  33352. * @returns The created animation
  33353. */
  33354. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  33355. /**
  33356. * Create and start an animation on a node
  33357. * @param name defines the name of the global animation that will be run on all nodes
  33358. * @param node defines the root node where the animation will take place
  33359. * @param targetProperty defines property to animate
  33360. * @param framePerSecond defines the number of frame per second yo use
  33361. * @param totalFrame defines the number of frames in total
  33362. * @param from defines the initial value
  33363. * @param to defines the final value
  33364. * @param loopMode defines which loop mode you want to use (off by default)
  33365. * @param easingFunction defines the easing function to use (linear by default)
  33366. * @param onAnimationEnd defines the callback to call when animation end
  33367. * @returns the animatable created for this animation
  33368. */
  33369. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  33370. /**
  33371. * Create and start an animation on a node and its descendants
  33372. * @param name defines the name of the global animation that will be run on all nodes
  33373. * @param node defines the root node where the animation will take place
  33374. * @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
  33375. * @param targetProperty defines property to animate
  33376. * @param framePerSecond defines the number of frame per second to use
  33377. * @param totalFrame defines the number of frames in total
  33378. * @param from defines the initial value
  33379. * @param to defines the final value
  33380. * @param loopMode defines which loop mode you want to use (off by default)
  33381. * @param easingFunction defines the easing function to use (linear by default)
  33382. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  33383. * @returns the list of animatables created for all nodes
  33384. * @example https://www.babylonjs-playground.com/#MH0VLI
  33385. */
  33386. 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[]>;
  33387. /**
  33388. * Creates a new animation, merges it with the existing animations and starts it
  33389. * @param name Name of the animation
  33390. * @param node Node which contains the scene that begins the animations
  33391. * @param targetProperty Specifies which property to animate
  33392. * @param framePerSecond The frames per second of the animation
  33393. * @param totalFrame The total number of frames
  33394. * @param from The frame at the beginning of the animation
  33395. * @param to The frame at the end of the animation
  33396. * @param loopMode Specifies the loop mode of the animation
  33397. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  33398. * @param onAnimationEnd Callback to run once the animation is complete
  33399. * @returns Nullable animation
  33400. */
  33401. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  33402. /**
  33403. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  33404. * @param sourceAnimation defines the Animation containing keyframes to convert
  33405. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  33406. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  33407. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  33408. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  33409. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  33410. */
  33411. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  33412. /**
  33413. * Transition property of an host to the target Value
  33414. * @param property The property to transition
  33415. * @param targetValue The target Value of the property
  33416. * @param host The object where the property to animate belongs
  33417. * @param scene Scene used to run the animation
  33418. * @param frameRate Framerate (in frame/s) to use
  33419. * @param transition The transition type we want to use
  33420. * @param duration The duration of the animation, in milliseconds
  33421. * @param onAnimationEnd Callback trigger at the end of the animation
  33422. * @returns Nullable animation
  33423. */
  33424. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  33425. /**
  33426. * Return the array of runtime animations currently using this animation
  33427. */
  33428. get runtimeAnimations(): RuntimeAnimation[];
  33429. /**
  33430. * Specifies if any of the runtime animations are currently running
  33431. */
  33432. get hasRunningRuntimeAnimations(): boolean;
  33433. /**
  33434. * Initializes the animation
  33435. * @param name Name of the animation
  33436. * @param targetProperty Property to animate
  33437. * @param framePerSecond The frames per second of the animation
  33438. * @param dataType The data type of the animation
  33439. * @param loopMode The loop mode of the animation
  33440. * @param enableBlending Specifies if blending should be enabled
  33441. */
  33442. constructor(
  33443. /**Name of the animation */
  33444. name: string,
  33445. /**Property to animate */
  33446. targetProperty: string,
  33447. /**The frames per second of the animation */
  33448. framePerSecond: number,
  33449. /**The data type of the animation */
  33450. dataType: number,
  33451. /**The loop mode of the animation */
  33452. loopMode?: number | undefined,
  33453. /**Specifies if blending should be enabled */
  33454. enableBlending?: boolean | undefined);
  33455. /**
  33456. * Converts the animation to a string
  33457. * @param fullDetails support for multiple levels of logging within scene loading
  33458. * @returns String form of the animation
  33459. */
  33460. toString(fullDetails?: boolean): string;
  33461. /**
  33462. * Add an event to this animation
  33463. * @param event Event to add
  33464. */
  33465. addEvent(event: AnimationEvent): void;
  33466. /**
  33467. * Remove all events found at the given frame
  33468. * @param frame The frame to remove events from
  33469. */
  33470. removeEvents(frame: number): void;
  33471. /**
  33472. * Retrieves all the events from the animation
  33473. * @returns Events from the animation
  33474. */
  33475. getEvents(): AnimationEvent[];
  33476. /**
  33477. * Creates an animation range
  33478. * @param name Name of the animation range
  33479. * @param from Starting frame of the animation range
  33480. * @param to Ending frame of the animation
  33481. */
  33482. createRange(name: string, from: number, to: number): void;
  33483. /**
  33484. * Deletes an animation range by name
  33485. * @param name Name of the animation range to delete
  33486. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  33487. */
  33488. deleteRange(name: string, deleteFrames?: boolean): void;
  33489. /**
  33490. * Gets the animation range by name, or null if not defined
  33491. * @param name Name of the animation range
  33492. * @returns Nullable animation range
  33493. */
  33494. getRange(name: string): Nullable<AnimationRange>;
  33495. /**
  33496. * Gets the key frames from the animation
  33497. * @returns The key frames of the animation
  33498. */
  33499. getKeys(): Array<IAnimationKey>;
  33500. /**
  33501. * Gets the highest frame rate of the animation
  33502. * @returns Highest frame rate of the animation
  33503. */
  33504. getHighestFrame(): number;
  33505. /**
  33506. * Gets the easing function of the animation
  33507. * @returns Easing function of the animation
  33508. */
  33509. getEasingFunction(): IEasingFunction;
  33510. /**
  33511. * Sets the easing function of the animation
  33512. * @param easingFunction A custom mathematical formula for animation
  33513. */
  33514. setEasingFunction(easingFunction: EasingFunction): void;
  33515. /**
  33516. * Interpolates a scalar linearly
  33517. * @param startValue Start value of the animation curve
  33518. * @param endValue End value of the animation curve
  33519. * @param gradient Scalar amount to interpolate
  33520. * @returns Interpolated scalar value
  33521. */
  33522. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  33523. /**
  33524. * Interpolates a scalar cubically
  33525. * @param startValue Start value of the animation curve
  33526. * @param outTangent End tangent of the animation
  33527. * @param endValue End value of the animation curve
  33528. * @param inTangent Start tangent of the animation curve
  33529. * @param gradient Scalar amount to interpolate
  33530. * @returns Interpolated scalar value
  33531. */
  33532. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  33533. /**
  33534. * Interpolates a quaternion using a spherical linear interpolation
  33535. * @param startValue Start value of the animation curve
  33536. * @param endValue End value of the animation curve
  33537. * @param gradient Scalar amount to interpolate
  33538. * @returns Interpolated quaternion value
  33539. */
  33540. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  33541. /**
  33542. * Interpolates a quaternion cubically
  33543. * @param startValue Start value of the animation curve
  33544. * @param outTangent End tangent of the animation curve
  33545. * @param endValue End value of the animation curve
  33546. * @param inTangent Start tangent of the animation curve
  33547. * @param gradient Scalar amount to interpolate
  33548. * @returns Interpolated quaternion value
  33549. */
  33550. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  33551. /**
  33552. * Interpolates a Vector3 linearl
  33553. * @param startValue Start value of the animation curve
  33554. * @param endValue End value of the animation curve
  33555. * @param gradient Scalar amount to interpolate
  33556. * @returns Interpolated scalar value
  33557. */
  33558. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  33559. /**
  33560. * Interpolates a Vector3 cubically
  33561. * @param startValue Start value of the animation curve
  33562. * @param outTangent End tangent of the animation
  33563. * @param endValue End value of the animation curve
  33564. * @param inTangent Start tangent of the animation curve
  33565. * @param gradient Scalar amount to interpolate
  33566. * @returns InterpolatedVector3 value
  33567. */
  33568. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  33569. /**
  33570. * Interpolates a Vector2 linearly
  33571. * @param startValue Start value of the animation curve
  33572. * @param endValue End value of the animation curve
  33573. * @param gradient Scalar amount to interpolate
  33574. * @returns Interpolated Vector2 value
  33575. */
  33576. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  33577. /**
  33578. * Interpolates a Vector2 cubically
  33579. * @param startValue Start value of the animation curve
  33580. * @param outTangent End tangent of the animation
  33581. * @param endValue End value of the animation curve
  33582. * @param inTangent Start tangent of the animation curve
  33583. * @param gradient Scalar amount to interpolate
  33584. * @returns Interpolated Vector2 value
  33585. */
  33586. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  33587. /**
  33588. * Interpolates a size linearly
  33589. * @param startValue Start value of the animation curve
  33590. * @param endValue End value of the animation curve
  33591. * @param gradient Scalar amount to interpolate
  33592. * @returns Interpolated Size value
  33593. */
  33594. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  33595. /**
  33596. * Interpolates a Color3 linearly
  33597. * @param startValue Start value of the animation curve
  33598. * @param endValue End value of the animation curve
  33599. * @param gradient Scalar amount to interpolate
  33600. * @returns Interpolated Color3 value
  33601. */
  33602. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  33603. /**
  33604. * Interpolates a Color4 linearly
  33605. * @param startValue Start value of the animation curve
  33606. * @param endValue End value of the animation curve
  33607. * @param gradient Scalar amount to interpolate
  33608. * @returns Interpolated Color3 value
  33609. */
  33610. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  33611. /**
  33612. * @hidden Internal use only
  33613. */
  33614. _getKeyValue(value: any): any;
  33615. /**
  33616. * @hidden Internal use only
  33617. */
  33618. _interpolate(currentFrame: number, state: _IAnimationState): any;
  33619. /**
  33620. * Defines the function to use to interpolate matrices
  33621. * @param startValue defines the start matrix
  33622. * @param endValue defines the end matrix
  33623. * @param gradient defines the gradient between both matrices
  33624. * @param result defines an optional target matrix where to store the interpolation
  33625. * @returns the interpolated matrix
  33626. */
  33627. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  33628. /**
  33629. * Makes a copy of the animation
  33630. * @returns Cloned animation
  33631. */
  33632. clone(): Animation;
  33633. /**
  33634. * Sets the key frames of the animation
  33635. * @param values The animation key frames to set
  33636. */
  33637. setKeys(values: Array<IAnimationKey>): void;
  33638. /**
  33639. * Serializes the animation to an object
  33640. * @returns Serialized object
  33641. */
  33642. serialize(): any;
  33643. /**
  33644. * Float animation type
  33645. */
  33646. static readonly ANIMATIONTYPE_FLOAT: number;
  33647. /**
  33648. * Vector3 animation type
  33649. */
  33650. static readonly ANIMATIONTYPE_VECTOR3: number;
  33651. /**
  33652. * Quaternion animation type
  33653. */
  33654. static readonly ANIMATIONTYPE_QUATERNION: number;
  33655. /**
  33656. * Matrix animation type
  33657. */
  33658. static readonly ANIMATIONTYPE_MATRIX: number;
  33659. /**
  33660. * Color3 animation type
  33661. */
  33662. static readonly ANIMATIONTYPE_COLOR3: number;
  33663. /**
  33664. * Color3 animation type
  33665. */
  33666. static readonly ANIMATIONTYPE_COLOR4: number;
  33667. /**
  33668. * Vector2 animation type
  33669. */
  33670. static readonly ANIMATIONTYPE_VECTOR2: number;
  33671. /**
  33672. * Size animation type
  33673. */
  33674. static readonly ANIMATIONTYPE_SIZE: number;
  33675. /**
  33676. * Relative Loop Mode
  33677. */
  33678. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  33679. /**
  33680. * Cycle Loop Mode
  33681. */
  33682. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  33683. /**
  33684. * Constant Loop Mode
  33685. */
  33686. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  33687. /** @hidden */
  33688. static _UniversalLerp(left: any, right: any, amount: number): any;
  33689. /**
  33690. * Parses an animation object and creates an animation
  33691. * @param parsedAnimation Parsed animation object
  33692. * @returns Animation object
  33693. */
  33694. static Parse(parsedAnimation: any): Animation;
  33695. /**
  33696. * Appends the serialized animations from the source animations
  33697. * @param source Source containing the animations
  33698. * @param destination Target to store the animations
  33699. */
  33700. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  33701. }
  33702. }
  33703. declare module "babylonjs/Animations/animatable.interface" {
  33704. import { Nullable } from "babylonjs/types";
  33705. import { Animation } from "babylonjs/Animations/animation";
  33706. /**
  33707. * Interface containing an array of animations
  33708. */
  33709. export interface IAnimatable {
  33710. /**
  33711. * Array of animations
  33712. */
  33713. animations: Nullable<Array<Animation>>;
  33714. }
  33715. }
  33716. declare module "babylonjs/Misc/decorators" {
  33717. import { Nullable } from "babylonjs/types";
  33718. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33719. import { Scene } from "babylonjs/scene";
  33720. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  33721. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33722. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33723. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33724. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33725. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33726. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33727. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33728. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33729. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33730. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33731. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33732. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33733. /**
  33734. * Decorator used to define property that can be serialized as reference to a camera
  33735. * @param sourceName defines the name of the property to decorate
  33736. */
  33737. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33738. /**
  33739. * Class used to help serialization objects
  33740. */
  33741. export class SerializationHelper {
  33742. /** @hidden */
  33743. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  33744. /** @hidden */
  33745. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  33746. /** @hidden */
  33747. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  33748. /** @hidden */
  33749. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  33750. /**
  33751. * Appends the serialized animations from the source animations
  33752. * @param source Source containing the animations
  33753. * @param destination Target to store the animations
  33754. */
  33755. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  33756. /**
  33757. * Static function used to serialized a specific entity
  33758. * @param entity defines the entity to serialize
  33759. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  33760. * @returns a JSON compatible object representing the serialization of the entity
  33761. */
  33762. static Serialize<T>(entity: T, serializationObject?: any): any;
  33763. /**
  33764. * Creates a new entity from a serialization data object
  33765. * @param creationFunction defines a function used to instanciated the new entity
  33766. * @param source defines the source serialization data
  33767. * @param scene defines the hosting scene
  33768. * @param rootUrl defines the root url for resources
  33769. * @returns a new entity
  33770. */
  33771. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  33772. /**
  33773. * Clones an object
  33774. * @param creationFunction defines the function used to instanciate the new object
  33775. * @param source defines the source object
  33776. * @returns the cloned object
  33777. */
  33778. static Clone<T>(creationFunction: () => T, source: T): T;
  33779. /**
  33780. * Instanciates a new object based on a source one (some data will be shared between both object)
  33781. * @param creationFunction defines the function used to instanciate the new object
  33782. * @param source defines the source object
  33783. * @returns the new object
  33784. */
  33785. static Instanciate<T>(creationFunction: () => T, source: T): T;
  33786. }
  33787. }
  33788. declare module "babylonjs/Materials/Textures/baseTexture" {
  33789. import { Observable } from "babylonjs/Misc/observable";
  33790. import { Nullable } from "babylonjs/types";
  33791. import { Scene } from "babylonjs/scene";
  33792. import { Matrix } from "babylonjs/Maths/math.vector";
  33793. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  33794. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33795. import { ISize } from "babylonjs/Maths/math.size";
  33796. import "babylonjs/Misc/fileTools";
  33797. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  33798. /**
  33799. * Base class of all the textures in babylon.
  33800. * It groups all the common properties the materials, post process, lights... might need
  33801. * in order to make a correct use of the texture.
  33802. */
  33803. export class BaseTexture implements IAnimatable {
  33804. /**
  33805. * Default anisotropic filtering level for the application.
  33806. * It is set to 4 as a good tradeoff between perf and quality.
  33807. */
  33808. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  33809. /**
  33810. * Gets or sets the unique id of the texture
  33811. */
  33812. uniqueId: number;
  33813. /**
  33814. * Define the name of the texture.
  33815. */
  33816. name: string;
  33817. /**
  33818. * Gets or sets an object used to store user defined information.
  33819. */
  33820. metadata: any;
  33821. /**
  33822. * For internal use only. Please do not use.
  33823. */
  33824. reservedDataStore: any;
  33825. private _hasAlpha;
  33826. /**
  33827. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  33828. */
  33829. set hasAlpha(value: boolean);
  33830. get hasAlpha(): boolean;
  33831. /**
  33832. * Defines if the alpha value should be determined via the rgb values.
  33833. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  33834. */
  33835. getAlphaFromRGB: boolean;
  33836. /**
  33837. * Intensity or strength of the texture.
  33838. * It is commonly used by materials to fine tune the intensity of the texture
  33839. */
  33840. level: number;
  33841. /**
  33842. * Define the UV chanel to use starting from 0 and defaulting to 0.
  33843. * This is part of the texture as textures usually maps to one uv set.
  33844. */
  33845. coordinatesIndex: number;
  33846. private _coordinatesMode;
  33847. /**
  33848. * How a texture is mapped.
  33849. *
  33850. * | Value | Type | Description |
  33851. * | ----- | ----------------------------------- | ----------- |
  33852. * | 0 | EXPLICIT_MODE | |
  33853. * | 1 | SPHERICAL_MODE | |
  33854. * | 2 | PLANAR_MODE | |
  33855. * | 3 | CUBIC_MODE | |
  33856. * | 4 | PROJECTION_MODE | |
  33857. * | 5 | SKYBOX_MODE | |
  33858. * | 6 | INVCUBIC_MODE | |
  33859. * | 7 | EQUIRECTANGULAR_MODE | |
  33860. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  33861. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  33862. */
  33863. set coordinatesMode(value: number);
  33864. get coordinatesMode(): number;
  33865. /**
  33866. * | Value | Type | Description |
  33867. * | ----- | ------------------ | ----------- |
  33868. * | 0 | CLAMP_ADDRESSMODE | |
  33869. * | 1 | WRAP_ADDRESSMODE | |
  33870. * | 2 | MIRROR_ADDRESSMODE | |
  33871. */
  33872. wrapU: number;
  33873. /**
  33874. * | Value | Type | Description |
  33875. * | ----- | ------------------ | ----------- |
  33876. * | 0 | CLAMP_ADDRESSMODE | |
  33877. * | 1 | WRAP_ADDRESSMODE | |
  33878. * | 2 | MIRROR_ADDRESSMODE | |
  33879. */
  33880. wrapV: number;
  33881. /**
  33882. * | Value | Type | Description |
  33883. * | ----- | ------------------ | ----------- |
  33884. * | 0 | CLAMP_ADDRESSMODE | |
  33885. * | 1 | WRAP_ADDRESSMODE | |
  33886. * | 2 | MIRROR_ADDRESSMODE | |
  33887. */
  33888. wrapR: number;
  33889. /**
  33890. * With compliant hardware and browser (supporting anisotropic filtering)
  33891. * this defines the level of anisotropic filtering in the texture.
  33892. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  33893. */
  33894. anisotropicFilteringLevel: number;
  33895. /**
  33896. * Define if the texture is a cube texture or if false a 2d texture.
  33897. */
  33898. get isCube(): boolean;
  33899. set isCube(value: boolean);
  33900. /**
  33901. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  33902. */
  33903. get is3D(): boolean;
  33904. set is3D(value: boolean);
  33905. /**
  33906. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  33907. */
  33908. get is2DArray(): boolean;
  33909. set is2DArray(value: boolean);
  33910. /**
  33911. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  33912. * HDR texture are usually stored in linear space.
  33913. * This only impacts the PBR and Background materials
  33914. */
  33915. gammaSpace: boolean;
  33916. /**
  33917. * Gets or sets whether or not the texture contains RGBD data.
  33918. */
  33919. get isRGBD(): boolean;
  33920. set isRGBD(value: boolean);
  33921. /**
  33922. * Is Z inverted in the texture (useful in a cube texture).
  33923. */
  33924. invertZ: boolean;
  33925. /**
  33926. * Are mip maps generated for this texture or not.
  33927. */
  33928. get noMipmap(): boolean;
  33929. /**
  33930. * @hidden
  33931. */
  33932. lodLevelInAlpha: boolean;
  33933. /**
  33934. * With prefiltered texture, defined the offset used during the prefiltering steps.
  33935. */
  33936. get lodGenerationOffset(): number;
  33937. set lodGenerationOffset(value: number);
  33938. /**
  33939. * With prefiltered texture, defined the scale used during the prefiltering steps.
  33940. */
  33941. get lodGenerationScale(): number;
  33942. set lodGenerationScale(value: number);
  33943. /**
  33944. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  33945. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  33946. * average roughness values.
  33947. */
  33948. get linearSpecularLOD(): boolean;
  33949. set linearSpecularLOD(value: boolean);
  33950. /**
  33951. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  33952. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  33953. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  33954. */
  33955. get irradianceTexture(): Nullable<BaseTexture>;
  33956. set irradianceTexture(value: Nullable<BaseTexture>);
  33957. /**
  33958. * Define if the texture is a render target.
  33959. */
  33960. isRenderTarget: boolean;
  33961. /**
  33962. * Define the unique id of the texture in the scene.
  33963. */
  33964. get uid(): string;
  33965. /** @hidden */
  33966. _prefiltered: boolean;
  33967. /**
  33968. * Return a string representation of the texture.
  33969. * @returns the texture as a string
  33970. */
  33971. toString(): string;
  33972. /**
  33973. * Get the class name of the texture.
  33974. * @returns "BaseTexture"
  33975. */
  33976. getClassName(): string;
  33977. /**
  33978. * Define the list of animation attached to the texture.
  33979. */
  33980. animations: import("babylonjs/Animations/animation").Animation[];
  33981. /**
  33982. * An event triggered when the texture is disposed.
  33983. */
  33984. onDisposeObservable: Observable<BaseTexture>;
  33985. private _onDisposeObserver;
  33986. /**
  33987. * Callback triggered when the texture has been disposed.
  33988. * Kept for back compatibility, you can use the onDisposeObservable instead.
  33989. */
  33990. set onDispose(callback: () => void);
  33991. /**
  33992. * Define the current state of the loading sequence when in delayed load mode.
  33993. */
  33994. delayLoadState: number;
  33995. private _scene;
  33996. private _engine;
  33997. /** @hidden */
  33998. _texture: Nullable<InternalTexture>;
  33999. private _uid;
  34000. /**
  34001. * Define if the texture is preventinga material to render or not.
  34002. * If not and the texture is not ready, the engine will use a default black texture instead.
  34003. */
  34004. get isBlocking(): boolean;
  34005. /**
  34006. * Instantiates a new BaseTexture.
  34007. * Base class of all the textures in babylon.
  34008. * It groups all the common properties the materials, post process, lights... might need
  34009. * in order to make a correct use of the texture.
  34010. * @param sceneOrEngine Define the scene or engine the texture blongs to
  34011. */
  34012. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  34013. /**
  34014. * Get the scene the texture belongs to.
  34015. * @returns the scene or null if undefined
  34016. */
  34017. getScene(): Nullable<Scene>;
  34018. /** @hidden */
  34019. protected _getEngine(): Nullable<ThinEngine>;
  34020. /**
  34021. * Get the texture transform matrix used to offset tile the texture for istance.
  34022. * @returns the transformation matrix
  34023. */
  34024. getTextureMatrix(): Matrix;
  34025. /**
  34026. * Get the texture reflection matrix used to rotate/transform the reflection.
  34027. * @returns the reflection matrix
  34028. */
  34029. getReflectionTextureMatrix(): Matrix;
  34030. /**
  34031. * Get the underlying lower level texture from Babylon.
  34032. * @returns the insternal texture
  34033. */
  34034. getInternalTexture(): Nullable<InternalTexture>;
  34035. /**
  34036. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  34037. * @returns true if ready or not blocking
  34038. */
  34039. isReadyOrNotBlocking(): boolean;
  34040. /**
  34041. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  34042. * @returns true if fully ready
  34043. */
  34044. isReady(): boolean;
  34045. private _cachedSize;
  34046. /**
  34047. * Get the size of the texture.
  34048. * @returns the texture size.
  34049. */
  34050. getSize(): ISize;
  34051. /**
  34052. * Get the base size of the texture.
  34053. * It can be different from the size if the texture has been resized for POT for instance
  34054. * @returns the base size
  34055. */
  34056. getBaseSize(): ISize;
  34057. /**
  34058. * Update the sampling mode of the texture.
  34059. * Default is Trilinear mode.
  34060. *
  34061. * | Value | Type | Description |
  34062. * | ----- | ------------------ | ----------- |
  34063. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  34064. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  34065. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  34066. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  34067. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  34068. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  34069. * | 7 | NEAREST_LINEAR | |
  34070. * | 8 | NEAREST_NEAREST | |
  34071. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  34072. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  34073. * | 11 | LINEAR_LINEAR | |
  34074. * | 12 | LINEAR_NEAREST | |
  34075. *
  34076. * > _mag_: magnification filter (close to the viewer)
  34077. * > _min_: minification filter (far from the viewer)
  34078. * > _mip_: filter used between mip map levels
  34079. *@param samplingMode Define the new sampling mode of the texture
  34080. */
  34081. updateSamplingMode(samplingMode: number): void;
  34082. /**
  34083. * Scales the texture if is `canRescale()`
  34084. * @param ratio the resize factor we want to use to rescale
  34085. */
  34086. scale(ratio: number): void;
  34087. /**
  34088. * Get if the texture can rescale.
  34089. */
  34090. get canRescale(): boolean;
  34091. /** @hidden */
  34092. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  34093. /** @hidden */
  34094. _rebuild(): void;
  34095. /**
  34096. * Triggers the load sequence in delayed load mode.
  34097. */
  34098. delayLoad(): void;
  34099. /**
  34100. * Clones the texture.
  34101. * @returns the cloned texture
  34102. */
  34103. clone(): Nullable<BaseTexture>;
  34104. /**
  34105. * Get the texture underlying type (INT, FLOAT...)
  34106. */
  34107. get textureType(): number;
  34108. /**
  34109. * Get the texture underlying format (RGB, RGBA...)
  34110. */
  34111. get textureFormat(): number;
  34112. /**
  34113. * Indicates that textures need to be re-calculated for all materials
  34114. */
  34115. protected _markAllSubMeshesAsTexturesDirty(): void;
  34116. /**
  34117. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  34118. * This will returns an RGBA array buffer containing either in values (0-255) or
  34119. * float values (0-1) depending of the underlying buffer type.
  34120. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  34121. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  34122. * @param buffer defines a user defined buffer to fill with data (can be null)
  34123. * @returns The Array buffer containing the pixels data.
  34124. */
  34125. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  34126. /**
  34127. * Release and destroy the underlying lower level texture aka internalTexture.
  34128. */
  34129. releaseInternalTexture(): void;
  34130. /** @hidden */
  34131. get _lodTextureHigh(): Nullable<BaseTexture>;
  34132. /** @hidden */
  34133. get _lodTextureMid(): Nullable<BaseTexture>;
  34134. /** @hidden */
  34135. get _lodTextureLow(): Nullable<BaseTexture>;
  34136. /**
  34137. * Dispose the texture and release its associated resources.
  34138. */
  34139. dispose(): void;
  34140. /**
  34141. * Serialize the texture into a JSON representation that can be parsed later on.
  34142. * @returns the JSON representation of the texture
  34143. */
  34144. serialize(): any;
  34145. /**
  34146. * Helper function to be called back once a list of texture contains only ready textures.
  34147. * @param textures Define the list of textures to wait for
  34148. * @param callback Define the callback triggered once the entire list will be ready
  34149. */
  34150. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  34151. private static _isScene;
  34152. }
  34153. }
  34154. declare module "babylonjs/Materials/effect" {
  34155. import { Observable } from "babylonjs/Misc/observable";
  34156. import { Nullable } from "babylonjs/types";
  34157. import { IDisposable } from "babylonjs/scene";
  34158. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  34159. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  34160. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  34161. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  34162. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  34163. import { Engine } from "babylonjs/Engines/engine";
  34164. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  34165. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34166. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  34167. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  34168. /**
  34169. * Options to be used when creating an effect.
  34170. */
  34171. export interface IEffectCreationOptions {
  34172. /**
  34173. * Atrributes that will be used in the shader.
  34174. */
  34175. attributes: string[];
  34176. /**
  34177. * Uniform varible names that will be set in the shader.
  34178. */
  34179. uniformsNames: string[];
  34180. /**
  34181. * Uniform buffer variable names that will be set in the shader.
  34182. */
  34183. uniformBuffersNames: string[];
  34184. /**
  34185. * Sampler texture variable names that will be set in the shader.
  34186. */
  34187. samplers: string[];
  34188. /**
  34189. * Define statements that will be set in the shader.
  34190. */
  34191. defines: any;
  34192. /**
  34193. * Possible fallbacks for this effect to improve performance when needed.
  34194. */
  34195. fallbacks: Nullable<IEffectFallbacks>;
  34196. /**
  34197. * Callback that will be called when the shader is compiled.
  34198. */
  34199. onCompiled: Nullable<(effect: Effect) => void>;
  34200. /**
  34201. * Callback that will be called if an error occurs during shader compilation.
  34202. */
  34203. onError: Nullable<(effect: Effect, errors: string) => void>;
  34204. /**
  34205. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  34206. */
  34207. indexParameters?: any;
  34208. /**
  34209. * Max number of lights that can be used in the shader.
  34210. */
  34211. maxSimultaneousLights?: number;
  34212. /**
  34213. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  34214. */
  34215. transformFeedbackVaryings?: Nullable<string[]>;
  34216. /**
  34217. * 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
  34218. */
  34219. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  34220. }
  34221. /**
  34222. * Effect containing vertex and fragment shader that can be executed on an object.
  34223. */
  34224. export class Effect implements IDisposable {
  34225. /**
  34226. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  34227. */
  34228. static ShadersRepository: string;
  34229. /**
  34230. * Enable logging of the shader code when a compilation error occurs
  34231. */
  34232. static LogShaderCodeOnCompilationError: boolean;
  34233. /**
  34234. * Name of the effect.
  34235. */
  34236. name: any;
  34237. /**
  34238. * String container all the define statements that should be set on the shader.
  34239. */
  34240. defines: string;
  34241. /**
  34242. * Callback that will be called when the shader is compiled.
  34243. */
  34244. onCompiled: Nullable<(effect: Effect) => void>;
  34245. /**
  34246. * Callback that will be called if an error occurs during shader compilation.
  34247. */
  34248. onError: Nullable<(effect: Effect, errors: string) => void>;
  34249. /**
  34250. * Callback that will be called when effect is bound.
  34251. */
  34252. onBind: Nullable<(effect: Effect) => void>;
  34253. /**
  34254. * Unique ID of the effect.
  34255. */
  34256. uniqueId: number;
  34257. /**
  34258. * Observable that will be called when the shader is compiled.
  34259. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  34260. */
  34261. onCompileObservable: Observable<Effect>;
  34262. /**
  34263. * Observable that will be called if an error occurs during shader compilation.
  34264. */
  34265. onErrorObservable: Observable<Effect>;
  34266. /** @hidden */
  34267. _onBindObservable: Nullable<Observable<Effect>>;
  34268. /**
  34269. * @hidden
  34270. * Specifies if the effect was previously ready
  34271. */
  34272. _wasPreviouslyReady: boolean;
  34273. /**
  34274. * Observable that will be called when effect is bound.
  34275. */
  34276. get onBindObservable(): Observable<Effect>;
  34277. /** @hidden */
  34278. _bonesComputationForcedToCPU: boolean;
  34279. private static _uniqueIdSeed;
  34280. private _engine;
  34281. private _uniformBuffersNames;
  34282. private _uniformBuffersNamesList;
  34283. private _uniformsNames;
  34284. private _samplerList;
  34285. private _samplers;
  34286. private _isReady;
  34287. private _compilationError;
  34288. private _allFallbacksProcessed;
  34289. private _attributesNames;
  34290. private _attributes;
  34291. private _attributeLocationByName;
  34292. private _uniforms;
  34293. /**
  34294. * Key for the effect.
  34295. * @hidden
  34296. */
  34297. _key: string;
  34298. private _indexParameters;
  34299. private _fallbacks;
  34300. private _vertexSourceCode;
  34301. private _fragmentSourceCode;
  34302. private _vertexSourceCodeOverride;
  34303. private _fragmentSourceCodeOverride;
  34304. private _transformFeedbackVaryings;
  34305. /**
  34306. * Compiled shader to webGL program.
  34307. * @hidden
  34308. */
  34309. _pipelineContext: Nullable<IPipelineContext>;
  34310. private _valueCache;
  34311. private static _baseCache;
  34312. /**
  34313. * Instantiates an effect.
  34314. * An effect can be used to create/manage/execute vertex and fragment shaders.
  34315. * @param baseName Name of the effect.
  34316. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  34317. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  34318. * @param samplers List of sampler variables that will be passed to the shader.
  34319. * @param engine Engine to be used to render the effect
  34320. * @param defines Define statements to be added to the shader.
  34321. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  34322. * @param onCompiled Callback that will be called when the shader is compiled.
  34323. * @param onError Callback that will be called if an error occurs during shader compilation.
  34324. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  34325. */
  34326. 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);
  34327. private _useFinalCode;
  34328. /**
  34329. * Unique key for this effect
  34330. */
  34331. get key(): string;
  34332. /**
  34333. * If the effect has been compiled and prepared.
  34334. * @returns if the effect is compiled and prepared.
  34335. */
  34336. isReady(): boolean;
  34337. private _isReadyInternal;
  34338. /**
  34339. * The engine the effect was initialized with.
  34340. * @returns the engine.
  34341. */
  34342. getEngine(): Engine;
  34343. /**
  34344. * The pipeline context for this effect
  34345. * @returns the associated pipeline context
  34346. */
  34347. getPipelineContext(): Nullable<IPipelineContext>;
  34348. /**
  34349. * The set of names of attribute variables for the shader.
  34350. * @returns An array of attribute names.
  34351. */
  34352. getAttributesNames(): string[];
  34353. /**
  34354. * Returns the attribute at the given index.
  34355. * @param index The index of the attribute.
  34356. * @returns The location of the attribute.
  34357. */
  34358. getAttributeLocation(index: number): number;
  34359. /**
  34360. * Returns the attribute based on the name of the variable.
  34361. * @param name of the attribute to look up.
  34362. * @returns the attribute location.
  34363. */
  34364. getAttributeLocationByName(name: string): number;
  34365. /**
  34366. * The number of attributes.
  34367. * @returns the numnber of attributes.
  34368. */
  34369. getAttributesCount(): number;
  34370. /**
  34371. * Gets the index of a uniform variable.
  34372. * @param uniformName of the uniform to look up.
  34373. * @returns the index.
  34374. */
  34375. getUniformIndex(uniformName: string): number;
  34376. /**
  34377. * Returns the attribute based on the name of the variable.
  34378. * @param uniformName of the uniform to look up.
  34379. * @returns the location of the uniform.
  34380. */
  34381. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  34382. /**
  34383. * Returns an array of sampler variable names
  34384. * @returns The array of sampler variable names.
  34385. */
  34386. getSamplers(): string[];
  34387. /**
  34388. * Returns an array of uniform variable names
  34389. * @returns The array of uniform variable names.
  34390. */
  34391. getUniformNames(): string[];
  34392. /**
  34393. * Returns an array of uniform buffer variable names
  34394. * @returns The array of uniform buffer variable names.
  34395. */
  34396. getUniformBuffersNames(): string[];
  34397. /**
  34398. * Returns the index parameters used to create the effect
  34399. * @returns The index parameters object
  34400. */
  34401. getIndexParameters(): any;
  34402. /**
  34403. * The error from the last compilation.
  34404. * @returns the error string.
  34405. */
  34406. getCompilationError(): string;
  34407. /**
  34408. * Gets a boolean indicating that all fallbacks were used during compilation
  34409. * @returns true if all fallbacks were used
  34410. */
  34411. allFallbacksProcessed(): boolean;
  34412. /**
  34413. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  34414. * @param func The callback to be used.
  34415. */
  34416. executeWhenCompiled(func: (effect: Effect) => void): void;
  34417. private _checkIsReady;
  34418. private _loadShader;
  34419. /**
  34420. * Gets the vertex shader source code of this effect
  34421. */
  34422. get vertexSourceCode(): string;
  34423. /**
  34424. * Gets the fragment shader source code of this effect
  34425. */
  34426. get fragmentSourceCode(): string;
  34427. /**
  34428. * Recompiles the webGL program
  34429. * @param vertexSourceCode The source code for the vertex shader.
  34430. * @param fragmentSourceCode The source code for the fragment shader.
  34431. * @param onCompiled Callback called when completed.
  34432. * @param onError Callback called on error.
  34433. * @hidden
  34434. */
  34435. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  34436. /**
  34437. * Prepares the effect
  34438. * @hidden
  34439. */
  34440. _prepareEffect(): void;
  34441. private _getShaderCodeAndErrorLine;
  34442. private _processCompilationErrors;
  34443. /**
  34444. * Checks if the effect is supported. (Must be called after compilation)
  34445. */
  34446. get isSupported(): boolean;
  34447. /**
  34448. * Binds a texture to the engine to be used as output of the shader.
  34449. * @param channel Name of the output variable.
  34450. * @param texture Texture to bind.
  34451. * @hidden
  34452. */
  34453. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  34454. /**
  34455. * Sets a texture on the engine to be used in the shader.
  34456. * @param channel Name of the sampler variable.
  34457. * @param texture Texture to set.
  34458. */
  34459. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  34460. /**
  34461. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  34462. * @param channel Name of the sampler variable.
  34463. * @param texture Texture to set.
  34464. */
  34465. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  34466. /**
  34467. * Sets an array of textures on the engine to be used in the shader.
  34468. * @param channel Name of the variable.
  34469. * @param textures Textures to set.
  34470. */
  34471. setTextureArray(channel: string, textures: BaseTexture[]): void;
  34472. /**
  34473. * 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)
  34474. * @param channel Name of the sampler variable.
  34475. * @param postProcess Post process to get the input texture from.
  34476. */
  34477. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  34478. /**
  34479. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  34480. * 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)
  34481. * @param channel Name of the sampler variable.
  34482. * @param postProcess Post process to get the output texture from.
  34483. */
  34484. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  34485. /** @hidden */
  34486. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  34487. /** @hidden */
  34488. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  34489. /** @hidden */
  34490. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  34491. /** @hidden */
  34492. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  34493. /**
  34494. * Binds a buffer to a uniform.
  34495. * @param buffer Buffer to bind.
  34496. * @param name Name of the uniform variable to bind to.
  34497. */
  34498. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  34499. /**
  34500. * Binds block to a uniform.
  34501. * @param blockName Name of the block to bind.
  34502. * @param index Index to bind.
  34503. */
  34504. bindUniformBlock(blockName: string, index: number): void;
  34505. /**
  34506. * Sets an interger value on a uniform variable.
  34507. * @param uniformName Name of the variable.
  34508. * @param value Value to be set.
  34509. * @returns this effect.
  34510. */
  34511. setInt(uniformName: string, value: number): Effect;
  34512. /**
  34513. * Sets an int array on a uniform variable.
  34514. * @param uniformName Name of the variable.
  34515. * @param array array to be set.
  34516. * @returns this effect.
  34517. */
  34518. setIntArray(uniformName: string, array: Int32Array): Effect;
  34519. /**
  34520. * 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)
  34521. * @param uniformName Name of the variable.
  34522. * @param array array to be set.
  34523. * @returns this effect.
  34524. */
  34525. setIntArray2(uniformName: string, array: Int32Array): Effect;
  34526. /**
  34527. * 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)
  34528. * @param uniformName Name of the variable.
  34529. * @param array array to be set.
  34530. * @returns this effect.
  34531. */
  34532. setIntArray3(uniformName: string, array: Int32Array): Effect;
  34533. /**
  34534. * 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)
  34535. * @param uniformName Name of the variable.
  34536. * @param array array to be set.
  34537. * @returns this effect.
  34538. */
  34539. setIntArray4(uniformName: string, array: Int32Array): Effect;
  34540. /**
  34541. * Sets an float array on a uniform variable.
  34542. * @param uniformName Name of the variable.
  34543. * @param array array to be set.
  34544. * @returns this effect.
  34545. */
  34546. setFloatArray(uniformName: string, array: Float32Array): Effect;
  34547. /**
  34548. * 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)
  34549. * @param uniformName Name of the variable.
  34550. * @param array array to be set.
  34551. * @returns this effect.
  34552. */
  34553. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  34554. /**
  34555. * 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)
  34556. * @param uniformName Name of the variable.
  34557. * @param array array to be set.
  34558. * @returns this effect.
  34559. */
  34560. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  34561. /**
  34562. * 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)
  34563. * @param uniformName Name of the variable.
  34564. * @param array array to be set.
  34565. * @returns this effect.
  34566. */
  34567. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  34568. /**
  34569. * Sets an array on a uniform variable.
  34570. * @param uniformName Name of the variable.
  34571. * @param array array to be set.
  34572. * @returns this effect.
  34573. */
  34574. setArray(uniformName: string, array: number[]): Effect;
  34575. /**
  34576. * 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)
  34577. * @param uniformName Name of the variable.
  34578. * @param array array to be set.
  34579. * @returns this effect.
  34580. */
  34581. setArray2(uniformName: string, array: number[]): Effect;
  34582. /**
  34583. * 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)
  34584. * @param uniformName Name of the variable.
  34585. * @param array array to be set.
  34586. * @returns this effect.
  34587. */
  34588. setArray3(uniformName: string, array: number[]): Effect;
  34589. /**
  34590. * 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)
  34591. * @param uniformName Name of the variable.
  34592. * @param array array to be set.
  34593. * @returns this effect.
  34594. */
  34595. setArray4(uniformName: string, array: number[]): Effect;
  34596. /**
  34597. * Sets matrices on a uniform variable.
  34598. * @param uniformName Name of the variable.
  34599. * @param matrices matrices to be set.
  34600. * @returns this effect.
  34601. */
  34602. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  34603. /**
  34604. * Sets matrix on a uniform variable.
  34605. * @param uniformName Name of the variable.
  34606. * @param matrix matrix to be set.
  34607. * @returns this effect.
  34608. */
  34609. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  34610. /**
  34611. * 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)
  34612. * @param uniformName Name of the variable.
  34613. * @param matrix matrix to be set.
  34614. * @returns this effect.
  34615. */
  34616. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  34617. /**
  34618. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  34619. * @param uniformName Name of the variable.
  34620. * @param matrix matrix to be set.
  34621. * @returns this effect.
  34622. */
  34623. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  34624. /**
  34625. * Sets a float on a uniform variable.
  34626. * @param uniformName Name of the variable.
  34627. * @param value value to be set.
  34628. * @returns this effect.
  34629. */
  34630. setFloat(uniformName: string, value: number): Effect;
  34631. /**
  34632. * Sets a boolean on a uniform variable.
  34633. * @param uniformName Name of the variable.
  34634. * @param bool value to be set.
  34635. * @returns this effect.
  34636. */
  34637. setBool(uniformName: string, bool: boolean): Effect;
  34638. /**
  34639. * Sets a Vector2 on a uniform variable.
  34640. * @param uniformName Name of the variable.
  34641. * @param vector2 vector2 to be set.
  34642. * @returns this effect.
  34643. */
  34644. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  34645. /**
  34646. * Sets a float2 on a uniform variable.
  34647. * @param uniformName Name of the variable.
  34648. * @param x First float in float2.
  34649. * @param y Second float in float2.
  34650. * @returns this effect.
  34651. */
  34652. setFloat2(uniformName: string, x: number, y: number): Effect;
  34653. /**
  34654. * Sets a Vector3 on a uniform variable.
  34655. * @param uniformName Name of the variable.
  34656. * @param vector3 Value to be set.
  34657. * @returns this effect.
  34658. */
  34659. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  34660. /**
  34661. * Sets a float3 on a uniform variable.
  34662. * @param uniformName Name of the variable.
  34663. * @param x First float in float3.
  34664. * @param y Second float in float3.
  34665. * @param z Third float in float3.
  34666. * @returns this effect.
  34667. */
  34668. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  34669. /**
  34670. * Sets a Vector4 on a uniform variable.
  34671. * @param uniformName Name of the variable.
  34672. * @param vector4 Value to be set.
  34673. * @returns this effect.
  34674. */
  34675. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  34676. /**
  34677. * Sets a float4 on a uniform variable.
  34678. * @param uniformName Name of the variable.
  34679. * @param x First float in float4.
  34680. * @param y Second float in float4.
  34681. * @param z Third float in float4.
  34682. * @param w Fourth float in float4.
  34683. * @returns this effect.
  34684. */
  34685. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  34686. /**
  34687. * Sets a Color3 on a uniform variable.
  34688. * @param uniformName Name of the variable.
  34689. * @param color3 Value to be set.
  34690. * @returns this effect.
  34691. */
  34692. setColor3(uniformName: string, color3: IColor3Like): Effect;
  34693. /**
  34694. * Sets a Color4 on a uniform variable.
  34695. * @param uniformName Name of the variable.
  34696. * @param color3 Value to be set.
  34697. * @param alpha Alpha value to be set.
  34698. * @returns this effect.
  34699. */
  34700. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  34701. /**
  34702. * Sets a Color4 on a uniform variable
  34703. * @param uniformName defines the name of the variable
  34704. * @param color4 defines the value to be set
  34705. * @returns this effect.
  34706. */
  34707. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  34708. /** Release all associated resources */
  34709. dispose(): void;
  34710. /**
  34711. * This function will add a new shader to the shader store
  34712. * @param name the name of the shader
  34713. * @param pixelShader optional pixel shader content
  34714. * @param vertexShader optional vertex shader content
  34715. */
  34716. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  34717. /**
  34718. * Store of each shader (The can be looked up using effect.key)
  34719. */
  34720. static ShadersStore: {
  34721. [key: string]: string;
  34722. };
  34723. /**
  34724. * Store of each included file for a shader (The can be looked up using effect.key)
  34725. */
  34726. static IncludesShadersStore: {
  34727. [key: string]: string;
  34728. };
  34729. /**
  34730. * Resets the cache of effects.
  34731. */
  34732. static ResetCache(): void;
  34733. }
  34734. }
  34735. declare module "babylonjs/Engines/engineCapabilities" {
  34736. /**
  34737. * Interface used to describe the capabilities of the engine relatively to the current browser
  34738. */
  34739. export interface EngineCapabilities {
  34740. /** Maximum textures units per fragment shader */
  34741. maxTexturesImageUnits: number;
  34742. /** Maximum texture units per vertex shader */
  34743. maxVertexTextureImageUnits: number;
  34744. /** Maximum textures units in the entire pipeline */
  34745. maxCombinedTexturesImageUnits: number;
  34746. /** Maximum texture size */
  34747. maxTextureSize: number;
  34748. /** Maximum texture samples */
  34749. maxSamples?: number;
  34750. /** Maximum cube texture size */
  34751. maxCubemapTextureSize: number;
  34752. /** Maximum render texture size */
  34753. maxRenderTextureSize: number;
  34754. /** Maximum number of vertex attributes */
  34755. maxVertexAttribs: number;
  34756. /** Maximum number of varyings */
  34757. maxVaryingVectors: number;
  34758. /** Maximum number of uniforms per vertex shader */
  34759. maxVertexUniformVectors: number;
  34760. /** Maximum number of uniforms per fragment shader */
  34761. maxFragmentUniformVectors: number;
  34762. /** Defines if standard derivates (dx/dy) are supported */
  34763. standardDerivatives: boolean;
  34764. /** Defines if s3tc texture compression is supported */
  34765. s3tc?: WEBGL_compressed_texture_s3tc;
  34766. /** Defines if pvrtc texture compression is supported */
  34767. pvrtc: any;
  34768. /** Defines if etc1 texture compression is supported */
  34769. etc1: any;
  34770. /** Defines if etc2 texture compression is supported */
  34771. etc2: any;
  34772. /** Defines if astc texture compression is supported */
  34773. astc: any;
  34774. /** Defines if float textures are supported */
  34775. textureFloat: boolean;
  34776. /** Defines if vertex array objects are supported */
  34777. vertexArrayObject: boolean;
  34778. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  34779. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  34780. /** Gets the maximum level of anisotropy supported */
  34781. maxAnisotropy: number;
  34782. /** Defines if instancing is supported */
  34783. instancedArrays: boolean;
  34784. /** Defines if 32 bits indices are supported */
  34785. uintIndices: boolean;
  34786. /** Defines if high precision shaders are supported */
  34787. highPrecisionShaderSupported: boolean;
  34788. /** Defines if depth reading in the fragment shader is supported */
  34789. fragmentDepthSupported: boolean;
  34790. /** Defines if float texture linear filtering is supported*/
  34791. textureFloatLinearFiltering: boolean;
  34792. /** Defines if rendering to float textures is supported */
  34793. textureFloatRender: boolean;
  34794. /** Defines if half float textures are supported*/
  34795. textureHalfFloat: boolean;
  34796. /** Defines if half float texture linear filtering is supported*/
  34797. textureHalfFloatLinearFiltering: boolean;
  34798. /** Defines if rendering to half float textures is supported */
  34799. textureHalfFloatRender: boolean;
  34800. /** Defines if textureLOD shader command is supported */
  34801. textureLOD: boolean;
  34802. /** Defines if draw buffers extension is supported */
  34803. drawBuffersExtension: boolean;
  34804. /** Defines if depth textures are supported */
  34805. depthTextureExtension: boolean;
  34806. /** Defines if float color buffer are supported */
  34807. colorBufferFloat: boolean;
  34808. /** Gets disjoint timer query extension (null if not supported) */
  34809. timerQuery?: EXT_disjoint_timer_query;
  34810. /** Defines if timestamp can be used with timer query */
  34811. canUseTimestampForTimerQuery: boolean;
  34812. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  34813. multiview?: any;
  34814. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  34815. oculusMultiview?: any;
  34816. /** Function used to let the system compiles shaders in background */
  34817. parallelShaderCompile?: {
  34818. COMPLETION_STATUS_KHR: number;
  34819. };
  34820. /** Max number of texture samples for MSAA */
  34821. maxMSAASamples: number;
  34822. /** Defines if the blend min max extension is supported */
  34823. blendMinMax: boolean;
  34824. }
  34825. }
  34826. declare module "babylonjs/States/depthCullingState" {
  34827. import { Nullable } from "babylonjs/types";
  34828. /**
  34829. * @hidden
  34830. **/
  34831. export class DepthCullingState {
  34832. private _isDepthTestDirty;
  34833. private _isDepthMaskDirty;
  34834. private _isDepthFuncDirty;
  34835. private _isCullFaceDirty;
  34836. private _isCullDirty;
  34837. private _isZOffsetDirty;
  34838. private _isFrontFaceDirty;
  34839. private _depthTest;
  34840. private _depthMask;
  34841. private _depthFunc;
  34842. private _cull;
  34843. private _cullFace;
  34844. private _zOffset;
  34845. private _frontFace;
  34846. /**
  34847. * Initializes the state.
  34848. */
  34849. constructor();
  34850. get isDirty(): boolean;
  34851. get zOffset(): number;
  34852. set zOffset(value: number);
  34853. get cullFace(): Nullable<number>;
  34854. set cullFace(value: Nullable<number>);
  34855. get cull(): Nullable<boolean>;
  34856. set cull(value: Nullable<boolean>);
  34857. get depthFunc(): Nullable<number>;
  34858. set depthFunc(value: Nullable<number>);
  34859. get depthMask(): boolean;
  34860. set depthMask(value: boolean);
  34861. get depthTest(): boolean;
  34862. set depthTest(value: boolean);
  34863. get frontFace(): Nullable<number>;
  34864. set frontFace(value: Nullable<number>);
  34865. reset(): void;
  34866. apply(gl: WebGLRenderingContext): void;
  34867. }
  34868. }
  34869. declare module "babylonjs/States/stencilState" {
  34870. /**
  34871. * @hidden
  34872. **/
  34873. export class StencilState {
  34874. /** 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 */
  34875. static readonly ALWAYS: number;
  34876. /** Passed to stencilOperation to specify that stencil value must be kept */
  34877. static readonly KEEP: number;
  34878. /** Passed to stencilOperation to specify that stencil value must be replaced */
  34879. static readonly REPLACE: number;
  34880. private _isStencilTestDirty;
  34881. private _isStencilMaskDirty;
  34882. private _isStencilFuncDirty;
  34883. private _isStencilOpDirty;
  34884. private _stencilTest;
  34885. private _stencilMask;
  34886. private _stencilFunc;
  34887. private _stencilFuncRef;
  34888. private _stencilFuncMask;
  34889. private _stencilOpStencilFail;
  34890. private _stencilOpDepthFail;
  34891. private _stencilOpStencilDepthPass;
  34892. get isDirty(): boolean;
  34893. get stencilFunc(): number;
  34894. set stencilFunc(value: number);
  34895. get stencilFuncRef(): number;
  34896. set stencilFuncRef(value: number);
  34897. get stencilFuncMask(): number;
  34898. set stencilFuncMask(value: number);
  34899. get stencilOpStencilFail(): number;
  34900. set stencilOpStencilFail(value: number);
  34901. get stencilOpDepthFail(): number;
  34902. set stencilOpDepthFail(value: number);
  34903. get stencilOpStencilDepthPass(): number;
  34904. set stencilOpStencilDepthPass(value: number);
  34905. get stencilMask(): number;
  34906. set stencilMask(value: number);
  34907. get stencilTest(): boolean;
  34908. set stencilTest(value: boolean);
  34909. constructor();
  34910. reset(): void;
  34911. apply(gl: WebGLRenderingContext): void;
  34912. }
  34913. }
  34914. declare module "babylonjs/States/alphaCullingState" {
  34915. /**
  34916. * @hidden
  34917. **/
  34918. export class AlphaState {
  34919. private _isAlphaBlendDirty;
  34920. private _isBlendFunctionParametersDirty;
  34921. private _isBlendEquationParametersDirty;
  34922. private _isBlendConstantsDirty;
  34923. private _alphaBlend;
  34924. private _blendFunctionParameters;
  34925. private _blendEquationParameters;
  34926. private _blendConstants;
  34927. /**
  34928. * Initializes the state.
  34929. */
  34930. constructor();
  34931. get isDirty(): boolean;
  34932. get alphaBlend(): boolean;
  34933. set alphaBlend(value: boolean);
  34934. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  34935. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  34936. setAlphaEquationParameters(rgb: number, alpha: number): void;
  34937. reset(): void;
  34938. apply(gl: WebGLRenderingContext): void;
  34939. }
  34940. }
  34941. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  34942. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  34943. /** @hidden */
  34944. export class WebGL2ShaderProcessor implements IShaderProcessor {
  34945. attributeProcessor(attribute: string): string;
  34946. varyingProcessor(varying: string, isFragment: boolean): string;
  34947. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  34948. }
  34949. }
  34950. declare module "babylonjs/Engines/instancingAttributeInfo" {
  34951. /**
  34952. * Interface for attribute information associated with buffer instanciation
  34953. */
  34954. export interface InstancingAttributeInfo {
  34955. /**
  34956. * Name of the GLSL attribute
  34957. * if attribute index is not specified, this is used to retrieve the index from the effect
  34958. */
  34959. attributeName: string;
  34960. /**
  34961. * Index/offset of the attribute in the vertex shader
  34962. * if not specified, this will be computes from the name.
  34963. */
  34964. index?: number;
  34965. /**
  34966. * size of the attribute, 1, 2, 3 or 4
  34967. */
  34968. attributeSize: number;
  34969. /**
  34970. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  34971. */
  34972. offset: number;
  34973. /**
  34974. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  34975. * default to 1
  34976. */
  34977. divisor?: number;
  34978. /**
  34979. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  34980. * default is FLOAT
  34981. */
  34982. attributeType?: number;
  34983. /**
  34984. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  34985. */
  34986. normalized?: boolean;
  34987. }
  34988. }
  34989. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  34990. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  34991. import { Nullable } from "babylonjs/types";
  34992. module "babylonjs/Engines/thinEngine" {
  34993. interface ThinEngine {
  34994. /**
  34995. * Update a video texture
  34996. * @param texture defines the texture to update
  34997. * @param video defines the video element to use
  34998. * @param invertY defines if data must be stored with Y axis inverted
  34999. */
  35000. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  35001. }
  35002. }
  35003. }
  35004. declare module "babylonjs/Materials/Textures/videoTexture" {
  35005. import { Observable } from "babylonjs/Misc/observable";
  35006. import { Nullable } from "babylonjs/types";
  35007. import { Scene } from "babylonjs/scene";
  35008. import { Texture } from "babylonjs/Materials/Textures/texture";
  35009. import "babylonjs/Engines/Extensions/engine.videoTexture";
  35010. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  35011. /**
  35012. * Settings for finer control over video usage
  35013. */
  35014. export interface VideoTextureSettings {
  35015. /**
  35016. * Applies `autoplay` to video, if specified
  35017. */
  35018. autoPlay?: boolean;
  35019. /**
  35020. * Applies `loop` to video, if specified
  35021. */
  35022. loop?: boolean;
  35023. /**
  35024. * Automatically updates internal texture from video at every frame in the render loop
  35025. */
  35026. autoUpdateTexture: boolean;
  35027. /**
  35028. * Image src displayed during the video loading or until the user interacts with the video.
  35029. */
  35030. poster?: string;
  35031. }
  35032. /**
  35033. * If you want to display a video in your scene, this is the special texture for that.
  35034. * This special texture works similar to other textures, with the exception of a few parameters.
  35035. * @see https://doc.babylonjs.com/how_to/video_texture
  35036. */
  35037. export class VideoTexture extends Texture {
  35038. /**
  35039. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  35040. */
  35041. readonly autoUpdateTexture: boolean;
  35042. /**
  35043. * The video instance used by the texture internally
  35044. */
  35045. readonly video: HTMLVideoElement;
  35046. private _onUserActionRequestedObservable;
  35047. /**
  35048. * Event triggerd when a dom action is required by the user to play the video.
  35049. * This happens due to recent changes in browser policies preventing video to auto start.
  35050. */
  35051. get onUserActionRequestedObservable(): Observable<Texture>;
  35052. private _generateMipMaps;
  35053. private _stillImageCaptured;
  35054. private _displayingPosterTexture;
  35055. private _settings;
  35056. private _createInternalTextureOnEvent;
  35057. private _frameId;
  35058. private _currentSrc;
  35059. /**
  35060. * Creates a video texture.
  35061. * If you want to display a video in your scene, this is the special texture for that.
  35062. * This special texture works similar to other textures, with the exception of a few parameters.
  35063. * @see https://doc.babylonjs.com/how_to/video_texture
  35064. * @param name optional name, will detect from video source, if not defined
  35065. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  35066. * @param scene is obviously the current scene.
  35067. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  35068. * @param invertY is false by default but can be used to invert video on Y axis
  35069. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  35070. * @param settings allows finer control over video usage
  35071. */
  35072. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  35073. private _getName;
  35074. private _getVideo;
  35075. private _createInternalTexture;
  35076. private reset;
  35077. /**
  35078. * @hidden Internal method to initiate `update`.
  35079. */
  35080. _rebuild(): void;
  35081. /**
  35082. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  35083. */
  35084. update(): void;
  35085. /**
  35086. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  35087. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  35088. */
  35089. updateTexture(isVisible: boolean): void;
  35090. protected _updateInternalTexture: () => void;
  35091. /**
  35092. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  35093. * @param url New url.
  35094. */
  35095. updateURL(url: string): void;
  35096. /**
  35097. * Clones the texture.
  35098. * @returns the cloned texture
  35099. */
  35100. clone(): VideoTexture;
  35101. /**
  35102. * Dispose the texture and release its associated resources.
  35103. */
  35104. dispose(): void;
  35105. /**
  35106. * Creates a video texture straight from a stream.
  35107. * @param scene Define the scene the texture should be created in
  35108. * @param stream Define the stream the texture should be created from
  35109. * @returns The created video texture as a promise
  35110. */
  35111. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  35112. /**
  35113. * Creates a video texture straight from your WebCam video feed.
  35114. * @param scene Define the scene the texture should be created in
  35115. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  35116. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  35117. * @returns The created video texture as a promise
  35118. */
  35119. static CreateFromWebCamAsync(scene: Scene, constraints: {
  35120. minWidth: number;
  35121. maxWidth: number;
  35122. minHeight: number;
  35123. maxHeight: number;
  35124. deviceId: string;
  35125. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  35126. /**
  35127. * Creates a video texture straight from your WebCam video feed.
  35128. * @param scene Define the scene the texture should be created in
  35129. * @param onReady Define a callback to triggered once the texture will be ready
  35130. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  35131. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  35132. */
  35133. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  35134. minWidth: number;
  35135. maxWidth: number;
  35136. minHeight: number;
  35137. maxHeight: number;
  35138. deviceId: string;
  35139. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  35140. }
  35141. }
  35142. declare module "babylonjs/Engines/thinEngine" {
  35143. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  35144. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  35145. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  35146. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  35147. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  35148. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  35149. import { Observable } from "babylonjs/Misc/observable";
  35150. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  35151. import { StencilState } from "babylonjs/States/stencilState";
  35152. import { AlphaState } from "babylonjs/States/alphaCullingState";
  35153. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  35154. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  35155. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  35156. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  35157. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  35158. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  35159. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  35160. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  35161. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35162. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  35163. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  35164. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  35165. import { WebRequest } from "babylonjs/Misc/webRequest";
  35166. import { LoadFileError } from "babylonjs/Misc/fileTools";
  35167. /**
  35168. * Defines the interface used by objects working like Scene
  35169. * @hidden
  35170. */
  35171. export interface ISceneLike {
  35172. _addPendingData(data: any): void;
  35173. _removePendingData(data: any): void;
  35174. offlineProvider: IOfflineProvider;
  35175. }
  35176. /** Interface defining initialization parameters for Engine class */
  35177. export interface EngineOptions extends WebGLContextAttributes {
  35178. /**
  35179. * Defines if the engine should no exceed a specified device ratio
  35180. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  35181. */
  35182. limitDeviceRatio?: number;
  35183. /**
  35184. * Defines if webvr should be enabled automatically
  35185. * @see http://doc.babylonjs.com/how_to/webvr_camera
  35186. */
  35187. autoEnableWebVR?: boolean;
  35188. /**
  35189. * Defines if webgl2 should be turned off even if supported
  35190. * @see http://doc.babylonjs.com/features/webgl2
  35191. */
  35192. disableWebGL2Support?: boolean;
  35193. /**
  35194. * Defines if webaudio should be initialized as well
  35195. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35196. */
  35197. audioEngine?: boolean;
  35198. /**
  35199. * Defines if animations should run using a deterministic lock step
  35200. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35201. */
  35202. deterministicLockstep?: boolean;
  35203. /** Defines the maximum steps to use with deterministic lock step mode */
  35204. lockstepMaxSteps?: number;
  35205. /** Defines the seconds between each deterministic lock step */
  35206. timeStep?: number;
  35207. /**
  35208. * Defines that engine should ignore context lost events
  35209. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  35210. */
  35211. doNotHandleContextLost?: boolean;
  35212. /**
  35213. * Defines that engine should ignore modifying touch action attribute and style
  35214. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  35215. */
  35216. doNotHandleTouchAction?: boolean;
  35217. /**
  35218. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  35219. */
  35220. useHighPrecisionFloats?: boolean;
  35221. }
  35222. /**
  35223. * The base engine class (root of all engines)
  35224. */
  35225. export class ThinEngine {
  35226. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  35227. static ExceptionList: ({
  35228. key: string;
  35229. capture: string;
  35230. captureConstraint: number;
  35231. targets: string[];
  35232. } | {
  35233. key: string;
  35234. capture: null;
  35235. captureConstraint: null;
  35236. targets: string[];
  35237. })[];
  35238. /** @hidden */
  35239. static _TextureLoaders: IInternalTextureLoader[];
  35240. /**
  35241. * Returns the current npm package of the sdk
  35242. */
  35243. static get NpmPackage(): string;
  35244. /**
  35245. * Returns the current version of the framework
  35246. */
  35247. static get Version(): string;
  35248. /**
  35249. * Returns a string describing the current engine
  35250. */
  35251. get description(): string;
  35252. /**
  35253. * Gets or sets the epsilon value used by collision engine
  35254. */
  35255. static CollisionsEpsilon: number;
  35256. /**
  35257. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  35258. */
  35259. static get ShadersRepository(): string;
  35260. static set ShadersRepository(value: string);
  35261. /** @hidden */
  35262. _shaderProcessor: IShaderProcessor;
  35263. /**
  35264. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  35265. */
  35266. forcePOTTextures: boolean;
  35267. /**
  35268. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  35269. */
  35270. isFullscreen: boolean;
  35271. /**
  35272. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  35273. */
  35274. cullBackFaces: boolean;
  35275. /**
  35276. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  35277. */
  35278. renderEvenInBackground: boolean;
  35279. /**
  35280. * Gets or sets a boolean indicating that cache can be kept between frames
  35281. */
  35282. preventCacheWipeBetweenFrames: boolean;
  35283. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  35284. validateShaderPrograms: boolean;
  35285. /**
  35286. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  35287. * This can provide greater z depth for distant objects.
  35288. */
  35289. useReverseDepthBuffer: boolean;
  35290. /**
  35291. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  35292. */
  35293. disableUniformBuffers: boolean;
  35294. /** @hidden */
  35295. _uniformBuffers: UniformBuffer[];
  35296. /**
  35297. * Gets a boolean indicating that the engine supports uniform buffers
  35298. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  35299. */
  35300. get supportsUniformBuffers(): boolean;
  35301. /** @hidden */
  35302. _gl: WebGLRenderingContext;
  35303. /** @hidden */
  35304. _webGLVersion: number;
  35305. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  35306. protected _windowIsBackground: boolean;
  35307. protected _creationOptions: EngineOptions;
  35308. protected _highPrecisionShadersAllowed: boolean;
  35309. /** @hidden */
  35310. get _shouldUseHighPrecisionShader(): boolean;
  35311. /**
  35312. * Gets a boolean indicating that only power of 2 textures are supported
  35313. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  35314. */
  35315. get needPOTTextures(): boolean;
  35316. /** @hidden */
  35317. _badOS: boolean;
  35318. /** @hidden */
  35319. _badDesktopOS: boolean;
  35320. private _hardwareScalingLevel;
  35321. /** @hidden */
  35322. _caps: EngineCapabilities;
  35323. private _isStencilEnable;
  35324. private _glVersion;
  35325. private _glRenderer;
  35326. private _glVendor;
  35327. /** @hidden */
  35328. _videoTextureSupported: boolean;
  35329. protected _renderingQueueLaunched: boolean;
  35330. protected _activeRenderLoops: (() => void)[];
  35331. /**
  35332. * Observable signaled when a context lost event is raised
  35333. */
  35334. onContextLostObservable: Observable<ThinEngine>;
  35335. /**
  35336. * Observable signaled when a context restored event is raised
  35337. */
  35338. onContextRestoredObservable: Observable<ThinEngine>;
  35339. private _onContextLost;
  35340. private _onContextRestored;
  35341. protected _contextWasLost: boolean;
  35342. /** @hidden */
  35343. _doNotHandleContextLost: boolean;
  35344. /**
  35345. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  35346. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  35347. */
  35348. get doNotHandleContextLost(): boolean;
  35349. set doNotHandleContextLost(value: boolean);
  35350. /**
  35351. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  35352. */
  35353. disableVertexArrayObjects: boolean;
  35354. /** @hidden */
  35355. protected _colorWrite: boolean;
  35356. /** @hidden */
  35357. protected _colorWriteChanged: boolean;
  35358. /** @hidden */
  35359. protected _depthCullingState: DepthCullingState;
  35360. /** @hidden */
  35361. protected _stencilState: StencilState;
  35362. /** @hidden */
  35363. _alphaState: AlphaState;
  35364. /** @hidden */
  35365. _alphaMode: number;
  35366. /** @hidden */
  35367. _alphaEquation: number;
  35368. /** @hidden */
  35369. _internalTexturesCache: InternalTexture[];
  35370. /** @hidden */
  35371. protected _activeChannel: number;
  35372. private _currentTextureChannel;
  35373. /** @hidden */
  35374. protected _boundTexturesCache: {
  35375. [key: string]: Nullable<InternalTexture>;
  35376. };
  35377. /** @hidden */
  35378. protected _currentEffect: Nullable<Effect>;
  35379. /** @hidden */
  35380. protected _currentProgram: Nullable<WebGLProgram>;
  35381. private _compiledEffects;
  35382. private _vertexAttribArraysEnabled;
  35383. /** @hidden */
  35384. protected _cachedViewport: Nullable<IViewportLike>;
  35385. private _cachedVertexArrayObject;
  35386. /** @hidden */
  35387. protected _cachedVertexBuffers: any;
  35388. /** @hidden */
  35389. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  35390. /** @hidden */
  35391. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  35392. /** @hidden */
  35393. _currentRenderTarget: Nullable<InternalTexture>;
  35394. private _uintIndicesCurrentlySet;
  35395. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  35396. /** @hidden */
  35397. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  35398. /** @hidden */
  35399. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  35400. private _currentBufferPointers;
  35401. private _currentInstanceLocations;
  35402. private _currentInstanceBuffers;
  35403. private _textureUnits;
  35404. /** @hidden */
  35405. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  35406. /** @hidden */
  35407. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  35408. /** @hidden */
  35409. _boundRenderFunction: any;
  35410. private _vaoRecordInProgress;
  35411. private _mustWipeVertexAttributes;
  35412. private _emptyTexture;
  35413. private _emptyCubeTexture;
  35414. private _emptyTexture3D;
  35415. private _emptyTexture2DArray;
  35416. /** @hidden */
  35417. _frameHandler: number;
  35418. private _nextFreeTextureSlots;
  35419. private _maxSimultaneousTextures;
  35420. private _activeRequests;
  35421. /** @hidden */
  35422. _transformTextureUrl: Nullable<(url: string) => string>;
  35423. protected get _supportsHardwareTextureRescaling(): boolean;
  35424. private _framebufferDimensionsObject;
  35425. /**
  35426. * sets the object from which width and height will be taken from when getting render width and height
  35427. * Will fallback to the gl object
  35428. * @param dimensions the framebuffer width and height that will be used.
  35429. */
  35430. set framebufferDimensionsObject(dimensions: Nullable<{
  35431. framebufferWidth: number;
  35432. framebufferHeight: number;
  35433. }>);
  35434. /**
  35435. * Gets the current viewport
  35436. */
  35437. get currentViewport(): Nullable<IViewportLike>;
  35438. /**
  35439. * Gets the default empty texture
  35440. */
  35441. get emptyTexture(): InternalTexture;
  35442. /**
  35443. * Gets the default empty 3D texture
  35444. */
  35445. get emptyTexture3D(): InternalTexture;
  35446. /**
  35447. * Gets the default empty 2D array texture
  35448. */
  35449. get emptyTexture2DArray(): InternalTexture;
  35450. /**
  35451. * Gets the default empty cube texture
  35452. */
  35453. get emptyCubeTexture(): InternalTexture;
  35454. /**
  35455. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  35456. */
  35457. readonly premultipliedAlpha: boolean;
  35458. /**
  35459. * Observable event triggered before each texture is initialized
  35460. */
  35461. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  35462. /**
  35463. * Creates a new engine
  35464. * @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
  35465. * @param antialias defines enable antialiasing (default: false)
  35466. * @param options defines further options to be sent to the getContext() function
  35467. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  35468. */
  35469. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  35470. private _rebuildInternalTextures;
  35471. private _rebuildEffects;
  35472. /**
  35473. * Gets a boolean indicating if all created effects are ready
  35474. * @returns true if all effects are ready
  35475. */
  35476. areAllEffectsReady(): boolean;
  35477. protected _rebuildBuffers(): void;
  35478. protected _initGLContext(): void;
  35479. /**
  35480. * Gets version of the current webGL context
  35481. */
  35482. get webGLVersion(): number;
  35483. /**
  35484. * Gets a string idenfifying the name of the class
  35485. * @returns "Engine" string
  35486. */
  35487. getClassName(): string;
  35488. /**
  35489. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  35490. */
  35491. get isStencilEnable(): boolean;
  35492. /** @hidden */
  35493. _prepareWorkingCanvas(): void;
  35494. /**
  35495. * Reset the texture cache to empty state
  35496. */
  35497. resetTextureCache(): void;
  35498. /**
  35499. * Gets an object containing information about the current webGL context
  35500. * @returns an object containing the vender, the renderer and the version of the current webGL context
  35501. */
  35502. getGlInfo(): {
  35503. vendor: string;
  35504. renderer: string;
  35505. version: string;
  35506. };
  35507. /**
  35508. * Defines the hardware scaling level.
  35509. * By default the hardware scaling level is computed from the window device ratio.
  35510. * 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.
  35511. * @param level defines the level to use
  35512. */
  35513. setHardwareScalingLevel(level: number): void;
  35514. /**
  35515. * Gets the current hardware scaling level.
  35516. * By default the hardware scaling level is computed from the window device ratio.
  35517. * 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.
  35518. * @returns a number indicating the current hardware scaling level
  35519. */
  35520. getHardwareScalingLevel(): number;
  35521. /**
  35522. * Gets the list of loaded textures
  35523. * @returns an array containing all loaded textures
  35524. */
  35525. getLoadedTexturesCache(): InternalTexture[];
  35526. /**
  35527. * Gets the object containing all engine capabilities
  35528. * @returns the EngineCapabilities object
  35529. */
  35530. getCaps(): EngineCapabilities;
  35531. /**
  35532. * stop executing a render loop function and remove it from the execution array
  35533. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  35534. */
  35535. stopRenderLoop(renderFunction?: () => void): void;
  35536. /** @hidden */
  35537. _renderLoop(): void;
  35538. /**
  35539. * Gets the HTML canvas attached with the current webGL context
  35540. * @returns a HTML canvas
  35541. */
  35542. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  35543. /**
  35544. * Gets host window
  35545. * @returns the host window object
  35546. */
  35547. getHostWindow(): Nullable<Window>;
  35548. /**
  35549. * Gets the current render width
  35550. * @param useScreen defines if screen size must be used (or the current render target if any)
  35551. * @returns a number defining the current render width
  35552. */
  35553. getRenderWidth(useScreen?: boolean): number;
  35554. /**
  35555. * Gets the current render height
  35556. * @param useScreen defines if screen size must be used (or the current render target if any)
  35557. * @returns a number defining the current render height
  35558. */
  35559. getRenderHeight(useScreen?: boolean): number;
  35560. /**
  35561. * Can be used to override the current requestAnimationFrame requester.
  35562. * @hidden
  35563. */
  35564. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  35565. /**
  35566. * Register and execute a render loop. The engine can have more than one render function
  35567. * @param renderFunction defines the function to continuously execute
  35568. */
  35569. runRenderLoop(renderFunction: () => void): void;
  35570. /**
  35571. * Clear the current render buffer or the current render target (if any is set up)
  35572. * @param color defines the color to use
  35573. * @param backBuffer defines if the back buffer must be cleared
  35574. * @param depth defines if the depth buffer must be cleared
  35575. * @param stencil defines if the stencil buffer must be cleared
  35576. */
  35577. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  35578. private _viewportCached;
  35579. /** @hidden */
  35580. _viewport(x: number, y: number, width: number, height: number): void;
  35581. /**
  35582. * Set the WebGL's viewport
  35583. * @param viewport defines the viewport element to be used
  35584. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  35585. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  35586. */
  35587. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  35588. /**
  35589. * Begin a new frame
  35590. */
  35591. beginFrame(): void;
  35592. /**
  35593. * Enf the current frame
  35594. */
  35595. endFrame(): void;
  35596. /**
  35597. * Resize the view according to the canvas' size
  35598. */
  35599. resize(): void;
  35600. /**
  35601. * Force a specific size of the canvas
  35602. * @param width defines the new canvas' width
  35603. * @param height defines the new canvas' height
  35604. */
  35605. setSize(width: number, height: number): void;
  35606. /**
  35607. * Binds the frame buffer to the specified texture.
  35608. * @param texture The texture to render to or null for the default canvas
  35609. * @param faceIndex The face of the texture to render to in case of cube texture
  35610. * @param requiredWidth The width of the target to render to
  35611. * @param requiredHeight The height of the target to render to
  35612. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  35613. * @param lodLevel defines the lod level to bind to the frame buffer
  35614. * @param layer defines the 2d array index to bind to frame buffer to
  35615. */
  35616. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  35617. /** @hidden */
  35618. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  35619. /**
  35620. * Unbind the current render target texture from the webGL context
  35621. * @param texture defines the render target texture to unbind
  35622. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  35623. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  35624. */
  35625. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  35626. /**
  35627. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  35628. */
  35629. flushFramebuffer(): void;
  35630. /**
  35631. * Unbind the current render target and bind the default framebuffer
  35632. */
  35633. restoreDefaultFramebuffer(): void;
  35634. /** @hidden */
  35635. protected _resetVertexBufferBinding(): void;
  35636. /**
  35637. * Creates a vertex buffer
  35638. * @param data the data for the vertex buffer
  35639. * @returns the new WebGL static buffer
  35640. */
  35641. createVertexBuffer(data: DataArray): DataBuffer;
  35642. private _createVertexBuffer;
  35643. /**
  35644. * Creates a dynamic vertex buffer
  35645. * @param data the data for the dynamic vertex buffer
  35646. * @returns the new WebGL dynamic buffer
  35647. */
  35648. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  35649. protected _resetIndexBufferBinding(): void;
  35650. /**
  35651. * Creates a new index buffer
  35652. * @param indices defines the content of the index buffer
  35653. * @param updatable defines if the index buffer must be updatable
  35654. * @returns a new webGL buffer
  35655. */
  35656. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  35657. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  35658. /**
  35659. * Bind a webGL buffer to the webGL context
  35660. * @param buffer defines the buffer to bind
  35661. */
  35662. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  35663. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  35664. private bindBuffer;
  35665. /**
  35666. * update the bound buffer with the given data
  35667. * @param data defines the data to update
  35668. */
  35669. updateArrayBuffer(data: Float32Array): void;
  35670. private _vertexAttribPointer;
  35671. /** @hidden */
  35672. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  35673. private _bindVertexBuffersAttributes;
  35674. /**
  35675. * Records a vertex array object
  35676. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  35677. * @param vertexBuffers defines the list of vertex buffers to store
  35678. * @param indexBuffer defines the index buffer to store
  35679. * @param effect defines the effect to store
  35680. * @returns the new vertex array object
  35681. */
  35682. recordVertexArrayObject(vertexBuffers: {
  35683. [key: string]: VertexBuffer;
  35684. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  35685. /**
  35686. * Bind a specific vertex array object
  35687. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  35688. * @param vertexArrayObject defines the vertex array object to bind
  35689. * @param indexBuffer defines the index buffer to bind
  35690. */
  35691. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  35692. /**
  35693. * Bind webGl buffers directly to the webGL context
  35694. * @param vertexBuffer defines the vertex buffer to bind
  35695. * @param indexBuffer defines the index buffer to bind
  35696. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  35697. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  35698. * @param effect defines the effect associated with the vertex buffer
  35699. */
  35700. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  35701. private _unbindVertexArrayObject;
  35702. /**
  35703. * Bind a list of vertex buffers to the webGL context
  35704. * @param vertexBuffers defines the list of vertex buffers to bind
  35705. * @param indexBuffer defines the index buffer to bind
  35706. * @param effect defines the effect associated with the vertex buffers
  35707. */
  35708. bindBuffers(vertexBuffers: {
  35709. [key: string]: Nullable<VertexBuffer>;
  35710. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  35711. /**
  35712. * Unbind all instance attributes
  35713. */
  35714. unbindInstanceAttributes(): void;
  35715. /**
  35716. * Release and free the memory of a vertex array object
  35717. * @param vao defines the vertex array object to delete
  35718. */
  35719. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  35720. /** @hidden */
  35721. _releaseBuffer(buffer: DataBuffer): boolean;
  35722. protected _deleteBuffer(buffer: DataBuffer): void;
  35723. /**
  35724. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  35725. * @param instancesBuffer defines the webGL buffer to update and bind
  35726. * @param data defines the data to store in the buffer
  35727. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  35728. */
  35729. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  35730. /**
  35731. * Bind the content of a webGL buffer used with instantiation
  35732. * @param instancesBuffer defines the webGL buffer to bind
  35733. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  35734. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  35735. */
  35736. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  35737. /**
  35738. * Disable the instance attribute corresponding to the name in parameter
  35739. * @param name defines the name of the attribute to disable
  35740. */
  35741. disableInstanceAttributeByName(name: string): void;
  35742. /**
  35743. * Disable the instance attribute corresponding to the location in parameter
  35744. * @param attributeLocation defines the attribute location of the attribute to disable
  35745. */
  35746. disableInstanceAttribute(attributeLocation: number): void;
  35747. /**
  35748. * Disable the attribute corresponding to the location in parameter
  35749. * @param attributeLocation defines the attribute location of the attribute to disable
  35750. */
  35751. disableAttributeByIndex(attributeLocation: number): void;
  35752. /**
  35753. * Send a draw order
  35754. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  35755. * @param indexStart defines the starting index
  35756. * @param indexCount defines the number of index to draw
  35757. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35758. */
  35759. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  35760. /**
  35761. * Draw a list of points
  35762. * @param verticesStart defines the index of first vertex to draw
  35763. * @param verticesCount defines the count of vertices to draw
  35764. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35765. */
  35766. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35767. /**
  35768. * Draw a list of unindexed primitives
  35769. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  35770. * @param verticesStart defines the index of first vertex to draw
  35771. * @param verticesCount defines the count of vertices to draw
  35772. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35773. */
  35774. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35775. /**
  35776. * Draw a list of indexed primitives
  35777. * @param fillMode defines the primitive to use
  35778. * @param indexStart defines the starting index
  35779. * @param indexCount defines the number of index to draw
  35780. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35781. */
  35782. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  35783. /**
  35784. * Draw a list of unindexed primitives
  35785. * @param fillMode defines the primitive to use
  35786. * @param verticesStart defines the index of first vertex to draw
  35787. * @param verticesCount defines the count of vertices to draw
  35788. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35789. */
  35790. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35791. private _drawMode;
  35792. /** @hidden */
  35793. protected _reportDrawCall(): void;
  35794. /** @hidden */
  35795. _releaseEffect(effect: Effect): void;
  35796. /** @hidden */
  35797. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  35798. /**
  35799. * Create a new effect (used to store vertex/fragment shaders)
  35800. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  35801. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  35802. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  35803. * @param samplers defines an array of string used to represent textures
  35804. * @param defines defines the string containing the defines to use to compile the shaders
  35805. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  35806. * @param onCompiled defines a function to call when the effect creation is successful
  35807. * @param onError defines a function to call when the effect creation has failed
  35808. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  35809. * @returns the new Effect
  35810. */
  35811. 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;
  35812. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  35813. private _compileShader;
  35814. private _compileRawShader;
  35815. /** @hidden */
  35816. _getShaderSource(shader: WebGLShader): Nullable<string>;
  35817. /**
  35818. * Directly creates a webGL program
  35819. * @param pipelineContext defines the pipeline context to attach to
  35820. * @param vertexCode defines the vertex shader code to use
  35821. * @param fragmentCode defines the fragment shader code to use
  35822. * @param context defines the webGL context to use (if not set, the current one will be used)
  35823. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  35824. * @returns the new webGL program
  35825. */
  35826. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35827. /**
  35828. * Creates a webGL program
  35829. * @param pipelineContext defines the pipeline context to attach to
  35830. * @param vertexCode defines the vertex shader code to use
  35831. * @param fragmentCode defines the fragment shader code to use
  35832. * @param defines defines the string containing the defines to use to compile the shaders
  35833. * @param context defines the webGL context to use (if not set, the current one will be used)
  35834. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  35835. * @returns the new webGL program
  35836. */
  35837. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35838. /**
  35839. * Creates a new pipeline context
  35840. * @returns the new pipeline
  35841. */
  35842. createPipelineContext(): IPipelineContext;
  35843. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35844. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  35845. /** @hidden */
  35846. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  35847. /** @hidden */
  35848. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  35849. /** @hidden */
  35850. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  35851. /**
  35852. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  35853. * @param pipelineContext defines the pipeline context to use
  35854. * @param uniformsNames defines the list of uniform names
  35855. * @returns an array of webGL uniform locations
  35856. */
  35857. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  35858. /**
  35859. * Gets the lsit of active attributes for a given webGL program
  35860. * @param pipelineContext defines the pipeline context to use
  35861. * @param attributesNames defines the list of attribute names to get
  35862. * @returns an array of indices indicating the offset of each attribute
  35863. */
  35864. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  35865. /**
  35866. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  35867. * @param effect defines the effect to activate
  35868. */
  35869. enableEffect(effect: Nullable<Effect>): void;
  35870. /**
  35871. * Set the value of an uniform to a number (int)
  35872. * @param uniform defines the webGL uniform location where to store the value
  35873. * @param value defines the int number to store
  35874. */
  35875. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  35876. /**
  35877. * Set the value of an uniform to an array of int32
  35878. * @param uniform defines the webGL uniform location where to store the value
  35879. * @param array defines the array of int32 to store
  35880. */
  35881. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35882. /**
  35883. * Set the value of an uniform to an array of int32 (stored as vec2)
  35884. * @param uniform defines the webGL uniform location where to store the value
  35885. * @param array defines the array of int32 to store
  35886. */
  35887. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35888. /**
  35889. * Set the value of an uniform to an array of int32 (stored as vec3)
  35890. * @param uniform defines the webGL uniform location where to store the value
  35891. * @param array defines the array of int32 to store
  35892. */
  35893. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35894. /**
  35895. * Set the value of an uniform to an array of int32 (stored as vec4)
  35896. * @param uniform defines the webGL uniform location where to store the value
  35897. * @param array defines the array of int32 to store
  35898. */
  35899. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35900. /**
  35901. * Set the value of an uniform to an array of number
  35902. * @param uniform defines the webGL uniform location where to store the value
  35903. * @param array defines the array of number to store
  35904. */
  35905. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35906. /**
  35907. * Set the value of an uniform to an array of number (stored as vec2)
  35908. * @param uniform defines the webGL uniform location where to store the value
  35909. * @param array defines the array of number to store
  35910. */
  35911. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35912. /**
  35913. * Set the value of an uniform to an array of number (stored as vec3)
  35914. * @param uniform defines the webGL uniform location where to store the value
  35915. * @param array defines the array of number to store
  35916. */
  35917. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35918. /**
  35919. * Set the value of an uniform to an array of number (stored as vec4)
  35920. * @param uniform defines the webGL uniform location where to store the value
  35921. * @param array defines the array of number to store
  35922. */
  35923. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35924. /**
  35925. * Set the value of an uniform to an array of float32 (stored as matrices)
  35926. * @param uniform defines the webGL uniform location where to store the value
  35927. * @param matrices defines the array of float32 to store
  35928. */
  35929. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  35930. /**
  35931. * Set the value of an uniform to a matrix (3x3)
  35932. * @param uniform defines the webGL uniform location where to store the value
  35933. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  35934. */
  35935. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  35936. /**
  35937. * Set the value of an uniform to a matrix (2x2)
  35938. * @param uniform defines the webGL uniform location where to store the value
  35939. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  35940. */
  35941. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  35942. /**
  35943. * Set the value of an uniform to a number (float)
  35944. * @param uniform defines the webGL uniform location where to store the value
  35945. * @param value defines the float number to store
  35946. */
  35947. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  35948. /**
  35949. * Set the value of an uniform to a vec2
  35950. * @param uniform defines the webGL uniform location where to store the value
  35951. * @param x defines the 1st component of the value
  35952. * @param y defines the 2nd component of the value
  35953. */
  35954. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  35955. /**
  35956. * Set the value of an uniform to a vec3
  35957. * @param uniform defines the webGL uniform location where to store the value
  35958. * @param x defines the 1st component of the value
  35959. * @param y defines the 2nd component of the value
  35960. * @param z defines the 3rd component of the value
  35961. */
  35962. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  35963. /**
  35964. * Set the value of an uniform to a vec4
  35965. * @param uniform defines the webGL uniform location where to store the value
  35966. * @param x defines the 1st component of the value
  35967. * @param y defines the 2nd component of the value
  35968. * @param z defines the 3rd component of the value
  35969. * @param w defines the 4th component of the value
  35970. */
  35971. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  35972. /**
  35973. * Apply all cached states (depth, culling, stencil and alpha)
  35974. */
  35975. applyStates(): void;
  35976. /**
  35977. * Enable or disable color writing
  35978. * @param enable defines the state to set
  35979. */
  35980. setColorWrite(enable: boolean): void;
  35981. /**
  35982. * Gets a boolean indicating if color writing is enabled
  35983. * @returns the current color writing state
  35984. */
  35985. getColorWrite(): boolean;
  35986. /**
  35987. * Gets the depth culling state manager
  35988. */
  35989. get depthCullingState(): DepthCullingState;
  35990. /**
  35991. * Gets the alpha state manager
  35992. */
  35993. get alphaState(): AlphaState;
  35994. /**
  35995. * Gets the stencil state manager
  35996. */
  35997. get stencilState(): StencilState;
  35998. /**
  35999. * Clears the list of texture accessible through engine.
  36000. * This can help preventing texture load conflict due to name collision.
  36001. */
  36002. clearInternalTexturesCache(): void;
  36003. /**
  36004. * Force the entire cache to be cleared
  36005. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  36006. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  36007. */
  36008. wipeCaches(bruteForce?: boolean): void;
  36009. /** @hidden */
  36010. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  36011. min: number;
  36012. mag: number;
  36013. };
  36014. /** @hidden */
  36015. _createTexture(): WebGLTexture;
  36016. /**
  36017. * Usually called from Texture.ts.
  36018. * Passed information to create a WebGLTexture
  36019. * @param url defines a value which contains one of the following:
  36020. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  36021. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  36022. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  36023. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  36024. * @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)
  36025. * @param scene needed for loading to the correct scene
  36026. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  36027. * @param onLoad optional callback to be called upon successful completion
  36028. * @param onError optional callback to be called upon failure
  36029. * @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
  36030. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  36031. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  36032. * @param forcedExtension defines the extension to use to pick the right loader
  36033. * @param mimeType defines an optional mime type
  36034. * @returns a InternalTexture for assignment back into BABYLON.Texture
  36035. */
  36036. 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;
  36037. /**
  36038. * Loads an image as an HTMLImageElement.
  36039. * @param input url string, ArrayBuffer, or Blob to load
  36040. * @param onLoad callback called when the image successfully loads
  36041. * @param onError callback called when the image fails to load
  36042. * @param offlineProvider offline provider for caching
  36043. * @param mimeType optional mime type
  36044. * @returns the HTMLImageElement of the loaded image
  36045. * @hidden
  36046. */
  36047. 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>;
  36048. /**
  36049. * @hidden
  36050. */
  36051. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  36052. private _unpackFlipYCached;
  36053. /**
  36054. * In case you are sharing the context with other applications, it might
  36055. * be interested to not cache the unpack flip y state to ensure a consistent
  36056. * value would be set.
  36057. */
  36058. enableUnpackFlipYCached: boolean;
  36059. /** @hidden */
  36060. _unpackFlipY(value: boolean): void;
  36061. /** @hidden */
  36062. _getUnpackAlignement(): number;
  36063. private _getTextureTarget;
  36064. /**
  36065. * Update the sampling mode of a given texture
  36066. * @param samplingMode defines the required sampling mode
  36067. * @param texture defines the texture to update
  36068. * @param generateMipMaps defines whether to generate mipmaps for the texture
  36069. */
  36070. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  36071. /**
  36072. * Update the sampling mode of a given texture
  36073. * @param texture defines the texture to update
  36074. * @param wrapU defines the texture wrap mode of the u coordinates
  36075. * @param wrapV defines the texture wrap mode of the v coordinates
  36076. * @param wrapR defines the texture wrap mode of the r coordinates
  36077. */
  36078. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  36079. /** @hidden */
  36080. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  36081. width: number;
  36082. height: number;
  36083. layers?: number;
  36084. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  36085. /** @hidden */
  36086. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  36087. /** @hidden */
  36088. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  36089. /**
  36090. * Update a portion of an internal texture
  36091. * @param texture defines the texture to update
  36092. * @param imageData defines the data to store into the texture
  36093. * @param xOffset defines the x coordinates of the update rectangle
  36094. * @param yOffset defines the y coordinates of the update rectangle
  36095. * @param width defines the width of the update rectangle
  36096. * @param height defines the height of the update rectangle
  36097. * @param faceIndex defines the face index if texture is a cube (0 by default)
  36098. * @param lod defines the lod level to update (0 by default)
  36099. */
  36100. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  36101. /** @hidden */
  36102. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  36103. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  36104. private _prepareWebGLTexture;
  36105. /** @hidden */
  36106. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  36107. private _getDepthStencilBuffer;
  36108. /** @hidden */
  36109. _releaseFramebufferObjects(texture: InternalTexture): void;
  36110. /** @hidden */
  36111. _releaseTexture(texture: InternalTexture): void;
  36112. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  36113. protected _setProgram(program: WebGLProgram): void;
  36114. protected _boundUniforms: {
  36115. [key: number]: WebGLUniformLocation;
  36116. };
  36117. /**
  36118. * Binds an effect to the webGL context
  36119. * @param effect defines the effect to bind
  36120. */
  36121. bindSamplers(effect: Effect): void;
  36122. private _activateCurrentTexture;
  36123. /** @hidden */
  36124. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  36125. /** @hidden */
  36126. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  36127. /**
  36128. * Unbind all textures from the webGL context
  36129. */
  36130. unbindAllTextures(): void;
  36131. /**
  36132. * Sets a texture to the according uniform.
  36133. * @param channel The texture channel
  36134. * @param uniform The uniform to set
  36135. * @param texture The texture to apply
  36136. */
  36137. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  36138. private _bindSamplerUniformToChannel;
  36139. private _getTextureWrapMode;
  36140. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  36141. /**
  36142. * Sets an array of texture to the webGL context
  36143. * @param channel defines the channel where the texture array must be set
  36144. * @param uniform defines the associated uniform location
  36145. * @param textures defines the array of textures to bind
  36146. */
  36147. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  36148. /** @hidden */
  36149. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  36150. private _setTextureParameterFloat;
  36151. private _setTextureParameterInteger;
  36152. /**
  36153. * Unbind all vertex attributes from the webGL context
  36154. */
  36155. unbindAllAttributes(): void;
  36156. /**
  36157. * 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
  36158. */
  36159. releaseEffects(): void;
  36160. /**
  36161. * Dispose and release all associated resources
  36162. */
  36163. dispose(): void;
  36164. /**
  36165. * Attach a new callback raised when context lost event is fired
  36166. * @param callback defines the callback to call
  36167. */
  36168. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  36169. /**
  36170. * Attach a new callback raised when context restored event is fired
  36171. * @param callback defines the callback to call
  36172. */
  36173. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  36174. /**
  36175. * Get the current error code of the webGL context
  36176. * @returns the error code
  36177. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  36178. */
  36179. getError(): number;
  36180. private _canRenderToFloatFramebuffer;
  36181. private _canRenderToHalfFloatFramebuffer;
  36182. private _canRenderToFramebuffer;
  36183. /** @hidden */
  36184. _getWebGLTextureType(type: number): number;
  36185. /** @hidden */
  36186. _getInternalFormat(format: number): number;
  36187. /** @hidden */
  36188. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  36189. /** @hidden */
  36190. _getRGBAMultiSampleBufferFormat(type: number): number;
  36191. /** @hidden */
  36192. _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;
  36193. /**
  36194. * Loads a file from a url
  36195. * @param url url to load
  36196. * @param onSuccess callback called when the file successfully loads
  36197. * @param onProgress callback called while file is loading (if the server supports this mode)
  36198. * @param offlineProvider defines the offline provider for caching
  36199. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  36200. * @param onError callback called when the file fails to load
  36201. * @returns a file request object
  36202. * @hidden
  36203. */
  36204. 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;
  36205. /**
  36206. * Reads pixels from the current frame buffer. Please note that this function can be slow
  36207. * @param x defines the x coordinate of the rectangle where pixels must be read
  36208. * @param y defines the y coordinate of the rectangle where pixels must be read
  36209. * @param width defines the width of the rectangle where pixels must be read
  36210. * @param height defines the height of the rectangle where pixels must be read
  36211. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  36212. * @returns a Uint8Array containing RGBA colors
  36213. */
  36214. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  36215. private static _isSupported;
  36216. /**
  36217. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  36218. * @returns true if the engine can be created
  36219. * @ignorenaming
  36220. */
  36221. static isSupported(): boolean;
  36222. /**
  36223. * Find the next highest power of two.
  36224. * @param x Number to start search from.
  36225. * @return Next highest power of two.
  36226. */
  36227. static CeilingPOT(x: number): number;
  36228. /**
  36229. * Find the next lowest power of two.
  36230. * @param x Number to start search from.
  36231. * @return Next lowest power of two.
  36232. */
  36233. static FloorPOT(x: number): number;
  36234. /**
  36235. * Find the nearest power of two.
  36236. * @param x Number to start search from.
  36237. * @return Next nearest power of two.
  36238. */
  36239. static NearestPOT(x: number): number;
  36240. /**
  36241. * Get the closest exponent of two
  36242. * @param value defines the value to approximate
  36243. * @param max defines the maximum value to return
  36244. * @param mode defines how to define the closest value
  36245. * @returns closest exponent of two of the given value
  36246. */
  36247. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  36248. /**
  36249. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  36250. * @param func - the function to be called
  36251. * @param requester - the object that will request the next frame. Falls back to window.
  36252. * @returns frame number
  36253. */
  36254. static QueueNewFrame(func: () => void, requester?: any): number;
  36255. /**
  36256. * Gets host document
  36257. * @returns the host document object
  36258. */
  36259. getHostDocument(): Nullable<Document>;
  36260. }
  36261. }
  36262. declare module "babylonjs/Maths/sphericalPolynomial" {
  36263. import { Vector3 } from "babylonjs/Maths/math.vector";
  36264. import { Color3 } from "babylonjs/Maths/math.color";
  36265. /**
  36266. * Class representing spherical harmonics coefficients to the 3rd degree
  36267. */
  36268. export class SphericalHarmonics {
  36269. /**
  36270. * Defines whether or not the harmonics have been prescaled for rendering.
  36271. */
  36272. preScaled: boolean;
  36273. /**
  36274. * The l0,0 coefficients of the spherical harmonics
  36275. */
  36276. l00: Vector3;
  36277. /**
  36278. * The l1,-1 coefficients of the spherical harmonics
  36279. */
  36280. l1_1: Vector3;
  36281. /**
  36282. * The l1,0 coefficients of the spherical harmonics
  36283. */
  36284. l10: Vector3;
  36285. /**
  36286. * The l1,1 coefficients of the spherical harmonics
  36287. */
  36288. l11: Vector3;
  36289. /**
  36290. * The l2,-2 coefficients of the spherical harmonics
  36291. */
  36292. l2_2: Vector3;
  36293. /**
  36294. * The l2,-1 coefficients of the spherical harmonics
  36295. */
  36296. l2_1: Vector3;
  36297. /**
  36298. * The l2,0 coefficients of the spherical harmonics
  36299. */
  36300. l20: Vector3;
  36301. /**
  36302. * The l2,1 coefficients of the spherical harmonics
  36303. */
  36304. l21: Vector3;
  36305. /**
  36306. * The l2,2 coefficients of the spherical harmonics
  36307. */
  36308. l22: Vector3;
  36309. /**
  36310. * Adds a light to the spherical harmonics
  36311. * @param direction the direction of the light
  36312. * @param color the color of the light
  36313. * @param deltaSolidAngle the delta solid angle of the light
  36314. */
  36315. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  36316. /**
  36317. * Scales the spherical harmonics by the given amount
  36318. * @param scale the amount to scale
  36319. */
  36320. scaleInPlace(scale: number): void;
  36321. /**
  36322. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  36323. *
  36324. * ```
  36325. * E_lm = A_l * L_lm
  36326. * ```
  36327. *
  36328. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  36329. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  36330. * the scaling factors are given in equation 9.
  36331. */
  36332. convertIncidentRadianceToIrradiance(): void;
  36333. /**
  36334. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  36335. *
  36336. * ```
  36337. * L = (1/pi) * E * rho
  36338. * ```
  36339. *
  36340. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  36341. */
  36342. convertIrradianceToLambertianRadiance(): void;
  36343. /**
  36344. * Integrates the reconstruction coefficients directly in to the SH preventing further
  36345. * required operations at run time.
  36346. *
  36347. * This is simply done by scaling back the SH with Ylm constants parameter.
  36348. * The trigonometric part being applied by the shader at run time.
  36349. */
  36350. preScaleForRendering(): void;
  36351. /**
  36352. * Constructs a spherical harmonics from an array.
  36353. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  36354. * @returns the spherical harmonics
  36355. */
  36356. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  36357. /**
  36358. * Gets the spherical harmonics from polynomial
  36359. * @param polynomial the spherical polynomial
  36360. * @returns the spherical harmonics
  36361. */
  36362. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  36363. }
  36364. /**
  36365. * Class representing spherical polynomial coefficients to the 3rd degree
  36366. */
  36367. export class SphericalPolynomial {
  36368. private _harmonics;
  36369. /**
  36370. * The spherical harmonics used to create the polynomials.
  36371. */
  36372. get preScaledHarmonics(): SphericalHarmonics;
  36373. /**
  36374. * The x coefficients of the spherical polynomial
  36375. */
  36376. x: Vector3;
  36377. /**
  36378. * The y coefficients of the spherical polynomial
  36379. */
  36380. y: Vector3;
  36381. /**
  36382. * The z coefficients of the spherical polynomial
  36383. */
  36384. z: Vector3;
  36385. /**
  36386. * The xx coefficients of the spherical polynomial
  36387. */
  36388. xx: Vector3;
  36389. /**
  36390. * The yy coefficients of the spherical polynomial
  36391. */
  36392. yy: Vector3;
  36393. /**
  36394. * The zz coefficients of the spherical polynomial
  36395. */
  36396. zz: Vector3;
  36397. /**
  36398. * The xy coefficients of the spherical polynomial
  36399. */
  36400. xy: Vector3;
  36401. /**
  36402. * The yz coefficients of the spherical polynomial
  36403. */
  36404. yz: Vector3;
  36405. /**
  36406. * The zx coefficients of the spherical polynomial
  36407. */
  36408. zx: Vector3;
  36409. /**
  36410. * Adds an ambient color to the spherical polynomial
  36411. * @param color the color to add
  36412. */
  36413. addAmbient(color: Color3): void;
  36414. /**
  36415. * Scales the spherical polynomial by the given amount
  36416. * @param scale the amount to scale
  36417. */
  36418. scaleInPlace(scale: number): void;
  36419. /**
  36420. * Gets the spherical polynomial from harmonics
  36421. * @param harmonics the spherical harmonics
  36422. * @returns the spherical polynomial
  36423. */
  36424. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  36425. /**
  36426. * Constructs a spherical polynomial from an array.
  36427. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  36428. * @returns the spherical polynomial
  36429. */
  36430. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  36431. }
  36432. }
  36433. declare module "babylonjs/Materials/Textures/internalTexture" {
  36434. import { Observable } from "babylonjs/Misc/observable";
  36435. import { Nullable, int } from "babylonjs/types";
  36436. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  36437. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36438. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  36439. /**
  36440. * Defines the source of the internal texture
  36441. */
  36442. export enum InternalTextureSource {
  36443. /**
  36444. * The source of the texture data is unknown
  36445. */
  36446. Unknown = 0,
  36447. /**
  36448. * Texture data comes from an URL
  36449. */
  36450. Url = 1,
  36451. /**
  36452. * Texture data is only used for temporary storage
  36453. */
  36454. Temp = 2,
  36455. /**
  36456. * Texture data comes from raw data (ArrayBuffer)
  36457. */
  36458. Raw = 3,
  36459. /**
  36460. * Texture content is dynamic (video or dynamic texture)
  36461. */
  36462. Dynamic = 4,
  36463. /**
  36464. * Texture content is generated by rendering to it
  36465. */
  36466. RenderTarget = 5,
  36467. /**
  36468. * Texture content is part of a multi render target process
  36469. */
  36470. MultiRenderTarget = 6,
  36471. /**
  36472. * Texture data comes from a cube data file
  36473. */
  36474. Cube = 7,
  36475. /**
  36476. * Texture data comes from a raw cube data
  36477. */
  36478. CubeRaw = 8,
  36479. /**
  36480. * Texture data come from a prefiltered cube data file
  36481. */
  36482. CubePrefiltered = 9,
  36483. /**
  36484. * Texture content is raw 3D data
  36485. */
  36486. Raw3D = 10,
  36487. /**
  36488. * Texture content is raw 2D array data
  36489. */
  36490. Raw2DArray = 11,
  36491. /**
  36492. * Texture content is a depth texture
  36493. */
  36494. Depth = 12,
  36495. /**
  36496. * Texture data comes from a raw cube data encoded with RGBD
  36497. */
  36498. CubeRawRGBD = 13
  36499. }
  36500. /**
  36501. * Class used to store data associated with WebGL texture data for the engine
  36502. * This class should not be used directly
  36503. */
  36504. export class InternalTexture {
  36505. /** @hidden */
  36506. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  36507. /**
  36508. * Defines if the texture is ready
  36509. */
  36510. isReady: boolean;
  36511. /**
  36512. * Defines if the texture is a cube texture
  36513. */
  36514. isCube: boolean;
  36515. /**
  36516. * Defines if the texture contains 3D data
  36517. */
  36518. is3D: boolean;
  36519. /**
  36520. * Defines if the texture contains 2D array data
  36521. */
  36522. is2DArray: boolean;
  36523. /**
  36524. * Defines if the texture contains multiview data
  36525. */
  36526. isMultiview: boolean;
  36527. /**
  36528. * Gets the URL used to load this texture
  36529. */
  36530. url: string;
  36531. /**
  36532. * Gets the sampling mode of the texture
  36533. */
  36534. samplingMode: number;
  36535. /**
  36536. * Gets a boolean indicating if the texture needs mipmaps generation
  36537. */
  36538. generateMipMaps: boolean;
  36539. /**
  36540. * Gets the number of samples used by the texture (WebGL2+ only)
  36541. */
  36542. samples: number;
  36543. /**
  36544. * Gets the type of the texture (int, float...)
  36545. */
  36546. type: number;
  36547. /**
  36548. * Gets the format of the texture (RGB, RGBA...)
  36549. */
  36550. format: number;
  36551. /**
  36552. * Observable called when the texture is loaded
  36553. */
  36554. onLoadedObservable: Observable<InternalTexture>;
  36555. /**
  36556. * Gets the width of the texture
  36557. */
  36558. width: number;
  36559. /**
  36560. * Gets the height of the texture
  36561. */
  36562. height: number;
  36563. /**
  36564. * Gets the depth of the texture
  36565. */
  36566. depth: number;
  36567. /**
  36568. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  36569. */
  36570. baseWidth: number;
  36571. /**
  36572. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  36573. */
  36574. baseHeight: number;
  36575. /**
  36576. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  36577. */
  36578. baseDepth: number;
  36579. /**
  36580. * Gets a boolean indicating if the texture is inverted on Y axis
  36581. */
  36582. invertY: boolean;
  36583. /** @hidden */
  36584. _invertVScale: boolean;
  36585. /** @hidden */
  36586. _associatedChannel: number;
  36587. /** @hidden */
  36588. _source: InternalTextureSource;
  36589. /** @hidden */
  36590. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  36591. /** @hidden */
  36592. _bufferView: Nullable<ArrayBufferView>;
  36593. /** @hidden */
  36594. _bufferViewArray: Nullable<ArrayBufferView[]>;
  36595. /** @hidden */
  36596. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  36597. /** @hidden */
  36598. _size: number;
  36599. /** @hidden */
  36600. _extension: string;
  36601. /** @hidden */
  36602. _files: Nullable<string[]>;
  36603. /** @hidden */
  36604. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  36605. /** @hidden */
  36606. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  36607. /** @hidden */
  36608. _framebuffer: Nullable<WebGLFramebuffer>;
  36609. /** @hidden */
  36610. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  36611. /** @hidden */
  36612. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  36613. /** @hidden */
  36614. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  36615. /** @hidden */
  36616. _attachments: Nullable<number[]>;
  36617. /** @hidden */
  36618. _cachedCoordinatesMode: Nullable<number>;
  36619. /** @hidden */
  36620. _cachedWrapU: Nullable<number>;
  36621. /** @hidden */
  36622. _cachedWrapV: Nullable<number>;
  36623. /** @hidden */
  36624. _cachedWrapR: Nullable<number>;
  36625. /** @hidden */
  36626. _cachedAnisotropicFilteringLevel: Nullable<number>;
  36627. /** @hidden */
  36628. _isDisabled: boolean;
  36629. /** @hidden */
  36630. _compression: Nullable<string>;
  36631. /** @hidden */
  36632. _generateStencilBuffer: boolean;
  36633. /** @hidden */
  36634. _generateDepthBuffer: boolean;
  36635. /** @hidden */
  36636. _comparisonFunction: number;
  36637. /** @hidden */
  36638. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  36639. /** @hidden */
  36640. _lodGenerationScale: number;
  36641. /** @hidden */
  36642. _lodGenerationOffset: number;
  36643. /** @hidden */
  36644. _depthStencilTexture: Nullable<InternalTexture>;
  36645. /** @hidden */
  36646. _colorTextureArray: Nullable<WebGLTexture>;
  36647. /** @hidden */
  36648. _depthStencilTextureArray: Nullable<WebGLTexture>;
  36649. /** @hidden */
  36650. _lodTextureHigh: Nullable<BaseTexture>;
  36651. /** @hidden */
  36652. _lodTextureMid: Nullable<BaseTexture>;
  36653. /** @hidden */
  36654. _lodTextureLow: Nullable<BaseTexture>;
  36655. /** @hidden */
  36656. _isRGBD: boolean;
  36657. /** @hidden */
  36658. _linearSpecularLOD: boolean;
  36659. /** @hidden */
  36660. _irradianceTexture: Nullable<BaseTexture>;
  36661. /** @hidden */
  36662. _webGLTexture: Nullable<WebGLTexture>;
  36663. /** @hidden */
  36664. _references: number;
  36665. private _engine;
  36666. /**
  36667. * Gets the Engine the texture belongs to.
  36668. * @returns The babylon engine
  36669. */
  36670. getEngine(): ThinEngine;
  36671. /**
  36672. * Gets the data source type of the texture
  36673. */
  36674. get source(): InternalTextureSource;
  36675. /**
  36676. * Creates a new InternalTexture
  36677. * @param engine defines the engine to use
  36678. * @param source defines the type of data that will be used
  36679. * @param delayAllocation if the texture allocation should be delayed (default: false)
  36680. */
  36681. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  36682. /**
  36683. * Increments the number of references (ie. the number of Texture that point to it)
  36684. */
  36685. incrementReferences(): void;
  36686. /**
  36687. * Change the size of the texture (not the size of the content)
  36688. * @param width defines the new width
  36689. * @param height defines the new height
  36690. * @param depth defines the new depth (1 by default)
  36691. */
  36692. updateSize(width: int, height: int, depth?: int): void;
  36693. /** @hidden */
  36694. _rebuild(): void;
  36695. /** @hidden */
  36696. _swapAndDie(target: InternalTexture): void;
  36697. /**
  36698. * Dispose the current allocated resources
  36699. */
  36700. dispose(): void;
  36701. }
  36702. }
  36703. declare module "babylonjs/Audio/analyser" {
  36704. import { Scene } from "babylonjs/scene";
  36705. /**
  36706. * Class used to work with sound analyzer using fast fourier transform (FFT)
  36707. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36708. */
  36709. export class Analyser {
  36710. /**
  36711. * Gets or sets the smoothing
  36712. * @ignorenaming
  36713. */
  36714. SMOOTHING: number;
  36715. /**
  36716. * Gets or sets the FFT table size
  36717. * @ignorenaming
  36718. */
  36719. FFT_SIZE: number;
  36720. /**
  36721. * Gets or sets the bar graph amplitude
  36722. * @ignorenaming
  36723. */
  36724. BARGRAPHAMPLITUDE: number;
  36725. /**
  36726. * Gets or sets the position of the debug canvas
  36727. * @ignorenaming
  36728. */
  36729. DEBUGCANVASPOS: {
  36730. x: number;
  36731. y: number;
  36732. };
  36733. /**
  36734. * Gets or sets the debug canvas size
  36735. * @ignorenaming
  36736. */
  36737. DEBUGCANVASSIZE: {
  36738. width: number;
  36739. height: number;
  36740. };
  36741. private _byteFreqs;
  36742. private _byteTime;
  36743. private _floatFreqs;
  36744. private _webAudioAnalyser;
  36745. private _debugCanvas;
  36746. private _debugCanvasContext;
  36747. private _scene;
  36748. private _registerFunc;
  36749. private _audioEngine;
  36750. /**
  36751. * Creates a new analyser
  36752. * @param scene defines hosting scene
  36753. */
  36754. constructor(scene: Scene);
  36755. /**
  36756. * Get the number of data values you will have to play with for the visualization
  36757. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  36758. * @returns a number
  36759. */
  36760. getFrequencyBinCount(): number;
  36761. /**
  36762. * Gets the current frequency data as a byte array
  36763. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  36764. * @returns a Uint8Array
  36765. */
  36766. getByteFrequencyData(): Uint8Array;
  36767. /**
  36768. * Gets the current waveform as a byte array
  36769. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  36770. * @returns a Uint8Array
  36771. */
  36772. getByteTimeDomainData(): Uint8Array;
  36773. /**
  36774. * Gets the current frequency data as a float array
  36775. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  36776. * @returns a Float32Array
  36777. */
  36778. getFloatFrequencyData(): Float32Array;
  36779. /**
  36780. * Renders the debug canvas
  36781. */
  36782. drawDebugCanvas(): void;
  36783. /**
  36784. * Stops rendering the debug canvas and removes it
  36785. */
  36786. stopDebugCanvas(): void;
  36787. /**
  36788. * Connects two audio nodes
  36789. * @param inputAudioNode defines first node to connect
  36790. * @param outputAudioNode defines second node to connect
  36791. */
  36792. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  36793. /**
  36794. * Releases all associated resources
  36795. */
  36796. dispose(): void;
  36797. }
  36798. }
  36799. declare module "babylonjs/Audio/audioEngine" {
  36800. import { IDisposable } from "babylonjs/scene";
  36801. import { Analyser } from "babylonjs/Audio/analyser";
  36802. import { Nullable } from "babylonjs/types";
  36803. import { Observable } from "babylonjs/Misc/observable";
  36804. /**
  36805. * This represents an audio engine and it is responsible
  36806. * to play, synchronize and analyse sounds throughout the application.
  36807. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36808. */
  36809. export interface IAudioEngine extends IDisposable {
  36810. /**
  36811. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  36812. */
  36813. readonly canUseWebAudio: boolean;
  36814. /**
  36815. * Gets the current AudioContext if available.
  36816. */
  36817. readonly audioContext: Nullable<AudioContext>;
  36818. /**
  36819. * The master gain node defines the global audio volume of your audio engine.
  36820. */
  36821. readonly masterGain: GainNode;
  36822. /**
  36823. * Gets whether or not mp3 are supported by your browser.
  36824. */
  36825. readonly isMP3supported: boolean;
  36826. /**
  36827. * Gets whether or not ogg are supported by your browser.
  36828. */
  36829. readonly isOGGsupported: boolean;
  36830. /**
  36831. * Defines if Babylon should emit a warning if WebAudio is not supported.
  36832. * @ignoreNaming
  36833. */
  36834. WarnedWebAudioUnsupported: boolean;
  36835. /**
  36836. * Defines if the audio engine relies on a custom unlocked button.
  36837. * In this case, the embedded button will not be displayed.
  36838. */
  36839. useCustomUnlockedButton: boolean;
  36840. /**
  36841. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  36842. */
  36843. readonly unlocked: boolean;
  36844. /**
  36845. * Event raised when audio has been unlocked on the browser.
  36846. */
  36847. onAudioUnlockedObservable: Observable<AudioEngine>;
  36848. /**
  36849. * Event raised when audio has been locked on the browser.
  36850. */
  36851. onAudioLockedObservable: Observable<AudioEngine>;
  36852. /**
  36853. * Flags the audio engine in Locked state.
  36854. * This happens due to new browser policies preventing audio to autoplay.
  36855. */
  36856. lock(): void;
  36857. /**
  36858. * Unlocks the audio engine once a user action has been done on the dom.
  36859. * This is helpful to resume play once browser policies have been satisfied.
  36860. */
  36861. unlock(): void;
  36862. /**
  36863. * Gets the global volume sets on the master gain.
  36864. * @returns the global volume if set or -1 otherwise
  36865. */
  36866. getGlobalVolume(): number;
  36867. /**
  36868. * Sets the global volume of your experience (sets on the master gain).
  36869. * @param newVolume Defines the new global volume of the application
  36870. */
  36871. setGlobalVolume(newVolume: number): void;
  36872. /**
  36873. * Connect the audio engine to an audio analyser allowing some amazing
  36874. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36875. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36876. * @param analyser The analyser to connect to the engine
  36877. */
  36878. connectToAnalyser(analyser: Analyser): void;
  36879. }
  36880. /**
  36881. * This represents the default audio engine used in babylon.
  36882. * It is responsible to play, synchronize and analyse sounds throughout the application.
  36883. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36884. */
  36885. export class AudioEngine implements IAudioEngine {
  36886. private _audioContext;
  36887. private _audioContextInitialized;
  36888. private _muteButton;
  36889. private _hostElement;
  36890. /**
  36891. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  36892. */
  36893. canUseWebAudio: boolean;
  36894. /**
  36895. * The master gain node defines the global audio volume of your audio engine.
  36896. */
  36897. masterGain: GainNode;
  36898. /**
  36899. * Defines if Babylon should emit a warning if WebAudio is not supported.
  36900. * @ignoreNaming
  36901. */
  36902. WarnedWebAudioUnsupported: boolean;
  36903. /**
  36904. * Gets whether or not mp3 are supported by your browser.
  36905. */
  36906. isMP3supported: boolean;
  36907. /**
  36908. * Gets whether or not ogg are supported by your browser.
  36909. */
  36910. isOGGsupported: boolean;
  36911. /**
  36912. * Gets whether audio has been unlocked on the device.
  36913. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  36914. * a user interaction has happened.
  36915. */
  36916. unlocked: boolean;
  36917. /**
  36918. * Defines if the audio engine relies on a custom unlocked button.
  36919. * In this case, the embedded button will not be displayed.
  36920. */
  36921. useCustomUnlockedButton: boolean;
  36922. /**
  36923. * Event raised when audio has been unlocked on the browser.
  36924. */
  36925. onAudioUnlockedObservable: Observable<AudioEngine>;
  36926. /**
  36927. * Event raised when audio has been locked on the browser.
  36928. */
  36929. onAudioLockedObservable: Observable<AudioEngine>;
  36930. /**
  36931. * Gets the current AudioContext if available.
  36932. */
  36933. get audioContext(): Nullable<AudioContext>;
  36934. private _connectedAnalyser;
  36935. /**
  36936. * Instantiates a new audio engine.
  36937. *
  36938. * There should be only one per page as some browsers restrict the number
  36939. * of audio contexts you can create.
  36940. * @param hostElement defines the host element where to display the mute icon if necessary
  36941. */
  36942. constructor(hostElement?: Nullable<HTMLElement>);
  36943. /**
  36944. * Flags the audio engine in Locked state.
  36945. * This happens due to new browser policies preventing audio to autoplay.
  36946. */
  36947. lock(): void;
  36948. /**
  36949. * Unlocks the audio engine once a user action has been done on the dom.
  36950. * This is helpful to resume play once browser policies have been satisfied.
  36951. */
  36952. unlock(): void;
  36953. private _resumeAudioContext;
  36954. private _initializeAudioContext;
  36955. private _tryToRun;
  36956. private _triggerRunningState;
  36957. private _triggerSuspendedState;
  36958. private _displayMuteButton;
  36959. private _moveButtonToTopLeft;
  36960. private _onResize;
  36961. private _hideMuteButton;
  36962. /**
  36963. * Destroy and release the resources associated with the audio ccontext.
  36964. */
  36965. dispose(): void;
  36966. /**
  36967. * Gets the global volume sets on the master gain.
  36968. * @returns the global volume if set or -1 otherwise
  36969. */
  36970. getGlobalVolume(): number;
  36971. /**
  36972. * Sets the global volume of your experience (sets on the master gain).
  36973. * @param newVolume Defines the new global volume of the application
  36974. */
  36975. setGlobalVolume(newVolume: number): void;
  36976. /**
  36977. * Connect the audio engine to an audio analyser allowing some amazing
  36978. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36979. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36980. * @param analyser The analyser to connect to the engine
  36981. */
  36982. connectToAnalyser(analyser: Analyser): void;
  36983. }
  36984. }
  36985. declare module "babylonjs/Loading/loadingScreen" {
  36986. /**
  36987. * Interface used to present a loading screen while loading a scene
  36988. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36989. */
  36990. export interface ILoadingScreen {
  36991. /**
  36992. * Function called to display the loading screen
  36993. */
  36994. displayLoadingUI: () => void;
  36995. /**
  36996. * Function called to hide the loading screen
  36997. */
  36998. hideLoadingUI: () => void;
  36999. /**
  37000. * Gets or sets the color to use for the background
  37001. */
  37002. loadingUIBackgroundColor: string;
  37003. /**
  37004. * Gets or sets the text to display while loading
  37005. */
  37006. loadingUIText: string;
  37007. }
  37008. /**
  37009. * Class used for the default loading screen
  37010. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37011. */
  37012. export class DefaultLoadingScreen implements ILoadingScreen {
  37013. private _renderingCanvas;
  37014. private _loadingText;
  37015. private _loadingDivBackgroundColor;
  37016. private _loadingDiv;
  37017. private _loadingTextDiv;
  37018. /** Gets or sets the logo url to use for the default loading screen */
  37019. static DefaultLogoUrl: string;
  37020. /** Gets or sets the spinner url to use for the default loading screen */
  37021. static DefaultSpinnerUrl: string;
  37022. /**
  37023. * Creates a new default loading screen
  37024. * @param _renderingCanvas defines the canvas used to render the scene
  37025. * @param _loadingText defines the default text to display
  37026. * @param _loadingDivBackgroundColor defines the default background color
  37027. */
  37028. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  37029. /**
  37030. * Function called to display the loading screen
  37031. */
  37032. displayLoadingUI(): void;
  37033. /**
  37034. * Function called to hide the loading screen
  37035. */
  37036. hideLoadingUI(): void;
  37037. /**
  37038. * Gets or sets the text to display while loading
  37039. */
  37040. set loadingUIText(text: string);
  37041. get loadingUIText(): string;
  37042. /**
  37043. * Gets or sets the color to use for the background
  37044. */
  37045. get loadingUIBackgroundColor(): string;
  37046. set loadingUIBackgroundColor(color: string);
  37047. private _resizeLoadingUI;
  37048. }
  37049. }
  37050. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  37051. /**
  37052. * Interface for any object that can request an animation frame
  37053. */
  37054. export interface ICustomAnimationFrameRequester {
  37055. /**
  37056. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  37057. */
  37058. renderFunction?: Function;
  37059. /**
  37060. * Called to request the next frame to render to
  37061. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  37062. */
  37063. requestAnimationFrame: Function;
  37064. /**
  37065. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  37066. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  37067. */
  37068. requestID?: number;
  37069. }
  37070. }
  37071. declare module "babylonjs/Misc/performanceMonitor" {
  37072. /**
  37073. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  37074. */
  37075. export class PerformanceMonitor {
  37076. private _enabled;
  37077. private _rollingFrameTime;
  37078. private _lastFrameTimeMs;
  37079. /**
  37080. * constructor
  37081. * @param frameSampleSize The number of samples required to saturate the sliding window
  37082. */
  37083. constructor(frameSampleSize?: number);
  37084. /**
  37085. * Samples current frame
  37086. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  37087. */
  37088. sampleFrame(timeMs?: number): void;
  37089. /**
  37090. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  37091. */
  37092. get averageFrameTime(): number;
  37093. /**
  37094. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  37095. */
  37096. get averageFrameTimeVariance(): number;
  37097. /**
  37098. * Returns the frame time of the most recent frame
  37099. */
  37100. get instantaneousFrameTime(): number;
  37101. /**
  37102. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  37103. */
  37104. get averageFPS(): number;
  37105. /**
  37106. * Returns the average framerate in frames per second using the most recent frame time
  37107. */
  37108. get instantaneousFPS(): number;
  37109. /**
  37110. * Returns true if enough samples have been taken to completely fill the sliding window
  37111. */
  37112. get isSaturated(): boolean;
  37113. /**
  37114. * Enables contributions to the sliding window sample set
  37115. */
  37116. enable(): void;
  37117. /**
  37118. * Disables contributions to the sliding window sample set
  37119. * Samples will not be interpolated over the disabled period
  37120. */
  37121. disable(): void;
  37122. /**
  37123. * Returns true if sampling is enabled
  37124. */
  37125. get isEnabled(): boolean;
  37126. /**
  37127. * Resets performance monitor
  37128. */
  37129. reset(): void;
  37130. }
  37131. /**
  37132. * RollingAverage
  37133. *
  37134. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  37135. */
  37136. export class RollingAverage {
  37137. /**
  37138. * Current average
  37139. */
  37140. average: number;
  37141. /**
  37142. * Current variance
  37143. */
  37144. variance: number;
  37145. protected _samples: Array<number>;
  37146. protected _sampleCount: number;
  37147. protected _pos: number;
  37148. protected _m2: number;
  37149. /**
  37150. * constructor
  37151. * @param length The number of samples required to saturate the sliding window
  37152. */
  37153. constructor(length: number);
  37154. /**
  37155. * Adds a sample to the sample set
  37156. * @param v The sample value
  37157. */
  37158. add(v: number): void;
  37159. /**
  37160. * Returns previously added values or null if outside of history or outside the sliding window domain
  37161. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  37162. * @return Value previously recorded with add() or null if outside of range
  37163. */
  37164. history(i: number): number;
  37165. /**
  37166. * Returns true if enough samples have been taken to completely fill the sliding window
  37167. * @return true if sample-set saturated
  37168. */
  37169. isSaturated(): boolean;
  37170. /**
  37171. * Resets the rolling average (equivalent to 0 samples taken so far)
  37172. */
  37173. reset(): void;
  37174. /**
  37175. * Wraps a value around the sample range boundaries
  37176. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  37177. * @return Wrapped position in sample range
  37178. */
  37179. protected _wrapPosition(i: number): number;
  37180. }
  37181. }
  37182. declare module "babylonjs/Misc/perfCounter" {
  37183. /**
  37184. * This class is used to track a performance counter which is number based.
  37185. * The user has access to many properties which give statistics of different nature.
  37186. *
  37187. * The implementer can track two kinds of Performance Counter: time and count.
  37188. * 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.
  37189. * 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.
  37190. */
  37191. export class PerfCounter {
  37192. /**
  37193. * Gets or sets a global boolean to turn on and off all the counters
  37194. */
  37195. static Enabled: boolean;
  37196. /**
  37197. * Returns the smallest value ever
  37198. */
  37199. get min(): number;
  37200. /**
  37201. * Returns the biggest value ever
  37202. */
  37203. get max(): number;
  37204. /**
  37205. * Returns the average value since the performance counter is running
  37206. */
  37207. get average(): number;
  37208. /**
  37209. * Returns the average value of the last second the counter was monitored
  37210. */
  37211. get lastSecAverage(): number;
  37212. /**
  37213. * Returns the current value
  37214. */
  37215. get current(): number;
  37216. /**
  37217. * Gets the accumulated total
  37218. */
  37219. get total(): number;
  37220. /**
  37221. * Gets the total value count
  37222. */
  37223. get count(): number;
  37224. /**
  37225. * Creates a new counter
  37226. */
  37227. constructor();
  37228. /**
  37229. * Call this method to start monitoring a new frame.
  37230. * 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.
  37231. */
  37232. fetchNewFrame(): void;
  37233. /**
  37234. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  37235. * @param newCount the count value to add to the monitored count
  37236. * @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.
  37237. */
  37238. addCount(newCount: number, fetchResult: boolean): void;
  37239. /**
  37240. * Start monitoring this performance counter
  37241. */
  37242. beginMonitoring(): void;
  37243. /**
  37244. * Compute the time lapsed since the previous beginMonitoring() call.
  37245. * @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
  37246. */
  37247. endMonitoring(newFrame?: boolean): void;
  37248. private _fetchResult;
  37249. private _startMonitoringTime;
  37250. private _min;
  37251. private _max;
  37252. private _average;
  37253. private _current;
  37254. private _totalValueCount;
  37255. private _totalAccumulated;
  37256. private _lastSecAverage;
  37257. private _lastSecAccumulated;
  37258. private _lastSecTime;
  37259. private _lastSecValueCount;
  37260. }
  37261. }
  37262. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  37263. module "babylonjs/Engines/thinEngine" {
  37264. interface ThinEngine {
  37265. /**
  37266. * Sets alpha constants used by some alpha blending modes
  37267. * @param r defines the red component
  37268. * @param g defines the green component
  37269. * @param b defines the blue component
  37270. * @param a defines the alpha component
  37271. */
  37272. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  37273. /**
  37274. * Sets the current alpha mode
  37275. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  37276. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  37277. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  37278. */
  37279. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  37280. /**
  37281. * Gets the current alpha mode
  37282. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  37283. * @returns the current alpha mode
  37284. */
  37285. getAlphaMode(): number;
  37286. /**
  37287. * Sets the current alpha equation
  37288. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  37289. */
  37290. setAlphaEquation(equation: number): void;
  37291. /**
  37292. * Gets the current alpha equation.
  37293. * @returns the current alpha equation
  37294. */
  37295. getAlphaEquation(): number;
  37296. }
  37297. }
  37298. }
  37299. declare module "babylonjs/Engines/Extensions/engine.readTexture" {
  37300. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  37301. import { Nullable } from "babylonjs/types";
  37302. module "babylonjs/Engines/thinEngine" {
  37303. interface ThinEngine {
  37304. /** @hidden */
  37305. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  37306. }
  37307. }
  37308. }
  37309. declare module "babylonjs/Engines/engine" {
  37310. import { Observable } from "babylonjs/Misc/observable";
  37311. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  37312. import { Scene } from "babylonjs/scene";
  37313. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  37314. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  37315. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  37316. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  37317. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  37318. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  37319. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  37320. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  37321. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  37322. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  37323. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  37324. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  37325. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  37326. import "babylonjs/Engines/Extensions/engine.alpha";
  37327. import "babylonjs/Engines/Extensions/engine.readTexture";
  37328. import { Material } from "babylonjs/Materials/material";
  37329. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  37330. /**
  37331. * Defines the interface used by display changed events
  37332. */
  37333. export interface IDisplayChangedEventArgs {
  37334. /** Gets the vrDisplay object (if any) */
  37335. vrDisplay: Nullable<any>;
  37336. /** Gets a boolean indicating if webVR is supported */
  37337. vrSupported: boolean;
  37338. }
  37339. /**
  37340. * Defines the interface used by objects containing a viewport (like a camera)
  37341. */
  37342. interface IViewportOwnerLike {
  37343. /**
  37344. * Gets or sets the viewport
  37345. */
  37346. viewport: IViewportLike;
  37347. }
  37348. /**
  37349. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  37350. */
  37351. export class Engine extends ThinEngine {
  37352. /** Defines that alpha blending is disabled */
  37353. static readonly ALPHA_DISABLE: number;
  37354. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  37355. static readonly ALPHA_ADD: number;
  37356. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  37357. static readonly ALPHA_COMBINE: number;
  37358. /** Defines that alpha blending to DEST - SRC * DEST */
  37359. static readonly ALPHA_SUBTRACT: number;
  37360. /** Defines that alpha blending to SRC * DEST */
  37361. static readonly ALPHA_MULTIPLY: number;
  37362. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  37363. static readonly ALPHA_MAXIMIZED: number;
  37364. /** Defines that alpha blending to SRC + DEST */
  37365. static readonly ALPHA_ONEONE: number;
  37366. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  37367. static readonly ALPHA_PREMULTIPLIED: number;
  37368. /**
  37369. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  37370. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  37371. */
  37372. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  37373. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  37374. static readonly ALPHA_INTERPOLATE: number;
  37375. /**
  37376. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  37377. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  37378. */
  37379. static readonly ALPHA_SCREENMODE: number;
  37380. /** Defines that the ressource is not delayed*/
  37381. static readonly DELAYLOADSTATE_NONE: number;
  37382. /** Defines that the ressource was successfully delay loaded */
  37383. static readonly DELAYLOADSTATE_LOADED: number;
  37384. /** Defines that the ressource is currently delay loading */
  37385. static readonly DELAYLOADSTATE_LOADING: number;
  37386. /** Defines that the ressource is delayed and has not started loading */
  37387. static readonly DELAYLOADSTATE_NOTLOADED: number;
  37388. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  37389. static readonly NEVER: number;
  37390. /** 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 */
  37391. static readonly ALWAYS: number;
  37392. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  37393. static readonly LESS: number;
  37394. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  37395. static readonly EQUAL: number;
  37396. /** 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 */
  37397. static readonly LEQUAL: number;
  37398. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  37399. static readonly GREATER: number;
  37400. /** 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 */
  37401. static readonly GEQUAL: number;
  37402. /** 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 */
  37403. static readonly NOTEQUAL: number;
  37404. /** Passed to stencilOperation to specify that stencil value must be kept */
  37405. static readonly KEEP: number;
  37406. /** Passed to stencilOperation to specify that stencil value must be replaced */
  37407. static readonly REPLACE: number;
  37408. /** Passed to stencilOperation to specify that stencil value must be incremented */
  37409. static readonly INCR: number;
  37410. /** Passed to stencilOperation to specify that stencil value must be decremented */
  37411. static readonly DECR: number;
  37412. /** Passed to stencilOperation to specify that stencil value must be inverted */
  37413. static readonly INVERT: number;
  37414. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  37415. static readonly INCR_WRAP: number;
  37416. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  37417. static readonly DECR_WRAP: number;
  37418. /** Texture is not repeating outside of 0..1 UVs */
  37419. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  37420. /** Texture is repeating outside of 0..1 UVs */
  37421. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  37422. /** Texture is repeating and mirrored */
  37423. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  37424. /** ALPHA */
  37425. static readonly TEXTUREFORMAT_ALPHA: number;
  37426. /** LUMINANCE */
  37427. static readonly TEXTUREFORMAT_LUMINANCE: number;
  37428. /** LUMINANCE_ALPHA */
  37429. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  37430. /** RGB */
  37431. static readonly TEXTUREFORMAT_RGB: number;
  37432. /** RGBA */
  37433. static readonly TEXTUREFORMAT_RGBA: number;
  37434. /** RED */
  37435. static readonly TEXTUREFORMAT_RED: number;
  37436. /** RED (2nd reference) */
  37437. static readonly TEXTUREFORMAT_R: number;
  37438. /** RG */
  37439. static readonly TEXTUREFORMAT_RG: number;
  37440. /** RED_INTEGER */
  37441. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  37442. /** RED_INTEGER (2nd reference) */
  37443. static readonly TEXTUREFORMAT_R_INTEGER: number;
  37444. /** RG_INTEGER */
  37445. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  37446. /** RGB_INTEGER */
  37447. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  37448. /** RGBA_INTEGER */
  37449. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  37450. /** UNSIGNED_BYTE */
  37451. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  37452. /** UNSIGNED_BYTE (2nd reference) */
  37453. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  37454. /** FLOAT */
  37455. static readonly TEXTURETYPE_FLOAT: number;
  37456. /** HALF_FLOAT */
  37457. static readonly TEXTURETYPE_HALF_FLOAT: number;
  37458. /** BYTE */
  37459. static readonly TEXTURETYPE_BYTE: number;
  37460. /** SHORT */
  37461. static readonly TEXTURETYPE_SHORT: number;
  37462. /** UNSIGNED_SHORT */
  37463. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  37464. /** INT */
  37465. static readonly TEXTURETYPE_INT: number;
  37466. /** UNSIGNED_INT */
  37467. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  37468. /** UNSIGNED_SHORT_4_4_4_4 */
  37469. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  37470. /** UNSIGNED_SHORT_5_5_5_1 */
  37471. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  37472. /** UNSIGNED_SHORT_5_6_5 */
  37473. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  37474. /** UNSIGNED_INT_2_10_10_10_REV */
  37475. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  37476. /** UNSIGNED_INT_24_8 */
  37477. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  37478. /** UNSIGNED_INT_10F_11F_11F_REV */
  37479. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  37480. /** UNSIGNED_INT_5_9_9_9_REV */
  37481. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  37482. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  37483. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  37484. /** nearest is mag = nearest and min = nearest and mip = linear */
  37485. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  37486. /** Bilinear is mag = linear and min = linear and mip = nearest */
  37487. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  37488. /** Trilinear is mag = linear and min = linear and mip = linear */
  37489. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  37490. /** nearest is mag = nearest and min = nearest and mip = linear */
  37491. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  37492. /** Bilinear is mag = linear and min = linear and mip = nearest */
  37493. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  37494. /** Trilinear is mag = linear and min = linear and mip = linear */
  37495. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  37496. /** mag = nearest and min = nearest and mip = nearest */
  37497. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  37498. /** mag = nearest and min = linear and mip = nearest */
  37499. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  37500. /** mag = nearest and min = linear and mip = linear */
  37501. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  37502. /** mag = nearest and min = linear and mip = none */
  37503. static readonly TEXTURE_NEAREST_LINEAR: number;
  37504. /** mag = nearest and min = nearest and mip = none */
  37505. static readonly TEXTURE_NEAREST_NEAREST: number;
  37506. /** mag = linear and min = nearest and mip = nearest */
  37507. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  37508. /** mag = linear and min = nearest and mip = linear */
  37509. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  37510. /** mag = linear and min = linear and mip = none */
  37511. static readonly TEXTURE_LINEAR_LINEAR: number;
  37512. /** mag = linear and min = nearest and mip = none */
  37513. static readonly TEXTURE_LINEAR_NEAREST: number;
  37514. /** Explicit coordinates mode */
  37515. static readonly TEXTURE_EXPLICIT_MODE: number;
  37516. /** Spherical coordinates mode */
  37517. static readonly TEXTURE_SPHERICAL_MODE: number;
  37518. /** Planar coordinates mode */
  37519. static readonly TEXTURE_PLANAR_MODE: number;
  37520. /** Cubic coordinates mode */
  37521. static readonly TEXTURE_CUBIC_MODE: number;
  37522. /** Projection coordinates mode */
  37523. static readonly TEXTURE_PROJECTION_MODE: number;
  37524. /** Skybox coordinates mode */
  37525. static readonly TEXTURE_SKYBOX_MODE: number;
  37526. /** Inverse Cubic coordinates mode */
  37527. static readonly TEXTURE_INVCUBIC_MODE: number;
  37528. /** Equirectangular coordinates mode */
  37529. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  37530. /** Equirectangular Fixed coordinates mode */
  37531. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  37532. /** Equirectangular Fixed Mirrored coordinates mode */
  37533. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  37534. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  37535. static readonly SCALEMODE_FLOOR: number;
  37536. /** Defines that texture rescaling will look for the nearest power of 2 size */
  37537. static readonly SCALEMODE_NEAREST: number;
  37538. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  37539. static readonly SCALEMODE_CEILING: number;
  37540. /**
  37541. * Returns the current npm package of the sdk
  37542. */
  37543. static get NpmPackage(): string;
  37544. /**
  37545. * Returns the current version of the framework
  37546. */
  37547. static get Version(): string;
  37548. /** Gets the list of created engines */
  37549. static get Instances(): Engine[];
  37550. /**
  37551. * Gets the latest created engine
  37552. */
  37553. static get LastCreatedEngine(): Nullable<Engine>;
  37554. /**
  37555. * Gets the latest created scene
  37556. */
  37557. static get LastCreatedScene(): Nullable<Scene>;
  37558. /**
  37559. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  37560. * @param flag defines which part of the materials must be marked as dirty
  37561. * @param predicate defines a predicate used to filter which materials should be affected
  37562. */
  37563. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37564. /**
  37565. * Method called to create the default loading screen.
  37566. * This can be overriden in your own app.
  37567. * @param canvas The rendering canvas element
  37568. * @returns The loading screen
  37569. */
  37570. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  37571. /**
  37572. * Method called to create the default rescale post process on each engine.
  37573. */
  37574. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  37575. /**
  37576. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  37577. **/
  37578. enableOfflineSupport: boolean;
  37579. /**
  37580. * 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)
  37581. **/
  37582. disableManifestCheck: boolean;
  37583. /**
  37584. * Gets the list of created scenes
  37585. */
  37586. scenes: Scene[];
  37587. /**
  37588. * Event raised when a new scene is created
  37589. */
  37590. onNewSceneAddedObservable: Observable<Scene>;
  37591. /**
  37592. * Gets the list of created postprocesses
  37593. */
  37594. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  37595. /**
  37596. * Gets a boolean indicating if the pointer is currently locked
  37597. */
  37598. isPointerLock: boolean;
  37599. /**
  37600. * Observable event triggered each time the rendering canvas is resized
  37601. */
  37602. onResizeObservable: Observable<Engine>;
  37603. /**
  37604. * Observable event triggered each time the canvas loses focus
  37605. */
  37606. onCanvasBlurObservable: Observable<Engine>;
  37607. /**
  37608. * Observable event triggered each time the canvas gains focus
  37609. */
  37610. onCanvasFocusObservable: Observable<Engine>;
  37611. /**
  37612. * Observable event triggered each time the canvas receives pointerout event
  37613. */
  37614. onCanvasPointerOutObservable: Observable<PointerEvent>;
  37615. /**
  37616. * Observable raised when the engine begins a new frame
  37617. */
  37618. onBeginFrameObservable: Observable<Engine>;
  37619. /**
  37620. * If set, will be used to request the next animation frame for the render loop
  37621. */
  37622. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  37623. /**
  37624. * Observable raised when the engine ends the current frame
  37625. */
  37626. onEndFrameObservable: Observable<Engine>;
  37627. /**
  37628. * Observable raised when the engine is about to compile a shader
  37629. */
  37630. onBeforeShaderCompilationObservable: Observable<Engine>;
  37631. /**
  37632. * Observable raised when the engine has jsut compiled a shader
  37633. */
  37634. onAfterShaderCompilationObservable: Observable<Engine>;
  37635. /**
  37636. * Gets the audio engine
  37637. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37638. * @ignorenaming
  37639. */
  37640. static audioEngine: IAudioEngine;
  37641. /**
  37642. * Default AudioEngine factory responsible of creating the Audio Engine.
  37643. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  37644. */
  37645. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  37646. /**
  37647. * Default offline support factory responsible of creating a tool used to store data locally.
  37648. * By default, this will create a Database object if the workload has been embedded.
  37649. */
  37650. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  37651. private _loadingScreen;
  37652. private _pointerLockRequested;
  37653. private _rescalePostProcess;
  37654. private _deterministicLockstep;
  37655. private _lockstepMaxSteps;
  37656. private _timeStep;
  37657. protected get _supportsHardwareTextureRescaling(): boolean;
  37658. private _fps;
  37659. private _deltaTime;
  37660. /** @hidden */
  37661. _drawCalls: PerfCounter;
  37662. /** 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 */
  37663. canvasTabIndex: number;
  37664. /**
  37665. * Turn this value on if you want to pause FPS computation when in background
  37666. */
  37667. disablePerformanceMonitorInBackground: boolean;
  37668. private _performanceMonitor;
  37669. /**
  37670. * Gets the performance monitor attached to this engine
  37671. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  37672. */
  37673. get performanceMonitor(): PerformanceMonitor;
  37674. private _onFocus;
  37675. private _onBlur;
  37676. private _onCanvasPointerOut;
  37677. private _onCanvasBlur;
  37678. private _onCanvasFocus;
  37679. private _onFullscreenChange;
  37680. private _onPointerLockChange;
  37681. /**
  37682. * Gets the HTML element used to attach event listeners
  37683. * @returns a HTML element
  37684. */
  37685. getInputElement(): Nullable<HTMLElement>;
  37686. /**
  37687. * Creates a new engine
  37688. * @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
  37689. * @param antialias defines enable antialiasing (default: false)
  37690. * @param options defines further options to be sent to the getContext() function
  37691. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  37692. */
  37693. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  37694. /**
  37695. * Gets current aspect ratio
  37696. * @param viewportOwner defines the camera to use to get the aspect ratio
  37697. * @param useScreen defines if screen size must be used (or the current render target if any)
  37698. * @returns a number defining the aspect ratio
  37699. */
  37700. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  37701. /**
  37702. * Gets current screen aspect ratio
  37703. * @returns a number defining the aspect ratio
  37704. */
  37705. getScreenAspectRatio(): number;
  37706. /**
  37707. * Gets the client rect of the HTML canvas attached with the current webGL context
  37708. * @returns a client rectanglee
  37709. */
  37710. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  37711. /**
  37712. * Gets the client rect of the HTML element used for events
  37713. * @returns a client rectanglee
  37714. */
  37715. getInputElementClientRect(): Nullable<ClientRect>;
  37716. /**
  37717. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  37718. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37719. * @returns true if engine is in deterministic lock step mode
  37720. */
  37721. isDeterministicLockStep(): boolean;
  37722. /**
  37723. * Gets the max steps when engine is running in deterministic lock step
  37724. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37725. * @returns the max steps
  37726. */
  37727. getLockstepMaxSteps(): number;
  37728. /**
  37729. * Returns the time in ms between steps when using deterministic lock step.
  37730. * @returns time step in (ms)
  37731. */
  37732. getTimeStep(): number;
  37733. /**
  37734. * Force the mipmap generation for the given render target texture
  37735. * @param texture defines the render target texture to use
  37736. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  37737. */
  37738. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  37739. /** States */
  37740. /**
  37741. * Set various states to the webGL context
  37742. * @param culling defines backface culling state
  37743. * @param zOffset defines the value to apply to zOffset (0 by default)
  37744. * @param force defines if states must be applied even if cache is up to date
  37745. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  37746. */
  37747. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  37748. /**
  37749. * Set the z offset to apply to current rendering
  37750. * @param value defines the offset to apply
  37751. */
  37752. setZOffset(value: number): void;
  37753. /**
  37754. * Gets the current value of the zOffset
  37755. * @returns the current zOffset state
  37756. */
  37757. getZOffset(): number;
  37758. /**
  37759. * Enable or disable depth buffering
  37760. * @param enable defines the state to set
  37761. */
  37762. setDepthBuffer(enable: boolean): void;
  37763. /**
  37764. * Gets a boolean indicating if depth writing is enabled
  37765. * @returns the current depth writing state
  37766. */
  37767. getDepthWrite(): boolean;
  37768. /**
  37769. * Enable or disable depth writing
  37770. * @param enable defines the state to set
  37771. */
  37772. setDepthWrite(enable: boolean): void;
  37773. /**
  37774. * Gets a boolean indicating if stencil buffer is enabled
  37775. * @returns the current stencil buffer state
  37776. */
  37777. getStencilBuffer(): boolean;
  37778. /**
  37779. * Enable or disable the stencil buffer
  37780. * @param enable defines if the stencil buffer must be enabled or disabled
  37781. */
  37782. setStencilBuffer(enable: boolean): void;
  37783. /**
  37784. * Gets the current stencil mask
  37785. * @returns a number defining the new stencil mask to use
  37786. */
  37787. getStencilMask(): number;
  37788. /**
  37789. * Sets the current stencil mask
  37790. * @param mask defines the new stencil mask to use
  37791. */
  37792. setStencilMask(mask: number): void;
  37793. /**
  37794. * Gets the current stencil function
  37795. * @returns a number defining the stencil function to use
  37796. */
  37797. getStencilFunction(): number;
  37798. /**
  37799. * Gets the current stencil reference value
  37800. * @returns a number defining the stencil reference value to use
  37801. */
  37802. getStencilFunctionReference(): number;
  37803. /**
  37804. * Gets the current stencil mask
  37805. * @returns a number defining the stencil mask to use
  37806. */
  37807. getStencilFunctionMask(): number;
  37808. /**
  37809. * Sets the current stencil function
  37810. * @param stencilFunc defines the new stencil function to use
  37811. */
  37812. setStencilFunction(stencilFunc: number): void;
  37813. /**
  37814. * Sets the current stencil reference
  37815. * @param reference defines the new stencil reference to use
  37816. */
  37817. setStencilFunctionReference(reference: number): void;
  37818. /**
  37819. * Sets the current stencil mask
  37820. * @param mask defines the new stencil mask to use
  37821. */
  37822. setStencilFunctionMask(mask: number): void;
  37823. /**
  37824. * Gets the current stencil operation when stencil fails
  37825. * @returns a number defining stencil operation to use when stencil fails
  37826. */
  37827. getStencilOperationFail(): number;
  37828. /**
  37829. * Gets the current stencil operation when depth fails
  37830. * @returns a number defining stencil operation to use when depth fails
  37831. */
  37832. getStencilOperationDepthFail(): number;
  37833. /**
  37834. * Gets the current stencil operation when stencil passes
  37835. * @returns a number defining stencil operation to use when stencil passes
  37836. */
  37837. getStencilOperationPass(): number;
  37838. /**
  37839. * Sets the stencil operation to use when stencil fails
  37840. * @param operation defines the stencil operation to use when stencil fails
  37841. */
  37842. setStencilOperationFail(operation: number): void;
  37843. /**
  37844. * Sets the stencil operation to use when depth fails
  37845. * @param operation defines the stencil operation to use when depth fails
  37846. */
  37847. setStencilOperationDepthFail(operation: number): void;
  37848. /**
  37849. * Sets the stencil operation to use when stencil passes
  37850. * @param operation defines the stencil operation to use when stencil passes
  37851. */
  37852. setStencilOperationPass(operation: number): void;
  37853. /**
  37854. * Sets a boolean indicating if the dithering state is enabled or disabled
  37855. * @param value defines the dithering state
  37856. */
  37857. setDitheringState(value: boolean): void;
  37858. /**
  37859. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  37860. * @param value defines the rasterizer state
  37861. */
  37862. setRasterizerState(value: boolean): void;
  37863. /**
  37864. * Gets the current depth function
  37865. * @returns a number defining the depth function
  37866. */
  37867. getDepthFunction(): Nullable<number>;
  37868. /**
  37869. * Sets the current depth function
  37870. * @param depthFunc defines the function to use
  37871. */
  37872. setDepthFunction(depthFunc: number): void;
  37873. /**
  37874. * Sets the current depth function to GREATER
  37875. */
  37876. setDepthFunctionToGreater(): void;
  37877. /**
  37878. * Sets the current depth function to GEQUAL
  37879. */
  37880. setDepthFunctionToGreaterOrEqual(): void;
  37881. /**
  37882. * Sets the current depth function to LESS
  37883. */
  37884. setDepthFunctionToLess(): void;
  37885. /**
  37886. * Sets the current depth function to LEQUAL
  37887. */
  37888. setDepthFunctionToLessOrEqual(): void;
  37889. private _cachedStencilBuffer;
  37890. private _cachedStencilFunction;
  37891. private _cachedStencilMask;
  37892. private _cachedStencilOperationPass;
  37893. private _cachedStencilOperationFail;
  37894. private _cachedStencilOperationDepthFail;
  37895. private _cachedStencilReference;
  37896. /**
  37897. * Caches the the state of the stencil buffer
  37898. */
  37899. cacheStencilState(): void;
  37900. /**
  37901. * Restores the state of the stencil buffer
  37902. */
  37903. restoreStencilState(): void;
  37904. /**
  37905. * Directly set the WebGL Viewport
  37906. * @param x defines the x coordinate of the viewport (in screen space)
  37907. * @param y defines the y coordinate of the viewport (in screen space)
  37908. * @param width defines the width of the viewport (in screen space)
  37909. * @param height defines the height of the viewport (in screen space)
  37910. * @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
  37911. */
  37912. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  37913. /**
  37914. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  37915. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  37916. * @param y defines the y-coordinate of the corner of the clear rectangle
  37917. * @param width defines the width of the clear rectangle
  37918. * @param height defines the height of the clear rectangle
  37919. * @param clearColor defines the clear color
  37920. */
  37921. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  37922. /**
  37923. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  37924. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  37925. * @param y defines the y-coordinate of the corner of the clear rectangle
  37926. * @param width defines the width of the clear rectangle
  37927. * @param height defines the height of the clear rectangle
  37928. */
  37929. enableScissor(x: number, y: number, width: number, height: number): void;
  37930. /**
  37931. * Disable previously set scissor test rectangle
  37932. */
  37933. disableScissor(): void;
  37934. protected _reportDrawCall(): void;
  37935. /**
  37936. * Initializes a webVR display and starts listening to display change events
  37937. * The onVRDisplayChangedObservable will be notified upon these changes
  37938. * @returns The onVRDisplayChangedObservable
  37939. */
  37940. initWebVR(): Observable<IDisplayChangedEventArgs>;
  37941. /** @hidden */
  37942. _prepareVRComponent(): void;
  37943. /** @hidden */
  37944. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  37945. /** @hidden */
  37946. _submitVRFrame(): void;
  37947. /**
  37948. * Call this function to leave webVR mode
  37949. * Will do nothing if webVR is not supported or if there is no webVR device
  37950. * @see http://doc.babylonjs.com/how_to/webvr_camera
  37951. */
  37952. disableVR(): void;
  37953. /**
  37954. * Gets a boolean indicating that the system is in VR mode and is presenting
  37955. * @returns true if VR mode is engaged
  37956. */
  37957. isVRPresenting(): boolean;
  37958. /** @hidden */
  37959. _requestVRFrame(): void;
  37960. /** @hidden */
  37961. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37962. /**
  37963. * Gets the source code of the vertex shader associated with a specific webGL program
  37964. * @param program defines the program to use
  37965. * @returns a string containing the source code of the vertex shader associated with the program
  37966. */
  37967. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  37968. /**
  37969. * Gets the source code of the fragment shader associated with a specific webGL program
  37970. * @param program defines the program to use
  37971. * @returns a string containing the source code of the fragment shader associated with the program
  37972. */
  37973. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  37974. /**
  37975. * Sets a depth stencil texture from a render target to the according uniform.
  37976. * @param channel The texture channel
  37977. * @param uniform The uniform to set
  37978. * @param texture The render target texture containing the depth stencil texture to apply
  37979. */
  37980. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  37981. /**
  37982. * Sets a texture to the webGL context from a postprocess
  37983. * @param channel defines the channel to use
  37984. * @param postProcess defines the source postprocess
  37985. */
  37986. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  37987. /**
  37988. * Binds the output of the passed in post process to the texture channel specified
  37989. * @param channel The channel the texture should be bound to
  37990. * @param postProcess The post process which's output should be bound
  37991. */
  37992. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  37993. protected _rebuildBuffers(): void;
  37994. /** @hidden */
  37995. _renderFrame(): void;
  37996. _renderLoop(): void;
  37997. /** @hidden */
  37998. _renderViews(): boolean;
  37999. /**
  38000. * Toggle full screen mode
  38001. * @param requestPointerLock defines if a pointer lock should be requested from the user
  38002. */
  38003. switchFullscreen(requestPointerLock: boolean): void;
  38004. /**
  38005. * Enters full screen mode
  38006. * @param requestPointerLock defines if a pointer lock should be requested from the user
  38007. */
  38008. enterFullscreen(requestPointerLock: boolean): void;
  38009. /**
  38010. * Exits full screen mode
  38011. */
  38012. exitFullscreen(): void;
  38013. /**
  38014. * Enters Pointerlock mode
  38015. */
  38016. enterPointerlock(): void;
  38017. /**
  38018. * Exits Pointerlock mode
  38019. */
  38020. exitPointerlock(): void;
  38021. /**
  38022. * Begin a new frame
  38023. */
  38024. beginFrame(): void;
  38025. /**
  38026. * Enf the current frame
  38027. */
  38028. endFrame(): void;
  38029. resize(): void;
  38030. /**
  38031. * Force a specific size of the canvas
  38032. * @param width defines the new canvas' width
  38033. * @param height defines the new canvas' height
  38034. */
  38035. setSize(width: number, height: number): void;
  38036. /**
  38037. * Updates a dynamic vertex buffer.
  38038. * @param vertexBuffer the vertex buffer to update
  38039. * @param data the data used to update the vertex buffer
  38040. * @param byteOffset the byte offset of the data
  38041. * @param byteLength the byte length of the data
  38042. */
  38043. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  38044. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  38045. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  38046. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  38047. _releaseTexture(texture: InternalTexture): void;
  38048. /**
  38049. * @hidden
  38050. * Rescales a texture
  38051. * @param source input texutre
  38052. * @param destination destination texture
  38053. * @param scene scene to use to render the resize
  38054. * @param internalFormat format to use when resizing
  38055. * @param onComplete callback to be called when resize has completed
  38056. */
  38057. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  38058. /**
  38059. * Gets the current framerate
  38060. * @returns a number representing the framerate
  38061. */
  38062. getFps(): number;
  38063. /**
  38064. * Gets the time spent between current and previous frame
  38065. * @returns a number representing the delta time in ms
  38066. */
  38067. getDeltaTime(): number;
  38068. private _measureFps;
  38069. /** @hidden */
  38070. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  38071. /**
  38072. * Update a dynamic index buffer
  38073. * @param indexBuffer defines the target index buffer
  38074. * @param indices defines the data to update
  38075. * @param offset defines the offset in the target index buffer where update should start
  38076. */
  38077. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  38078. /**
  38079. * Updates the sample count of a render target texture
  38080. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  38081. * @param texture defines the texture to update
  38082. * @param samples defines the sample count to set
  38083. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  38084. */
  38085. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  38086. /**
  38087. * Updates a depth texture Comparison Mode and Function.
  38088. * If the comparison Function is equal to 0, the mode will be set to none.
  38089. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  38090. * @param texture The texture to set the comparison function for
  38091. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  38092. */
  38093. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  38094. /**
  38095. * Creates a webGL buffer to use with instanciation
  38096. * @param capacity defines the size of the buffer
  38097. * @returns the webGL buffer
  38098. */
  38099. createInstancesBuffer(capacity: number): DataBuffer;
  38100. /**
  38101. * Delete a webGL buffer used with instanciation
  38102. * @param buffer defines the webGL buffer to delete
  38103. */
  38104. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  38105. private _clientWaitAsync;
  38106. /** @hidden */
  38107. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  38108. dispose(): void;
  38109. private _disableTouchAction;
  38110. /**
  38111. * Display the loading screen
  38112. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38113. */
  38114. displayLoadingUI(): void;
  38115. /**
  38116. * Hide the loading screen
  38117. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38118. */
  38119. hideLoadingUI(): void;
  38120. /**
  38121. * Gets the current loading screen object
  38122. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38123. */
  38124. get loadingScreen(): ILoadingScreen;
  38125. /**
  38126. * Sets the current loading screen object
  38127. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38128. */
  38129. set loadingScreen(loadingScreen: ILoadingScreen);
  38130. /**
  38131. * Sets the current loading screen text
  38132. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38133. */
  38134. set loadingUIText(text: string);
  38135. /**
  38136. * Sets the current loading screen background color
  38137. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38138. */
  38139. set loadingUIBackgroundColor(color: string);
  38140. /** Pointerlock and fullscreen */
  38141. /**
  38142. * Ask the browser to promote the current element to pointerlock mode
  38143. * @param element defines the DOM element to promote
  38144. */
  38145. static _RequestPointerlock(element: HTMLElement): void;
  38146. /**
  38147. * Asks the browser to exit pointerlock mode
  38148. */
  38149. static _ExitPointerlock(): void;
  38150. /**
  38151. * Ask the browser to promote the current element to fullscreen rendering mode
  38152. * @param element defines the DOM element to promote
  38153. */
  38154. static _RequestFullscreen(element: HTMLElement): void;
  38155. /**
  38156. * Asks the browser to exit fullscreen mode
  38157. */
  38158. static _ExitFullscreen(): void;
  38159. }
  38160. }
  38161. declare module "babylonjs/Engines/engineStore" {
  38162. import { Nullable } from "babylonjs/types";
  38163. import { Engine } from "babylonjs/Engines/engine";
  38164. import { Scene } from "babylonjs/scene";
  38165. /**
  38166. * The engine store class is responsible to hold all the instances of Engine and Scene created
  38167. * during the life time of the application.
  38168. */
  38169. export class EngineStore {
  38170. /** Gets the list of created engines */
  38171. static Instances: import("babylonjs/Engines/engine").Engine[];
  38172. /** @hidden */
  38173. static _LastCreatedScene: Nullable<Scene>;
  38174. /**
  38175. * Gets the latest created engine
  38176. */
  38177. static get LastCreatedEngine(): Nullable<Engine>;
  38178. /**
  38179. * Gets the latest created scene
  38180. */
  38181. static get LastCreatedScene(): Nullable<Scene>;
  38182. /**
  38183. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  38184. * @ignorenaming
  38185. */
  38186. static UseFallbackTexture: boolean;
  38187. /**
  38188. * Texture content used if a texture cannot loaded
  38189. * @ignorenaming
  38190. */
  38191. static FallbackTexture: string;
  38192. }
  38193. }
  38194. declare module "babylonjs/Misc/promise" {
  38195. /**
  38196. * Helper class that provides a small promise polyfill
  38197. */
  38198. export class PromisePolyfill {
  38199. /**
  38200. * Static function used to check if the polyfill is required
  38201. * If this is the case then the function will inject the polyfill to window.Promise
  38202. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  38203. */
  38204. static Apply(force?: boolean): void;
  38205. }
  38206. }
  38207. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  38208. /**
  38209. * Interface for screenshot methods with describe argument called `size` as object with options
  38210. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  38211. */
  38212. export interface IScreenshotSize {
  38213. /**
  38214. * number in pixels for canvas height
  38215. */
  38216. height?: number;
  38217. /**
  38218. * multiplier allowing render at a higher or lower resolution
  38219. * If value is defined then height and width will be ignored and taken from camera
  38220. */
  38221. precision?: number;
  38222. /**
  38223. * number in pixels for canvas width
  38224. */
  38225. width?: number;
  38226. }
  38227. }
  38228. declare module "babylonjs/Misc/tools" {
  38229. import { Nullable, float } from "babylonjs/types";
  38230. import { DomManagement } from "babylonjs/Misc/domManagement";
  38231. import { WebRequest } from "babylonjs/Misc/webRequest";
  38232. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  38233. import { ReadFileError } from "babylonjs/Misc/fileTools";
  38234. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  38235. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  38236. import { Camera } from "babylonjs/Cameras/camera";
  38237. import { Engine } from "babylonjs/Engines/engine";
  38238. interface IColor4Like {
  38239. r: float;
  38240. g: float;
  38241. b: float;
  38242. a: float;
  38243. }
  38244. /**
  38245. * Class containing a set of static utilities functions
  38246. */
  38247. export class Tools {
  38248. /**
  38249. * Gets or sets the base URL to use to load assets
  38250. */
  38251. static get BaseUrl(): string;
  38252. static set BaseUrl(value: string);
  38253. /**
  38254. * Enable/Disable Custom HTTP Request Headers globally.
  38255. * default = false
  38256. * @see CustomRequestHeaders
  38257. */
  38258. static UseCustomRequestHeaders: boolean;
  38259. /**
  38260. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  38261. * i.e. when loading files, where the server/service expects an Authorization header
  38262. */
  38263. static CustomRequestHeaders: {
  38264. [key: string]: string;
  38265. };
  38266. /**
  38267. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  38268. */
  38269. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  38270. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  38271. /**
  38272. * Default behaviour for cors in the application.
  38273. * It can be a string if the expected behavior is identical in the entire app.
  38274. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  38275. */
  38276. static get CorsBehavior(): string | ((url: string | string[]) => string);
  38277. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  38278. /**
  38279. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  38280. * @ignorenaming
  38281. */
  38282. static get UseFallbackTexture(): boolean;
  38283. static set UseFallbackTexture(value: boolean);
  38284. /**
  38285. * Use this object to register external classes like custom textures or material
  38286. * to allow the laoders to instantiate them
  38287. */
  38288. static get RegisteredExternalClasses(): {
  38289. [key: string]: Object;
  38290. };
  38291. static set RegisteredExternalClasses(classes: {
  38292. [key: string]: Object;
  38293. });
  38294. /**
  38295. * Texture content used if a texture cannot loaded
  38296. * @ignorenaming
  38297. */
  38298. static get fallbackTexture(): string;
  38299. static set fallbackTexture(value: string);
  38300. /**
  38301. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  38302. * @param u defines the coordinate on X axis
  38303. * @param v defines the coordinate on Y axis
  38304. * @param width defines the width of the source data
  38305. * @param height defines the height of the source data
  38306. * @param pixels defines the source byte array
  38307. * @param color defines the output color
  38308. */
  38309. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  38310. /**
  38311. * Interpolates between a and b via alpha
  38312. * @param a The lower value (returned when alpha = 0)
  38313. * @param b The upper value (returned when alpha = 1)
  38314. * @param alpha The interpolation-factor
  38315. * @return The mixed value
  38316. */
  38317. static Mix(a: number, b: number, alpha: number): number;
  38318. /**
  38319. * Tries to instantiate a new object from a given class name
  38320. * @param className defines the class name to instantiate
  38321. * @returns the new object or null if the system was not able to do the instantiation
  38322. */
  38323. static Instantiate(className: string): any;
  38324. /**
  38325. * Provides a slice function that will work even on IE
  38326. * @param data defines the array to slice
  38327. * @param start defines the start of the data (optional)
  38328. * @param end defines the end of the data (optional)
  38329. * @returns the new sliced array
  38330. */
  38331. static Slice<T>(data: T, start?: number, end?: number): T;
  38332. /**
  38333. * Polyfill for setImmediate
  38334. * @param action defines the action to execute after the current execution block
  38335. */
  38336. static SetImmediate(action: () => void): void;
  38337. /**
  38338. * Function indicating if a number is an exponent of 2
  38339. * @param value defines the value to test
  38340. * @returns true if the value is an exponent of 2
  38341. */
  38342. static IsExponentOfTwo(value: number): boolean;
  38343. private static _tmpFloatArray;
  38344. /**
  38345. * Returns the nearest 32-bit single precision float representation of a Number
  38346. * @param value A Number. If the parameter is of a different type, it will get converted
  38347. * to a number or to NaN if it cannot be converted
  38348. * @returns number
  38349. */
  38350. static FloatRound(value: number): number;
  38351. /**
  38352. * Extracts the filename from a path
  38353. * @param path defines the path to use
  38354. * @returns the filename
  38355. */
  38356. static GetFilename(path: string): string;
  38357. /**
  38358. * Extracts the "folder" part of a path (everything before the filename).
  38359. * @param uri The URI to extract the info from
  38360. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  38361. * @returns The "folder" part of the path
  38362. */
  38363. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  38364. /**
  38365. * Extracts text content from a DOM element hierarchy
  38366. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  38367. */
  38368. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  38369. /**
  38370. * Convert an angle in radians to degrees
  38371. * @param angle defines the angle to convert
  38372. * @returns the angle in degrees
  38373. */
  38374. static ToDegrees(angle: number): number;
  38375. /**
  38376. * Convert an angle in degrees to radians
  38377. * @param angle defines the angle to convert
  38378. * @returns the angle in radians
  38379. */
  38380. static ToRadians(angle: number): number;
  38381. /**
  38382. * Returns an array if obj is not an array
  38383. * @param obj defines the object to evaluate as an array
  38384. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  38385. * @returns either obj directly if obj is an array or a new array containing obj
  38386. */
  38387. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  38388. /**
  38389. * Gets the pointer prefix to use
  38390. * @param engine defines the engine we are finding the prefix for
  38391. * @returns "pointer" if touch is enabled. Else returns "mouse"
  38392. */
  38393. static GetPointerPrefix(engine: Engine): string;
  38394. /**
  38395. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  38396. * @param url define the url we are trying
  38397. * @param element define the dom element where to configure the cors policy
  38398. */
  38399. static SetCorsBehavior(url: string | string[], element: {
  38400. crossOrigin: string | null;
  38401. }): void;
  38402. /**
  38403. * Removes unwanted characters from an url
  38404. * @param url defines the url to clean
  38405. * @returns the cleaned url
  38406. */
  38407. static CleanUrl(url: string): string;
  38408. /**
  38409. * Gets or sets a function used to pre-process url before using them to load assets
  38410. */
  38411. static get PreprocessUrl(): (url: string) => string;
  38412. static set PreprocessUrl(processor: (url: string) => string);
  38413. /**
  38414. * Loads an image as an HTMLImageElement.
  38415. * @param input url string, ArrayBuffer, or Blob to load
  38416. * @param onLoad callback called when the image successfully loads
  38417. * @param onError callback called when the image fails to load
  38418. * @param offlineProvider offline provider for caching
  38419. * @param mimeType optional mime type
  38420. * @returns the HTMLImageElement of the loaded image
  38421. */
  38422. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  38423. /**
  38424. * Loads a file from a url
  38425. * @param url url string, ArrayBuffer, or Blob to load
  38426. * @param onSuccess callback called when the file successfully loads
  38427. * @param onProgress callback called while file is loading (if the server supports this mode)
  38428. * @param offlineProvider defines the offline provider for caching
  38429. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  38430. * @param onError callback called when the file fails to load
  38431. * @returns a file request object
  38432. */
  38433. 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;
  38434. /**
  38435. * Loads a file from a url
  38436. * @param url the file url to load
  38437. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  38438. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  38439. */
  38440. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  38441. /**
  38442. * Load a script (identified by an url). When the url returns, the
  38443. * content of this file is added into a new script element, attached to the DOM (body element)
  38444. * @param scriptUrl defines the url of the script to laod
  38445. * @param onSuccess defines the callback called when the script is loaded
  38446. * @param onError defines the callback to call if an error occurs
  38447. * @param scriptId defines the id of the script element
  38448. */
  38449. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  38450. /**
  38451. * Load an asynchronous script (identified by an url). When the url returns, the
  38452. * content of this file is added into a new script element, attached to the DOM (body element)
  38453. * @param scriptUrl defines the url of the script to laod
  38454. * @param scriptId defines the id of the script element
  38455. * @returns a promise request object
  38456. */
  38457. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  38458. /**
  38459. * Loads a file from a blob
  38460. * @param fileToLoad defines the blob to use
  38461. * @param callback defines the callback to call when data is loaded
  38462. * @param progressCallback defines the callback to call during loading process
  38463. * @returns a file request object
  38464. */
  38465. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  38466. /**
  38467. * Reads a file from a File object
  38468. * @param file defines the file to load
  38469. * @param onSuccess defines the callback to call when data is loaded
  38470. * @param onProgress defines the callback to call during loading process
  38471. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  38472. * @param onError defines the callback to call when an error occurs
  38473. * @returns a file request object
  38474. */
  38475. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  38476. /**
  38477. * Creates a data url from a given string content
  38478. * @param content defines the content to convert
  38479. * @returns the new data url link
  38480. */
  38481. static FileAsURL(content: string): string;
  38482. /**
  38483. * Format the given number to a specific decimal format
  38484. * @param value defines the number to format
  38485. * @param decimals defines the number of decimals to use
  38486. * @returns the formatted string
  38487. */
  38488. static Format(value: number, decimals?: number): string;
  38489. /**
  38490. * Tries to copy an object by duplicating every property
  38491. * @param source defines the source object
  38492. * @param destination defines the target object
  38493. * @param doNotCopyList defines a list of properties to avoid
  38494. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  38495. */
  38496. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  38497. /**
  38498. * Gets a boolean indicating if the given object has no own property
  38499. * @param obj defines the object to test
  38500. * @returns true if object has no own property
  38501. */
  38502. static IsEmpty(obj: any): boolean;
  38503. /**
  38504. * Function used to register events at window level
  38505. * @param windowElement defines the Window object to use
  38506. * @param events defines the events to register
  38507. */
  38508. static RegisterTopRootEvents(windowElement: Window, events: {
  38509. name: string;
  38510. handler: Nullable<(e: FocusEvent) => any>;
  38511. }[]): void;
  38512. /**
  38513. * Function used to unregister events from window level
  38514. * @param windowElement defines the Window object to use
  38515. * @param events defines the events to unregister
  38516. */
  38517. static UnregisterTopRootEvents(windowElement: Window, events: {
  38518. name: string;
  38519. handler: Nullable<(e: FocusEvent) => any>;
  38520. }[]): void;
  38521. /**
  38522. * @ignore
  38523. */
  38524. static _ScreenshotCanvas: HTMLCanvasElement;
  38525. /**
  38526. * Dumps the current bound framebuffer
  38527. * @param width defines the rendering width
  38528. * @param height defines the rendering height
  38529. * @param engine defines the hosting engine
  38530. * @param successCallback defines the callback triggered once the data are available
  38531. * @param mimeType defines the mime type of the result
  38532. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  38533. */
  38534. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38535. /**
  38536. * Converts the canvas data to blob.
  38537. * This acts as a polyfill for browsers not supporting the to blob function.
  38538. * @param canvas Defines the canvas to extract the data from
  38539. * @param successCallback Defines the callback triggered once the data are available
  38540. * @param mimeType Defines the mime type of the result
  38541. */
  38542. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  38543. /**
  38544. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  38545. * @param successCallback defines the callback triggered once the data are available
  38546. * @param mimeType defines the mime type of the result
  38547. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  38548. */
  38549. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38550. /**
  38551. * Downloads a blob in the browser
  38552. * @param blob defines the blob to download
  38553. * @param fileName defines the name of the downloaded file
  38554. */
  38555. static Download(blob: Blob, fileName: string): void;
  38556. /**
  38557. * Captures a screenshot of the current rendering
  38558. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  38559. * @param engine defines the rendering engine
  38560. * @param camera defines the source camera
  38561. * @param size This parameter can be set to a single number or to an object with the
  38562. * following (optional) properties: precision, width, height. If a single number is passed,
  38563. * it will be used for both width and height. If an object is passed, the screenshot size
  38564. * will be derived from the parameters. The precision property is a multiplier allowing
  38565. * rendering at a higher or lower resolution
  38566. * @param successCallback defines the callback receives a single parameter which contains the
  38567. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38568. * src parameter of an <img> to display it
  38569. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  38570. * Check your browser for supported MIME types
  38571. */
  38572. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  38573. /**
  38574. * Captures a screenshot of the current rendering
  38575. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  38576. * @param engine defines the rendering engine
  38577. * @param camera defines the source camera
  38578. * @param size This parameter can be set to a single number or to an object with the
  38579. * following (optional) properties: precision, width, height. If a single number is passed,
  38580. * it will be used for both width and height. If an object is passed, the screenshot size
  38581. * will be derived from the parameters. The precision property is a multiplier allowing
  38582. * rendering at a higher or lower resolution
  38583. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  38584. * Check your browser for supported MIME types
  38585. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  38586. * to the src parameter of an <img> to display it
  38587. */
  38588. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  38589. /**
  38590. * Generates an image screenshot from the specified camera.
  38591. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  38592. * @param engine The engine to use for rendering
  38593. * @param camera The camera to use for rendering
  38594. * @param size This parameter can be set to a single number or to an object with the
  38595. * following (optional) properties: precision, width, height. If a single number is passed,
  38596. * it will be used for both width and height. If an object is passed, the screenshot size
  38597. * will be derived from the parameters. The precision property is a multiplier allowing
  38598. * rendering at a higher or lower resolution
  38599. * @param successCallback The callback receives a single parameter which contains the
  38600. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38601. * src parameter of an <img> to display it
  38602. * @param mimeType The MIME type of the screenshot image (default: image/png).
  38603. * Check your browser for supported MIME types
  38604. * @param samples Texture samples (default: 1)
  38605. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  38606. * @param fileName A name for for the downloaded file.
  38607. */
  38608. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  38609. /**
  38610. * Generates an image screenshot from the specified camera.
  38611. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  38612. * @param engine The engine to use for rendering
  38613. * @param camera The camera to use for rendering
  38614. * @param size This parameter can be set to a single number or to an object with the
  38615. * following (optional) properties: precision, width, height. If a single number is passed,
  38616. * it will be used for both width and height. If an object is passed, the screenshot size
  38617. * will be derived from the parameters. The precision property is a multiplier allowing
  38618. * rendering at a higher or lower resolution
  38619. * @param mimeType The MIME type of the screenshot image (default: image/png).
  38620. * Check your browser for supported MIME types
  38621. * @param samples Texture samples (default: 1)
  38622. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  38623. * @param fileName A name for for the downloaded file.
  38624. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  38625. * to the src parameter of an <img> to display it
  38626. */
  38627. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  38628. /**
  38629. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  38630. * Be aware Math.random() could cause collisions, but:
  38631. * "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"
  38632. * @returns a pseudo random id
  38633. */
  38634. static RandomId(): string;
  38635. /**
  38636. * Test if the given uri is a base64 string
  38637. * @param uri The uri to test
  38638. * @return True if the uri is a base64 string or false otherwise
  38639. */
  38640. static IsBase64(uri: string): boolean;
  38641. /**
  38642. * Decode the given base64 uri.
  38643. * @param uri The uri to decode
  38644. * @return The decoded base64 data.
  38645. */
  38646. static DecodeBase64(uri: string): ArrayBuffer;
  38647. /**
  38648. * Gets the absolute url.
  38649. * @param url the input url
  38650. * @return the absolute url
  38651. */
  38652. static GetAbsoluteUrl(url: string): string;
  38653. /**
  38654. * No log
  38655. */
  38656. static readonly NoneLogLevel: number;
  38657. /**
  38658. * Only message logs
  38659. */
  38660. static readonly MessageLogLevel: number;
  38661. /**
  38662. * Only warning logs
  38663. */
  38664. static readonly WarningLogLevel: number;
  38665. /**
  38666. * Only error logs
  38667. */
  38668. static readonly ErrorLogLevel: number;
  38669. /**
  38670. * All logs
  38671. */
  38672. static readonly AllLogLevel: number;
  38673. /**
  38674. * Gets a value indicating the number of loading errors
  38675. * @ignorenaming
  38676. */
  38677. static get errorsCount(): number;
  38678. /**
  38679. * Callback called when a new log is added
  38680. */
  38681. static OnNewCacheEntry: (entry: string) => void;
  38682. /**
  38683. * Log a message to the console
  38684. * @param message defines the message to log
  38685. */
  38686. static Log(message: string): void;
  38687. /**
  38688. * Write a warning message to the console
  38689. * @param message defines the message to log
  38690. */
  38691. static Warn(message: string): void;
  38692. /**
  38693. * Write an error message to the console
  38694. * @param message defines the message to log
  38695. */
  38696. static Error(message: string): void;
  38697. /**
  38698. * Gets current log cache (list of logs)
  38699. */
  38700. static get LogCache(): string;
  38701. /**
  38702. * Clears the log cache
  38703. */
  38704. static ClearLogCache(): void;
  38705. /**
  38706. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  38707. */
  38708. static set LogLevels(level: number);
  38709. /**
  38710. * Checks if the window object exists
  38711. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  38712. */
  38713. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  38714. /**
  38715. * No performance log
  38716. */
  38717. static readonly PerformanceNoneLogLevel: number;
  38718. /**
  38719. * Use user marks to log performance
  38720. */
  38721. static readonly PerformanceUserMarkLogLevel: number;
  38722. /**
  38723. * Log performance to the console
  38724. */
  38725. static readonly PerformanceConsoleLogLevel: number;
  38726. private static _performance;
  38727. /**
  38728. * Sets the current performance log level
  38729. */
  38730. static set PerformanceLogLevel(level: number);
  38731. private static _StartPerformanceCounterDisabled;
  38732. private static _EndPerformanceCounterDisabled;
  38733. private static _StartUserMark;
  38734. private static _EndUserMark;
  38735. private static _StartPerformanceConsole;
  38736. private static _EndPerformanceConsole;
  38737. /**
  38738. * Starts a performance counter
  38739. */
  38740. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  38741. /**
  38742. * Ends a specific performance coutner
  38743. */
  38744. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  38745. /**
  38746. * Gets either window.performance.now() if supported or Date.now() else
  38747. */
  38748. static get Now(): number;
  38749. /**
  38750. * This method will return the name of the class used to create the instance of the given object.
  38751. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  38752. * @param object the object to get the class name from
  38753. * @param isType defines if the object is actually a type
  38754. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  38755. */
  38756. static GetClassName(object: any, isType?: boolean): string;
  38757. /**
  38758. * Gets the first element of an array satisfying a given predicate
  38759. * @param array defines the array to browse
  38760. * @param predicate defines the predicate to use
  38761. * @returns null if not found or the element
  38762. */
  38763. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  38764. /**
  38765. * This method will return the name of the full name of the class, including its owning module (if any).
  38766. * 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).
  38767. * @param object the object to get the class name from
  38768. * @param isType defines if the object is actually a type
  38769. * @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.
  38770. * @ignorenaming
  38771. */
  38772. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  38773. /**
  38774. * Returns a promise that resolves after the given amount of time.
  38775. * @param delay Number of milliseconds to delay
  38776. * @returns Promise that resolves after the given amount of time
  38777. */
  38778. static DelayAsync(delay: number): Promise<void>;
  38779. /**
  38780. * Utility function to detect if the current user agent is Safari
  38781. * @returns whether or not the current user agent is safari
  38782. */
  38783. static IsSafari(): boolean;
  38784. }
  38785. /**
  38786. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  38787. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  38788. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  38789. * @param name The name of the class, case should be preserved
  38790. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  38791. */
  38792. export function className(name: string, module?: string): (target: Object) => void;
  38793. /**
  38794. * An implementation of a loop for asynchronous functions.
  38795. */
  38796. export class AsyncLoop {
  38797. /**
  38798. * Defines the number of iterations for the loop
  38799. */
  38800. iterations: number;
  38801. /**
  38802. * Defines the current index of the loop.
  38803. */
  38804. index: number;
  38805. private _done;
  38806. private _fn;
  38807. private _successCallback;
  38808. /**
  38809. * Constructor.
  38810. * @param iterations the number of iterations.
  38811. * @param func the function to run each iteration
  38812. * @param successCallback the callback that will be called upon succesful execution
  38813. * @param offset starting offset.
  38814. */
  38815. constructor(
  38816. /**
  38817. * Defines the number of iterations for the loop
  38818. */
  38819. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  38820. /**
  38821. * Execute the next iteration. Must be called after the last iteration was finished.
  38822. */
  38823. executeNext(): void;
  38824. /**
  38825. * Break the loop and run the success callback.
  38826. */
  38827. breakLoop(): void;
  38828. /**
  38829. * Create and run an async loop.
  38830. * @param iterations the number of iterations.
  38831. * @param fn the function to run each iteration
  38832. * @param successCallback the callback that will be called upon succesful execution
  38833. * @param offset starting offset.
  38834. * @returns the created async loop object
  38835. */
  38836. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  38837. /**
  38838. * A for-loop that will run a given number of iterations synchronous and the rest async.
  38839. * @param iterations total number of iterations
  38840. * @param syncedIterations number of synchronous iterations in each async iteration.
  38841. * @param fn the function to call each iteration.
  38842. * @param callback a success call back that will be called when iterating stops.
  38843. * @param breakFunction a break condition (optional)
  38844. * @param timeout timeout settings for the setTimeout function. default - 0.
  38845. * @returns the created async loop object
  38846. */
  38847. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  38848. }
  38849. }
  38850. declare module "babylonjs/Misc/stringDictionary" {
  38851. import { Nullable } from "babylonjs/types";
  38852. /**
  38853. * This class implement a typical dictionary using a string as key and the generic type T as value.
  38854. * The underlying implementation relies on an associative array to ensure the best performances.
  38855. * The value can be anything including 'null' but except 'undefined'
  38856. */
  38857. export class StringDictionary<T> {
  38858. /**
  38859. * This will clear this dictionary and copy the content from the 'source' one.
  38860. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  38861. * @param source the dictionary to take the content from and copy to this dictionary
  38862. */
  38863. copyFrom(source: StringDictionary<T>): void;
  38864. /**
  38865. * Get a value based from its key
  38866. * @param key the given key to get the matching value from
  38867. * @return the value if found, otherwise undefined is returned
  38868. */
  38869. get(key: string): T | undefined;
  38870. /**
  38871. * Get a value from its key or add it if it doesn't exist.
  38872. * This method will ensure you that a given key/data will be present in the dictionary.
  38873. * @param key the given key to get the matching value from
  38874. * @param factory the factory that will create the value if the key is not present in the dictionary.
  38875. * The factory will only be invoked if there's no data for the given key.
  38876. * @return the value corresponding to the key.
  38877. */
  38878. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  38879. /**
  38880. * Get a value from its key if present in the dictionary otherwise add it
  38881. * @param key the key to get the value from
  38882. * @param val if there's no such key/value pair in the dictionary add it with this value
  38883. * @return the value corresponding to the key
  38884. */
  38885. getOrAdd(key: string, val: T): T;
  38886. /**
  38887. * Check if there's a given key in the dictionary
  38888. * @param key the key to check for
  38889. * @return true if the key is present, false otherwise
  38890. */
  38891. contains(key: string): boolean;
  38892. /**
  38893. * Add a new key and its corresponding value
  38894. * @param key the key to add
  38895. * @param value the value corresponding to the key
  38896. * @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
  38897. */
  38898. add(key: string, value: T): boolean;
  38899. /**
  38900. * Update a specific value associated to a key
  38901. * @param key defines the key to use
  38902. * @param value defines the value to store
  38903. * @returns true if the value was updated (or false if the key was not found)
  38904. */
  38905. set(key: string, value: T): boolean;
  38906. /**
  38907. * Get the element of the given key and remove it from the dictionary
  38908. * @param key defines the key to search
  38909. * @returns the value associated with the key or null if not found
  38910. */
  38911. getAndRemove(key: string): Nullable<T>;
  38912. /**
  38913. * Remove a key/value from the dictionary.
  38914. * @param key the key to remove
  38915. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  38916. */
  38917. remove(key: string): boolean;
  38918. /**
  38919. * Clear the whole content of the dictionary
  38920. */
  38921. clear(): void;
  38922. /**
  38923. * Gets the current count
  38924. */
  38925. get count(): number;
  38926. /**
  38927. * Execute a callback on each key/val of the dictionary.
  38928. * Note that you can remove any element in this dictionary in the callback implementation
  38929. * @param callback the callback to execute on a given key/value pair
  38930. */
  38931. forEach(callback: (key: string, val: T) => void): void;
  38932. /**
  38933. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  38934. * If the callback returns null or undefined the method will iterate to the next key/value pair
  38935. * Note that you can remove any element in this dictionary in the callback implementation
  38936. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  38937. * @returns the first item
  38938. */
  38939. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  38940. private _count;
  38941. private _data;
  38942. }
  38943. }
  38944. declare module "babylonjs/Collisions/collisionCoordinator" {
  38945. import { Nullable } from "babylonjs/types";
  38946. import { Scene } from "babylonjs/scene";
  38947. import { Vector3 } from "babylonjs/Maths/math.vector";
  38948. import { Collider } from "babylonjs/Collisions/collider";
  38949. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38950. /** @hidden */
  38951. export interface ICollisionCoordinator {
  38952. createCollider(): Collider;
  38953. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  38954. init(scene: Scene): void;
  38955. }
  38956. /** @hidden */
  38957. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  38958. private _scene;
  38959. private _scaledPosition;
  38960. private _scaledVelocity;
  38961. private _finalPosition;
  38962. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  38963. createCollider(): Collider;
  38964. init(scene: Scene): void;
  38965. private _collideWithWorld;
  38966. }
  38967. }
  38968. declare module "babylonjs/Inputs/scene.inputManager" {
  38969. import { Nullable } from "babylonjs/types";
  38970. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  38971. import { Vector2 } from "babylonjs/Maths/math.vector";
  38972. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38973. import { Scene } from "babylonjs/scene";
  38974. /**
  38975. * Class used to manage all inputs for the scene.
  38976. */
  38977. export class InputManager {
  38978. /** The distance in pixel that you have to move to prevent some events */
  38979. static DragMovementThreshold: number;
  38980. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  38981. static LongPressDelay: number;
  38982. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  38983. static DoubleClickDelay: number;
  38984. /** If you need to check double click without raising a single click at first click, enable this flag */
  38985. static ExclusiveDoubleClickMode: boolean;
  38986. private _wheelEventName;
  38987. private _onPointerMove;
  38988. private _onPointerDown;
  38989. private _onPointerUp;
  38990. private _initClickEvent;
  38991. private _initActionManager;
  38992. private _delayedSimpleClick;
  38993. private _delayedSimpleClickTimeout;
  38994. private _previousDelayedSimpleClickTimeout;
  38995. private _meshPickProceed;
  38996. private _previousButtonPressed;
  38997. private _currentPickResult;
  38998. private _previousPickResult;
  38999. private _totalPointersPressed;
  39000. private _doubleClickOccured;
  39001. private _pointerOverMesh;
  39002. private _pickedDownMesh;
  39003. private _pickedUpMesh;
  39004. private _pointerX;
  39005. private _pointerY;
  39006. private _unTranslatedPointerX;
  39007. private _unTranslatedPointerY;
  39008. private _startingPointerPosition;
  39009. private _previousStartingPointerPosition;
  39010. private _startingPointerTime;
  39011. private _previousStartingPointerTime;
  39012. private _pointerCaptures;
  39013. private _onKeyDown;
  39014. private _onKeyUp;
  39015. private _onCanvasFocusObserver;
  39016. private _onCanvasBlurObserver;
  39017. private _scene;
  39018. /**
  39019. * Creates a new InputManager
  39020. * @param scene defines the hosting scene
  39021. */
  39022. constructor(scene: Scene);
  39023. /**
  39024. * Gets the mesh that is currently under the pointer
  39025. */
  39026. get meshUnderPointer(): Nullable<AbstractMesh>;
  39027. /**
  39028. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  39029. */
  39030. get unTranslatedPointer(): Vector2;
  39031. /**
  39032. * Gets or sets the current on-screen X position of the pointer
  39033. */
  39034. get pointerX(): number;
  39035. set pointerX(value: number);
  39036. /**
  39037. * Gets or sets the current on-screen Y position of the pointer
  39038. */
  39039. get pointerY(): number;
  39040. set pointerY(value: number);
  39041. private _updatePointerPosition;
  39042. private _processPointerMove;
  39043. private _setRayOnPointerInfo;
  39044. private _checkPrePointerObservable;
  39045. /**
  39046. * Use this method to simulate a pointer move on a mesh
  39047. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39048. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39049. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39050. */
  39051. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  39052. /**
  39053. * Use this method to simulate a pointer down on a mesh
  39054. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39055. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39056. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39057. */
  39058. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  39059. private _processPointerDown;
  39060. /** @hidden */
  39061. _isPointerSwiping(): boolean;
  39062. /**
  39063. * Use this method to simulate a pointer up on a mesh
  39064. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39065. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39066. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39067. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  39068. */
  39069. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  39070. private _processPointerUp;
  39071. /**
  39072. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  39073. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  39074. * @returns true if the pointer was captured
  39075. */
  39076. isPointerCaptured(pointerId?: number): boolean;
  39077. /**
  39078. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  39079. * @param attachUp defines if you want to attach events to pointerup
  39080. * @param attachDown defines if you want to attach events to pointerdown
  39081. * @param attachMove defines if you want to attach events to pointermove
  39082. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  39083. */
  39084. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  39085. /**
  39086. * Detaches all event handlers
  39087. */
  39088. detachControl(): void;
  39089. /**
  39090. * Force the value of meshUnderPointer
  39091. * @param mesh defines the mesh to use
  39092. */
  39093. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  39094. /**
  39095. * Gets the mesh under the pointer
  39096. * @returns a Mesh or null if no mesh is under the pointer
  39097. */
  39098. getPointerOverMesh(): Nullable<AbstractMesh>;
  39099. }
  39100. }
  39101. declare module "babylonjs/Animations/animationGroup" {
  39102. import { Animatable } from "babylonjs/Animations/animatable";
  39103. import { Animation } from "babylonjs/Animations/animation";
  39104. import { Scene, IDisposable } from "babylonjs/scene";
  39105. import { Observable } from "babylonjs/Misc/observable";
  39106. import { Nullable } from "babylonjs/types";
  39107. import "babylonjs/Animations/animatable";
  39108. /**
  39109. * This class defines the direct association between an animation and a target
  39110. */
  39111. export class TargetedAnimation {
  39112. /**
  39113. * Animation to perform
  39114. */
  39115. animation: Animation;
  39116. /**
  39117. * Target to animate
  39118. */
  39119. target: any;
  39120. /**
  39121. * Serialize the object
  39122. * @returns the JSON object representing the current entity
  39123. */
  39124. serialize(): any;
  39125. }
  39126. /**
  39127. * Use this class to create coordinated animations on multiple targets
  39128. */
  39129. export class AnimationGroup implements IDisposable {
  39130. /** The name of the animation group */
  39131. name: string;
  39132. private _scene;
  39133. private _targetedAnimations;
  39134. private _animatables;
  39135. private _from;
  39136. private _to;
  39137. private _isStarted;
  39138. private _isPaused;
  39139. private _speedRatio;
  39140. private _loopAnimation;
  39141. private _isAdditive;
  39142. /**
  39143. * Gets or sets the unique id of the node
  39144. */
  39145. uniqueId: number;
  39146. /**
  39147. * This observable will notify when one animation have ended
  39148. */
  39149. onAnimationEndObservable: Observable<TargetedAnimation>;
  39150. /**
  39151. * Observer raised when one animation loops
  39152. */
  39153. onAnimationLoopObservable: Observable<TargetedAnimation>;
  39154. /**
  39155. * Observer raised when all animations have looped
  39156. */
  39157. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  39158. /**
  39159. * This observable will notify when all animations have ended.
  39160. */
  39161. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  39162. /**
  39163. * This observable will notify when all animations have paused.
  39164. */
  39165. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  39166. /**
  39167. * This observable will notify when all animations are playing.
  39168. */
  39169. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  39170. /**
  39171. * Gets the first frame
  39172. */
  39173. get from(): number;
  39174. /**
  39175. * Gets the last frame
  39176. */
  39177. get to(): number;
  39178. /**
  39179. * Define if the animations are started
  39180. */
  39181. get isStarted(): boolean;
  39182. /**
  39183. * Gets a value indicating that the current group is playing
  39184. */
  39185. get isPlaying(): boolean;
  39186. /**
  39187. * Gets or sets the speed ratio to use for all animations
  39188. */
  39189. get speedRatio(): number;
  39190. /**
  39191. * Gets or sets the speed ratio to use for all animations
  39192. */
  39193. set speedRatio(value: number);
  39194. /**
  39195. * Gets or sets if all animations should loop or not
  39196. */
  39197. get loopAnimation(): boolean;
  39198. set loopAnimation(value: boolean);
  39199. /**
  39200. * Gets or sets if all animations should be evaluated additively
  39201. */
  39202. get isAdditive(): boolean;
  39203. set isAdditive(value: boolean);
  39204. /**
  39205. * Gets the targeted animations for this animation group
  39206. */
  39207. get targetedAnimations(): Array<TargetedAnimation>;
  39208. /**
  39209. * returning the list of animatables controlled by this animation group.
  39210. */
  39211. get animatables(): Array<Animatable>;
  39212. /**
  39213. * Instantiates a new Animation Group.
  39214. * This helps managing several animations at once.
  39215. * @see http://doc.babylonjs.com/how_to/group
  39216. * @param name Defines the name of the group
  39217. * @param scene Defines the scene the group belongs to
  39218. */
  39219. constructor(
  39220. /** The name of the animation group */
  39221. name: string, scene?: Nullable<Scene>);
  39222. /**
  39223. * Add an animation (with its target) in the group
  39224. * @param animation defines the animation we want to add
  39225. * @param target defines the target of the animation
  39226. * @returns the TargetedAnimation object
  39227. */
  39228. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  39229. /**
  39230. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  39231. * It can add constant keys at begin or end
  39232. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  39233. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  39234. * @returns the animation group
  39235. */
  39236. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  39237. private _animationLoopCount;
  39238. private _animationLoopFlags;
  39239. private _processLoop;
  39240. /**
  39241. * Start all animations on given targets
  39242. * @param loop defines if animations must loop
  39243. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  39244. * @param from defines the from key (optional)
  39245. * @param to defines the to key (optional)
  39246. * @param isAdditive defines the additive state for the resulting animatables (optional)
  39247. * @returns the current animation group
  39248. */
  39249. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  39250. /**
  39251. * Pause all animations
  39252. * @returns the animation group
  39253. */
  39254. pause(): AnimationGroup;
  39255. /**
  39256. * Play all animations to initial state
  39257. * This function will start() the animations if they were not started or will restart() them if they were paused
  39258. * @param loop defines if animations must loop
  39259. * @returns the animation group
  39260. */
  39261. play(loop?: boolean): AnimationGroup;
  39262. /**
  39263. * Reset all animations to initial state
  39264. * @returns the animation group
  39265. */
  39266. reset(): AnimationGroup;
  39267. /**
  39268. * Restart animations from key 0
  39269. * @returns the animation group
  39270. */
  39271. restart(): AnimationGroup;
  39272. /**
  39273. * Stop all animations
  39274. * @returns the animation group
  39275. */
  39276. stop(): AnimationGroup;
  39277. /**
  39278. * Set animation weight for all animatables
  39279. * @param weight defines the weight to use
  39280. * @return the animationGroup
  39281. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  39282. */
  39283. setWeightForAllAnimatables(weight: number): AnimationGroup;
  39284. /**
  39285. * Synchronize and normalize all animatables with a source animatable
  39286. * @param root defines the root animatable to synchronize with
  39287. * @return the animationGroup
  39288. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  39289. */
  39290. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  39291. /**
  39292. * Goes to a specific frame in this animation group
  39293. * @param frame the frame number to go to
  39294. * @return the animationGroup
  39295. */
  39296. goToFrame(frame: number): AnimationGroup;
  39297. /**
  39298. * Dispose all associated resources
  39299. */
  39300. dispose(): void;
  39301. private _checkAnimationGroupEnded;
  39302. /**
  39303. * Clone the current animation group and returns a copy
  39304. * @param newName defines the name of the new group
  39305. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  39306. * @returns the new aniamtion group
  39307. */
  39308. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  39309. /**
  39310. * Serializes the animationGroup to an object
  39311. * @returns Serialized object
  39312. */
  39313. serialize(): any;
  39314. /**
  39315. * Returns a new AnimationGroup object parsed from the source provided.
  39316. * @param parsedAnimationGroup defines the source
  39317. * @param scene defines the scene that will receive the animationGroup
  39318. * @returns a new AnimationGroup
  39319. */
  39320. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  39321. /**
  39322. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  39323. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  39324. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  39325. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  39326. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  39327. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  39328. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  39329. */
  39330. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  39331. /**
  39332. * Returns the string "AnimationGroup"
  39333. * @returns "AnimationGroup"
  39334. */
  39335. getClassName(): string;
  39336. /**
  39337. * Creates a detailled string about the object
  39338. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  39339. * @returns a string representing the object
  39340. */
  39341. toString(fullDetails?: boolean): string;
  39342. }
  39343. }
  39344. declare module "babylonjs/scene" {
  39345. import { Nullable } from "babylonjs/types";
  39346. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  39347. import { Observable } from "babylonjs/Misc/observable";
  39348. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  39349. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  39350. import { Geometry } from "babylonjs/Meshes/geometry";
  39351. import { TransformNode } from "babylonjs/Meshes/transformNode";
  39352. import { SubMesh } from "babylonjs/Meshes/subMesh";
  39353. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39354. import { Mesh } from "babylonjs/Meshes/mesh";
  39355. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  39356. import { Bone } from "babylonjs/Bones/bone";
  39357. import { Skeleton } from "babylonjs/Bones/skeleton";
  39358. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  39359. import { Camera } from "babylonjs/Cameras/camera";
  39360. import { AbstractScene } from "babylonjs/abstractScene";
  39361. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39362. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  39363. import { Material } from "babylonjs/Materials/material";
  39364. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  39365. import { Effect } from "babylonjs/Materials/effect";
  39366. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  39367. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  39368. import { Light } from "babylonjs/Lights/light";
  39369. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  39370. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  39371. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  39372. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  39373. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39374. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  39375. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  39376. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  39377. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  39378. import { Engine } from "babylonjs/Engines/engine";
  39379. import { Node } from "babylonjs/node";
  39380. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  39381. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  39382. import { WebRequest } from "babylonjs/Misc/webRequest";
  39383. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  39384. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  39385. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  39386. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  39387. import { Plane } from "babylonjs/Maths/math.plane";
  39388. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  39389. import { Ray } from "babylonjs/Culling/ray";
  39390. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  39391. import { Animation } from "babylonjs/Animations/animation";
  39392. import { Animatable } from "babylonjs/Animations/animatable";
  39393. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  39394. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  39395. import { Collider } from "babylonjs/Collisions/collider";
  39396. /**
  39397. * Define an interface for all classes that will hold resources
  39398. */
  39399. export interface IDisposable {
  39400. /**
  39401. * Releases all held resources
  39402. */
  39403. dispose(): void;
  39404. }
  39405. /** Interface defining initialization parameters for Scene class */
  39406. export interface SceneOptions {
  39407. /**
  39408. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  39409. * It will improve performance when the number of geometries becomes important.
  39410. */
  39411. useGeometryUniqueIdsMap?: boolean;
  39412. /**
  39413. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  39414. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  39415. */
  39416. useMaterialMeshMap?: boolean;
  39417. /**
  39418. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  39419. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  39420. */
  39421. useClonedMeshMap?: boolean;
  39422. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  39423. virtual?: boolean;
  39424. }
  39425. /**
  39426. * Represents a scene to be rendered by the engine.
  39427. * @see http://doc.babylonjs.com/features/scene
  39428. */
  39429. export class Scene extends AbstractScene implements IAnimatable {
  39430. /** The fog is deactivated */
  39431. static readonly FOGMODE_NONE: number;
  39432. /** The fog density is following an exponential function */
  39433. static readonly FOGMODE_EXP: number;
  39434. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  39435. static readonly FOGMODE_EXP2: number;
  39436. /** The fog density is following a linear function. */
  39437. static readonly FOGMODE_LINEAR: number;
  39438. /**
  39439. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  39440. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39441. */
  39442. static MinDeltaTime: number;
  39443. /**
  39444. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  39445. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39446. */
  39447. static MaxDeltaTime: number;
  39448. /**
  39449. * Factory used to create the default material.
  39450. * @param name The name of the material to create
  39451. * @param scene The scene to create the material for
  39452. * @returns The default material
  39453. */
  39454. static DefaultMaterialFactory(scene: Scene): Material;
  39455. /**
  39456. * Factory used to create the a collision coordinator.
  39457. * @returns The collision coordinator
  39458. */
  39459. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  39460. /** @hidden */
  39461. _inputManager: InputManager;
  39462. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  39463. cameraToUseForPointers: Nullable<Camera>;
  39464. /** @hidden */
  39465. readonly _isScene: boolean;
  39466. /** @hidden */
  39467. _blockEntityCollection: boolean;
  39468. /**
  39469. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  39470. */
  39471. autoClear: boolean;
  39472. /**
  39473. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  39474. */
  39475. autoClearDepthAndStencil: boolean;
  39476. /**
  39477. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  39478. */
  39479. clearColor: Color4;
  39480. /**
  39481. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  39482. */
  39483. ambientColor: Color3;
  39484. /**
  39485. * This is use to store the default BRDF lookup for PBR materials in your scene.
  39486. * It should only be one of the following (if not the default embedded one):
  39487. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  39488. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  39489. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  39490. * The material properties need to be setup according to the type of texture in use.
  39491. */
  39492. environmentBRDFTexture: BaseTexture;
  39493. /** @hidden */
  39494. protected _environmentTexture: Nullable<BaseTexture>;
  39495. /**
  39496. * Texture used in all pbr material as the reflection texture.
  39497. * As in the majority of the scene they are the same (exception for multi room and so on),
  39498. * this is easier to reference from here than from all the materials.
  39499. */
  39500. get environmentTexture(): Nullable<BaseTexture>;
  39501. /**
  39502. * Texture used in all pbr material as the reflection texture.
  39503. * As in the majority of the scene they are the same (exception for multi room and so on),
  39504. * this is easier to set here than in all the materials.
  39505. */
  39506. set environmentTexture(value: Nullable<BaseTexture>);
  39507. /** @hidden */
  39508. protected _environmentIntensity: number;
  39509. /**
  39510. * Intensity of the environment in all pbr material.
  39511. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  39512. * As in the majority of the scene they are the same (exception for multi room and so on),
  39513. * this is easier to reference from here than from all the materials.
  39514. */
  39515. get environmentIntensity(): number;
  39516. /**
  39517. * Intensity of the environment in all pbr material.
  39518. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  39519. * As in the majority of the scene they are the same (exception for multi room and so on),
  39520. * this is easier to set here than in all the materials.
  39521. */
  39522. set environmentIntensity(value: number);
  39523. /** @hidden */
  39524. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39525. /**
  39526. * Default image processing configuration used either in the rendering
  39527. * Forward main pass or through the imageProcessingPostProcess if present.
  39528. * As in the majority of the scene they are the same (exception for multi camera),
  39529. * this is easier to reference from here than from all the materials and post process.
  39530. *
  39531. * No setter as we it is a shared configuration, you can set the values instead.
  39532. */
  39533. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  39534. private _forceWireframe;
  39535. /**
  39536. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  39537. */
  39538. set forceWireframe(value: boolean);
  39539. get forceWireframe(): boolean;
  39540. private _skipFrustumClipping;
  39541. /**
  39542. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  39543. */
  39544. set skipFrustumClipping(value: boolean);
  39545. get skipFrustumClipping(): boolean;
  39546. private _forcePointsCloud;
  39547. /**
  39548. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  39549. */
  39550. set forcePointsCloud(value: boolean);
  39551. get forcePointsCloud(): boolean;
  39552. /**
  39553. * Gets or sets the active clipplane 1
  39554. */
  39555. clipPlane: Nullable<Plane>;
  39556. /**
  39557. * Gets or sets the active clipplane 2
  39558. */
  39559. clipPlane2: Nullable<Plane>;
  39560. /**
  39561. * Gets or sets the active clipplane 3
  39562. */
  39563. clipPlane3: Nullable<Plane>;
  39564. /**
  39565. * Gets or sets the active clipplane 4
  39566. */
  39567. clipPlane4: Nullable<Plane>;
  39568. /**
  39569. * Gets or sets the active clipplane 5
  39570. */
  39571. clipPlane5: Nullable<Plane>;
  39572. /**
  39573. * Gets or sets the active clipplane 6
  39574. */
  39575. clipPlane6: Nullable<Plane>;
  39576. /**
  39577. * Gets or sets a boolean indicating if animations are enabled
  39578. */
  39579. animationsEnabled: boolean;
  39580. private _animationPropertiesOverride;
  39581. /**
  39582. * Gets or sets the animation properties override
  39583. */
  39584. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  39585. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  39586. /**
  39587. * Gets or sets a boolean indicating if a constant deltatime has to be used
  39588. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  39589. */
  39590. useConstantAnimationDeltaTime: boolean;
  39591. /**
  39592. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  39593. * Please note that it requires to run a ray cast through the scene on every frame
  39594. */
  39595. constantlyUpdateMeshUnderPointer: boolean;
  39596. /**
  39597. * Defines the HTML cursor to use when hovering over interactive elements
  39598. */
  39599. hoverCursor: string;
  39600. /**
  39601. * Defines the HTML default cursor to use (empty by default)
  39602. */
  39603. defaultCursor: string;
  39604. /**
  39605. * Defines whether cursors are handled by the scene.
  39606. */
  39607. doNotHandleCursors: boolean;
  39608. /**
  39609. * This is used to call preventDefault() on pointer down
  39610. * in order to block unwanted artifacts like system double clicks
  39611. */
  39612. preventDefaultOnPointerDown: boolean;
  39613. /**
  39614. * This is used to call preventDefault() on pointer up
  39615. * in order to block unwanted artifacts like system double clicks
  39616. */
  39617. preventDefaultOnPointerUp: boolean;
  39618. /**
  39619. * Gets or sets user defined metadata
  39620. */
  39621. metadata: any;
  39622. /**
  39623. * For internal use only. Please do not use.
  39624. */
  39625. reservedDataStore: any;
  39626. /**
  39627. * Gets the name of the plugin used to load this scene (null by default)
  39628. */
  39629. loadingPluginName: string;
  39630. /**
  39631. * Use this array to add regular expressions used to disable offline support for specific urls
  39632. */
  39633. disableOfflineSupportExceptionRules: RegExp[];
  39634. /**
  39635. * An event triggered when the scene is disposed.
  39636. */
  39637. onDisposeObservable: Observable<Scene>;
  39638. private _onDisposeObserver;
  39639. /** Sets a function to be executed when this scene is disposed. */
  39640. set onDispose(callback: () => void);
  39641. /**
  39642. * An event triggered before rendering the scene (right after animations and physics)
  39643. */
  39644. onBeforeRenderObservable: Observable<Scene>;
  39645. private _onBeforeRenderObserver;
  39646. /** Sets a function to be executed before rendering this scene */
  39647. set beforeRender(callback: Nullable<() => void>);
  39648. /**
  39649. * An event triggered after rendering the scene
  39650. */
  39651. onAfterRenderObservable: Observable<Scene>;
  39652. /**
  39653. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  39654. */
  39655. onAfterRenderCameraObservable: Observable<Camera>;
  39656. private _onAfterRenderObserver;
  39657. /** Sets a function to be executed after rendering this scene */
  39658. set afterRender(callback: Nullable<() => void>);
  39659. /**
  39660. * An event triggered before animating the scene
  39661. */
  39662. onBeforeAnimationsObservable: Observable<Scene>;
  39663. /**
  39664. * An event triggered after animations processing
  39665. */
  39666. onAfterAnimationsObservable: Observable<Scene>;
  39667. /**
  39668. * An event triggered before draw calls are ready to be sent
  39669. */
  39670. onBeforeDrawPhaseObservable: Observable<Scene>;
  39671. /**
  39672. * An event triggered after draw calls have been sent
  39673. */
  39674. onAfterDrawPhaseObservable: Observable<Scene>;
  39675. /**
  39676. * An event triggered when the scene is ready
  39677. */
  39678. onReadyObservable: Observable<Scene>;
  39679. /**
  39680. * An event triggered before rendering a camera
  39681. */
  39682. onBeforeCameraRenderObservable: Observable<Camera>;
  39683. private _onBeforeCameraRenderObserver;
  39684. /** Sets a function to be executed before rendering a camera*/
  39685. set beforeCameraRender(callback: () => void);
  39686. /**
  39687. * An event triggered after rendering a camera
  39688. */
  39689. onAfterCameraRenderObservable: Observable<Camera>;
  39690. private _onAfterCameraRenderObserver;
  39691. /** Sets a function to be executed after rendering a camera*/
  39692. set afterCameraRender(callback: () => void);
  39693. /**
  39694. * An event triggered when active meshes evaluation is about to start
  39695. */
  39696. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  39697. /**
  39698. * An event triggered when active meshes evaluation is done
  39699. */
  39700. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  39701. /**
  39702. * An event triggered when particles rendering is about to start
  39703. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  39704. */
  39705. onBeforeParticlesRenderingObservable: Observable<Scene>;
  39706. /**
  39707. * An event triggered when particles rendering is done
  39708. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  39709. */
  39710. onAfterParticlesRenderingObservable: Observable<Scene>;
  39711. /**
  39712. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  39713. */
  39714. onDataLoadedObservable: Observable<Scene>;
  39715. /**
  39716. * An event triggered when a camera is created
  39717. */
  39718. onNewCameraAddedObservable: Observable<Camera>;
  39719. /**
  39720. * An event triggered when a camera is removed
  39721. */
  39722. onCameraRemovedObservable: Observable<Camera>;
  39723. /**
  39724. * An event triggered when a light is created
  39725. */
  39726. onNewLightAddedObservable: Observable<Light>;
  39727. /**
  39728. * An event triggered when a light is removed
  39729. */
  39730. onLightRemovedObservable: Observable<Light>;
  39731. /**
  39732. * An event triggered when a geometry is created
  39733. */
  39734. onNewGeometryAddedObservable: Observable<Geometry>;
  39735. /**
  39736. * An event triggered when a geometry is removed
  39737. */
  39738. onGeometryRemovedObservable: Observable<Geometry>;
  39739. /**
  39740. * An event triggered when a transform node is created
  39741. */
  39742. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  39743. /**
  39744. * An event triggered when a transform node is removed
  39745. */
  39746. onTransformNodeRemovedObservable: Observable<TransformNode>;
  39747. /**
  39748. * An event triggered when a mesh is created
  39749. */
  39750. onNewMeshAddedObservable: Observable<AbstractMesh>;
  39751. /**
  39752. * An event triggered when a mesh is removed
  39753. */
  39754. onMeshRemovedObservable: Observable<AbstractMesh>;
  39755. /**
  39756. * An event triggered when a skeleton is created
  39757. */
  39758. onNewSkeletonAddedObservable: Observable<Skeleton>;
  39759. /**
  39760. * An event triggered when a skeleton is removed
  39761. */
  39762. onSkeletonRemovedObservable: Observable<Skeleton>;
  39763. /**
  39764. * An event triggered when a material is created
  39765. */
  39766. onNewMaterialAddedObservable: Observable<Material>;
  39767. /**
  39768. * An event triggered when a material is removed
  39769. */
  39770. onMaterialRemovedObservable: Observable<Material>;
  39771. /**
  39772. * An event triggered when a texture is created
  39773. */
  39774. onNewTextureAddedObservable: Observable<BaseTexture>;
  39775. /**
  39776. * An event triggered when a texture is removed
  39777. */
  39778. onTextureRemovedObservable: Observable<BaseTexture>;
  39779. /**
  39780. * An event triggered when render targets are about to be rendered
  39781. * Can happen multiple times per frame.
  39782. */
  39783. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  39784. /**
  39785. * An event triggered when render targets were rendered.
  39786. * Can happen multiple times per frame.
  39787. */
  39788. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  39789. /**
  39790. * An event triggered before calculating deterministic simulation step
  39791. */
  39792. onBeforeStepObservable: Observable<Scene>;
  39793. /**
  39794. * An event triggered after calculating deterministic simulation step
  39795. */
  39796. onAfterStepObservable: Observable<Scene>;
  39797. /**
  39798. * An event triggered when the activeCamera property is updated
  39799. */
  39800. onActiveCameraChanged: Observable<Scene>;
  39801. /**
  39802. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  39803. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  39804. * 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)
  39805. */
  39806. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  39807. /**
  39808. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  39809. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  39810. * 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)
  39811. */
  39812. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  39813. /**
  39814. * This Observable will when a mesh has been imported into the scene.
  39815. */
  39816. onMeshImportedObservable: Observable<AbstractMesh>;
  39817. /**
  39818. * This Observable will when an animation file has been imported into the scene.
  39819. */
  39820. onAnimationFileImportedObservable: Observable<Scene>;
  39821. /**
  39822. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  39823. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  39824. */
  39825. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  39826. /** @hidden */
  39827. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  39828. /**
  39829. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  39830. */
  39831. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  39832. /**
  39833. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  39834. */
  39835. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  39836. /**
  39837. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  39838. */
  39839. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  39840. /** Callback called when a pointer move is detected */
  39841. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  39842. /** Callback called when a pointer down is detected */
  39843. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  39844. /** Callback called when a pointer up is detected */
  39845. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  39846. /** Callback called when a pointer pick is detected */
  39847. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  39848. /**
  39849. * 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).
  39850. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  39851. */
  39852. onPrePointerObservable: Observable<PointerInfoPre>;
  39853. /**
  39854. * Observable event triggered each time an input event is received from the rendering canvas
  39855. */
  39856. onPointerObservable: Observable<PointerInfo>;
  39857. /**
  39858. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  39859. */
  39860. get unTranslatedPointer(): Vector2;
  39861. /**
  39862. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  39863. */
  39864. static get DragMovementThreshold(): number;
  39865. static set DragMovementThreshold(value: number);
  39866. /**
  39867. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  39868. */
  39869. static get LongPressDelay(): number;
  39870. static set LongPressDelay(value: number);
  39871. /**
  39872. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  39873. */
  39874. static get DoubleClickDelay(): number;
  39875. static set DoubleClickDelay(value: number);
  39876. /** If you need to check double click without raising a single click at first click, enable this flag */
  39877. static get ExclusiveDoubleClickMode(): boolean;
  39878. static set ExclusiveDoubleClickMode(value: boolean);
  39879. /** @hidden */
  39880. _mirroredCameraPosition: Nullable<Vector3>;
  39881. /**
  39882. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  39883. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  39884. */
  39885. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  39886. /**
  39887. * Observable event triggered each time an keyboard event is received from the hosting window
  39888. */
  39889. onKeyboardObservable: Observable<KeyboardInfo>;
  39890. private _useRightHandedSystem;
  39891. /**
  39892. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  39893. */
  39894. set useRightHandedSystem(value: boolean);
  39895. get useRightHandedSystem(): boolean;
  39896. private _timeAccumulator;
  39897. private _currentStepId;
  39898. private _currentInternalStep;
  39899. /**
  39900. * Sets the step Id used by deterministic lock step
  39901. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39902. * @param newStepId defines the step Id
  39903. */
  39904. setStepId(newStepId: number): void;
  39905. /**
  39906. * Gets the step Id used by deterministic lock step
  39907. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39908. * @returns the step Id
  39909. */
  39910. getStepId(): number;
  39911. /**
  39912. * Gets the internal step used by deterministic lock step
  39913. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39914. * @returns the internal step
  39915. */
  39916. getInternalStep(): number;
  39917. private _fogEnabled;
  39918. /**
  39919. * Gets or sets a boolean indicating if fog is enabled on this scene
  39920. * @see http://doc.babylonjs.com/babylon101/environment#fog
  39921. * (Default is true)
  39922. */
  39923. set fogEnabled(value: boolean);
  39924. get fogEnabled(): boolean;
  39925. private _fogMode;
  39926. /**
  39927. * Gets or sets the fog mode to use
  39928. * @see http://doc.babylonjs.com/babylon101/environment#fog
  39929. * | mode | value |
  39930. * | --- | --- |
  39931. * | FOGMODE_NONE | 0 |
  39932. * | FOGMODE_EXP | 1 |
  39933. * | FOGMODE_EXP2 | 2 |
  39934. * | FOGMODE_LINEAR | 3 |
  39935. */
  39936. set fogMode(value: number);
  39937. get fogMode(): number;
  39938. /**
  39939. * Gets or sets the fog color to use
  39940. * @see http://doc.babylonjs.com/babylon101/environment#fog
  39941. * (Default is Color3(0.2, 0.2, 0.3))
  39942. */
  39943. fogColor: Color3;
  39944. /**
  39945. * Gets or sets the fog density to use
  39946. * @see http://doc.babylonjs.com/babylon101/environment#fog
  39947. * (Default is 0.1)
  39948. */
  39949. fogDensity: number;
  39950. /**
  39951. * Gets or sets the fog start distance to use
  39952. * @see http://doc.babylonjs.com/babylon101/environment#fog
  39953. * (Default is 0)
  39954. */
  39955. fogStart: number;
  39956. /**
  39957. * Gets or sets the fog end distance to use
  39958. * @see http://doc.babylonjs.com/babylon101/environment#fog
  39959. * (Default is 1000)
  39960. */
  39961. fogEnd: number;
  39962. private _shadowsEnabled;
  39963. /**
  39964. * Gets or sets a boolean indicating if shadows are enabled on this scene
  39965. */
  39966. set shadowsEnabled(value: boolean);
  39967. get shadowsEnabled(): boolean;
  39968. private _lightsEnabled;
  39969. /**
  39970. * Gets or sets a boolean indicating if lights are enabled on this scene
  39971. */
  39972. set lightsEnabled(value: boolean);
  39973. get lightsEnabled(): boolean;
  39974. /** All of the active cameras added to this scene. */
  39975. activeCameras: Camera[];
  39976. /** @hidden */
  39977. _activeCamera: Nullable<Camera>;
  39978. /** Gets or sets the current active camera */
  39979. get activeCamera(): Nullable<Camera>;
  39980. set activeCamera(value: Nullable<Camera>);
  39981. private _defaultMaterial;
  39982. /** The default material used on meshes when no material is affected */
  39983. get defaultMaterial(): Material;
  39984. /** The default material used on meshes when no material is affected */
  39985. set defaultMaterial(value: Material);
  39986. private _texturesEnabled;
  39987. /**
  39988. * Gets or sets a boolean indicating if textures are enabled on this scene
  39989. */
  39990. set texturesEnabled(value: boolean);
  39991. get texturesEnabled(): boolean;
  39992. /**
  39993. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  39994. */
  39995. physicsEnabled: boolean;
  39996. /**
  39997. * Gets or sets a boolean indicating if particles are enabled on this scene
  39998. */
  39999. particlesEnabled: boolean;
  40000. /**
  40001. * Gets or sets a boolean indicating if sprites are enabled on this scene
  40002. */
  40003. spritesEnabled: boolean;
  40004. private _skeletonsEnabled;
  40005. /**
  40006. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  40007. */
  40008. set skeletonsEnabled(value: boolean);
  40009. get skeletonsEnabled(): boolean;
  40010. /**
  40011. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  40012. */
  40013. lensFlaresEnabled: boolean;
  40014. /**
  40015. * Gets or sets a boolean indicating if collisions are enabled on this scene
  40016. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  40017. */
  40018. collisionsEnabled: boolean;
  40019. private _collisionCoordinator;
  40020. /** @hidden */
  40021. get collisionCoordinator(): ICollisionCoordinator;
  40022. /**
  40023. * Defines the gravity applied to this scene (used only for collisions)
  40024. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  40025. */
  40026. gravity: Vector3;
  40027. /**
  40028. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  40029. */
  40030. postProcessesEnabled: boolean;
  40031. /**
  40032. * The list of postprocesses added to the scene
  40033. */
  40034. postProcesses: PostProcess[];
  40035. /**
  40036. * Gets the current postprocess manager
  40037. */
  40038. postProcessManager: PostProcessManager;
  40039. /**
  40040. * Gets or sets a boolean indicating if render targets are enabled on this scene
  40041. */
  40042. renderTargetsEnabled: boolean;
  40043. /**
  40044. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  40045. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  40046. */
  40047. dumpNextRenderTargets: boolean;
  40048. /**
  40049. * The list of user defined render targets added to the scene
  40050. */
  40051. customRenderTargets: RenderTargetTexture[];
  40052. /**
  40053. * Defines if texture loading must be delayed
  40054. * If true, textures will only be loaded when they need to be rendered
  40055. */
  40056. useDelayedTextureLoading: boolean;
  40057. /**
  40058. * Gets the list of meshes imported to the scene through SceneLoader
  40059. */
  40060. importedMeshesFiles: String[];
  40061. /**
  40062. * Gets or sets a boolean indicating if probes are enabled on this scene
  40063. */
  40064. probesEnabled: boolean;
  40065. /**
  40066. * Gets or sets the current offline provider to use to store scene data
  40067. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  40068. */
  40069. offlineProvider: IOfflineProvider;
  40070. /**
  40071. * Gets or sets the action manager associated with the scene
  40072. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  40073. */
  40074. actionManager: AbstractActionManager;
  40075. private _meshesForIntersections;
  40076. /**
  40077. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  40078. */
  40079. proceduralTexturesEnabled: boolean;
  40080. private _engine;
  40081. private _totalVertices;
  40082. /** @hidden */
  40083. _activeIndices: PerfCounter;
  40084. /** @hidden */
  40085. _activeParticles: PerfCounter;
  40086. /** @hidden */
  40087. _activeBones: PerfCounter;
  40088. private _animationRatio;
  40089. /** @hidden */
  40090. _animationTimeLast: number;
  40091. /** @hidden */
  40092. _animationTime: number;
  40093. /**
  40094. * Gets or sets a general scale for animation speed
  40095. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  40096. */
  40097. animationTimeScale: number;
  40098. /** @hidden */
  40099. _cachedMaterial: Nullable<Material>;
  40100. /** @hidden */
  40101. _cachedEffect: Nullable<Effect>;
  40102. /** @hidden */
  40103. _cachedVisibility: Nullable<number>;
  40104. private _renderId;
  40105. private _frameId;
  40106. private _executeWhenReadyTimeoutId;
  40107. private _intermediateRendering;
  40108. private _viewUpdateFlag;
  40109. private _projectionUpdateFlag;
  40110. /** @hidden */
  40111. _toBeDisposed: Nullable<IDisposable>[];
  40112. private _activeRequests;
  40113. /** @hidden */
  40114. _pendingData: any[];
  40115. private _isDisposed;
  40116. /**
  40117. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  40118. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  40119. */
  40120. dispatchAllSubMeshesOfActiveMeshes: boolean;
  40121. private _activeMeshes;
  40122. private _processedMaterials;
  40123. private _renderTargets;
  40124. /** @hidden */
  40125. _activeParticleSystems: SmartArray<IParticleSystem>;
  40126. private _activeSkeletons;
  40127. private _softwareSkinnedMeshes;
  40128. private _renderingManager;
  40129. /** @hidden */
  40130. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  40131. private _transformMatrix;
  40132. private _sceneUbo;
  40133. /** @hidden */
  40134. _viewMatrix: Matrix;
  40135. private _projectionMatrix;
  40136. /** @hidden */
  40137. _forcedViewPosition: Nullable<Vector3>;
  40138. /** @hidden */
  40139. _frustumPlanes: Plane[];
  40140. /**
  40141. * Gets the list of frustum planes (built from the active camera)
  40142. */
  40143. get frustumPlanes(): Plane[];
  40144. /**
  40145. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  40146. * This is useful if there are more lights that the maximum simulteanous authorized
  40147. */
  40148. requireLightSorting: boolean;
  40149. /** @hidden */
  40150. readonly useMaterialMeshMap: boolean;
  40151. /** @hidden */
  40152. readonly useClonedMeshMap: boolean;
  40153. private _externalData;
  40154. private _uid;
  40155. /**
  40156. * @hidden
  40157. * Backing store of defined scene components.
  40158. */
  40159. _components: ISceneComponent[];
  40160. /**
  40161. * @hidden
  40162. * Backing store of defined scene components.
  40163. */
  40164. _serializableComponents: ISceneSerializableComponent[];
  40165. /**
  40166. * List of components to register on the next registration step.
  40167. */
  40168. private _transientComponents;
  40169. /**
  40170. * Registers the transient components if needed.
  40171. */
  40172. private _registerTransientComponents;
  40173. /**
  40174. * @hidden
  40175. * Add a component to the scene.
  40176. * Note that the ccomponent could be registered on th next frame if this is called after
  40177. * the register component stage.
  40178. * @param component Defines the component to add to the scene
  40179. */
  40180. _addComponent(component: ISceneComponent): void;
  40181. /**
  40182. * @hidden
  40183. * Gets a component from the scene.
  40184. * @param name defines the name of the component to retrieve
  40185. * @returns the component or null if not present
  40186. */
  40187. _getComponent(name: string): Nullable<ISceneComponent>;
  40188. /**
  40189. * @hidden
  40190. * Defines the actions happening before camera updates.
  40191. */
  40192. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  40193. /**
  40194. * @hidden
  40195. * Defines the actions happening before clear the canvas.
  40196. */
  40197. _beforeClearStage: Stage<SimpleStageAction>;
  40198. /**
  40199. * @hidden
  40200. * Defines the actions when collecting render targets for the frame.
  40201. */
  40202. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  40203. /**
  40204. * @hidden
  40205. * Defines the actions happening for one camera in the frame.
  40206. */
  40207. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  40208. /**
  40209. * @hidden
  40210. * Defines the actions happening during the per mesh ready checks.
  40211. */
  40212. _isReadyForMeshStage: Stage<MeshStageAction>;
  40213. /**
  40214. * @hidden
  40215. * Defines the actions happening before evaluate active mesh checks.
  40216. */
  40217. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  40218. /**
  40219. * @hidden
  40220. * Defines the actions happening during the evaluate sub mesh checks.
  40221. */
  40222. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  40223. /**
  40224. * @hidden
  40225. * Defines the actions happening during the active mesh stage.
  40226. */
  40227. _activeMeshStage: Stage<ActiveMeshStageAction>;
  40228. /**
  40229. * @hidden
  40230. * Defines the actions happening during the per camera render target step.
  40231. */
  40232. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  40233. /**
  40234. * @hidden
  40235. * Defines the actions happening just before the active camera is drawing.
  40236. */
  40237. _beforeCameraDrawStage: Stage<CameraStageAction>;
  40238. /**
  40239. * @hidden
  40240. * Defines the actions happening just before a render target is drawing.
  40241. */
  40242. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  40243. /**
  40244. * @hidden
  40245. * Defines the actions happening just before a rendering group is drawing.
  40246. */
  40247. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  40248. /**
  40249. * @hidden
  40250. * Defines the actions happening just before a mesh is drawing.
  40251. */
  40252. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  40253. /**
  40254. * @hidden
  40255. * Defines the actions happening just after a mesh has been drawn.
  40256. */
  40257. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  40258. /**
  40259. * @hidden
  40260. * Defines the actions happening just after a rendering group has been drawn.
  40261. */
  40262. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  40263. /**
  40264. * @hidden
  40265. * Defines the actions happening just after the active camera has been drawn.
  40266. */
  40267. _afterCameraDrawStage: Stage<CameraStageAction>;
  40268. /**
  40269. * @hidden
  40270. * Defines the actions happening just after a render target has been drawn.
  40271. */
  40272. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  40273. /**
  40274. * @hidden
  40275. * Defines the actions happening just after rendering all cameras and computing intersections.
  40276. */
  40277. _afterRenderStage: Stage<SimpleStageAction>;
  40278. /**
  40279. * @hidden
  40280. * Defines the actions happening when a pointer move event happens.
  40281. */
  40282. _pointerMoveStage: Stage<PointerMoveStageAction>;
  40283. /**
  40284. * @hidden
  40285. * Defines the actions happening when a pointer down event happens.
  40286. */
  40287. _pointerDownStage: Stage<PointerUpDownStageAction>;
  40288. /**
  40289. * @hidden
  40290. * Defines the actions happening when a pointer up event happens.
  40291. */
  40292. _pointerUpStage: Stage<PointerUpDownStageAction>;
  40293. /**
  40294. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  40295. */
  40296. private geometriesByUniqueId;
  40297. /**
  40298. * Creates a new Scene
  40299. * @param engine defines the engine to use to render this scene
  40300. * @param options defines the scene options
  40301. */
  40302. constructor(engine: Engine, options?: SceneOptions);
  40303. /**
  40304. * Gets a string idenfifying the name of the class
  40305. * @returns "Scene" string
  40306. */
  40307. getClassName(): string;
  40308. private _defaultMeshCandidates;
  40309. /**
  40310. * @hidden
  40311. */
  40312. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40313. private _defaultSubMeshCandidates;
  40314. /**
  40315. * @hidden
  40316. */
  40317. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40318. /**
  40319. * Sets the default candidate providers for the scene.
  40320. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  40321. * and getCollidingSubMeshCandidates to their default function
  40322. */
  40323. setDefaultCandidateProviders(): void;
  40324. /**
  40325. * Gets the mesh that is currently under the pointer
  40326. */
  40327. get meshUnderPointer(): Nullable<AbstractMesh>;
  40328. /**
  40329. * Gets or sets the current on-screen X position of the pointer
  40330. */
  40331. get pointerX(): number;
  40332. set pointerX(value: number);
  40333. /**
  40334. * Gets or sets the current on-screen Y position of the pointer
  40335. */
  40336. get pointerY(): number;
  40337. set pointerY(value: number);
  40338. /**
  40339. * Gets the cached material (ie. the latest rendered one)
  40340. * @returns the cached material
  40341. */
  40342. getCachedMaterial(): Nullable<Material>;
  40343. /**
  40344. * Gets the cached effect (ie. the latest rendered one)
  40345. * @returns the cached effect
  40346. */
  40347. getCachedEffect(): Nullable<Effect>;
  40348. /**
  40349. * Gets the cached visibility state (ie. the latest rendered one)
  40350. * @returns the cached visibility state
  40351. */
  40352. getCachedVisibility(): Nullable<number>;
  40353. /**
  40354. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  40355. * @param material defines the current material
  40356. * @param effect defines the current effect
  40357. * @param visibility defines the current visibility state
  40358. * @returns true if one parameter is not cached
  40359. */
  40360. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  40361. /**
  40362. * Gets the engine associated with the scene
  40363. * @returns an Engine
  40364. */
  40365. getEngine(): Engine;
  40366. /**
  40367. * Gets the total number of vertices rendered per frame
  40368. * @returns the total number of vertices rendered per frame
  40369. */
  40370. getTotalVertices(): number;
  40371. /**
  40372. * Gets the performance counter for total vertices
  40373. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40374. */
  40375. get totalVerticesPerfCounter(): PerfCounter;
  40376. /**
  40377. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  40378. * @returns the total number of active indices rendered per frame
  40379. */
  40380. getActiveIndices(): number;
  40381. /**
  40382. * Gets the performance counter for active indices
  40383. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40384. */
  40385. get totalActiveIndicesPerfCounter(): PerfCounter;
  40386. /**
  40387. * Gets the total number of active particles rendered per frame
  40388. * @returns the total number of active particles rendered per frame
  40389. */
  40390. getActiveParticles(): number;
  40391. /**
  40392. * Gets the performance counter for active particles
  40393. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40394. */
  40395. get activeParticlesPerfCounter(): PerfCounter;
  40396. /**
  40397. * Gets the total number of active bones rendered per frame
  40398. * @returns the total number of active bones rendered per frame
  40399. */
  40400. getActiveBones(): number;
  40401. /**
  40402. * Gets the performance counter for active bones
  40403. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40404. */
  40405. get activeBonesPerfCounter(): PerfCounter;
  40406. /**
  40407. * Gets the array of active meshes
  40408. * @returns an array of AbstractMesh
  40409. */
  40410. getActiveMeshes(): SmartArray<AbstractMesh>;
  40411. /**
  40412. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  40413. * @returns a number
  40414. */
  40415. getAnimationRatio(): number;
  40416. /**
  40417. * Gets an unique Id for the current render phase
  40418. * @returns a number
  40419. */
  40420. getRenderId(): number;
  40421. /**
  40422. * Gets an unique Id for the current frame
  40423. * @returns a number
  40424. */
  40425. getFrameId(): number;
  40426. /** Call this function if you want to manually increment the render Id*/
  40427. incrementRenderId(): void;
  40428. private _createUbo;
  40429. /**
  40430. * Use this method to simulate a pointer move on a mesh
  40431. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40432. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40433. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40434. * @returns the current scene
  40435. */
  40436. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  40437. /**
  40438. * Use this method to simulate a pointer down on a mesh
  40439. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40440. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40441. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40442. * @returns the current scene
  40443. */
  40444. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  40445. /**
  40446. * Use this method to simulate a pointer up on a mesh
  40447. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40448. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40449. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40450. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  40451. * @returns the current scene
  40452. */
  40453. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  40454. /**
  40455. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  40456. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  40457. * @returns true if the pointer was captured
  40458. */
  40459. isPointerCaptured(pointerId?: number): boolean;
  40460. /**
  40461. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  40462. * @param attachUp defines if you want to attach events to pointerup
  40463. * @param attachDown defines if you want to attach events to pointerdown
  40464. * @param attachMove defines if you want to attach events to pointermove
  40465. */
  40466. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  40467. /** Detaches all event handlers*/
  40468. detachControl(): void;
  40469. /**
  40470. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  40471. * Delay loaded resources are not taking in account
  40472. * @return true if all required resources are ready
  40473. */
  40474. isReady(): boolean;
  40475. /** Resets all cached information relative to material (including effect and visibility) */
  40476. resetCachedMaterial(): void;
  40477. /**
  40478. * Registers a function to be called before every frame render
  40479. * @param func defines the function to register
  40480. */
  40481. registerBeforeRender(func: () => void): void;
  40482. /**
  40483. * Unregisters a function called before every frame render
  40484. * @param func defines the function to unregister
  40485. */
  40486. unregisterBeforeRender(func: () => void): void;
  40487. /**
  40488. * Registers a function to be called after every frame render
  40489. * @param func defines the function to register
  40490. */
  40491. registerAfterRender(func: () => void): void;
  40492. /**
  40493. * Unregisters a function called after every frame render
  40494. * @param func defines the function to unregister
  40495. */
  40496. unregisterAfterRender(func: () => void): void;
  40497. private _executeOnceBeforeRender;
  40498. /**
  40499. * The provided function will run before render once and will be disposed afterwards.
  40500. * A timeout delay can be provided so that the function will be executed in N ms.
  40501. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  40502. * @param func The function to be executed.
  40503. * @param timeout optional delay in ms
  40504. */
  40505. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  40506. /** @hidden */
  40507. _addPendingData(data: any): void;
  40508. /** @hidden */
  40509. _removePendingData(data: any): void;
  40510. /**
  40511. * Returns the number of items waiting to be loaded
  40512. * @returns the number of items waiting to be loaded
  40513. */
  40514. getWaitingItemsCount(): number;
  40515. /**
  40516. * Returns a boolean indicating if the scene is still loading data
  40517. */
  40518. get isLoading(): boolean;
  40519. /**
  40520. * Registers a function to be executed when the scene is ready
  40521. * @param {Function} func - the function to be executed
  40522. */
  40523. executeWhenReady(func: () => void): void;
  40524. /**
  40525. * Returns a promise that resolves when the scene is ready
  40526. * @returns A promise that resolves when the scene is ready
  40527. */
  40528. whenReadyAsync(): Promise<void>;
  40529. /** @hidden */
  40530. _checkIsReady(): void;
  40531. /**
  40532. * Gets all animatable attached to the scene
  40533. */
  40534. get animatables(): Animatable[];
  40535. /**
  40536. * Resets the last animation time frame.
  40537. * Useful to override when animations start running when loading a scene for the first time.
  40538. */
  40539. resetLastAnimationTimeFrame(): void;
  40540. /**
  40541. * Gets the current view matrix
  40542. * @returns a Matrix
  40543. */
  40544. getViewMatrix(): Matrix;
  40545. /**
  40546. * Gets the current projection matrix
  40547. * @returns a Matrix
  40548. */
  40549. getProjectionMatrix(): Matrix;
  40550. /**
  40551. * Gets the current transform matrix
  40552. * @returns a Matrix made of View * Projection
  40553. */
  40554. getTransformMatrix(): Matrix;
  40555. /**
  40556. * Sets the current transform matrix
  40557. * @param viewL defines the View matrix to use
  40558. * @param projectionL defines the Projection matrix to use
  40559. * @param viewR defines the right View matrix to use (if provided)
  40560. * @param projectionR defines the right Projection matrix to use (if provided)
  40561. */
  40562. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  40563. /**
  40564. * Gets the uniform buffer used to store scene data
  40565. * @returns a UniformBuffer
  40566. */
  40567. getSceneUniformBuffer(): UniformBuffer;
  40568. /**
  40569. * Gets an unique (relatively to the current scene) Id
  40570. * @returns an unique number for the scene
  40571. */
  40572. getUniqueId(): number;
  40573. /**
  40574. * Add a mesh to the list of scene's meshes
  40575. * @param newMesh defines the mesh to add
  40576. * @param recursive if all child meshes should also be added to the scene
  40577. */
  40578. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  40579. /**
  40580. * Remove a mesh for the list of scene's meshes
  40581. * @param toRemove defines the mesh to remove
  40582. * @param recursive if all child meshes should also be removed from the scene
  40583. * @returns the index where the mesh was in the mesh list
  40584. */
  40585. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  40586. /**
  40587. * Add a transform node to the list of scene's transform nodes
  40588. * @param newTransformNode defines the transform node to add
  40589. */
  40590. addTransformNode(newTransformNode: TransformNode): void;
  40591. /**
  40592. * Remove a transform node for the list of scene's transform nodes
  40593. * @param toRemove defines the transform node to remove
  40594. * @returns the index where the transform node was in the transform node list
  40595. */
  40596. removeTransformNode(toRemove: TransformNode): number;
  40597. /**
  40598. * Remove a skeleton for the list of scene's skeletons
  40599. * @param toRemove defines the skeleton to remove
  40600. * @returns the index where the skeleton was in the skeleton list
  40601. */
  40602. removeSkeleton(toRemove: Skeleton): number;
  40603. /**
  40604. * Remove a morph target for the list of scene's morph targets
  40605. * @param toRemove defines the morph target to remove
  40606. * @returns the index where the morph target was in the morph target list
  40607. */
  40608. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  40609. /**
  40610. * Remove a light for the list of scene's lights
  40611. * @param toRemove defines the light to remove
  40612. * @returns the index where the light was in the light list
  40613. */
  40614. removeLight(toRemove: Light): number;
  40615. /**
  40616. * Remove a camera for the list of scene's cameras
  40617. * @param toRemove defines the camera to remove
  40618. * @returns the index where the camera was in the camera list
  40619. */
  40620. removeCamera(toRemove: Camera): number;
  40621. /**
  40622. * Remove a particle system for the list of scene's particle systems
  40623. * @param toRemove defines the particle system to remove
  40624. * @returns the index where the particle system was in the particle system list
  40625. */
  40626. removeParticleSystem(toRemove: IParticleSystem): number;
  40627. /**
  40628. * Remove a animation for the list of scene's animations
  40629. * @param toRemove defines the animation to remove
  40630. * @returns the index where the animation was in the animation list
  40631. */
  40632. removeAnimation(toRemove: Animation): number;
  40633. /**
  40634. * Will stop the animation of the given target
  40635. * @param target - the target
  40636. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  40637. * @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)
  40638. */
  40639. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  40640. /**
  40641. * Removes the given animation group from this scene.
  40642. * @param toRemove The animation group to remove
  40643. * @returns The index of the removed animation group
  40644. */
  40645. removeAnimationGroup(toRemove: AnimationGroup): number;
  40646. /**
  40647. * Removes the given multi-material from this scene.
  40648. * @param toRemove The multi-material to remove
  40649. * @returns The index of the removed multi-material
  40650. */
  40651. removeMultiMaterial(toRemove: MultiMaterial): number;
  40652. /**
  40653. * Removes the given material from this scene.
  40654. * @param toRemove The material to remove
  40655. * @returns The index of the removed material
  40656. */
  40657. removeMaterial(toRemove: Material): number;
  40658. /**
  40659. * Removes the given action manager from this scene.
  40660. * @param toRemove The action manager to remove
  40661. * @returns The index of the removed action manager
  40662. */
  40663. removeActionManager(toRemove: AbstractActionManager): number;
  40664. /**
  40665. * Removes the given texture from this scene.
  40666. * @param toRemove The texture to remove
  40667. * @returns The index of the removed texture
  40668. */
  40669. removeTexture(toRemove: BaseTexture): number;
  40670. /**
  40671. * Adds the given light to this scene
  40672. * @param newLight The light to add
  40673. */
  40674. addLight(newLight: Light): void;
  40675. /**
  40676. * Sorts the list list based on light priorities
  40677. */
  40678. sortLightsByPriority(): void;
  40679. /**
  40680. * Adds the given camera to this scene
  40681. * @param newCamera The camera to add
  40682. */
  40683. addCamera(newCamera: Camera): void;
  40684. /**
  40685. * Adds the given skeleton to this scene
  40686. * @param newSkeleton The skeleton to add
  40687. */
  40688. addSkeleton(newSkeleton: Skeleton): void;
  40689. /**
  40690. * Adds the given particle system to this scene
  40691. * @param newParticleSystem The particle system to add
  40692. */
  40693. addParticleSystem(newParticleSystem: IParticleSystem): void;
  40694. /**
  40695. * Adds the given animation to this scene
  40696. * @param newAnimation The animation to add
  40697. */
  40698. addAnimation(newAnimation: Animation): void;
  40699. /**
  40700. * Adds the given animation group to this scene.
  40701. * @param newAnimationGroup The animation group to add
  40702. */
  40703. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  40704. /**
  40705. * Adds the given multi-material to this scene
  40706. * @param newMultiMaterial The multi-material to add
  40707. */
  40708. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  40709. /**
  40710. * Adds the given material to this scene
  40711. * @param newMaterial The material to add
  40712. */
  40713. addMaterial(newMaterial: Material): void;
  40714. /**
  40715. * Adds the given morph target to this scene
  40716. * @param newMorphTargetManager The morph target to add
  40717. */
  40718. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  40719. /**
  40720. * Adds the given geometry to this scene
  40721. * @param newGeometry The geometry to add
  40722. */
  40723. addGeometry(newGeometry: Geometry): void;
  40724. /**
  40725. * Adds the given action manager to this scene
  40726. * @param newActionManager The action manager to add
  40727. */
  40728. addActionManager(newActionManager: AbstractActionManager): void;
  40729. /**
  40730. * Adds the given texture to this scene.
  40731. * @param newTexture The texture to add
  40732. */
  40733. addTexture(newTexture: BaseTexture): void;
  40734. /**
  40735. * Switch active camera
  40736. * @param newCamera defines the new active camera
  40737. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  40738. */
  40739. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  40740. /**
  40741. * sets the active camera of the scene using its ID
  40742. * @param id defines the camera's ID
  40743. * @return the new active camera or null if none found.
  40744. */
  40745. setActiveCameraByID(id: string): Nullable<Camera>;
  40746. /**
  40747. * sets the active camera of the scene using its name
  40748. * @param name defines the camera's name
  40749. * @returns the new active camera or null if none found.
  40750. */
  40751. setActiveCameraByName(name: string): Nullable<Camera>;
  40752. /**
  40753. * get an animation group using its name
  40754. * @param name defines the material's name
  40755. * @return the animation group or null if none found.
  40756. */
  40757. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  40758. /**
  40759. * Get a material using its unique id
  40760. * @param uniqueId defines the material's unique id
  40761. * @return the material or null if none found.
  40762. */
  40763. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  40764. /**
  40765. * get a material using its id
  40766. * @param id defines the material's ID
  40767. * @return the material or null if none found.
  40768. */
  40769. getMaterialByID(id: string): Nullable<Material>;
  40770. /**
  40771. * Gets a the last added material using a given id
  40772. * @param id defines the material's ID
  40773. * @return the last material with the given id or null if none found.
  40774. */
  40775. getLastMaterialByID(id: string): Nullable<Material>;
  40776. /**
  40777. * Gets a material using its name
  40778. * @param name defines the material's name
  40779. * @return the material or null if none found.
  40780. */
  40781. getMaterialByName(name: string): Nullable<Material>;
  40782. /**
  40783. * Get a texture using its unique id
  40784. * @param uniqueId defines the texture's unique id
  40785. * @return the texture or null if none found.
  40786. */
  40787. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  40788. /**
  40789. * Gets a camera using its id
  40790. * @param id defines the id to look for
  40791. * @returns the camera or null if not found
  40792. */
  40793. getCameraByID(id: string): Nullable<Camera>;
  40794. /**
  40795. * Gets a camera using its unique id
  40796. * @param uniqueId defines the unique id to look for
  40797. * @returns the camera or null if not found
  40798. */
  40799. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  40800. /**
  40801. * Gets a camera using its name
  40802. * @param name defines the camera's name
  40803. * @return the camera or null if none found.
  40804. */
  40805. getCameraByName(name: string): Nullable<Camera>;
  40806. /**
  40807. * Gets a bone using its id
  40808. * @param id defines the bone's id
  40809. * @return the bone or null if not found
  40810. */
  40811. getBoneByID(id: string): Nullable<Bone>;
  40812. /**
  40813. * Gets a bone using its id
  40814. * @param name defines the bone's name
  40815. * @return the bone or null if not found
  40816. */
  40817. getBoneByName(name: string): Nullable<Bone>;
  40818. /**
  40819. * Gets a light node using its name
  40820. * @param name defines the the light's name
  40821. * @return the light or null if none found.
  40822. */
  40823. getLightByName(name: string): Nullable<Light>;
  40824. /**
  40825. * Gets a light node using its id
  40826. * @param id defines the light's id
  40827. * @return the light or null if none found.
  40828. */
  40829. getLightByID(id: string): Nullable<Light>;
  40830. /**
  40831. * Gets a light node using its scene-generated unique ID
  40832. * @param uniqueId defines the light's unique id
  40833. * @return the light or null if none found.
  40834. */
  40835. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  40836. /**
  40837. * Gets a particle system by id
  40838. * @param id defines the particle system id
  40839. * @return the corresponding system or null if none found
  40840. */
  40841. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  40842. /**
  40843. * Gets a geometry using its ID
  40844. * @param id defines the geometry's id
  40845. * @return the geometry or null if none found.
  40846. */
  40847. getGeometryByID(id: string): Nullable<Geometry>;
  40848. private _getGeometryByUniqueID;
  40849. /**
  40850. * Add a new geometry to this scene
  40851. * @param geometry defines the geometry to be added to the scene.
  40852. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  40853. * @return a boolean defining if the geometry was added or not
  40854. */
  40855. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  40856. /**
  40857. * Removes an existing geometry
  40858. * @param geometry defines the geometry to be removed from the scene
  40859. * @return a boolean defining if the geometry was removed or not
  40860. */
  40861. removeGeometry(geometry: Geometry): boolean;
  40862. /**
  40863. * Gets the list of geometries attached to the scene
  40864. * @returns an array of Geometry
  40865. */
  40866. getGeometries(): Geometry[];
  40867. /**
  40868. * Gets the first added mesh found of a given ID
  40869. * @param id defines the id to search for
  40870. * @return the mesh found or null if not found at all
  40871. */
  40872. getMeshByID(id: string): Nullable<AbstractMesh>;
  40873. /**
  40874. * Gets a list of meshes using their id
  40875. * @param id defines the id to search for
  40876. * @returns a list of meshes
  40877. */
  40878. getMeshesByID(id: string): Array<AbstractMesh>;
  40879. /**
  40880. * Gets the first added transform node found of a given ID
  40881. * @param id defines the id to search for
  40882. * @return the found transform node or null if not found at all.
  40883. */
  40884. getTransformNodeByID(id: string): Nullable<TransformNode>;
  40885. /**
  40886. * Gets a transform node with its auto-generated unique id
  40887. * @param uniqueId efines the unique id to search for
  40888. * @return the found transform node or null if not found at all.
  40889. */
  40890. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  40891. /**
  40892. * Gets a list of transform nodes using their id
  40893. * @param id defines the id to search for
  40894. * @returns a list of transform nodes
  40895. */
  40896. getTransformNodesByID(id: string): Array<TransformNode>;
  40897. /**
  40898. * Gets a mesh with its auto-generated unique id
  40899. * @param uniqueId defines the unique id to search for
  40900. * @return the found mesh or null if not found at all.
  40901. */
  40902. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  40903. /**
  40904. * Gets a the last added mesh using a given id
  40905. * @param id defines the id to search for
  40906. * @return the found mesh or null if not found at all.
  40907. */
  40908. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  40909. /**
  40910. * Gets a the last added node (Mesh, Camera, Light) using a given id
  40911. * @param id defines the id to search for
  40912. * @return the found node or null if not found at all
  40913. */
  40914. getLastEntryByID(id: string): Nullable<Node>;
  40915. /**
  40916. * Gets a node (Mesh, Camera, Light) using a given id
  40917. * @param id defines the id to search for
  40918. * @return the found node or null if not found at all
  40919. */
  40920. getNodeByID(id: string): Nullable<Node>;
  40921. /**
  40922. * Gets a node (Mesh, Camera, Light) using a given name
  40923. * @param name defines the name to search for
  40924. * @return the found node or null if not found at all.
  40925. */
  40926. getNodeByName(name: string): Nullable<Node>;
  40927. /**
  40928. * Gets a mesh using a given name
  40929. * @param name defines the name to search for
  40930. * @return the found mesh or null if not found at all.
  40931. */
  40932. getMeshByName(name: string): Nullable<AbstractMesh>;
  40933. /**
  40934. * Gets a transform node using a given name
  40935. * @param name defines the name to search for
  40936. * @return the found transform node or null if not found at all.
  40937. */
  40938. getTransformNodeByName(name: string): Nullable<TransformNode>;
  40939. /**
  40940. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  40941. * @param id defines the id to search for
  40942. * @return the found skeleton or null if not found at all.
  40943. */
  40944. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  40945. /**
  40946. * Gets a skeleton using a given auto generated unique id
  40947. * @param uniqueId defines the unique id to search for
  40948. * @return the found skeleton or null if not found at all.
  40949. */
  40950. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  40951. /**
  40952. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  40953. * @param id defines the id to search for
  40954. * @return the found skeleton or null if not found at all.
  40955. */
  40956. getSkeletonById(id: string): Nullable<Skeleton>;
  40957. /**
  40958. * Gets a skeleton using a given name
  40959. * @param name defines the name to search for
  40960. * @return the found skeleton or null if not found at all.
  40961. */
  40962. getSkeletonByName(name: string): Nullable<Skeleton>;
  40963. /**
  40964. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  40965. * @param id defines the id to search for
  40966. * @return the found morph target manager or null if not found at all.
  40967. */
  40968. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  40969. /**
  40970. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  40971. * @param id defines the id to search for
  40972. * @return the found morph target or null if not found at all.
  40973. */
  40974. getMorphTargetById(id: string): Nullable<MorphTarget>;
  40975. /**
  40976. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  40977. * @param name defines the name to search for
  40978. * @return the found morph target or null if not found at all.
  40979. */
  40980. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  40981. /**
  40982. * Gets a boolean indicating if the given mesh is active
  40983. * @param mesh defines the mesh to look for
  40984. * @returns true if the mesh is in the active list
  40985. */
  40986. isActiveMesh(mesh: AbstractMesh): boolean;
  40987. /**
  40988. * Return a unique id as a string which can serve as an identifier for the scene
  40989. */
  40990. get uid(): string;
  40991. /**
  40992. * Add an externaly attached data from its key.
  40993. * This method call will fail and return false, if such key already exists.
  40994. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  40995. * @param key the unique key that identifies the data
  40996. * @param data the data object to associate to the key for this Engine instance
  40997. * @return true if no such key were already present and the data was added successfully, false otherwise
  40998. */
  40999. addExternalData<T>(key: string, data: T): boolean;
  41000. /**
  41001. * Get an externaly attached data from its key
  41002. * @param key the unique key that identifies the data
  41003. * @return the associated data, if present (can be null), or undefined if not present
  41004. */
  41005. getExternalData<T>(key: string): Nullable<T>;
  41006. /**
  41007. * Get an externaly attached data from its key, create it using a factory if it's not already present
  41008. * @param key the unique key that identifies the data
  41009. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  41010. * @return the associated data, can be null if the factory returned null.
  41011. */
  41012. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  41013. /**
  41014. * Remove an externaly attached data from the Engine instance
  41015. * @param key the unique key that identifies the data
  41016. * @return true if the data was successfully removed, false if it doesn't exist
  41017. */
  41018. removeExternalData(key: string): boolean;
  41019. private _evaluateSubMesh;
  41020. /**
  41021. * Clear the processed materials smart array preventing retention point in material dispose.
  41022. */
  41023. freeProcessedMaterials(): void;
  41024. private _preventFreeActiveMeshesAndRenderingGroups;
  41025. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  41026. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  41027. * when disposing several meshes in a row or a hierarchy of meshes.
  41028. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  41029. */
  41030. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  41031. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  41032. /**
  41033. * Clear the active meshes smart array preventing retention point in mesh dispose.
  41034. */
  41035. freeActiveMeshes(): void;
  41036. /**
  41037. * Clear the info related to rendering groups preventing retention points during dispose.
  41038. */
  41039. freeRenderingGroups(): void;
  41040. /** @hidden */
  41041. _isInIntermediateRendering(): boolean;
  41042. /**
  41043. * Lambda returning the list of potentially active meshes.
  41044. */
  41045. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  41046. /**
  41047. * Lambda returning the list of potentially active sub meshes.
  41048. */
  41049. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  41050. /**
  41051. * Lambda returning the list of potentially intersecting sub meshes.
  41052. */
  41053. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  41054. /**
  41055. * Lambda returning the list of potentially colliding sub meshes.
  41056. */
  41057. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  41058. private _activeMeshesFrozen;
  41059. private _skipEvaluateActiveMeshesCompletely;
  41060. /**
  41061. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  41062. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  41063. * @returns the current scene
  41064. */
  41065. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  41066. /**
  41067. * Use this function to restart evaluating active meshes on every frame
  41068. * @returns the current scene
  41069. */
  41070. unfreezeActiveMeshes(): Scene;
  41071. private _evaluateActiveMeshes;
  41072. private _activeMesh;
  41073. /**
  41074. * Update the transform matrix to update from the current active camera
  41075. * @param force defines a boolean used to force the update even if cache is up to date
  41076. */
  41077. updateTransformMatrix(force?: boolean): void;
  41078. private _bindFrameBuffer;
  41079. /** @hidden */
  41080. _allowPostProcessClearColor: boolean;
  41081. /** @hidden */
  41082. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  41083. private _processSubCameras;
  41084. private _checkIntersections;
  41085. /** @hidden */
  41086. _advancePhysicsEngineStep(step: number): void;
  41087. /**
  41088. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  41089. */
  41090. getDeterministicFrameTime: () => number;
  41091. /** @hidden */
  41092. _animate(): void;
  41093. /** Execute all animations (for a frame) */
  41094. animate(): void;
  41095. /**
  41096. * Render the scene
  41097. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  41098. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  41099. */
  41100. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  41101. /**
  41102. * Freeze all materials
  41103. * A frozen material will not be updatable but should be faster to render
  41104. */
  41105. freezeMaterials(): void;
  41106. /**
  41107. * Unfreeze all materials
  41108. * A frozen material will not be updatable but should be faster to render
  41109. */
  41110. unfreezeMaterials(): void;
  41111. /**
  41112. * Releases all held ressources
  41113. */
  41114. dispose(): void;
  41115. /**
  41116. * Gets if the scene is already disposed
  41117. */
  41118. get isDisposed(): boolean;
  41119. /**
  41120. * Call this function to reduce memory footprint of the scene.
  41121. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  41122. */
  41123. clearCachedVertexData(): void;
  41124. /**
  41125. * This function will remove the local cached buffer data from texture.
  41126. * It will save memory but will prevent the texture from being rebuilt
  41127. */
  41128. cleanCachedTextureBuffer(): void;
  41129. /**
  41130. * Get the world extend vectors with an optional filter
  41131. *
  41132. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  41133. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  41134. */
  41135. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  41136. min: Vector3;
  41137. max: Vector3;
  41138. };
  41139. /**
  41140. * Creates a ray that can be used to pick in the scene
  41141. * @param x defines the x coordinate of the origin (on-screen)
  41142. * @param y defines the y coordinate of the origin (on-screen)
  41143. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  41144. * @param camera defines the camera to use for the picking
  41145. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  41146. * @returns a Ray
  41147. */
  41148. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  41149. /**
  41150. * Creates a ray that can be used to pick in the scene
  41151. * @param x defines the x coordinate of the origin (on-screen)
  41152. * @param y defines the y coordinate of the origin (on-screen)
  41153. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  41154. * @param result defines the ray where to store the picking ray
  41155. * @param camera defines the camera to use for the picking
  41156. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  41157. * @returns the current scene
  41158. */
  41159. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  41160. /**
  41161. * Creates a ray that can be used to pick in the scene
  41162. * @param x defines the x coordinate of the origin (on-screen)
  41163. * @param y defines the y coordinate of the origin (on-screen)
  41164. * @param camera defines the camera to use for the picking
  41165. * @returns a Ray
  41166. */
  41167. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  41168. /**
  41169. * Creates a ray that can be used to pick in the scene
  41170. * @param x defines the x coordinate of the origin (on-screen)
  41171. * @param y defines the y coordinate of the origin (on-screen)
  41172. * @param result defines the ray where to store the picking ray
  41173. * @param camera defines the camera to use for the picking
  41174. * @returns the current scene
  41175. */
  41176. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  41177. /** Launch a ray to try to pick a mesh in the scene
  41178. * @param x position on screen
  41179. * @param y position on screen
  41180. * @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
  41181. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41182. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41183. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41184. * @returns a PickingInfo
  41185. */
  41186. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  41187. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  41188. * @param x position on screen
  41189. * @param y position on screen
  41190. * @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
  41191. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41192. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41193. * @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)
  41194. */
  41195. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  41196. /** Use the given ray to pick a mesh in the scene
  41197. * @param ray The ray to use to pick meshes
  41198. * @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
  41199. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41200. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41201. * @returns a PickingInfo
  41202. */
  41203. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  41204. /**
  41205. * Launch a ray to try to pick a mesh in the scene
  41206. * @param x X position on screen
  41207. * @param y Y position on screen
  41208. * @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
  41209. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41210. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41211. * @returns an array of PickingInfo
  41212. */
  41213. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  41214. /**
  41215. * Launch a ray to try to pick a mesh in the scene
  41216. * @param ray Ray to use
  41217. * @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
  41218. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41219. * @returns an array of PickingInfo
  41220. */
  41221. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  41222. /**
  41223. * Force the value of meshUnderPointer
  41224. * @param mesh defines the mesh to use
  41225. */
  41226. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  41227. /**
  41228. * Gets the mesh under the pointer
  41229. * @returns a Mesh or null if no mesh is under the pointer
  41230. */
  41231. getPointerOverMesh(): Nullable<AbstractMesh>;
  41232. /** @hidden */
  41233. _rebuildGeometries(): void;
  41234. /** @hidden */
  41235. _rebuildTextures(): void;
  41236. private _getByTags;
  41237. /**
  41238. * Get a list of meshes by tags
  41239. * @param tagsQuery defines the tags query to use
  41240. * @param forEach defines a predicate used to filter results
  41241. * @returns an array of Mesh
  41242. */
  41243. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  41244. /**
  41245. * Get a list of cameras by tags
  41246. * @param tagsQuery defines the tags query to use
  41247. * @param forEach defines a predicate used to filter results
  41248. * @returns an array of Camera
  41249. */
  41250. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  41251. /**
  41252. * Get a list of lights by tags
  41253. * @param tagsQuery defines the tags query to use
  41254. * @param forEach defines a predicate used to filter results
  41255. * @returns an array of Light
  41256. */
  41257. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  41258. /**
  41259. * Get a list of materials by tags
  41260. * @param tagsQuery defines the tags query to use
  41261. * @param forEach defines a predicate used to filter results
  41262. * @returns an array of Material
  41263. */
  41264. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  41265. /**
  41266. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  41267. * This allowed control for front to back rendering or reversly depending of the special needs.
  41268. *
  41269. * @param renderingGroupId The rendering group id corresponding to its index
  41270. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  41271. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  41272. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  41273. */
  41274. 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;
  41275. /**
  41276. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  41277. *
  41278. * @param renderingGroupId The rendering group id corresponding to its index
  41279. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  41280. * @param depth Automatically clears depth between groups if true and autoClear is true.
  41281. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  41282. */
  41283. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  41284. /**
  41285. * Gets the current auto clear configuration for one rendering group of the rendering
  41286. * manager.
  41287. * @param index the rendering group index to get the information for
  41288. * @returns The auto clear setup for the requested rendering group
  41289. */
  41290. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  41291. private _blockMaterialDirtyMechanism;
  41292. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  41293. get blockMaterialDirtyMechanism(): boolean;
  41294. set blockMaterialDirtyMechanism(value: boolean);
  41295. /**
  41296. * Will flag all materials as dirty to trigger new shader compilation
  41297. * @param flag defines the flag used to specify which material part must be marked as dirty
  41298. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  41299. */
  41300. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  41301. /** @hidden */
  41302. _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;
  41303. /** @hidden */
  41304. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41305. /** @hidden */
  41306. _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;
  41307. /** @hidden */
  41308. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  41309. /** @hidden */
  41310. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  41311. /** @hidden */
  41312. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41313. }
  41314. }
  41315. declare module "babylonjs/assetContainer" {
  41316. import { AbstractScene } from "babylonjs/abstractScene";
  41317. import { Scene } from "babylonjs/scene";
  41318. import { Mesh } from "babylonjs/Meshes/mesh";
  41319. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41320. import { Skeleton } from "babylonjs/Bones/skeleton";
  41321. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  41322. import { Animatable } from "babylonjs/Animations/animatable";
  41323. import { Nullable } from "babylonjs/types";
  41324. import { Node } from "babylonjs/node";
  41325. /**
  41326. * Set of assets to keep when moving a scene into an asset container.
  41327. */
  41328. export class KeepAssets extends AbstractScene {
  41329. }
  41330. /**
  41331. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  41332. */
  41333. export class InstantiatedEntries {
  41334. /**
  41335. * List of new root nodes (eg. nodes with no parent)
  41336. */
  41337. rootNodes: TransformNode[];
  41338. /**
  41339. * List of new skeletons
  41340. */
  41341. skeletons: Skeleton[];
  41342. /**
  41343. * List of new animation groups
  41344. */
  41345. animationGroups: AnimationGroup[];
  41346. }
  41347. /**
  41348. * Container with a set of assets that can be added or removed from a scene.
  41349. */
  41350. export class AssetContainer extends AbstractScene {
  41351. private _wasAddedToScene;
  41352. /**
  41353. * The scene the AssetContainer belongs to.
  41354. */
  41355. scene: Scene;
  41356. /**
  41357. * Instantiates an AssetContainer.
  41358. * @param scene The scene the AssetContainer belongs to.
  41359. */
  41360. constructor(scene: Scene);
  41361. /**
  41362. * Instantiate or clone all meshes and add the new ones to the scene.
  41363. * Skeletons and animation groups will all be cloned
  41364. * @param nameFunction defines an optional function used to get new names for clones
  41365. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  41366. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  41367. */
  41368. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  41369. /**
  41370. * Adds all the assets from the container to the scene.
  41371. */
  41372. addAllToScene(): void;
  41373. /**
  41374. * Removes all the assets in the container from the scene
  41375. */
  41376. removeAllFromScene(): void;
  41377. /**
  41378. * Disposes all the assets in the container
  41379. */
  41380. dispose(): void;
  41381. private _moveAssets;
  41382. /**
  41383. * Removes all the assets contained in the scene and adds them to the container.
  41384. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  41385. */
  41386. moveAllFromScene(keepAssets?: KeepAssets): void;
  41387. /**
  41388. * 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.
  41389. * @returns the root mesh
  41390. */
  41391. createRootMesh(): Mesh;
  41392. /**
  41393. * Merge animations (direct and animation groups) from this asset container into a scene
  41394. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41395. * @param animatables set of animatables to retarget to a node from the scene
  41396. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  41397. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  41398. */
  41399. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  41400. }
  41401. }
  41402. declare module "babylonjs/abstractScene" {
  41403. import { Scene } from "babylonjs/scene";
  41404. import { Nullable } from "babylonjs/types";
  41405. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41406. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41407. import { Geometry } from "babylonjs/Meshes/geometry";
  41408. import { Skeleton } from "babylonjs/Bones/skeleton";
  41409. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  41410. import { AssetContainer } from "babylonjs/assetContainer";
  41411. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  41412. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  41413. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41414. import { Material } from "babylonjs/Materials/material";
  41415. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  41416. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  41417. import { Camera } from "babylonjs/Cameras/camera";
  41418. import { Light } from "babylonjs/Lights/light";
  41419. import { Node } from "babylonjs/node";
  41420. import { Animation } from "babylonjs/Animations/animation";
  41421. /**
  41422. * Defines how the parser contract is defined.
  41423. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  41424. */
  41425. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  41426. /**
  41427. * Defines how the individual parser contract is defined.
  41428. * These parser can parse an individual asset
  41429. */
  41430. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  41431. /**
  41432. * Base class of the scene acting as a container for the different elements composing a scene.
  41433. * This class is dynamically extended by the different components of the scene increasing
  41434. * flexibility and reducing coupling
  41435. */
  41436. export abstract class AbstractScene {
  41437. /**
  41438. * Stores the list of available parsers in the application.
  41439. */
  41440. private static _BabylonFileParsers;
  41441. /**
  41442. * Stores the list of available individual parsers in the application.
  41443. */
  41444. private static _IndividualBabylonFileParsers;
  41445. /**
  41446. * Adds a parser in the list of available ones
  41447. * @param name Defines the name of the parser
  41448. * @param parser Defines the parser to add
  41449. */
  41450. static AddParser(name: string, parser: BabylonFileParser): void;
  41451. /**
  41452. * Gets a general parser from the list of avaialble ones
  41453. * @param name Defines the name of the parser
  41454. * @returns the requested parser or null
  41455. */
  41456. static GetParser(name: string): Nullable<BabylonFileParser>;
  41457. /**
  41458. * Adds n individual parser in the list of available ones
  41459. * @param name Defines the name of the parser
  41460. * @param parser Defines the parser to add
  41461. */
  41462. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  41463. /**
  41464. * Gets an individual parser from the list of avaialble ones
  41465. * @param name Defines the name of the parser
  41466. * @returns the requested parser or null
  41467. */
  41468. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  41469. /**
  41470. * Parser json data and populate both a scene and its associated container object
  41471. * @param jsonData Defines the data to parse
  41472. * @param scene Defines the scene to parse the data for
  41473. * @param container Defines the container attached to the parsing sequence
  41474. * @param rootUrl Defines the root url of the data
  41475. */
  41476. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  41477. /**
  41478. * Gets the list of root nodes (ie. nodes with no parent)
  41479. */
  41480. rootNodes: Node[];
  41481. /** All of the cameras added to this scene
  41482. * @see http://doc.babylonjs.com/babylon101/cameras
  41483. */
  41484. cameras: Camera[];
  41485. /**
  41486. * All of the lights added to this scene
  41487. * @see http://doc.babylonjs.com/babylon101/lights
  41488. */
  41489. lights: Light[];
  41490. /**
  41491. * All of the (abstract) meshes added to this scene
  41492. */
  41493. meshes: AbstractMesh[];
  41494. /**
  41495. * The list of skeletons added to the scene
  41496. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  41497. */
  41498. skeletons: Skeleton[];
  41499. /**
  41500. * All of the particle systems added to this scene
  41501. * @see http://doc.babylonjs.com/babylon101/particles
  41502. */
  41503. particleSystems: IParticleSystem[];
  41504. /**
  41505. * Gets a list of Animations associated with the scene
  41506. */
  41507. animations: Animation[];
  41508. /**
  41509. * All of the animation groups added to this scene
  41510. * @see http://doc.babylonjs.com/how_to/group
  41511. */
  41512. animationGroups: AnimationGroup[];
  41513. /**
  41514. * All of the multi-materials added to this scene
  41515. * @see http://doc.babylonjs.com/how_to/multi_materials
  41516. */
  41517. multiMaterials: MultiMaterial[];
  41518. /**
  41519. * All of the materials added to this scene
  41520. * In the context of a Scene, it is not supposed to be modified manually.
  41521. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  41522. * Note also that the order of the Material within the array is not significant and might change.
  41523. * @see http://doc.babylonjs.com/babylon101/materials
  41524. */
  41525. materials: Material[];
  41526. /**
  41527. * The list of morph target managers added to the scene
  41528. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  41529. */
  41530. morphTargetManagers: MorphTargetManager[];
  41531. /**
  41532. * The list of geometries used in the scene.
  41533. */
  41534. geometries: Geometry[];
  41535. /**
  41536. * All of the tranform nodes added to this scene
  41537. * In the context of a Scene, it is not supposed to be modified manually.
  41538. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  41539. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  41540. * @see http://doc.babylonjs.com/how_to/transformnode
  41541. */
  41542. transformNodes: TransformNode[];
  41543. /**
  41544. * ActionManagers available on the scene.
  41545. */
  41546. actionManagers: AbstractActionManager[];
  41547. /**
  41548. * Textures to keep.
  41549. */
  41550. textures: BaseTexture[];
  41551. /**
  41552. * Environment texture for the scene
  41553. */
  41554. environmentTexture: Nullable<BaseTexture>;
  41555. /**
  41556. * @returns all meshes, lights, cameras, transformNodes and bones
  41557. */
  41558. getNodes(): Array<Node>;
  41559. }
  41560. }
  41561. declare module "babylonjs/Audio/sound" {
  41562. import { Observable } from "babylonjs/Misc/observable";
  41563. import { Vector3 } from "babylonjs/Maths/math.vector";
  41564. import { Nullable } from "babylonjs/types";
  41565. import { Scene } from "babylonjs/scene";
  41566. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41567. /**
  41568. * Interface used to define options for Sound class
  41569. */
  41570. export interface ISoundOptions {
  41571. /**
  41572. * Does the sound autoplay once loaded.
  41573. */
  41574. autoplay?: boolean;
  41575. /**
  41576. * Does the sound loop after it finishes playing once.
  41577. */
  41578. loop?: boolean;
  41579. /**
  41580. * Sound's volume
  41581. */
  41582. volume?: number;
  41583. /**
  41584. * Is it a spatial sound?
  41585. */
  41586. spatialSound?: boolean;
  41587. /**
  41588. * Maximum distance to hear that sound
  41589. */
  41590. maxDistance?: number;
  41591. /**
  41592. * Uses user defined attenuation function
  41593. */
  41594. useCustomAttenuation?: boolean;
  41595. /**
  41596. * Define the roll off factor of spatial sounds.
  41597. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41598. */
  41599. rolloffFactor?: number;
  41600. /**
  41601. * Define the reference distance the sound should be heard perfectly.
  41602. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41603. */
  41604. refDistance?: number;
  41605. /**
  41606. * Define the distance attenuation model the sound will follow.
  41607. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41608. */
  41609. distanceModel?: string;
  41610. /**
  41611. * Defines the playback speed (1 by default)
  41612. */
  41613. playbackRate?: number;
  41614. /**
  41615. * Defines if the sound is from a streaming source
  41616. */
  41617. streaming?: boolean;
  41618. /**
  41619. * Defines an optional length (in seconds) inside the sound file
  41620. */
  41621. length?: number;
  41622. /**
  41623. * Defines an optional offset (in seconds) inside the sound file
  41624. */
  41625. offset?: number;
  41626. /**
  41627. * If true, URLs will not be required to state the audio file codec to use.
  41628. */
  41629. skipCodecCheck?: boolean;
  41630. }
  41631. /**
  41632. * Defines a sound that can be played in the application.
  41633. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  41634. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  41635. */
  41636. export class Sound {
  41637. /**
  41638. * The name of the sound in the scene.
  41639. */
  41640. name: string;
  41641. /**
  41642. * Does the sound autoplay once loaded.
  41643. */
  41644. autoplay: boolean;
  41645. /**
  41646. * Does the sound loop after it finishes playing once.
  41647. */
  41648. loop: boolean;
  41649. /**
  41650. * Does the sound use a custom attenuation curve to simulate the falloff
  41651. * happening when the source gets further away from the camera.
  41652. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  41653. */
  41654. useCustomAttenuation: boolean;
  41655. /**
  41656. * The sound track id this sound belongs to.
  41657. */
  41658. soundTrackId: number;
  41659. /**
  41660. * Is this sound currently played.
  41661. */
  41662. isPlaying: boolean;
  41663. /**
  41664. * Is this sound currently paused.
  41665. */
  41666. isPaused: boolean;
  41667. /**
  41668. * Does this sound enables spatial sound.
  41669. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41670. */
  41671. spatialSound: boolean;
  41672. /**
  41673. * Define the reference distance the sound should be heard perfectly.
  41674. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41675. */
  41676. refDistance: number;
  41677. /**
  41678. * Define the roll off factor of spatial sounds.
  41679. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41680. */
  41681. rolloffFactor: number;
  41682. /**
  41683. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  41684. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41685. */
  41686. maxDistance: number;
  41687. /**
  41688. * Define the distance attenuation model the sound will follow.
  41689. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41690. */
  41691. distanceModel: string;
  41692. /**
  41693. * @hidden
  41694. * Back Compat
  41695. **/
  41696. onended: () => any;
  41697. /**
  41698. * Gets or sets an object used to store user defined information for the sound.
  41699. */
  41700. metadata: any;
  41701. /**
  41702. * Observable event when the current playing sound finishes.
  41703. */
  41704. onEndedObservable: Observable<Sound>;
  41705. private _panningModel;
  41706. private _playbackRate;
  41707. private _streaming;
  41708. private _startTime;
  41709. private _startOffset;
  41710. private _position;
  41711. /** @hidden */
  41712. _positionInEmitterSpace: boolean;
  41713. private _localDirection;
  41714. private _volume;
  41715. private _isReadyToPlay;
  41716. private _isDirectional;
  41717. private _readyToPlayCallback;
  41718. private _audioBuffer;
  41719. private _soundSource;
  41720. private _streamingSource;
  41721. private _soundPanner;
  41722. private _soundGain;
  41723. private _inputAudioNode;
  41724. private _outputAudioNode;
  41725. private _coneInnerAngle;
  41726. private _coneOuterAngle;
  41727. private _coneOuterGain;
  41728. private _scene;
  41729. private _connectedTransformNode;
  41730. private _customAttenuationFunction;
  41731. private _registerFunc;
  41732. private _isOutputConnected;
  41733. private _htmlAudioElement;
  41734. private _urlType;
  41735. private _length?;
  41736. private _offset?;
  41737. /** @hidden */
  41738. static _SceneComponentInitialization: (scene: Scene) => void;
  41739. /**
  41740. * Create a sound and attach it to a scene
  41741. * @param name Name of your sound
  41742. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  41743. * @param scene defines the scene the sound belongs to
  41744. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  41745. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  41746. */
  41747. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  41748. /**
  41749. * Release the sound and its associated resources
  41750. */
  41751. dispose(): void;
  41752. /**
  41753. * Gets if the sounds is ready to be played or not.
  41754. * @returns true if ready, otherwise false
  41755. */
  41756. isReady(): boolean;
  41757. private _soundLoaded;
  41758. /**
  41759. * Sets the data of the sound from an audiobuffer
  41760. * @param audioBuffer The audioBuffer containing the data
  41761. */
  41762. setAudioBuffer(audioBuffer: AudioBuffer): void;
  41763. /**
  41764. * Updates the current sounds options such as maxdistance, loop...
  41765. * @param options A JSON object containing values named as the object properties
  41766. */
  41767. updateOptions(options: ISoundOptions): void;
  41768. private _createSpatialParameters;
  41769. private _updateSpatialParameters;
  41770. /**
  41771. * Switch the panning model to HRTF:
  41772. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  41773. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41774. */
  41775. switchPanningModelToHRTF(): void;
  41776. /**
  41777. * Switch the panning model to Equal Power:
  41778. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  41779. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41780. */
  41781. switchPanningModelToEqualPower(): void;
  41782. private _switchPanningModel;
  41783. /**
  41784. * Connect this sound to a sound track audio node like gain...
  41785. * @param soundTrackAudioNode the sound track audio node to connect to
  41786. */
  41787. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  41788. /**
  41789. * Transform this sound into a directional source
  41790. * @param coneInnerAngle Size of the inner cone in degree
  41791. * @param coneOuterAngle Size of the outer cone in degree
  41792. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  41793. */
  41794. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  41795. /**
  41796. * Gets or sets the inner angle for the directional cone.
  41797. */
  41798. get directionalConeInnerAngle(): number;
  41799. /**
  41800. * Gets or sets the inner angle for the directional cone.
  41801. */
  41802. set directionalConeInnerAngle(value: number);
  41803. /**
  41804. * Gets or sets the outer angle for the directional cone.
  41805. */
  41806. get directionalConeOuterAngle(): number;
  41807. /**
  41808. * Gets or sets the outer angle for the directional cone.
  41809. */
  41810. set directionalConeOuterAngle(value: number);
  41811. /**
  41812. * Sets the position of the emitter if spatial sound is enabled
  41813. * @param newPosition Defines the new posisiton
  41814. */
  41815. setPosition(newPosition: Vector3): void;
  41816. /**
  41817. * Sets the local direction of the emitter if spatial sound is enabled
  41818. * @param newLocalDirection Defines the new local direction
  41819. */
  41820. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  41821. private _updateDirection;
  41822. /** @hidden */
  41823. updateDistanceFromListener(): void;
  41824. /**
  41825. * Sets a new custom attenuation function for the sound.
  41826. * @param callback Defines the function used for the attenuation
  41827. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  41828. */
  41829. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  41830. /**
  41831. * Play the sound
  41832. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  41833. * @param offset (optional) Start the sound at a specific time in seconds
  41834. * @param length (optional) Sound duration (in seconds)
  41835. */
  41836. play(time?: number, offset?: number, length?: number): void;
  41837. private _onended;
  41838. /**
  41839. * Stop the sound
  41840. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  41841. */
  41842. stop(time?: number): void;
  41843. /**
  41844. * Put the sound in pause
  41845. */
  41846. pause(): void;
  41847. /**
  41848. * Sets a dedicated volume for this sounds
  41849. * @param newVolume Define the new volume of the sound
  41850. * @param time Define time for gradual change to new volume
  41851. */
  41852. setVolume(newVolume: number, time?: number): void;
  41853. /**
  41854. * Set the sound play back rate
  41855. * @param newPlaybackRate Define the playback rate the sound should be played at
  41856. */
  41857. setPlaybackRate(newPlaybackRate: number): void;
  41858. /**
  41859. * Gets the volume of the sound.
  41860. * @returns the volume of the sound
  41861. */
  41862. getVolume(): number;
  41863. /**
  41864. * Attach the sound to a dedicated mesh
  41865. * @param transformNode The transform node to connect the sound with
  41866. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  41867. */
  41868. attachToMesh(transformNode: TransformNode): void;
  41869. /**
  41870. * Detach the sound from the previously attached mesh
  41871. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  41872. */
  41873. detachFromMesh(): void;
  41874. private _onRegisterAfterWorldMatrixUpdate;
  41875. /**
  41876. * Clone the current sound in the scene.
  41877. * @returns the new sound clone
  41878. */
  41879. clone(): Nullable<Sound>;
  41880. /**
  41881. * Gets the current underlying audio buffer containing the data
  41882. * @returns the audio buffer
  41883. */
  41884. getAudioBuffer(): Nullable<AudioBuffer>;
  41885. /**
  41886. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  41887. * @returns the source node
  41888. */
  41889. getSoundSource(): Nullable<AudioBufferSourceNode>;
  41890. /**
  41891. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  41892. * @returns the gain node
  41893. */
  41894. getSoundGain(): Nullable<GainNode>;
  41895. /**
  41896. * Serializes the Sound in a JSON representation
  41897. * @returns the JSON representation of the sound
  41898. */
  41899. serialize(): any;
  41900. /**
  41901. * Parse a JSON representation of a sound to innstantiate in a given scene
  41902. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  41903. * @param scene Define the scene the new parsed sound should be created in
  41904. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  41905. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  41906. * @returns the newly parsed sound
  41907. */
  41908. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  41909. }
  41910. }
  41911. declare module "babylonjs/Actions/directAudioActions" {
  41912. import { Action } from "babylonjs/Actions/action";
  41913. import { Condition } from "babylonjs/Actions/condition";
  41914. import { Sound } from "babylonjs/Audio/sound";
  41915. /**
  41916. * This defines an action helpful to play a defined sound on a triggered action.
  41917. */
  41918. export class PlaySoundAction extends Action {
  41919. private _sound;
  41920. /**
  41921. * Instantiate the action
  41922. * @param triggerOptions defines the trigger options
  41923. * @param sound defines the sound to play
  41924. * @param condition defines the trigger related conditions
  41925. */
  41926. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  41927. /** @hidden */
  41928. _prepare(): void;
  41929. /**
  41930. * Execute the action and play the sound.
  41931. */
  41932. execute(): void;
  41933. /**
  41934. * Serializes the actions and its related information.
  41935. * @param parent defines the object to serialize in
  41936. * @returns the serialized object
  41937. */
  41938. serialize(parent: any): any;
  41939. }
  41940. /**
  41941. * This defines an action helpful to stop a defined sound on a triggered action.
  41942. */
  41943. export class StopSoundAction extends Action {
  41944. private _sound;
  41945. /**
  41946. * Instantiate the action
  41947. * @param triggerOptions defines the trigger options
  41948. * @param sound defines the sound to stop
  41949. * @param condition defines the trigger related conditions
  41950. */
  41951. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  41952. /** @hidden */
  41953. _prepare(): void;
  41954. /**
  41955. * Execute the action and stop the sound.
  41956. */
  41957. execute(): void;
  41958. /**
  41959. * Serializes the actions and its related information.
  41960. * @param parent defines the object to serialize in
  41961. * @returns the serialized object
  41962. */
  41963. serialize(parent: any): any;
  41964. }
  41965. }
  41966. declare module "babylonjs/Actions/interpolateValueAction" {
  41967. import { Action } from "babylonjs/Actions/action";
  41968. import { Condition } from "babylonjs/Actions/condition";
  41969. import { Observable } from "babylonjs/Misc/observable";
  41970. /**
  41971. * This defines an action responsible to change the value of a property
  41972. * by interpolating between its current value and the newly set one once triggered.
  41973. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  41974. */
  41975. export class InterpolateValueAction extends Action {
  41976. /**
  41977. * Defines the path of the property where the value should be interpolated
  41978. */
  41979. propertyPath: string;
  41980. /**
  41981. * Defines the target value at the end of the interpolation.
  41982. */
  41983. value: any;
  41984. /**
  41985. * Defines the time it will take for the property to interpolate to the value.
  41986. */
  41987. duration: number;
  41988. /**
  41989. * Defines if the other scene animations should be stopped when the action has been triggered
  41990. */
  41991. stopOtherAnimations?: boolean;
  41992. /**
  41993. * Defines a callback raised once the interpolation animation has been done.
  41994. */
  41995. onInterpolationDone?: () => void;
  41996. /**
  41997. * Observable triggered once the interpolation animation has been done.
  41998. */
  41999. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  42000. private _target;
  42001. private _effectiveTarget;
  42002. private _property;
  42003. /**
  42004. * Instantiate the action
  42005. * @param triggerOptions defines the trigger options
  42006. * @param target defines the object containing the value to interpolate
  42007. * @param propertyPath defines the path to the property in the target object
  42008. * @param value defines the target value at the end of the interpolation
  42009. * @param duration deines the time it will take for the property to interpolate to the value.
  42010. * @param condition defines the trigger related conditions
  42011. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  42012. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  42013. */
  42014. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  42015. /** @hidden */
  42016. _prepare(): void;
  42017. /**
  42018. * Execute the action starts the value interpolation.
  42019. */
  42020. execute(): void;
  42021. /**
  42022. * Serializes the actions and its related information.
  42023. * @param parent defines the object to serialize in
  42024. * @returns the serialized object
  42025. */
  42026. serialize(parent: any): any;
  42027. }
  42028. }
  42029. declare module "babylonjs/Actions/index" {
  42030. export * from "babylonjs/Actions/abstractActionManager";
  42031. export * from "babylonjs/Actions/action";
  42032. export * from "babylonjs/Actions/actionEvent";
  42033. export * from "babylonjs/Actions/actionManager";
  42034. export * from "babylonjs/Actions/condition";
  42035. export * from "babylonjs/Actions/directActions";
  42036. export * from "babylonjs/Actions/directAudioActions";
  42037. export * from "babylonjs/Actions/interpolateValueAction";
  42038. }
  42039. declare module "babylonjs/Animations/index" {
  42040. export * from "babylonjs/Animations/animatable";
  42041. export * from "babylonjs/Animations/animation";
  42042. export * from "babylonjs/Animations/animationGroup";
  42043. export * from "babylonjs/Animations/animationPropertiesOverride";
  42044. export * from "babylonjs/Animations/easing";
  42045. export * from "babylonjs/Animations/runtimeAnimation";
  42046. export * from "babylonjs/Animations/animationEvent";
  42047. export * from "babylonjs/Animations/animationGroup";
  42048. export * from "babylonjs/Animations/animationKey";
  42049. export * from "babylonjs/Animations/animationRange";
  42050. export * from "babylonjs/Animations/animatable.interface";
  42051. }
  42052. declare module "babylonjs/Audio/soundTrack" {
  42053. import { Sound } from "babylonjs/Audio/sound";
  42054. import { Analyser } from "babylonjs/Audio/analyser";
  42055. import { Scene } from "babylonjs/scene";
  42056. /**
  42057. * Options allowed during the creation of a sound track.
  42058. */
  42059. export interface ISoundTrackOptions {
  42060. /**
  42061. * The volume the sound track should take during creation
  42062. */
  42063. volume?: number;
  42064. /**
  42065. * Define if the sound track is the main sound track of the scene
  42066. */
  42067. mainTrack?: boolean;
  42068. }
  42069. /**
  42070. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  42071. * It will be also used in a future release to apply effects on a specific track.
  42072. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  42073. */
  42074. export class SoundTrack {
  42075. /**
  42076. * The unique identifier of the sound track in the scene.
  42077. */
  42078. id: number;
  42079. /**
  42080. * The list of sounds included in the sound track.
  42081. */
  42082. soundCollection: Array<Sound>;
  42083. private _outputAudioNode;
  42084. private _scene;
  42085. private _connectedAnalyser;
  42086. private _options;
  42087. private _isInitialized;
  42088. /**
  42089. * Creates a new sound track.
  42090. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  42091. * @param scene Define the scene the sound track belongs to
  42092. * @param options
  42093. */
  42094. constructor(scene: Scene, options?: ISoundTrackOptions);
  42095. private _initializeSoundTrackAudioGraph;
  42096. /**
  42097. * Release the sound track and its associated resources
  42098. */
  42099. dispose(): void;
  42100. /**
  42101. * Adds a sound to this sound track
  42102. * @param sound define the cound to add
  42103. * @ignoreNaming
  42104. */
  42105. AddSound(sound: Sound): void;
  42106. /**
  42107. * Removes a sound to this sound track
  42108. * @param sound define the cound to remove
  42109. * @ignoreNaming
  42110. */
  42111. RemoveSound(sound: Sound): void;
  42112. /**
  42113. * Set a global volume for the full sound track.
  42114. * @param newVolume Define the new volume of the sound track
  42115. */
  42116. setVolume(newVolume: number): void;
  42117. /**
  42118. * Switch the panning model to HRTF:
  42119. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  42120. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42121. */
  42122. switchPanningModelToHRTF(): void;
  42123. /**
  42124. * Switch the panning model to Equal Power:
  42125. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  42126. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42127. */
  42128. switchPanningModelToEqualPower(): void;
  42129. /**
  42130. * Connect the sound track to an audio analyser allowing some amazing
  42131. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  42132. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  42133. * @param analyser The analyser to connect to the engine
  42134. */
  42135. connectToAnalyser(analyser: Analyser): void;
  42136. }
  42137. }
  42138. declare module "babylonjs/Audio/audioSceneComponent" {
  42139. import { Sound } from "babylonjs/Audio/sound";
  42140. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  42141. import { Nullable } from "babylonjs/types";
  42142. import { Vector3 } from "babylonjs/Maths/math.vector";
  42143. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  42144. import { Scene } from "babylonjs/scene";
  42145. import { AbstractScene } from "babylonjs/abstractScene";
  42146. import "babylonjs/Audio/audioEngine";
  42147. module "babylonjs/abstractScene" {
  42148. interface AbstractScene {
  42149. /**
  42150. * The list of sounds used in the scene.
  42151. */
  42152. sounds: Nullable<Array<Sound>>;
  42153. }
  42154. }
  42155. module "babylonjs/scene" {
  42156. interface Scene {
  42157. /**
  42158. * @hidden
  42159. * Backing field
  42160. */
  42161. _mainSoundTrack: SoundTrack;
  42162. /**
  42163. * The main sound track played by the scene.
  42164. * It cotains your primary collection of sounds.
  42165. */
  42166. mainSoundTrack: SoundTrack;
  42167. /**
  42168. * The list of sound tracks added to the scene
  42169. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  42170. */
  42171. soundTracks: Nullable<Array<SoundTrack>>;
  42172. /**
  42173. * Gets a sound using a given name
  42174. * @param name defines the name to search for
  42175. * @return the found sound or null if not found at all.
  42176. */
  42177. getSoundByName(name: string): Nullable<Sound>;
  42178. /**
  42179. * Gets or sets if audio support is enabled
  42180. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  42181. */
  42182. audioEnabled: boolean;
  42183. /**
  42184. * Gets or sets if audio will be output to headphones
  42185. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  42186. */
  42187. headphone: boolean;
  42188. /**
  42189. * Gets or sets custom audio listener position provider
  42190. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  42191. */
  42192. audioListenerPositionProvider: Nullable<() => Vector3>;
  42193. /**
  42194. * Gets or sets a refresh rate when using 3D audio positioning
  42195. */
  42196. audioPositioningRefreshRate: number;
  42197. }
  42198. }
  42199. /**
  42200. * Defines the sound scene component responsible to manage any sounds
  42201. * in a given scene.
  42202. */
  42203. export class AudioSceneComponent implements ISceneSerializableComponent {
  42204. /**
  42205. * The component name helpfull to identify the component in the list of scene components.
  42206. */
  42207. readonly name: string;
  42208. /**
  42209. * The scene the component belongs to.
  42210. */
  42211. scene: Scene;
  42212. private _audioEnabled;
  42213. /**
  42214. * Gets whether audio is enabled or not.
  42215. * Please use related enable/disable method to switch state.
  42216. */
  42217. get audioEnabled(): boolean;
  42218. private _headphone;
  42219. /**
  42220. * Gets whether audio is outputing to headphone or not.
  42221. * Please use the according Switch methods to change output.
  42222. */
  42223. get headphone(): boolean;
  42224. /**
  42225. * Gets or sets a refresh rate when using 3D audio positioning
  42226. */
  42227. audioPositioningRefreshRate: number;
  42228. private _audioListenerPositionProvider;
  42229. /**
  42230. * Gets the current audio listener position provider
  42231. */
  42232. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  42233. /**
  42234. * Sets a custom listener position for all sounds in the scene
  42235. * By default, this is the position of the first active camera
  42236. */
  42237. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  42238. /**
  42239. * Creates a new instance of the component for the given scene
  42240. * @param scene Defines the scene to register the component in
  42241. */
  42242. constructor(scene: Scene);
  42243. /**
  42244. * Registers the component in a given scene
  42245. */
  42246. register(): void;
  42247. /**
  42248. * Rebuilds the elements related to this component in case of
  42249. * context lost for instance.
  42250. */
  42251. rebuild(): void;
  42252. /**
  42253. * Serializes the component data to the specified json object
  42254. * @param serializationObject The object to serialize to
  42255. */
  42256. serialize(serializationObject: any): void;
  42257. /**
  42258. * Adds all the elements from the container to the scene
  42259. * @param container the container holding the elements
  42260. */
  42261. addFromContainer(container: AbstractScene): void;
  42262. /**
  42263. * Removes all the elements in the container from the scene
  42264. * @param container contains the elements to remove
  42265. * @param dispose if the removed element should be disposed (default: false)
  42266. */
  42267. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  42268. /**
  42269. * Disposes the component and the associated ressources.
  42270. */
  42271. dispose(): void;
  42272. /**
  42273. * Disables audio in the associated scene.
  42274. */
  42275. disableAudio(): void;
  42276. /**
  42277. * Enables audio in the associated scene.
  42278. */
  42279. enableAudio(): void;
  42280. /**
  42281. * Switch audio to headphone output.
  42282. */
  42283. switchAudioModeForHeadphones(): void;
  42284. /**
  42285. * Switch audio to normal speakers.
  42286. */
  42287. switchAudioModeForNormalSpeakers(): void;
  42288. private _cachedCameraDirection;
  42289. private _cachedCameraPosition;
  42290. private _lastCheck;
  42291. private _afterRender;
  42292. }
  42293. }
  42294. declare module "babylonjs/Audio/weightedsound" {
  42295. import { Sound } from "babylonjs/Audio/sound";
  42296. /**
  42297. * Wraps one or more Sound objects and selects one with random weight for playback.
  42298. */
  42299. export class WeightedSound {
  42300. /** When true a Sound will be selected and played when the current playing Sound completes. */
  42301. loop: boolean;
  42302. private _coneInnerAngle;
  42303. private _coneOuterAngle;
  42304. private _volume;
  42305. /** A Sound is currently playing. */
  42306. isPlaying: boolean;
  42307. /** A Sound is currently paused. */
  42308. isPaused: boolean;
  42309. private _sounds;
  42310. private _weights;
  42311. private _currentIndex?;
  42312. /**
  42313. * Creates a new WeightedSound from the list of sounds given.
  42314. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  42315. * @param sounds Array of Sounds that will be selected from.
  42316. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  42317. */
  42318. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  42319. /**
  42320. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  42321. */
  42322. get directionalConeInnerAngle(): number;
  42323. /**
  42324. * The size of cone in degress for a directional sound in which there will be no attenuation.
  42325. */
  42326. set directionalConeInnerAngle(value: number);
  42327. /**
  42328. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  42329. * Listener angles between innerAngle and outerAngle will falloff linearly.
  42330. */
  42331. get directionalConeOuterAngle(): number;
  42332. /**
  42333. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  42334. * Listener angles between innerAngle and outerAngle will falloff linearly.
  42335. */
  42336. set directionalConeOuterAngle(value: number);
  42337. /**
  42338. * Playback volume.
  42339. */
  42340. get volume(): number;
  42341. /**
  42342. * Playback volume.
  42343. */
  42344. set volume(value: number);
  42345. private _onended;
  42346. /**
  42347. * Suspend playback
  42348. */
  42349. pause(): void;
  42350. /**
  42351. * Stop playback
  42352. */
  42353. stop(): void;
  42354. /**
  42355. * Start playback.
  42356. * @param startOffset Position the clip head at a specific time in seconds.
  42357. */
  42358. play(startOffset?: number): void;
  42359. }
  42360. }
  42361. declare module "babylonjs/Audio/index" {
  42362. export * from "babylonjs/Audio/analyser";
  42363. export * from "babylonjs/Audio/audioEngine";
  42364. export * from "babylonjs/Audio/audioSceneComponent";
  42365. export * from "babylonjs/Audio/sound";
  42366. export * from "babylonjs/Audio/soundTrack";
  42367. export * from "babylonjs/Audio/weightedsound";
  42368. }
  42369. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  42370. import { Behavior } from "babylonjs/Behaviors/behavior";
  42371. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42372. import { BackEase } from "babylonjs/Animations/easing";
  42373. /**
  42374. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  42375. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  42376. */
  42377. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  42378. /**
  42379. * Gets the name of the behavior.
  42380. */
  42381. get name(): string;
  42382. /**
  42383. * The easing function used by animations
  42384. */
  42385. static EasingFunction: BackEase;
  42386. /**
  42387. * The easing mode used by animations
  42388. */
  42389. static EasingMode: number;
  42390. /**
  42391. * The duration of the animation, in milliseconds
  42392. */
  42393. transitionDuration: number;
  42394. /**
  42395. * Length of the distance animated by the transition when lower radius is reached
  42396. */
  42397. lowerRadiusTransitionRange: number;
  42398. /**
  42399. * Length of the distance animated by the transition when upper radius is reached
  42400. */
  42401. upperRadiusTransitionRange: number;
  42402. private _autoTransitionRange;
  42403. /**
  42404. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  42405. */
  42406. get autoTransitionRange(): boolean;
  42407. /**
  42408. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  42409. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  42410. */
  42411. set autoTransitionRange(value: boolean);
  42412. private _attachedCamera;
  42413. private _onAfterCheckInputsObserver;
  42414. private _onMeshTargetChangedObserver;
  42415. /**
  42416. * Initializes the behavior.
  42417. */
  42418. init(): void;
  42419. /**
  42420. * Attaches the behavior to its arc rotate camera.
  42421. * @param camera Defines the camera to attach the behavior to
  42422. */
  42423. attach(camera: ArcRotateCamera): void;
  42424. /**
  42425. * Detaches the behavior from its current arc rotate camera.
  42426. */
  42427. detach(): void;
  42428. private _radiusIsAnimating;
  42429. private _radiusBounceTransition;
  42430. private _animatables;
  42431. private _cachedWheelPrecision;
  42432. /**
  42433. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  42434. * @param radiusLimit The limit to check against.
  42435. * @return Bool to indicate if at limit.
  42436. */
  42437. private _isRadiusAtLimit;
  42438. /**
  42439. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  42440. * @param radiusDelta The delta by which to animate to. Can be negative.
  42441. */
  42442. private _applyBoundRadiusAnimation;
  42443. /**
  42444. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  42445. */
  42446. protected _clearAnimationLocks(): void;
  42447. /**
  42448. * Stops and removes all animations that have been applied to the camera
  42449. */
  42450. stopAllAnimations(): void;
  42451. }
  42452. }
  42453. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  42454. import { Behavior } from "babylonjs/Behaviors/behavior";
  42455. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42456. import { ExponentialEase } from "babylonjs/Animations/easing";
  42457. import { Nullable } from "babylonjs/types";
  42458. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42459. import { Vector3 } from "babylonjs/Maths/math.vector";
  42460. /**
  42461. * 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.
  42462. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  42463. */
  42464. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  42465. /**
  42466. * Gets the name of the behavior.
  42467. */
  42468. get name(): string;
  42469. private _mode;
  42470. private _radiusScale;
  42471. private _positionScale;
  42472. private _defaultElevation;
  42473. private _elevationReturnTime;
  42474. private _elevationReturnWaitTime;
  42475. private _zoomStopsAnimation;
  42476. private _framingTime;
  42477. /**
  42478. * The easing function used by animations
  42479. */
  42480. static EasingFunction: ExponentialEase;
  42481. /**
  42482. * The easing mode used by animations
  42483. */
  42484. static EasingMode: number;
  42485. /**
  42486. * Sets the current mode used by the behavior
  42487. */
  42488. set mode(mode: number);
  42489. /**
  42490. * Gets current mode used by the behavior.
  42491. */
  42492. get mode(): number;
  42493. /**
  42494. * Sets the scale applied to the radius (1 by default)
  42495. */
  42496. set radiusScale(radius: number);
  42497. /**
  42498. * Gets the scale applied to the radius
  42499. */
  42500. get radiusScale(): number;
  42501. /**
  42502. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  42503. */
  42504. set positionScale(scale: number);
  42505. /**
  42506. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  42507. */
  42508. get positionScale(): number;
  42509. /**
  42510. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  42511. * behaviour is triggered, in radians.
  42512. */
  42513. set defaultElevation(elevation: number);
  42514. /**
  42515. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  42516. * behaviour is triggered, in radians.
  42517. */
  42518. get defaultElevation(): number;
  42519. /**
  42520. * Sets the time (in milliseconds) taken to return to the default beta position.
  42521. * Negative value indicates camera should not return to default.
  42522. */
  42523. set elevationReturnTime(speed: number);
  42524. /**
  42525. * Gets the time (in milliseconds) taken to return to the default beta position.
  42526. * Negative value indicates camera should not return to default.
  42527. */
  42528. get elevationReturnTime(): number;
  42529. /**
  42530. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  42531. */
  42532. set elevationReturnWaitTime(time: number);
  42533. /**
  42534. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  42535. */
  42536. get elevationReturnWaitTime(): number;
  42537. /**
  42538. * Sets the flag that indicates if user zooming should stop animation.
  42539. */
  42540. set zoomStopsAnimation(flag: boolean);
  42541. /**
  42542. * Gets the flag that indicates if user zooming should stop animation.
  42543. */
  42544. get zoomStopsAnimation(): boolean;
  42545. /**
  42546. * Sets the transition time when framing the mesh, in milliseconds
  42547. */
  42548. set framingTime(time: number);
  42549. /**
  42550. * Gets the transition time when framing the mesh, in milliseconds
  42551. */
  42552. get framingTime(): number;
  42553. /**
  42554. * Define if the behavior should automatically change the configured
  42555. * camera limits and sensibilities.
  42556. */
  42557. autoCorrectCameraLimitsAndSensibility: boolean;
  42558. private _onPrePointerObservableObserver;
  42559. private _onAfterCheckInputsObserver;
  42560. private _onMeshTargetChangedObserver;
  42561. private _attachedCamera;
  42562. private _isPointerDown;
  42563. private _lastInteractionTime;
  42564. /**
  42565. * Initializes the behavior.
  42566. */
  42567. init(): void;
  42568. /**
  42569. * Attaches the behavior to its arc rotate camera.
  42570. * @param camera Defines the camera to attach the behavior to
  42571. */
  42572. attach(camera: ArcRotateCamera): void;
  42573. /**
  42574. * Detaches the behavior from its current arc rotate camera.
  42575. */
  42576. detach(): void;
  42577. private _animatables;
  42578. private _betaIsAnimating;
  42579. private _betaTransition;
  42580. private _radiusTransition;
  42581. private _vectorTransition;
  42582. /**
  42583. * Targets the given mesh and updates zoom level accordingly.
  42584. * @param mesh The mesh to target.
  42585. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42586. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42587. */
  42588. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42589. /**
  42590. * Targets the given mesh with its children and updates zoom level accordingly.
  42591. * @param mesh The mesh to target.
  42592. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42593. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42594. */
  42595. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42596. /**
  42597. * Targets the given meshes with their children and updates zoom level accordingly.
  42598. * @param meshes The mesh to target.
  42599. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42600. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42601. */
  42602. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42603. /**
  42604. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  42605. * @param minimumWorld Determines the smaller position of the bounding box extend
  42606. * @param maximumWorld Determines the bigger position of the bounding box extend
  42607. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42608. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42609. */
  42610. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42611. /**
  42612. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  42613. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  42614. * frustum width.
  42615. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  42616. * to fully enclose the mesh in the viewing frustum.
  42617. */
  42618. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  42619. /**
  42620. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  42621. * is automatically returned to its default position (expected to be above ground plane).
  42622. */
  42623. private _maintainCameraAboveGround;
  42624. /**
  42625. * Returns the frustum slope based on the canvas ratio and camera FOV
  42626. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  42627. */
  42628. private _getFrustumSlope;
  42629. /**
  42630. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  42631. */
  42632. private _clearAnimationLocks;
  42633. /**
  42634. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  42635. */
  42636. private _applyUserInteraction;
  42637. /**
  42638. * Stops and removes all animations that have been applied to the camera
  42639. */
  42640. stopAllAnimations(): void;
  42641. /**
  42642. * Gets a value indicating if the user is moving the camera
  42643. */
  42644. get isUserIsMoving(): boolean;
  42645. /**
  42646. * The camera can move all the way towards the mesh.
  42647. */
  42648. static IgnoreBoundsSizeMode: number;
  42649. /**
  42650. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  42651. */
  42652. static FitFrustumSidesMode: number;
  42653. }
  42654. }
  42655. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  42656. import { Nullable } from "babylonjs/types";
  42657. import { Camera } from "babylonjs/Cameras/camera";
  42658. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42659. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  42660. /**
  42661. * Base class for Camera Pointer Inputs.
  42662. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  42663. * for example usage.
  42664. */
  42665. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  42666. /**
  42667. * Defines the camera the input is attached to.
  42668. */
  42669. abstract camera: Camera;
  42670. /**
  42671. * Whether keyboard modifier keys are pressed at time of last mouse event.
  42672. */
  42673. protected _altKey: boolean;
  42674. protected _ctrlKey: boolean;
  42675. protected _metaKey: boolean;
  42676. protected _shiftKey: boolean;
  42677. /**
  42678. * Which mouse buttons were pressed at time of last mouse event.
  42679. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  42680. */
  42681. protected _buttonsPressed: number;
  42682. /**
  42683. * Defines the buttons associated with the input to handle camera move.
  42684. */
  42685. buttons: number[];
  42686. /**
  42687. * Attach the input controls to a specific dom element to get the input from.
  42688. * @param element Defines the element the controls should be listened from
  42689. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42690. */
  42691. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42692. /**
  42693. * Detach the current controls from the specified dom element.
  42694. * @param element Defines the element to stop listening the inputs from
  42695. */
  42696. detachControl(element: Nullable<HTMLElement>): void;
  42697. /**
  42698. * Gets the class name of the current input.
  42699. * @returns the class name
  42700. */
  42701. getClassName(): string;
  42702. /**
  42703. * Get the friendly name associated with the input class.
  42704. * @returns the input friendly name
  42705. */
  42706. getSimpleName(): string;
  42707. /**
  42708. * Called on pointer POINTERDOUBLETAP event.
  42709. * Override this method to provide functionality on POINTERDOUBLETAP event.
  42710. */
  42711. protected onDoubleTap(type: string): void;
  42712. /**
  42713. * Called on pointer POINTERMOVE event if only a single touch is active.
  42714. * Override this method to provide functionality.
  42715. */
  42716. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  42717. /**
  42718. * Called on pointer POINTERMOVE event if multiple touches are active.
  42719. * Override this method to provide functionality.
  42720. */
  42721. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  42722. /**
  42723. * Called on JS contextmenu event.
  42724. * Override this method to provide functionality.
  42725. */
  42726. protected onContextMenu(evt: PointerEvent): void;
  42727. /**
  42728. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  42729. * press.
  42730. * Override this method to provide functionality.
  42731. */
  42732. protected onButtonDown(evt: PointerEvent): void;
  42733. /**
  42734. * Called each time a new POINTERUP event occurs. Ie, for each button
  42735. * release.
  42736. * Override this method to provide functionality.
  42737. */
  42738. protected onButtonUp(evt: PointerEvent): void;
  42739. /**
  42740. * Called when window becomes inactive.
  42741. * Override this method to provide functionality.
  42742. */
  42743. protected onLostFocus(): void;
  42744. private _pointerInput;
  42745. private _observer;
  42746. private _onLostFocus;
  42747. private pointA;
  42748. private pointB;
  42749. }
  42750. }
  42751. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  42752. import { Nullable } from "babylonjs/types";
  42753. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42754. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  42755. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  42756. /**
  42757. * Manage the pointers inputs to control an arc rotate camera.
  42758. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42759. */
  42760. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  42761. /**
  42762. * Defines the camera the input is attached to.
  42763. */
  42764. camera: ArcRotateCamera;
  42765. /**
  42766. * Gets the class name of the current input.
  42767. * @returns the class name
  42768. */
  42769. getClassName(): string;
  42770. /**
  42771. * Defines the buttons associated with the input to handle camera move.
  42772. */
  42773. buttons: number[];
  42774. /**
  42775. * Defines the pointer angular sensibility along the X axis or how fast is
  42776. * the camera rotating.
  42777. */
  42778. angularSensibilityX: number;
  42779. /**
  42780. * Defines the pointer angular sensibility along the Y axis or how fast is
  42781. * the camera rotating.
  42782. */
  42783. angularSensibilityY: number;
  42784. /**
  42785. * Defines the pointer pinch precision or how fast is the camera zooming.
  42786. */
  42787. pinchPrecision: number;
  42788. /**
  42789. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  42790. * from 0.
  42791. * It defines the percentage of current camera.radius to use as delta when
  42792. * pinch zoom is used.
  42793. */
  42794. pinchDeltaPercentage: number;
  42795. /**
  42796. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  42797. * that any object in the plane at the camera's target point will scale
  42798. * perfectly with finger motion.
  42799. * Overrides pinchDeltaPercentage and pinchPrecision.
  42800. */
  42801. useNaturalPinchZoom: boolean;
  42802. /**
  42803. * Defines the pointer panning sensibility or how fast is the camera moving.
  42804. */
  42805. panningSensibility: number;
  42806. /**
  42807. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  42808. */
  42809. multiTouchPanning: boolean;
  42810. /**
  42811. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  42812. * zoom (pinch) through multitouch.
  42813. */
  42814. multiTouchPanAndZoom: boolean;
  42815. /**
  42816. * Revers pinch action direction.
  42817. */
  42818. pinchInwards: boolean;
  42819. private _isPanClick;
  42820. private _twoFingerActivityCount;
  42821. private _isPinching;
  42822. /**
  42823. * Called on pointer POINTERMOVE event if only a single touch is active.
  42824. */
  42825. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  42826. /**
  42827. * Called on pointer POINTERDOUBLETAP event.
  42828. */
  42829. protected onDoubleTap(type: string): void;
  42830. /**
  42831. * Called on pointer POINTERMOVE event if multiple touches are active.
  42832. */
  42833. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  42834. /**
  42835. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  42836. * press.
  42837. */
  42838. protected onButtonDown(evt: PointerEvent): void;
  42839. /**
  42840. * Called each time a new POINTERUP event occurs. Ie, for each button
  42841. * release.
  42842. */
  42843. protected onButtonUp(evt: PointerEvent): void;
  42844. /**
  42845. * Called when window becomes inactive.
  42846. */
  42847. protected onLostFocus(): void;
  42848. }
  42849. }
  42850. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  42851. import { Nullable } from "babylonjs/types";
  42852. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42853. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42854. /**
  42855. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  42856. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42857. */
  42858. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  42859. /**
  42860. * Defines the camera the input is attached to.
  42861. */
  42862. camera: ArcRotateCamera;
  42863. /**
  42864. * Defines the list of key codes associated with the up action (increase alpha)
  42865. */
  42866. keysUp: number[];
  42867. /**
  42868. * Defines the list of key codes associated with the down action (decrease alpha)
  42869. */
  42870. keysDown: number[];
  42871. /**
  42872. * Defines the list of key codes associated with the left action (increase beta)
  42873. */
  42874. keysLeft: number[];
  42875. /**
  42876. * Defines the list of key codes associated with the right action (decrease beta)
  42877. */
  42878. keysRight: number[];
  42879. /**
  42880. * Defines the list of key codes associated with the reset action.
  42881. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  42882. */
  42883. keysReset: number[];
  42884. /**
  42885. * Defines the panning sensibility of the inputs.
  42886. * (How fast is the camera panning)
  42887. */
  42888. panningSensibility: number;
  42889. /**
  42890. * Defines the zooming sensibility of the inputs.
  42891. * (How fast is the camera zooming)
  42892. */
  42893. zoomingSensibility: number;
  42894. /**
  42895. * Defines whether maintaining the alt key down switch the movement mode from
  42896. * orientation to zoom.
  42897. */
  42898. useAltToZoom: boolean;
  42899. /**
  42900. * Rotation speed of the camera
  42901. */
  42902. angularSpeed: number;
  42903. private _keys;
  42904. private _ctrlPressed;
  42905. private _altPressed;
  42906. private _onCanvasBlurObserver;
  42907. private _onKeyboardObserver;
  42908. private _engine;
  42909. private _scene;
  42910. /**
  42911. * Attach the input controls to a specific dom element to get the input from.
  42912. * @param element Defines the element the controls should be listened from
  42913. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42914. */
  42915. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42916. /**
  42917. * Detach the current controls from the specified dom element.
  42918. * @param element Defines the element to stop listening the inputs from
  42919. */
  42920. detachControl(element: Nullable<HTMLElement>): void;
  42921. /**
  42922. * Update the current camera state depending on the inputs that have been used this frame.
  42923. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42924. */
  42925. checkInputs(): void;
  42926. /**
  42927. * Gets the class name of the current intput.
  42928. * @returns the class name
  42929. */
  42930. getClassName(): string;
  42931. /**
  42932. * Get the friendly name associated with the input class.
  42933. * @returns the input friendly name
  42934. */
  42935. getSimpleName(): string;
  42936. }
  42937. }
  42938. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  42939. import { Nullable } from "babylonjs/types";
  42940. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42941. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42942. /**
  42943. * Manage the mouse wheel inputs to control an arc rotate camera.
  42944. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42945. */
  42946. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  42947. /**
  42948. * Defines the camera the input is attached to.
  42949. */
  42950. camera: ArcRotateCamera;
  42951. /**
  42952. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  42953. */
  42954. wheelPrecision: number;
  42955. /**
  42956. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  42957. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  42958. */
  42959. wheelDeltaPercentage: number;
  42960. private _wheel;
  42961. private _observer;
  42962. private computeDeltaFromMouseWheelLegacyEvent;
  42963. /**
  42964. * Attach the input controls to a specific dom element to get the input from.
  42965. * @param element Defines the element the controls should be listened from
  42966. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42967. */
  42968. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42969. /**
  42970. * Detach the current controls from the specified dom element.
  42971. * @param element Defines the element to stop listening the inputs from
  42972. */
  42973. detachControl(element: Nullable<HTMLElement>): void;
  42974. /**
  42975. * Gets the class name of the current intput.
  42976. * @returns the class name
  42977. */
  42978. getClassName(): string;
  42979. /**
  42980. * Get the friendly name associated with the input class.
  42981. * @returns the input friendly name
  42982. */
  42983. getSimpleName(): string;
  42984. }
  42985. }
  42986. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  42987. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42988. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  42989. /**
  42990. * Default Inputs manager for the ArcRotateCamera.
  42991. * It groups all the default supported inputs for ease of use.
  42992. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42993. */
  42994. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  42995. /**
  42996. * Instantiates a new ArcRotateCameraInputsManager.
  42997. * @param camera Defines the camera the inputs belong to
  42998. */
  42999. constructor(camera: ArcRotateCamera);
  43000. /**
  43001. * Add mouse wheel input support to the input manager.
  43002. * @returns the current input manager
  43003. */
  43004. addMouseWheel(): ArcRotateCameraInputsManager;
  43005. /**
  43006. * Add pointers input support to the input manager.
  43007. * @returns the current input manager
  43008. */
  43009. addPointers(): ArcRotateCameraInputsManager;
  43010. /**
  43011. * Add keyboard input support to the input manager.
  43012. * @returns the current input manager
  43013. */
  43014. addKeyboard(): ArcRotateCameraInputsManager;
  43015. }
  43016. }
  43017. declare module "babylonjs/Cameras/arcRotateCamera" {
  43018. import { Observable } from "babylonjs/Misc/observable";
  43019. import { Nullable } from "babylonjs/types";
  43020. import { Scene } from "babylonjs/scene";
  43021. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  43022. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43023. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  43024. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  43025. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  43026. import { Camera } from "babylonjs/Cameras/camera";
  43027. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  43028. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  43029. import { Collider } from "babylonjs/Collisions/collider";
  43030. /**
  43031. * This represents an orbital type of camera.
  43032. *
  43033. * 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.
  43034. * 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.
  43035. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  43036. */
  43037. export class ArcRotateCamera extends TargetCamera {
  43038. /**
  43039. * Defines the rotation angle of the camera along the longitudinal axis.
  43040. */
  43041. alpha: number;
  43042. /**
  43043. * Defines the rotation angle of the camera along the latitudinal axis.
  43044. */
  43045. beta: number;
  43046. /**
  43047. * Defines the radius of the camera from it s target point.
  43048. */
  43049. radius: number;
  43050. protected _target: Vector3;
  43051. protected _targetHost: Nullable<AbstractMesh>;
  43052. /**
  43053. * Defines the target point of the camera.
  43054. * The camera looks towards it form the radius distance.
  43055. */
  43056. get target(): Vector3;
  43057. set target(value: Vector3);
  43058. /**
  43059. * Define the current local position of the camera in the scene
  43060. */
  43061. get position(): Vector3;
  43062. set position(newPosition: Vector3);
  43063. protected _upVector: Vector3;
  43064. protected _upToYMatrix: Matrix;
  43065. protected _YToUpMatrix: Matrix;
  43066. /**
  43067. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  43068. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  43069. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  43070. */
  43071. set upVector(vec: Vector3);
  43072. get upVector(): Vector3;
  43073. /**
  43074. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  43075. */
  43076. setMatUp(): void;
  43077. /**
  43078. * Current inertia value on the longitudinal axis.
  43079. * The bigger this number the longer it will take for the camera to stop.
  43080. */
  43081. inertialAlphaOffset: number;
  43082. /**
  43083. * Current inertia value on the latitudinal axis.
  43084. * The bigger this number the longer it will take for the camera to stop.
  43085. */
  43086. inertialBetaOffset: number;
  43087. /**
  43088. * Current inertia value on the radius axis.
  43089. * The bigger this number the longer it will take for the camera to stop.
  43090. */
  43091. inertialRadiusOffset: number;
  43092. /**
  43093. * Minimum allowed angle on the longitudinal axis.
  43094. * This can help limiting how the Camera is able to move in the scene.
  43095. */
  43096. lowerAlphaLimit: Nullable<number>;
  43097. /**
  43098. * Maximum allowed angle on the longitudinal axis.
  43099. * This can help limiting how the Camera is able to move in the scene.
  43100. */
  43101. upperAlphaLimit: Nullable<number>;
  43102. /**
  43103. * Minimum allowed angle on the latitudinal axis.
  43104. * This can help limiting how the Camera is able to move in the scene.
  43105. */
  43106. lowerBetaLimit: number;
  43107. /**
  43108. * Maximum allowed angle on the latitudinal axis.
  43109. * This can help limiting how the Camera is able to move in the scene.
  43110. */
  43111. upperBetaLimit: number;
  43112. /**
  43113. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  43114. * This can help limiting how the Camera is able to move in the scene.
  43115. */
  43116. lowerRadiusLimit: Nullable<number>;
  43117. /**
  43118. * Maximum allowed distance of the camera to the target (The camera can not get further).
  43119. * This can help limiting how the Camera is able to move in the scene.
  43120. */
  43121. upperRadiusLimit: Nullable<number>;
  43122. /**
  43123. * Defines the current inertia value used during panning of the camera along the X axis.
  43124. */
  43125. inertialPanningX: number;
  43126. /**
  43127. * Defines the current inertia value used during panning of the camera along the Y axis.
  43128. */
  43129. inertialPanningY: number;
  43130. /**
  43131. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  43132. * Basically if your fingers moves away from more than this distance you will be considered
  43133. * in pinch mode.
  43134. */
  43135. pinchToPanMaxDistance: number;
  43136. /**
  43137. * Defines the maximum distance the camera can pan.
  43138. * This could help keeping the cammera always in your scene.
  43139. */
  43140. panningDistanceLimit: Nullable<number>;
  43141. /**
  43142. * Defines the target of the camera before paning.
  43143. */
  43144. panningOriginTarget: Vector3;
  43145. /**
  43146. * Defines the value of the inertia used during panning.
  43147. * 0 would mean stop inertia and one would mean no decelleration at all.
  43148. */
  43149. panningInertia: number;
  43150. /**
  43151. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  43152. */
  43153. get angularSensibilityX(): number;
  43154. set angularSensibilityX(value: number);
  43155. /**
  43156. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  43157. */
  43158. get angularSensibilityY(): number;
  43159. set angularSensibilityY(value: number);
  43160. /**
  43161. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  43162. */
  43163. get pinchPrecision(): number;
  43164. set pinchPrecision(value: number);
  43165. /**
  43166. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  43167. * It will be used instead of pinchDeltaPrecision if different from 0.
  43168. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  43169. */
  43170. get pinchDeltaPercentage(): number;
  43171. set pinchDeltaPercentage(value: number);
  43172. /**
  43173. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  43174. * and pinch delta percentage.
  43175. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  43176. * that any object in the plane at the camera's target point will scale
  43177. * perfectly with finger motion.
  43178. */
  43179. get useNaturalPinchZoom(): boolean;
  43180. set useNaturalPinchZoom(value: boolean);
  43181. /**
  43182. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  43183. */
  43184. get panningSensibility(): number;
  43185. set panningSensibility(value: number);
  43186. /**
  43187. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  43188. */
  43189. get keysUp(): number[];
  43190. set keysUp(value: number[]);
  43191. /**
  43192. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  43193. */
  43194. get keysDown(): number[];
  43195. set keysDown(value: number[]);
  43196. /**
  43197. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  43198. */
  43199. get keysLeft(): number[];
  43200. set keysLeft(value: number[]);
  43201. /**
  43202. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  43203. */
  43204. get keysRight(): number[];
  43205. set keysRight(value: number[]);
  43206. /**
  43207. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  43208. */
  43209. get wheelPrecision(): number;
  43210. set wheelPrecision(value: number);
  43211. /**
  43212. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  43213. * It will be used instead of pinchDeltaPrecision if different from 0.
  43214. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  43215. */
  43216. get wheelDeltaPercentage(): number;
  43217. set wheelDeltaPercentage(value: number);
  43218. /**
  43219. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  43220. */
  43221. zoomOnFactor: number;
  43222. /**
  43223. * Defines a screen offset for the camera position.
  43224. */
  43225. targetScreenOffset: Vector2;
  43226. /**
  43227. * Allows the camera to be completely reversed.
  43228. * If false the camera can not arrive upside down.
  43229. */
  43230. allowUpsideDown: boolean;
  43231. /**
  43232. * Define if double tap/click is used to restore the previously saved state of the camera.
  43233. */
  43234. useInputToRestoreState: boolean;
  43235. /** @hidden */
  43236. _viewMatrix: Matrix;
  43237. /** @hidden */
  43238. _useCtrlForPanning: boolean;
  43239. /** @hidden */
  43240. _panningMouseButton: number;
  43241. /**
  43242. * Defines the input associated to the camera.
  43243. */
  43244. inputs: ArcRotateCameraInputsManager;
  43245. /** @hidden */
  43246. _reset: () => void;
  43247. /**
  43248. * Defines the allowed panning axis.
  43249. */
  43250. panningAxis: Vector3;
  43251. protected _localDirection: Vector3;
  43252. protected _transformedDirection: Vector3;
  43253. private _bouncingBehavior;
  43254. /**
  43255. * Gets the bouncing behavior of the camera if it has been enabled.
  43256. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43257. */
  43258. get bouncingBehavior(): Nullable<BouncingBehavior>;
  43259. /**
  43260. * Defines if the bouncing behavior of the camera is enabled on the camera.
  43261. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43262. */
  43263. get useBouncingBehavior(): boolean;
  43264. set useBouncingBehavior(value: boolean);
  43265. private _framingBehavior;
  43266. /**
  43267. * Gets the framing behavior of the camera if it has been enabled.
  43268. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43269. */
  43270. get framingBehavior(): Nullable<FramingBehavior>;
  43271. /**
  43272. * Defines if the framing behavior of the camera is enabled on the camera.
  43273. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43274. */
  43275. get useFramingBehavior(): boolean;
  43276. set useFramingBehavior(value: boolean);
  43277. private _autoRotationBehavior;
  43278. /**
  43279. * Gets the auto rotation behavior of the camera if it has been enabled.
  43280. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43281. */
  43282. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  43283. /**
  43284. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  43285. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43286. */
  43287. get useAutoRotationBehavior(): boolean;
  43288. set useAutoRotationBehavior(value: boolean);
  43289. /**
  43290. * Observable triggered when the mesh target has been changed on the camera.
  43291. */
  43292. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  43293. /**
  43294. * Event raised when the camera is colliding with a mesh.
  43295. */
  43296. onCollide: (collidedMesh: AbstractMesh) => void;
  43297. /**
  43298. * Defines whether the camera should check collision with the objects oh the scene.
  43299. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  43300. */
  43301. checkCollisions: boolean;
  43302. /**
  43303. * Defines the collision radius of the camera.
  43304. * This simulates a sphere around the camera.
  43305. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  43306. */
  43307. collisionRadius: Vector3;
  43308. protected _collider: Collider;
  43309. protected _previousPosition: Vector3;
  43310. protected _collisionVelocity: Vector3;
  43311. protected _newPosition: Vector3;
  43312. protected _previousAlpha: number;
  43313. protected _previousBeta: number;
  43314. protected _previousRadius: number;
  43315. protected _collisionTriggered: boolean;
  43316. protected _targetBoundingCenter: Nullable<Vector3>;
  43317. private _computationVector;
  43318. /**
  43319. * Instantiates a new ArcRotateCamera in a given scene
  43320. * @param name Defines the name of the camera
  43321. * @param alpha Defines the camera rotation along the logitudinal axis
  43322. * @param beta Defines the camera rotation along the latitudinal axis
  43323. * @param radius Defines the camera distance from its target
  43324. * @param target Defines the camera target
  43325. * @param scene Defines the scene the camera belongs to
  43326. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  43327. */
  43328. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  43329. /** @hidden */
  43330. _initCache(): void;
  43331. /** @hidden */
  43332. _updateCache(ignoreParentClass?: boolean): void;
  43333. protected _getTargetPosition(): Vector3;
  43334. private _storedAlpha;
  43335. private _storedBeta;
  43336. private _storedRadius;
  43337. private _storedTarget;
  43338. private _storedTargetScreenOffset;
  43339. /**
  43340. * Stores the current state of the camera (alpha, beta, radius and target)
  43341. * @returns the camera itself
  43342. */
  43343. storeState(): Camera;
  43344. /**
  43345. * @hidden
  43346. * Restored camera state. You must call storeState() first
  43347. */
  43348. _restoreStateValues(): boolean;
  43349. /** @hidden */
  43350. _isSynchronizedViewMatrix(): boolean;
  43351. /**
  43352. * Attached controls to the current camera.
  43353. * @param element Defines the element the controls should be listened from
  43354. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43355. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  43356. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  43357. */
  43358. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  43359. /**
  43360. * Detach the current controls from the camera.
  43361. * The camera will stop reacting to inputs.
  43362. * @param element Defines the element to stop listening the inputs from
  43363. */
  43364. detachControl(element: HTMLElement): void;
  43365. /** @hidden */
  43366. _checkInputs(): void;
  43367. protected _checkLimits(): void;
  43368. /**
  43369. * Rebuilds angles (alpha, beta) and radius from the give position and target
  43370. */
  43371. rebuildAnglesAndRadius(): void;
  43372. /**
  43373. * Use a position to define the current camera related information like alpha, beta and radius
  43374. * @param position Defines the position to set the camera at
  43375. */
  43376. setPosition(position: Vector3): void;
  43377. /**
  43378. * Defines the target the camera should look at.
  43379. * This will automatically adapt alpha beta and radius to fit within the new target.
  43380. * @param target Defines the new target as a Vector or a mesh
  43381. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  43382. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  43383. */
  43384. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  43385. /** @hidden */
  43386. _getViewMatrix(): Matrix;
  43387. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  43388. /**
  43389. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  43390. * @param meshes Defines the mesh to zoom on
  43391. * @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)
  43392. */
  43393. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  43394. /**
  43395. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  43396. * The target will be changed but the radius
  43397. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  43398. * @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)
  43399. */
  43400. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  43401. min: Vector3;
  43402. max: Vector3;
  43403. distance: number;
  43404. }, doNotUpdateMaxZ?: boolean): void;
  43405. /**
  43406. * @override
  43407. * Override Camera.createRigCamera
  43408. */
  43409. createRigCamera(name: string, cameraIndex: number): Camera;
  43410. /**
  43411. * @hidden
  43412. * @override
  43413. * Override Camera._updateRigCameras
  43414. */
  43415. _updateRigCameras(): void;
  43416. /**
  43417. * Destroy the camera and release the current resources hold by it.
  43418. */
  43419. dispose(): void;
  43420. /**
  43421. * Gets the current object class name.
  43422. * @return the class name
  43423. */
  43424. getClassName(): string;
  43425. }
  43426. }
  43427. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  43428. import { Behavior } from "babylonjs/Behaviors/behavior";
  43429. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43430. /**
  43431. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  43432. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43433. */
  43434. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  43435. /**
  43436. * Gets the name of the behavior.
  43437. */
  43438. get name(): string;
  43439. private _zoomStopsAnimation;
  43440. private _idleRotationSpeed;
  43441. private _idleRotationWaitTime;
  43442. private _idleRotationSpinupTime;
  43443. /**
  43444. * Sets the flag that indicates if user zooming should stop animation.
  43445. */
  43446. set zoomStopsAnimation(flag: boolean);
  43447. /**
  43448. * Gets the flag that indicates if user zooming should stop animation.
  43449. */
  43450. get zoomStopsAnimation(): boolean;
  43451. /**
  43452. * Sets the default speed at which the camera rotates around the model.
  43453. */
  43454. set idleRotationSpeed(speed: number);
  43455. /**
  43456. * Gets the default speed at which the camera rotates around the model.
  43457. */
  43458. get idleRotationSpeed(): number;
  43459. /**
  43460. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  43461. */
  43462. set idleRotationWaitTime(time: number);
  43463. /**
  43464. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  43465. */
  43466. get idleRotationWaitTime(): number;
  43467. /**
  43468. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  43469. */
  43470. set idleRotationSpinupTime(time: number);
  43471. /**
  43472. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  43473. */
  43474. get idleRotationSpinupTime(): number;
  43475. /**
  43476. * Gets a value indicating if the camera is currently rotating because of this behavior
  43477. */
  43478. get rotationInProgress(): boolean;
  43479. private _onPrePointerObservableObserver;
  43480. private _onAfterCheckInputsObserver;
  43481. private _attachedCamera;
  43482. private _isPointerDown;
  43483. private _lastFrameTime;
  43484. private _lastInteractionTime;
  43485. private _cameraRotationSpeed;
  43486. /**
  43487. * Initializes the behavior.
  43488. */
  43489. init(): void;
  43490. /**
  43491. * Attaches the behavior to its arc rotate camera.
  43492. * @param camera Defines the camera to attach the behavior to
  43493. */
  43494. attach(camera: ArcRotateCamera): void;
  43495. /**
  43496. * Detaches the behavior from its current arc rotate camera.
  43497. */
  43498. detach(): void;
  43499. /**
  43500. * Returns true if user is scrolling.
  43501. * @return true if user is scrolling.
  43502. */
  43503. private _userIsZooming;
  43504. private _lastFrameRadius;
  43505. private _shouldAnimationStopForInteraction;
  43506. /**
  43507. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  43508. */
  43509. private _applyUserInteraction;
  43510. private _userIsMoving;
  43511. }
  43512. }
  43513. declare module "babylonjs/Behaviors/Cameras/index" {
  43514. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  43515. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  43516. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  43517. }
  43518. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  43519. import { Mesh } from "babylonjs/Meshes/mesh";
  43520. import { TransformNode } from "babylonjs/Meshes/transformNode";
  43521. import { Behavior } from "babylonjs/Behaviors/behavior";
  43522. /**
  43523. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  43524. */
  43525. export class AttachToBoxBehavior implements Behavior<Mesh> {
  43526. private ui;
  43527. /**
  43528. * The name of the behavior
  43529. */
  43530. name: string;
  43531. /**
  43532. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  43533. */
  43534. distanceAwayFromFace: number;
  43535. /**
  43536. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  43537. */
  43538. distanceAwayFromBottomOfFace: number;
  43539. private _faceVectors;
  43540. private _target;
  43541. private _scene;
  43542. private _onRenderObserver;
  43543. private _tmpMatrix;
  43544. private _tmpVector;
  43545. /**
  43546. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  43547. * @param ui The transform node that should be attched to the mesh
  43548. */
  43549. constructor(ui: TransformNode);
  43550. /**
  43551. * Initializes the behavior
  43552. */
  43553. init(): void;
  43554. private _closestFace;
  43555. private _zeroVector;
  43556. private _lookAtTmpMatrix;
  43557. private _lookAtToRef;
  43558. /**
  43559. * Attaches the AttachToBoxBehavior to the passed in mesh
  43560. * @param target The mesh that the specified node will be attached to
  43561. */
  43562. attach(target: Mesh): void;
  43563. /**
  43564. * Detaches the behavior from the mesh
  43565. */
  43566. detach(): void;
  43567. }
  43568. }
  43569. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  43570. import { Behavior } from "babylonjs/Behaviors/behavior";
  43571. import { Mesh } from "babylonjs/Meshes/mesh";
  43572. /**
  43573. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  43574. */
  43575. export class FadeInOutBehavior implements Behavior<Mesh> {
  43576. /**
  43577. * Time in milliseconds to delay before fading in (Default: 0)
  43578. */
  43579. delay: number;
  43580. /**
  43581. * Time in milliseconds for the mesh to fade in (Default: 300)
  43582. */
  43583. fadeInTime: number;
  43584. private _millisecondsPerFrame;
  43585. private _hovered;
  43586. private _hoverValue;
  43587. private _ownerNode;
  43588. /**
  43589. * Instatiates the FadeInOutBehavior
  43590. */
  43591. constructor();
  43592. /**
  43593. * The name of the behavior
  43594. */
  43595. get name(): string;
  43596. /**
  43597. * Initializes the behavior
  43598. */
  43599. init(): void;
  43600. /**
  43601. * Attaches the fade behavior on the passed in mesh
  43602. * @param ownerNode The mesh that will be faded in/out once attached
  43603. */
  43604. attach(ownerNode: Mesh): void;
  43605. /**
  43606. * Detaches the behavior from the mesh
  43607. */
  43608. detach(): void;
  43609. /**
  43610. * Triggers the mesh to begin fading in or out
  43611. * @param value if the object should fade in or out (true to fade in)
  43612. */
  43613. fadeIn(value: boolean): void;
  43614. private _update;
  43615. private _setAllVisibility;
  43616. }
  43617. }
  43618. declare module "babylonjs/Misc/pivotTools" {
  43619. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43620. /**
  43621. * Class containing a set of static utilities functions for managing Pivots
  43622. * @hidden
  43623. */
  43624. export class PivotTools {
  43625. private static _PivotCached;
  43626. private static _OldPivotPoint;
  43627. private static _PivotTranslation;
  43628. private static _PivotTmpVector;
  43629. /** @hidden */
  43630. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  43631. /** @hidden */
  43632. static _RestorePivotPoint(mesh: AbstractMesh): void;
  43633. }
  43634. }
  43635. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  43636. import { Scene } from "babylonjs/scene";
  43637. import { Vector4 } from "babylonjs/Maths/math.vector";
  43638. import { Mesh } from "babylonjs/Meshes/mesh";
  43639. import { Nullable } from "babylonjs/types";
  43640. import { Plane } from "babylonjs/Maths/math.plane";
  43641. /**
  43642. * Class containing static functions to help procedurally build meshes
  43643. */
  43644. export class PlaneBuilder {
  43645. /**
  43646. * Creates a plane mesh
  43647. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  43648. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  43649. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  43650. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43651. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43652. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43653. * @param name defines the name of the mesh
  43654. * @param options defines the options used to create the mesh
  43655. * @param scene defines the hosting scene
  43656. * @returns the plane mesh
  43657. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  43658. */
  43659. static CreatePlane(name: string, options: {
  43660. size?: number;
  43661. width?: number;
  43662. height?: number;
  43663. sideOrientation?: number;
  43664. frontUVs?: Vector4;
  43665. backUVs?: Vector4;
  43666. updatable?: boolean;
  43667. sourcePlane?: Plane;
  43668. }, scene?: Nullable<Scene>): Mesh;
  43669. }
  43670. }
  43671. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  43672. import { Behavior } from "babylonjs/Behaviors/behavior";
  43673. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43674. import { Observable } from "babylonjs/Misc/observable";
  43675. import { Vector3 } from "babylonjs/Maths/math.vector";
  43676. import { Ray } from "babylonjs/Culling/ray";
  43677. import "babylonjs/Meshes/Builders/planeBuilder";
  43678. /**
  43679. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  43680. */
  43681. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  43682. private static _AnyMouseID;
  43683. /**
  43684. * Abstract mesh the behavior is set on
  43685. */
  43686. attachedNode: AbstractMesh;
  43687. private _dragPlane;
  43688. private _scene;
  43689. private _pointerObserver;
  43690. private _beforeRenderObserver;
  43691. private static _planeScene;
  43692. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  43693. /**
  43694. * 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)
  43695. */
  43696. maxDragAngle: number;
  43697. /**
  43698. * @hidden
  43699. */
  43700. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  43701. /**
  43702. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  43703. */
  43704. currentDraggingPointerID: number;
  43705. /**
  43706. * The last position where the pointer hit the drag plane in world space
  43707. */
  43708. lastDragPosition: Vector3;
  43709. /**
  43710. * If the behavior is currently in a dragging state
  43711. */
  43712. dragging: boolean;
  43713. /**
  43714. * 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)
  43715. */
  43716. dragDeltaRatio: number;
  43717. /**
  43718. * If the drag plane orientation should be updated during the dragging (Default: true)
  43719. */
  43720. updateDragPlane: boolean;
  43721. private _debugMode;
  43722. private _moving;
  43723. /**
  43724. * Fires each time the attached mesh is dragged with the pointer
  43725. * * delta between last drag position and current drag position in world space
  43726. * * dragDistance along the drag axis
  43727. * * dragPlaneNormal normal of the current drag plane used during the drag
  43728. * * dragPlanePoint in world space where the drag intersects the drag plane
  43729. */
  43730. onDragObservable: Observable<{
  43731. delta: Vector3;
  43732. dragPlanePoint: Vector3;
  43733. dragPlaneNormal: Vector3;
  43734. dragDistance: number;
  43735. pointerId: number;
  43736. }>;
  43737. /**
  43738. * Fires each time a drag begins (eg. mouse down on mesh)
  43739. */
  43740. onDragStartObservable: Observable<{
  43741. dragPlanePoint: Vector3;
  43742. pointerId: number;
  43743. }>;
  43744. /**
  43745. * Fires each time a drag ends (eg. mouse release after drag)
  43746. */
  43747. onDragEndObservable: Observable<{
  43748. dragPlanePoint: Vector3;
  43749. pointerId: number;
  43750. }>;
  43751. /**
  43752. * If the attached mesh should be moved when dragged
  43753. */
  43754. moveAttached: boolean;
  43755. /**
  43756. * If the drag behavior will react to drag events (Default: true)
  43757. */
  43758. enabled: boolean;
  43759. /**
  43760. * If pointer events should start and release the drag (Default: true)
  43761. */
  43762. startAndReleaseDragOnPointerEvents: boolean;
  43763. /**
  43764. * If camera controls should be detached during the drag
  43765. */
  43766. detachCameraControls: boolean;
  43767. /**
  43768. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  43769. */
  43770. useObjectOrientationForDragging: boolean;
  43771. private _options;
  43772. /**
  43773. * Gets the options used by the behavior
  43774. */
  43775. get options(): {
  43776. dragAxis?: Vector3;
  43777. dragPlaneNormal?: Vector3;
  43778. };
  43779. /**
  43780. * Sets the options used by the behavior
  43781. */
  43782. set options(options: {
  43783. dragAxis?: Vector3;
  43784. dragPlaneNormal?: Vector3;
  43785. });
  43786. /**
  43787. * Creates a pointer drag behavior that can be attached to a mesh
  43788. * @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)
  43789. */
  43790. constructor(options?: {
  43791. dragAxis?: Vector3;
  43792. dragPlaneNormal?: Vector3;
  43793. });
  43794. /**
  43795. * Predicate to determine if it is valid to move the object to a new position when it is moved
  43796. */
  43797. validateDrag: (targetPosition: Vector3) => boolean;
  43798. /**
  43799. * The name of the behavior
  43800. */
  43801. get name(): string;
  43802. /**
  43803. * Initializes the behavior
  43804. */
  43805. init(): void;
  43806. private _tmpVector;
  43807. private _alternatePickedPoint;
  43808. private _worldDragAxis;
  43809. private _targetPosition;
  43810. private _attachedElement;
  43811. /**
  43812. * Attaches the drag behavior the passed in mesh
  43813. * @param ownerNode The mesh that will be dragged around once attached
  43814. * @param predicate Predicate to use for pick filtering
  43815. */
  43816. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  43817. /**
  43818. * Force relase the drag action by code.
  43819. */
  43820. releaseDrag(): void;
  43821. private _startDragRay;
  43822. private _lastPointerRay;
  43823. /**
  43824. * Simulates the start of a pointer drag event on the behavior
  43825. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  43826. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  43827. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  43828. */
  43829. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  43830. private _startDrag;
  43831. private _dragDelta;
  43832. private _moveDrag;
  43833. private _pickWithRayOnDragPlane;
  43834. private _pointA;
  43835. private _pointB;
  43836. private _pointC;
  43837. private _lineA;
  43838. private _lineB;
  43839. private _localAxis;
  43840. private _lookAt;
  43841. private _updateDragPlanePosition;
  43842. /**
  43843. * Detaches the behavior from the mesh
  43844. */
  43845. detach(): void;
  43846. }
  43847. }
  43848. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  43849. import { Mesh } from "babylonjs/Meshes/mesh";
  43850. import { Behavior } from "babylonjs/Behaviors/behavior";
  43851. /**
  43852. * A behavior that when attached to a mesh will allow the mesh to be scaled
  43853. */
  43854. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  43855. private _dragBehaviorA;
  43856. private _dragBehaviorB;
  43857. private _startDistance;
  43858. private _initialScale;
  43859. private _targetScale;
  43860. private _ownerNode;
  43861. private _sceneRenderObserver;
  43862. /**
  43863. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  43864. */
  43865. constructor();
  43866. /**
  43867. * The name of the behavior
  43868. */
  43869. get name(): string;
  43870. /**
  43871. * Initializes the behavior
  43872. */
  43873. init(): void;
  43874. private _getCurrentDistance;
  43875. /**
  43876. * Attaches the scale behavior the passed in mesh
  43877. * @param ownerNode The mesh that will be scaled around once attached
  43878. */
  43879. attach(ownerNode: Mesh): void;
  43880. /**
  43881. * Detaches the behavior from the mesh
  43882. */
  43883. detach(): void;
  43884. }
  43885. }
  43886. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  43887. import { Behavior } from "babylonjs/Behaviors/behavior";
  43888. import { Mesh } from "babylonjs/Meshes/mesh";
  43889. import { Observable } from "babylonjs/Misc/observable";
  43890. /**
  43891. * 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
  43892. */
  43893. export class SixDofDragBehavior implements Behavior<Mesh> {
  43894. private static _virtualScene;
  43895. private _ownerNode;
  43896. private _sceneRenderObserver;
  43897. private _scene;
  43898. private _targetPosition;
  43899. private _virtualOriginMesh;
  43900. private _virtualDragMesh;
  43901. private _pointerObserver;
  43902. private _moving;
  43903. private _startingOrientation;
  43904. private _attachedElement;
  43905. /**
  43906. * 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)
  43907. */
  43908. private zDragFactor;
  43909. /**
  43910. * If the object should rotate to face the drag origin
  43911. */
  43912. rotateDraggedObject: boolean;
  43913. /**
  43914. * If the behavior is currently in a dragging state
  43915. */
  43916. dragging: boolean;
  43917. /**
  43918. * 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)
  43919. */
  43920. dragDeltaRatio: number;
  43921. /**
  43922. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  43923. */
  43924. currentDraggingPointerID: number;
  43925. /**
  43926. * If camera controls should be detached during the drag
  43927. */
  43928. detachCameraControls: boolean;
  43929. /**
  43930. * Fires each time a drag starts
  43931. */
  43932. onDragStartObservable: Observable<{}>;
  43933. /**
  43934. * Fires each time a drag ends (eg. mouse release after drag)
  43935. */
  43936. onDragEndObservable: Observable<{}>;
  43937. /**
  43938. * 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
  43939. */
  43940. constructor();
  43941. /**
  43942. * The name of the behavior
  43943. */
  43944. get name(): string;
  43945. /**
  43946. * Initializes the behavior
  43947. */
  43948. init(): void;
  43949. /**
  43950. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  43951. */
  43952. private get _pointerCamera();
  43953. /**
  43954. * Attaches the scale behavior the passed in mesh
  43955. * @param ownerNode The mesh that will be scaled around once attached
  43956. */
  43957. attach(ownerNode: Mesh): void;
  43958. /**
  43959. * Detaches the behavior from the mesh
  43960. */
  43961. detach(): void;
  43962. }
  43963. }
  43964. declare module "babylonjs/Behaviors/Meshes/index" {
  43965. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  43966. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  43967. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  43968. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  43969. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  43970. }
  43971. declare module "babylonjs/Behaviors/index" {
  43972. export * from "babylonjs/Behaviors/behavior";
  43973. export * from "babylonjs/Behaviors/Cameras/index";
  43974. export * from "babylonjs/Behaviors/Meshes/index";
  43975. }
  43976. declare module "babylonjs/Bones/boneIKController" {
  43977. import { Bone } from "babylonjs/Bones/bone";
  43978. import { Vector3 } from "babylonjs/Maths/math.vector";
  43979. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43980. import { Nullable } from "babylonjs/types";
  43981. /**
  43982. * Class used to apply inverse kinematics to bones
  43983. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  43984. */
  43985. export class BoneIKController {
  43986. private static _tmpVecs;
  43987. private static _tmpQuat;
  43988. private static _tmpMats;
  43989. /**
  43990. * Gets or sets the target mesh
  43991. */
  43992. targetMesh: AbstractMesh;
  43993. /** Gets or sets the mesh used as pole */
  43994. poleTargetMesh: AbstractMesh;
  43995. /**
  43996. * Gets or sets the bone used as pole
  43997. */
  43998. poleTargetBone: Nullable<Bone>;
  43999. /**
  44000. * Gets or sets the target position
  44001. */
  44002. targetPosition: Vector3;
  44003. /**
  44004. * Gets or sets the pole target position
  44005. */
  44006. poleTargetPosition: Vector3;
  44007. /**
  44008. * Gets or sets the pole target local offset
  44009. */
  44010. poleTargetLocalOffset: Vector3;
  44011. /**
  44012. * Gets or sets the pole angle
  44013. */
  44014. poleAngle: number;
  44015. /**
  44016. * Gets or sets the mesh associated with the controller
  44017. */
  44018. mesh: AbstractMesh;
  44019. /**
  44020. * 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)
  44021. */
  44022. slerpAmount: number;
  44023. private _bone1Quat;
  44024. private _bone1Mat;
  44025. private _bone2Ang;
  44026. private _bone1;
  44027. private _bone2;
  44028. private _bone1Length;
  44029. private _bone2Length;
  44030. private _maxAngle;
  44031. private _maxReach;
  44032. private _rightHandedSystem;
  44033. private _bendAxis;
  44034. private _slerping;
  44035. private _adjustRoll;
  44036. /**
  44037. * Gets or sets maximum allowed angle
  44038. */
  44039. get maxAngle(): number;
  44040. set maxAngle(value: number);
  44041. /**
  44042. * Creates a new BoneIKController
  44043. * @param mesh defines the mesh to control
  44044. * @param bone defines the bone to control
  44045. * @param options defines options to set up the controller
  44046. */
  44047. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  44048. targetMesh?: AbstractMesh;
  44049. poleTargetMesh?: AbstractMesh;
  44050. poleTargetBone?: Bone;
  44051. poleTargetLocalOffset?: Vector3;
  44052. poleAngle?: number;
  44053. bendAxis?: Vector3;
  44054. maxAngle?: number;
  44055. slerpAmount?: number;
  44056. });
  44057. private _setMaxAngle;
  44058. /**
  44059. * Force the controller to update the bones
  44060. */
  44061. update(): void;
  44062. }
  44063. }
  44064. declare module "babylonjs/Bones/boneLookController" {
  44065. import { Vector3 } from "babylonjs/Maths/math.vector";
  44066. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44067. import { Bone } from "babylonjs/Bones/bone";
  44068. import { Space } from "babylonjs/Maths/math.axis";
  44069. /**
  44070. * Class used to make a bone look toward a point in space
  44071. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  44072. */
  44073. export class BoneLookController {
  44074. private static _tmpVecs;
  44075. private static _tmpQuat;
  44076. private static _tmpMats;
  44077. /**
  44078. * The target Vector3 that the bone will look at
  44079. */
  44080. target: Vector3;
  44081. /**
  44082. * The mesh that the bone is attached to
  44083. */
  44084. mesh: AbstractMesh;
  44085. /**
  44086. * The bone that will be looking to the target
  44087. */
  44088. bone: Bone;
  44089. /**
  44090. * The up axis of the coordinate system that is used when the bone is rotated
  44091. */
  44092. upAxis: Vector3;
  44093. /**
  44094. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  44095. */
  44096. upAxisSpace: Space;
  44097. /**
  44098. * Used to make an adjustment to the yaw of the bone
  44099. */
  44100. adjustYaw: number;
  44101. /**
  44102. * Used to make an adjustment to the pitch of the bone
  44103. */
  44104. adjustPitch: number;
  44105. /**
  44106. * Used to make an adjustment to the roll of the bone
  44107. */
  44108. adjustRoll: number;
  44109. /**
  44110. * 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)
  44111. */
  44112. slerpAmount: number;
  44113. private _minYaw;
  44114. private _maxYaw;
  44115. private _minPitch;
  44116. private _maxPitch;
  44117. private _minYawSin;
  44118. private _minYawCos;
  44119. private _maxYawSin;
  44120. private _maxYawCos;
  44121. private _midYawConstraint;
  44122. private _minPitchTan;
  44123. private _maxPitchTan;
  44124. private _boneQuat;
  44125. private _slerping;
  44126. private _transformYawPitch;
  44127. private _transformYawPitchInv;
  44128. private _firstFrameSkipped;
  44129. private _yawRange;
  44130. private _fowardAxis;
  44131. /**
  44132. * Gets or sets the minimum yaw angle that the bone can look to
  44133. */
  44134. get minYaw(): number;
  44135. set minYaw(value: number);
  44136. /**
  44137. * Gets or sets the maximum yaw angle that the bone can look to
  44138. */
  44139. get maxYaw(): number;
  44140. set maxYaw(value: number);
  44141. /**
  44142. * Gets or sets the minimum pitch angle that the bone can look to
  44143. */
  44144. get minPitch(): number;
  44145. set minPitch(value: number);
  44146. /**
  44147. * Gets or sets the maximum pitch angle that the bone can look to
  44148. */
  44149. get maxPitch(): number;
  44150. set maxPitch(value: number);
  44151. /**
  44152. * Create a BoneLookController
  44153. * @param mesh the mesh that the bone belongs to
  44154. * @param bone the bone that will be looking to the target
  44155. * @param target the target Vector3 to look at
  44156. * @param options optional settings:
  44157. * * maxYaw: the maximum angle the bone will yaw to
  44158. * * minYaw: the minimum angle the bone will yaw to
  44159. * * maxPitch: the maximum angle the bone will pitch to
  44160. * * minPitch: the minimum angle the bone will yaw to
  44161. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  44162. * * upAxis: the up axis of the coordinate system
  44163. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  44164. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  44165. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  44166. * * adjustYaw: used to make an adjustment to the yaw of the bone
  44167. * * adjustPitch: used to make an adjustment to the pitch of the bone
  44168. * * adjustRoll: used to make an adjustment to the roll of the bone
  44169. **/
  44170. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  44171. maxYaw?: number;
  44172. minYaw?: number;
  44173. maxPitch?: number;
  44174. minPitch?: number;
  44175. slerpAmount?: number;
  44176. upAxis?: Vector3;
  44177. upAxisSpace?: Space;
  44178. yawAxis?: Vector3;
  44179. pitchAxis?: Vector3;
  44180. adjustYaw?: number;
  44181. adjustPitch?: number;
  44182. adjustRoll?: number;
  44183. });
  44184. /**
  44185. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  44186. */
  44187. update(): void;
  44188. private _getAngleDiff;
  44189. private _getAngleBetween;
  44190. private _isAngleBetween;
  44191. }
  44192. }
  44193. declare module "babylonjs/Bones/index" {
  44194. export * from "babylonjs/Bones/bone";
  44195. export * from "babylonjs/Bones/boneIKController";
  44196. export * from "babylonjs/Bones/boneLookController";
  44197. export * from "babylonjs/Bones/skeleton";
  44198. }
  44199. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  44200. import { Nullable } from "babylonjs/types";
  44201. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44202. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44203. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  44204. /**
  44205. * Manage the gamepad inputs to control an arc rotate camera.
  44206. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44207. */
  44208. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  44209. /**
  44210. * Defines the camera the input is attached to.
  44211. */
  44212. camera: ArcRotateCamera;
  44213. /**
  44214. * Defines the gamepad the input is gathering event from.
  44215. */
  44216. gamepad: Nullable<Gamepad>;
  44217. /**
  44218. * Defines the gamepad rotation sensiblity.
  44219. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  44220. */
  44221. gamepadRotationSensibility: number;
  44222. /**
  44223. * Defines the gamepad move sensiblity.
  44224. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  44225. */
  44226. gamepadMoveSensibility: number;
  44227. private _yAxisScale;
  44228. /**
  44229. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  44230. */
  44231. get invertYAxis(): boolean;
  44232. set invertYAxis(value: boolean);
  44233. private _onGamepadConnectedObserver;
  44234. private _onGamepadDisconnectedObserver;
  44235. /**
  44236. * Attach the input controls to a specific dom element to get the input from.
  44237. * @param element Defines the element the controls should be listened from
  44238. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44239. */
  44240. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44241. /**
  44242. * Detach the current controls from the specified dom element.
  44243. * @param element Defines the element to stop listening the inputs from
  44244. */
  44245. detachControl(element: Nullable<HTMLElement>): void;
  44246. /**
  44247. * Update the current camera state depending on the inputs that have been used this frame.
  44248. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44249. */
  44250. checkInputs(): void;
  44251. /**
  44252. * Gets the class name of the current intput.
  44253. * @returns the class name
  44254. */
  44255. getClassName(): string;
  44256. /**
  44257. * Get the friendly name associated with the input class.
  44258. * @returns the input friendly name
  44259. */
  44260. getSimpleName(): string;
  44261. }
  44262. }
  44263. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  44264. import { Nullable } from "babylonjs/types";
  44265. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44266. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44267. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  44268. interface ArcRotateCameraInputsManager {
  44269. /**
  44270. * Add orientation input support to the input manager.
  44271. * @returns the current input manager
  44272. */
  44273. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  44274. }
  44275. }
  44276. /**
  44277. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  44278. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44279. */
  44280. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  44281. /**
  44282. * Defines the camera the input is attached to.
  44283. */
  44284. camera: ArcRotateCamera;
  44285. /**
  44286. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  44287. */
  44288. alphaCorrection: number;
  44289. /**
  44290. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  44291. */
  44292. gammaCorrection: number;
  44293. private _alpha;
  44294. private _gamma;
  44295. private _dirty;
  44296. private _deviceOrientationHandler;
  44297. /**
  44298. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  44299. */
  44300. constructor();
  44301. /**
  44302. * Attach the input controls to a specific dom element to get the input from.
  44303. * @param element Defines the element the controls should be listened from
  44304. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44305. */
  44306. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44307. /** @hidden */
  44308. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  44309. /**
  44310. * Update the current camera state depending on the inputs that have been used this frame.
  44311. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44312. */
  44313. checkInputs(): void;
  44314. /**
  44315. * Detach the current controls from the specified dom element.
  44316. * @param element Defines the element to stop listening the inputs from
  44317. */
  44318. detachControl(element: Nullable<HTMLElement>): void;
  44319. /**
  44320. * Gets the class name of the current intput.
  44321. * @returns the class name
  44322. */
  44323. getClassName(): string;
  44324. /**
  44325. * Get the friendly name associated with the input class.
  44326. * @returns the input friendly name
  44327. */
  44328. getSimpleName(): string;
  44329. }
  44330. }
  44331. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  44332. import { Nullable } from "babylonjs/types";
  44333. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44334. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  44335. /**
  44336. * Listen to mouse events to control the camera.
  44337. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44338. */
  44339. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  44340. /**
  44341. * Defines the camera the input is attached to.
  44342. */
  44343. camera: FlyCamera;
  44344. /**
  44345. * Defines if touch is enabled. (Default is true.)
  44346. */
  44347. touchEnabled: boolean;
  44348. /**
  44349. * Defines the buttons associated with the input to handle camera rotation.
  44350. */
  44351. buttons: number[];
  44352. /**
  44353. * Assign buttons for Yaw control.
  44354. */
  44355. buttonsYaw: number[];
  44356. /**
  44357. * Assign buttons for Pitch control.
  44358. */
  44359. buttonsPitch: number[];
  44360. /**
  44361. * Assign buttons for Roll control.
  44362. */
  44363. buttonsRoll: number[];
  44364. /**
  44365. * Detect if any button is being pressed while mouse is moved.
  44366. * -1 = Mouse locked.
  44367. * 0 = Left button.
  44368. * 1 = Middle Button.
  44369. * 2 = Right Button.
  44370. */
  44371. activeButton: number;
  44372. /**
  44373. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  44374. * Higher values reduce its sensitivity.
  44375. */
  44376. angularSensibility: number;
  44377. private _mousemoveCallback;
  44378. private _observer;
  44379. private _rollObserver;
  44380. private previousPosition;
  44381. private noPreventDefault;
  44382. private element;
  44383. /**
  44384. * Listen to mouse events to control the camera.
  44385. * @param touchEnabled Define if touch is enabled. (Default is true.)
  44386. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44387. */
  44388. constructor(touchEnabled?: boolean);
  44389. /**
  44390. * Attach the mouse control to the HTML DOM element.
  44391. * @param element Defines the element that listens to the input events.
  44392. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  44393. */
  44394. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44395. /**
  44396. * Detach the current controls from the specified dom element.
  44397. * @param element Defines the element to stop listening the inputs from
  44398. */
  44399. detachControl(element: Nullable<HTMLElement>): void;
  44400. /**
  44401. * Gets the class name of the current input.
  44402. * @returns the class name.
  44403. */
  44404. getClassName(): string;
  44405. /**
  44406. * Get the friendly name associated with the input class.
  44407. * @returns the input's friendly name.
  44408. */
  44409. getSimpleName(): string;
  44410. private _pointerInput;
  44411. private _onMouseMove;
  44412. /**
  44413. * Rotate camera by mouse offset.
  44414. */
  44415. private rotateCamera;
  44416. }
  44417. }
  44418. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  44419. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  44420. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  44421. /**
  44422. * Default Inputs manager for the FlyCamera.
  44423. * It groups all the default supported inputs for ease of use.
  44424. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44425. */
  44426. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  44427. /**
  44428. * Instantiates a new FlyCameraInputsManager.
  44429. * @param camera Defines the camera the inputs belong to.
  44430. */
  44431. constructor(camera: FlyCamera);
  44432. /**
  44433. * Add keyboard input support to the input manager.
  44434. * @returns the new FlyCameraKeyboardMoveInput().
  44435. */
  44436. addKeyboard(): FlyCameraInputsManager;
  44437. /**
  44438. * Add mouse input support to the input manager.
  44439. * @param touchEnabled Enable touch screen support.
  44440. * @returns the new FlyCameraMouseInput().
  44441. */
  44442. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  44443. }
  44444. }
  44445. declare module "babylonjs/Cameras/flyCamera" {
  44446. import { Scene } from "babylonjs/scene";
  44447. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  44448. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44449. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  44450. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  44451. /**
  44452. * This is a flying camera, designed for 3D movement and rotation in all directions,
  44453. * such as in a 3D Space Shooter or a Flight Simulator.
  44454. */
  44455. export class FlyCamera extends TargetCamera {
  44456. /**
  44457. * Define the collision ellipsoid of the camera.
  44458. * This is helpful for simulating a camera body, like a player's body.
  44459. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  44460. */
  44461. ellipsoid: Vector3;
  44462. /**
  44463. * Define an offset for the position of the ellipsoid around the camera.
  44464. * This can be helpful if the camera is attached away from the player's body center,
  44465. * such as at its head.
  44466. */
  44467. ellipsoidOffset: Vector3;
  44468. /**
  44469. * Enable or disable collisions of the camera with the rest of the scene objects.
  44470. */
  44471. checkCollisions: boolean;
  44472. /**
  44473. * Enable or disable gravity on the camera.
  44474. */
  44475. applyGravity: boolean;
  44476. /**
  44477. * Define the current direction the camera is moving to.
  44478. */
  44479. cameraDirection: Vector3;
  44480. /**
  44481. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  44482. * This overrides and empties cameraRotation.
  44483. */
  44484. rotationQuaternion: Quaternion;
  44485. /**
  44486. * Track Roll to maintain the wanted Rolling when looking around.
  44487. */
  44488. _trackRoll: number;
  44489. /**
  44490. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  44491. */
  44492. rollCorrect: number;
  44493. /**
  44494. * Mimic a banked turn, Rolling the camera when Yawing.
  44495. * It's recommended to use rollCorrect = 10 for faster banking correction.
  44496. */
  44497. bankedTurn: boolean;
  44498. /**
  44499. * Limit in radians for how much Roll banking will add. (Default: 90°)
  44500. */
  44501. bankedTurnLimit: number;
  44502. /**
  44503. * Value of 0 disables the banked Roll.
  44504. * Value of 1 is equal to the Yaw angle in radians.
  44505. */
  44506. bankedTurnMultiplier: number;
  44507. /**
  44508. * The inputs manager loads all the input sources, such as keyboard and mouse.
  44509. */
  44510. inputs: FlyCameraInputsManager;
  44511. /**
  44512. * Gets the input sensibility for mouse input.
  44513. * Higher values reduce sensitivity.
  44514. */
  44515. get angularSensibility(): number;
  44516. /**
  44517. * Sets the input sensibility for a mouse input.
  44518. * Higher values reduce sensitivity.
  44519. */
  44520. set angularSensibility(value: number);
  44521. /**
  44522. * Get the keys for camera movement forward.
  44523. */
  44524. get keysForward(): number[];
  44525. /**
  44526. * Set the keys for camera movement forward.
  44527. */
  44528. set keysForward(value: number[]);
  44529. /**
  44530. * Get the keys for camera movement backward.
  44531. */
  44532. get keysBackward(): number[];
  44533. set keysBackward(value: number[]);
  44534. /**
  44535. * Get the keys for camera movement up.
  44536. */
  44537. get keysUp(): number[];
  44538. /**
  44539. * Set the keys for camera movement up.
  44540. */
  44541. set keysUp(value: number[]);
  44542. /**
  44543. * Get the keys for camera movement down.
  44544. */
  44545. get keysDown(): number[];
  44546. /**
  44547. * Set the keys for camera movement down.
  44548. */
  44549. set keysDown(value: number[]);
  44550. /**
  44551. * Get the keys for camera movement left.
  44552. */
  44553. get keysLeft(): number[];
  44554. /**
  44555. * Set the keys for camera movement left.
  44556. */
  44557. set keysLeft(value: number[]);
  44558. /**
  44559. * Set the keys for camera movement right.
  44560. */
  44561. get keysRight(): number[];
  44562. /**
  44563. * Set the keys for camera movement right.
  44564. */
  44565. set keysRight(value: number[]);
  44566. /**
  44567. * Event raised when the camera collides with a mesh in the scene.
  44568. */
  44569. onCollide: (collidedMesh: AbstractMesh) => void;
  44570. private _collider;
  44571. private _needMoveForGravity;
  44572. private _oldPosition;
  44573. private _diffPosition;
  44574. private _newPosition;
  44575. /** @hidden */
  44576. _localDirection: Vector3;
  44577. /** @hidden */
  44578. _transformedDirection: Vector3;
  44579. /**
  44580. * Instantiates a FlyCamera.
  44581. * This is a flying camera, designed for 3D movement and rotation in all directions,
  44582. * such as in a 3D Space Shooter or a Flight Simulator.
  44583. * @param name Define the name of the camera in the scene.
  44584. * @param position Define the starting position of the camera in the scene.
  44585. * @param scene Define the scene the camera belongs to.
  44586. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  44587. */
  44588. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  44589. /**
  44590. * Attach a control to the HTML DOM element.
  44591. * @param element Defines the element that listens to the input events.
  44592. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  44593. */
  44594. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44595. /**
  44596. * Detach a control from the HTML DOM element.
  44597. * The camera will stop reacting to that input.
  44598. * @param element Defines the element that listens to the input events.
  44599. */
  44600. detachControl(element: HTMLElement): void;
  44601. private _collisionMask;
  44602. /**
  44603. * Get the mask that the camera ignores in collision events.
  44604. */
  44605. get collisionMask(): number;
  44606. /**
  44607. * Set the mask that the camera ignores in collision events.
  44608. */
  44609. set collisionMask(mask: number);
  44610. /** @hidden */
  44611. _collideWithWorld(displacement: Vector3): void;
  44612. /** @hidden */
  44613. private _onCollisionPositionChange;
  44614. /** @hidden */
  44615. _checkInputs(): void;
  44616. /** @hidden */
  44617. _decideIfNeedsToMove(): boolean;
  44618. /** @hidden */
  44619. _updatePosition(): void;
  44620. /**
  44621. * Restore the Roll to its target value at the rate specified.
  44622. * @param rate - Higher means slower restoring.
  44623. * @hidden
  44624. */
  44625. restoreRoll(rate: number): void;
  44626. /**
  44627. * Destroy the camera and release the current resources held by it.
  44628. */
  44629. dispose(): void;
  44630. /**
  44631. * Get the current object class name.
  44632. * @returns the class name.
  44633. */
  44634. getClassName(): string;
  44635. }
  44636. }
  44637. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  44638. import { Nullable } from "babylonjs/types";
  44639. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44640. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  44641. /**
  44642. * Listen to keyboard events to control the camera.
  44643. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44644. */
  44645. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  44646. /**
  44647. * Defines the camera the input is attached to.
  44648. */
  44649. camera: FlyCamera;
  44650. /**
  44651. * The list of keyboard keys used to control the forward move of the camera.
  44652. */
  44653. keysForward: number[];
  44654. /**
  44655. * The list of keyboard keys used to control the backward move of the camera.
  44656. */
  44657. keysBackward: number[];
  44658. /**
  44659. * The list of keyboard keys used to control the forward move of the camera.
  44660. */
  44661. keysUp: number[];
  44662. /**
  44663. * The list of keyboard keys used to control the backward move of the camera.
  44664. */
  44665. keysDown: number[];
  44666. /**
  44667. * The list of keyboard keys used to control the right strafe move of the camera.
  44668. */
  44669. keysRight: number[];
  44670. /**
  44671. * The list of keyboard keys used to control the left strafe move of the camera.
  44672. */
  44673. keysLeft: number[];
  44674. private _keys;
  44675. private _onCanvasBlurObserver;
  44676. private _onKeyboardObserver;
  44677. private _engine;
  44678. private _scene;
  44679. /**
  44680. * Attach the input controls to a specific dom element to get the input from.
  44681. * @param element Defines the element the controls should be listened from
  44682. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44683. */
  44684. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44685. /**
  44686. * Detach the current controls from the specified dom element.
  44687. * @param element Defines the element to stop listening the inputs from
  44688. */
  44689. detachControl(element: Nullable<HTMLElement>): void;
  44690. /**
  44691. * Gets the class name of the current intput.
  44692. * @returns the class name
  44693. */
  44694. getClassName(): string;
  44695. /** @hidden */
  44696. _onLostFocus(e: FocusEvent): void;
  44697. /**
  44698. * Get the friendly name associated with the input class.
  44699. * @returns the input friendly name
  44700. */
  44701. getSimpleName(): string;
  44702. /**
  44703. * Update the current camera state depending on the inputs that have been used this frame.
  44704. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44705. */
  44706. checkInputs(): void;
  44707. }
  44708. }
  44709. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  44710. import { Nullable } from "babylonjs/types";
  44711. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  44712. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44713. /**
  44714. * Manage the mouse wheel inputs to control a follow camera.
  44715. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44716. */
  44717. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  44718. /**
  44719. * Defines the camera the input is attached to.
  44720. */
  44721. camera: FollowCamera;
  44722. /**
  44723. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  44724. */
  44725. axisControlRadius: boolean;
  44726. /**
  44727. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  44728. */
  44729. axisControlHeight: boolean;
  44730. /**
  44731. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  44732. */
  44733. axisControlRotation: boolean;
  44734. /**
  44735. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  44736. * relation to mouseWheel events.
  44737. */
  44738. wheelPrecision: number;
  44739. /**
  44740. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  44741. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  44742. */
  44743. wheelDeltaPercentage: number;
  44744. private _wheel;
  44745. private _observer;
  44746. /**
  44747. * Attach the input controls to a specific dom element to get the input from.
  44748. * @param element Defines the element the controls should be listened from
  44749. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44750. */
  44751. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44752. /**
  44753. * Detach the current controls from the specified dom element.
  44754. * @param element Defines the element to stop listening the inputs from
  44755. */
  44756. detachControl(element: Nullable<HTMLElement>): void;
  44757. /**
  44758. * Gets the class name of the current intput.
  44759. * @returns the class name
  44760. */
  44761. getClassName(): string;
  44762. /**
  44763. * Get the friendly name associated with the input class.
  44764. * @returns the input friendly name
  44765. */
  44766. getSimpleName(): string;
  44767. }
  44768. }
  44769. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  44770. import { Nullable } from "babylonjs/types";
  44771. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  44772. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  44773. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  44774. /**
  44775. * Manage the pointers inputs to control an follow camera.
  44776. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44777. */
  44778. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  44779. /**
  44780. * Defines the camera the input is attached to.
  44781. */
  44782. camera: FollowCamera;
  44783. /**
  44784. * Gets the class name of the current input.
  44785. * @returns the class name
  44786. */
  44787. getClassName(): string;
  44788. /**
  44789. * Defines the pointer angular sensibility along the X axis or how fast is
  44790. * the camera rotating.
  44791. * A negative number will reverse the axis direction.
  44792. */
  44793. angularSensibilityX: number;
  44794. /**
  44795. * Defines the pointer angular sensibility along the Y axis or how fast is
  44796. * the camera rotating.
  44797. * A negative number will reverse the axis direction.
  44798. */
  44799. angularSensibilityY: number;
  44800. /**
  44801. * Defines the pointer pinch precision or how fast is the camera zooming.
  44802. * A negative number will reverse the axis direction.
  44803. */
  44804. pinchPrecision: number;
  44805. /**
  44806. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  44807. * from 0.
  44808. * It defines the percentage of current camera.radius to use as delta when
  44809. * pinch zoom is used.
  44810. */
  44811. pinchDeltaPercentage: number;
  44812. /**
  44813. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  44814. */
  44815. axisXControlRadius: boolean;
  44816. /**
  44817. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  44818. */
  44819. axisXControlHeight: boolean;
  44820. /**
  44821. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  44822. */
  44823. axisXControlRotation: boolean;
  44824. /**
  44825. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  44826. */
  44827. axisYControlRadius: boolean;
  44828. /**
  44829. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  44830. */
  44831. axisYControlHeight: boolean;
  44832. /**
  44833. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  44834. */
  44835. axisYControlRotation: boolean;
  44836. /**
  44837. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  44838. */
  44839. axisPinchControlRadius: boolean;
  44840. /**
  44841. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  44842. */
  44843. axisPinchControlHeight: boolean;
  44844. /**
  44845. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  44846. */
  44847. axisPinchControlRotation: boolean;
  44848. /**
  44849. * Log error messages if basic misconfiguration has occurred.
  44850. */
  44851. warningEnable: boolean;
  44852. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  44853. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  44854. private _warningCounter;
  44855. private _warning;
  44856. }
  44857. }
  44858. declare module "babylonjs/Cameras/followCameraInputsManager" {
  44859. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  44860. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  44861. /**
  44862. * Default Inputs manager for the FollowCamera.
  44863. * It groups all the default supported inputs for ease of use.
  44864. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44865. */
  44866. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  44867. /**
  44868. * Instantiates a new FollowCameraInputsManager.
  44869. * @param camera Defines the camera the inputs belong to
  44870. */
  44871. constructor(camera: FollowCamera);
  44872. /**
  44873. * Add keyboard input support to the input manager.
  44874. * @returns the current input manager
  44875. */
  44876. addKeyboard(): FollowCameraInputsManager;
  44877. /**
  44878. * Add mouse wheel input support to the input manager.
  44879. * @returns the current input manager
  44880. */
  44881. addMouseWheel(): FollowCameraInputsManager;
  44882. /**
  44883. * Add pointers input support to the input manager.
  44884. * @returns the current input manager
  44885. */
  44886. addPointers(): FollowCameraInputsManager;
  44887. /**
  44888. * Add orientation input support to the input manager.
  44889. * @returns the current input manager
  44890. */
  44891. addVRDeviceOrientation(): FollowCameraInputsManager;
  44892. }
  44893. }
  44894. declare module "babylonjs/Cameras/followCamera" {
  44895. import { Nullable } from "babylonjs/types";
  44896. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  44897. import { Scene } from "babylonjs/scene";
  44898. import { Vector3 } from "babylonjs/Maths/math.vector";
  44899. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44900. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  44901. /**
  44902. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  44903. * an arc rotate version arcFollowCamera are available.
  44904. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  44905. */
  44906. export class FollowCamera extends TargetCamera {
  44907. /**
  44908. * Distance the follow camera should follow an object at
  44909. */
  44910. radius: number;
  44911. /**
  44912. * Minimum allowed distance of the camera to the axis of rotation
  44913. * (The camera can not get closer).
  44914. * This can help limiting how the Camera is able to move in the scene.
  44915. */
  44916. lowerRadiusLimit: Nullable<number>;
  44917. /**
  44918. * Maximum allowed distance of the camera to the axis of rotation
  44919. * (The camera can not get further).
  44920. * This can help limiting how the Camera is able to move in the scene.
  44921. */
  44922. upperRadiusLimit: Nullable<number>;
  44923. /**
  44924. * Define a rotation offset between the camera and the object it follows
  44925. */
  44926. rotationOffset: number;
  44927. /**
  44928. * Minimum allowed angle to camera position relative to target object.
  44929. * This can help limiting how the Camera is able to move in the scene.
  44930. */
  44931. lowerRotationOffsetLimit: Nullable<number>;
  44932. /**
  44933. * Maximum allowed angle to camera position relative to target object.
  44934. * This can help limiting how the Camera is able to move in the scene.
  44935. */
  44936. upperRotationOffsetLimit: Nullable<number>;
  44937. /**
  44938. * Define a height offset between the camera and the object it follows.
  44939. * It can help following an object from the top (like a car chaing a plane)
  44940. */
  44941. heightOffset: number;
  44942. /**
  44943. * Minimum allowed height of camera position relative to target object.
  44944. * This can help limiting how the Camera is able to move in the scene.
  44945. */
  44946. lowerHeightOffsetLimit: Nullable<number>;
  44947. /**
  44948. * Maximum allowed height of camera position relative to target object.
  44949. * This can help limiting how the Camera is able to move in the scene.
  44950. */
  44951. upperHeightOffsetLimit: Nullable<number>;
  44952. /**
  44953. * Define how fast the camera can accelerate to follow it s target.
  44954. */
  44955. cameraAcceleration: number;
  44956. /**
  44957. * Define the speed limit of the camera following an object.
  44958. */
  44959. maxCameraSpeed: number;
  44960. /**
  44961. * Define the target of the camera.
  44962. */
  44963. lockedTarget: Nullable<AbstractMesh>;
  44964. /**
  44965. * Defines the input associated with the camera.
  44966. */
  44967. inputs: FollowCameraInputsManager;
  44968. /**
  44969. * Instantiates the follow camera.
  44970. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  44971. * @param name Define the name of the camera in the scene
  44972. * @param position Define the position of the camera
  44973. * @param scene Define the scene the camera belong to
  44974. * @param lockedTarget Define the target of the camera
  44975. */
  44976. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  44977. private _follow;
  44978. /**
  44979. * Attached controls to the current camera.
  44980. * @param element Defines the element the controls should be listened from
  44981. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44982. */
  44983. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44984. /**
  44985. * Detach the current controls from the camera.
  44986. * The camera will stop reacting to inputs.
  44987. * @param element Defines the element to stop listening the inputs from
  44988. */
  44989. detachControl(element: HTMLElement): void;
  44990. /** @hidden */
  44991. _checkInputs(): void;
  44992. private _checkLimits;
  44993. /**
  44994. * Gets the camera class name.
  44995. * @returns the class name
  44996. */
  44997. getClassName(): string;
  44998. }
  44999. /**
  45000. * Arc Rotate version of the follow camera.
  45001. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  45002. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  45003. */
  45004. export class ArcFollowCamera extends TargetCamera {
  45005. /** The longitudinal angle of the camera */
  45006. alpha: number;
  45007. /** The latitudinal angle of the camera */
  45008. beta: number;
  45009. /** The radius of the camera from its target */
  45010. radius: number;
  45011. /** Define the camera target (the messh it should follow) */
  45012. target: Nullable<AbstractMesh>;
  45013. private _cartesianCoordinates;
  45014. /**
  45015. * Instantiates a new ArcFollowCamera
  45016. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  45017. * @param name Define the name of the camera
  45018. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  45019. * @param beta Define the rotation angle of the camera around the elevation axis
  45020. * @param radius Define the radius of the camera from its target point
  45021. * @param target Define the target of the camera
  45022. * @param scene Define the scene the camera belongs to
  45023. */
  45024. constructor(name: string,
  45025. /** The longitudinal angle of the camera */
  45026. alpha: number,
  45027. /** The latitudinal angle of the camera */
  45028. beta: number,
  45029. /** The radius of the camera from its target */
  45030. radius: number,
  45031. /** Define the camera target (the messh it should follow) */
  45032. target: Nullable<AbstractMesh>, scene: Scene);
  45033. private _follow;
  45034. /** @hidden */
  45035. _checkInputs(): void;
  45036. /**
  45037. * Returns the class name of the object.
  45038. * It is mostly used internally for serialization purposes.
  45039. */
  45040. getClassName(): string;
  45041. }
  45042. }
  45043. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  45044. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45045. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  45046. import { Nullable } from "babylonjs/types";
  45047. /**
  45048. * Manage the keyboard inputs to control the movement of a follow camera.
  45049. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  45050. */
  45051. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  45052. /**
  45053. * Defines the camera the input is attached to.
  45054. */
  45055. camera: FollowCamera;
  45056. /**
  45057. * Defines the list of key codes associated with the up action (increase heightOffset)
  45058. */
  45059. keysHeightOffsetIncr: number[];
  45060. /**
  45061. * Defines the list of key codes associated with the down action (decrease heightOffset)
  45062. */
  45063. keysHeightOffsetDecr: number[];
  45064. /**
  45065. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  45066. */
  45067. keysHeightOffsetModifierAlt: boolean;
  45068. /**
  45069. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  45070. */
  45071. keysHeightOffsetModifierCtrl: boolean;
  45072. /**
  45073. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  45074. */
  45075. keysHeightOffsetModifierShift: boolean;
  45076. /**
  45077. * Defines the list of key codes associated with the left action (increase rotationOffset)
  45078. */
  45079. keysRotationOffsetIncr: number[];
  45080. /**
  45081. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  45082. */
  45083. keysRotationOffsetDecr: number[];
  45084. /**
  45085. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  45086. */
  45087. keysRotationOffsetModifierAlt: boolean;
  45088. /**
  45089. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  45090. */
  45091. keysRotationOffsetModifierCtrl: boolean;
  45092. /**
  45093. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  45094. */
  45095. keysRotationOffsetModifierShift: boolean;
  45096. /**
  45097. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  45098. */
  45099. keysRadiusIncr: number[];
  45100. /**
  45101. * Defines the list of key codes associated with the zoom-out action (increase radius)
  45102. */
  45103. keysRadiusDecr: number[];
  45104. /**
  45105. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  45106. */
  45107. keysRadiusModifierAlt: boolean;
  45108. /**
  45109. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  45110. */
  45111. keysRadiusModifierCtrl: boolean;
  45112. /**
  45113. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  45114. */
  45115. keysRadiusModifierShift: boolean;
  45116. /**
  45117. * Defines the rate of change of heightOffset.
  45118. */
  45119. heightSensibility: number;
  45120. /**
  45121. * Defines the rate of change of rotationOffset.
  45122. */
  45123. rotationSensibility: number;
  45124. /**
  45125. * Defines the rate of change of radius.
  45126. */
  45127. radiusSensibility: number;
  45128. private _keys;
  45129. private _ctrlPressed;
  45130. private _altPressed;
  45131. private _shiftPressed;
  45132. private _onCanvasBlurObserver;
  45133. private _onKeyboardObserver;
  45134. private _engine;
  45135. private _scene;
  45136. /**
  45137. * Attach the input controls to a specific dom element to get the input from.
  45138. * @param element Defines the element the controls should be listened from
  45139. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45140. */
  45141. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45142. /**
  45143. * Detach the current controls from the specified dom element.
  45144. * @param element Defines the element to stop listening the inputs from
  45145. */
  45146. detachControl(element: Nullable<HTMLElement>): void;
  45147. /**
  45148. * Update the current camera state depending on the inputs that have been used this frame.
  45149. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45150. */
  45151. checkInputs(): void;
  45152. /**
  45153. * Gets the class name of the current input.
  45154. * @returns the class name
  45155. */
  45156. getClassName(): string;
  45157. /**
  45158. * Get the friendly name associated with the input class.
  45159. * @returns the input friendly name
  45160. */
  45161. getSimpleName(): string;
  45162. /**
  45163. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  45164. * allow modification of the heightOffset value.
  45165. */
  45166. private _modifierHeightOffset;
  45167. /**
  45168. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  45169. * allow modification of the rotationOffset value.
  45170. */
  45171. private _modifierRotationOffset;
  45172. /**
  45173. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  45174. * allow modification of the radius value.
  45175. */
  45176. private _modifierRadius;
  45177. }
  45178. }
  45179. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  45180. import { Nullable } from "babylonjs/types";
  45181. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45182. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  45183. import { Observable } from "babylonjs/Misc/observable";
  45184. module "babylonjs/Cameras/freeCameraInputsManager" {
  45185. interface FreeCameraInputsManager {
  45186. /**
  45187. * @hidden
  45188. */
  45189. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  45190. /**
  45191. * Add orientation input support to the input manager.
  45192. * @returns the current input manager
  45193. */
  45194. addDeviceOrientation(): FreeCameraInputsManager;
  45195. }
  45196. }
  45197. /**
  45198. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  45199. * Screen rotation is taken into account.
  45200. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  45201. */
  45202. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  45203. private _camera;
  45204. private _screenOrientationAngle;
  45205. private _constantTranform;
  45206. private _screenQuaternion;
  45207. private _alpha;
  45208. private _beta;
  45209. private _gamma;
  45210. /**
  45211. * Can be used to detect if a device orientation sensor is available on a device
  45212. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  45213. * @returns a promise that will resolve on orientation change
  45214. */
  45215. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  45216. /**
  45217. * @hidden
  45218. */
  45219. _onDeviceOrientationChangedObservable: Observable<void>;
  45220. /**
  45221. * Instantiates a new input
  45222. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  45223. */
  45224. constructor();
  45225. /**
  45226. * Define the camera controlled by the input.
  45227. */
  45228. get camera(): FreeCamera;
  45229. set camera(camera: FreeCamera);
  45230. /**
  45231. * Attach the input controls to a specific dom element to get the input from.
  45232. * @param element Defines the element the controls should be listened from
  45233. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45234. */
  45235. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45236. private _orientationChanged;
  45237. private _deviceOrientation;
  45238. /**
  45239. * Detach the current controls from the specified dom element.
  45240. * @param element Defines the element to stop listening the inputs from
  45241. */
  45242. detachControl(element: Nullable<HTMLElement>): void;
  45243. /**
  45244. * Update the current camera state depending on the inputs that have been used this frame.
  45245. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45246. */
  45247. checkInputs(): void;
  45248. /**
  45249. * Gets the class name of the current intput.
  45250. * @returns the class name
  45251. */
  45252. getClassName(): string;
  45253. /**
  45254. * Get the friendly name associated with the input class.
  45255. * @returns the input friendly name
  45256. */
  45257. getSimpleName(): string;
  45258. }
  45259. }
  45260. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  45261. import { Nullable } from "babylonjs/types";
  45262. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45263. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  45264. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  45265. /**
  45266. * Manage the gamepad inputs to control a free camera.
  45267. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  45268. */
  45269. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  45270. /**
  45271. * Define the camera the input is attached to.
  45272. */
  45273. camera: FreeCamera;
  45274. /**
  45275. * Define the Gamepad controlling the input
  45276. */
  45277. gamepad: Nullable<Gamepad>;
  45278. /**
  45279. * Defines the gamepad rotation sensiblity.
  45280. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  45281. */
  45282. gamepadAngularSensibility: number;
  45283. /**
  45284. * Defines the gamepad move sensiblity.
  45285. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  45286. */
  45287. gamepadMoveSensibility: number;
  45288. private _yAxisScale;
  45289. /**
  45290. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  45291. */
  45292. get invertYAxis(): boolean;
  45293. set invertYAxis(value: boolean);
  45294. private _onGamepadConnectedObserver;
  45295. private _onGamepadDisconnectedObserver;
  45296. private _cameraTransform;
  45297. private _deltaTransform;
  45298. private _vector3;
  45299. private _vector2;
  45300. /**
  45301. * Attach the input controls to a specific dom element to get the input from.
  45302. * @param element Defines the element the controls should be listened from
  45303. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45304. */
  45305. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45306. /**
  45307. * Detach the current controls from the specified dom element.
  45308. * @param element Defines the element to stop listening the inputs from
  45309. */
  45310. detachControl(element: Nullable<HTMLElement>): void;
  45311. /**
  45312. * Update the current camera state depending on the inputs that have been used this frame.
  45313. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45314. */
  45315. checkInputs(): void;
  45316. /**
  45317. * Gets the class name of the current intput.
  45318. * @returns the class name
  45319. */
  45320. getClassName(): string;
  45321. /**
  45322. * Get the friendly name associated with the input class.
  45323. * @returns the input friendly name
  45324. */
  45325. getSimpleName(): string;
  45326. }
  45327. }
  45328. declare module "babylonjs/Misc/virtualJoystick" {
  45329. import { Nullable } from "babylonjs/types";
  45330. import { Vector3 } from "babylonjs/Maths/math.vector";
  45331. /**
  45332. * Defines the potential axis of a Joystick
  45333. */
  45334. export enum JoystickAxis {
  45335. /** X axis */
  45336. X = 0,
  45337. /** Y axis */
  45338. Y = 1,
  45339. /** Z axis */
  45340. Z = 2
  45341. }
  45342. /**
  45343. * Class used to define virtual joystick (used in touch mode)
  45344. */
  45345. export class VirtualJoystick {
  45346. /**
  45347. * Gets or sets a boolean indicating that left and right values must be inverted
  45348. */
  45349. reverseLeftRight: boolean;
  45350. /**
  45351. * Gets or sets a boolean indicating that up and down values must be inverted
  45352. */
  45353. reverseUpDown: boolean;
  45354. /**
  45355. * Gets the offset value for the position (ie. the change of the position value)
  45356. */
  45357. deltaPosition: Vector3;
  45358. /**
  45359. * Gets a boolean indicating if the virtual joystick was pressed
  45360. */
  45361. pressed: boolean;
  45362. /**
  45363. * Canvas the virtual joystick will render onto, default z-index of this is 5
  45364. */
  45365. static Canvas: Nullable<HTMLCanvasElement>;
  45366. private static _globalJoystickIndex;
  45367. private static vjCanvasContext;
  45368. private static vjCanvasWidth;
  45369. private static vjCanvasHeight;
  45370. private static halfWidth;
  45371. private _action;
  45372. private _axisTargetedByLeftAndRight;
  45373. private _axisTargetedByUpAndDown;
  45374. private _joystickSensibility;
  45375. private _inversedSensibility;
  45376. private _joystickPointerID;
  45377. private _joystickColor;
  45378. private _joystickPointerPos;
  45379. private _joystickPreviousPointerPos;
  45380. private _joystickPointerStartPos;
  45381. private _deltaJoystickVector;
  45382. private _leftJoystick;
  45383. private _touches;
  45384. private _onPointerDownHandlerRef;
  45385. private _onPointerMoveHandlerRef;
  45386. private _onPointerUpHandlerRef;
  45387. private _onResize;
  45388. /**
  45389. * Creates a new virtual joystick
  45390. * @param leftJoystick defines that the joystick is for left hand (false by default)
  45391. */
  45392. constructor(leftJoystick?: boolean);
  45393. /**
  45394. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  45395. * @param newJoystickSensibility defines the new sensibility
  45396. */
  45397. setJoystickSensibility(newJoystickSensibility: number): void;
  45398. private _onPointerDown;
  45399. private _onPointerMove;
  45400. private _onPointerUp;
  45401. /**
  45402. * Change the color of the virtual joystick
  45403. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  45404. */
  45405. setJoystickColor(newColor: string): void;
  45406. /**
  45407. * Defines a callback to call when the joystick is touched
  45408. * @param action defines the callback
  45409. */
  45410. setActionOnTouch(action: () => any): void;
  45411. /**
  45412. * Defines which axis you'd like to control for left & right
  45413. * @param axis defines the axis to use
  45414. */
  45415. setAxisForLeftRight(axis: JoystickAxis): void;
  45416. /**
  45417. * Defines which axis you'd like to control for up & down
  45418. * @param axis defines the axis to use
  45419. */
  45420. setAxisForUpDown(axis: JoystickAxis): void;
  45421. private _drawVirtualJoystick;
  45422. /**
  45423. * Release internal HTML canvas
  45424. */
  45425. releaseCanvas(): void;
  45426. }
  45427. }
  45428. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  45429. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  45430. import { Nullable } from "babylonjs/types";
  45431. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45432. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  45433. module "babylonjs/Cameras/freeCameraInputsManager" {
  45434. interface FreeCameraInputsManager {
  45435. /**
  45436. * Add virtual joystick input support to the input manager.
  45437. * @returns the current input manager
  45438. */
  45439. addVirtualJoystick(): FreeCameraInputsManager;
  45440. }
  45441. }
  45442. /**
  45443. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  45444. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  45445. */
  45446. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  45447. /**
  45448. * Defines the camera the input is attached to.
  45449. */
  45450. camera: FreeCamera;
  45451. private _leftjoystick;
  45452. private _rightjoystick;
  45453. /**
  45454. * Gets the left stick of the virtual joystick.
  45455. * @returns The virtual Joystick
  45456. */
  45457. getLeftJoystick(): VirtualJoystick;
  45458. /**
  45459. * Gets the right stick of the virtual joystick.
  45460. * @returns The virtual Joystick
  45461. */
  45462. getRightJoystick(): VirtualJoystick;
  45463. /**
  45464. * Update the current camera state depending on the inputs that have been used this frame.
  45465. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45466. */
  45467. checkInputs(): void;
  45468. /**
  45469. * Attach the input controls to a specific dom element to get the input from.
  45470. * @param element Defines the element the controls should be listened from
  45471. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45472. */
  45473. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45474. /**
  45475. * Detach the current controls from the specified dom element.
  45476. * @param element Defines the element to stop listening the inputs from
  45477. */
  45478. detachControl(element: Nullable<HTMLElement>): void;
  45479. /**
  45480. * Gets the class name of the current intput.
  45481. * @returns the class name
  45482. */
  45483. getClassName(): string;
  45484. /**
  45485. * Get the friendly name associated with the input class.
  45486. * @returns the input friendly name
  45487. */
  45488. getSimpleName(): string;
  45489. }
  45490. }
  45491. declare module "babylonjs/Cameras/Inputs/index" {
  45492. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  45493. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  45494. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  45495. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  45496. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  45497. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  45498. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  45499. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  45500. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  45501. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  45502. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  45503. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  45504. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  45505. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  45506. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  45507. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  45508. }
  45509. declare module "babylonjs/Cameras/touchCamera" {
  45510. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  45511. import { Scene } from "babylonjs/scene";
  45512. import { Vector3 } from "babylonjs/Maths/math.vector";
  45513. /**
  45514. * This represents a FPS type of camera controlled by touch.
  45515. * This is like a universal camera minus the Gamepad controls.
  45516. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  45517. */
  45518. export class TouchCamera extends FreeCamera {
  45519. /**
  45520. * Defines the touch sensibility for rotation.
  45521. * The higher the faster.
  45522. */
  45523. get touchAngularSensibility(): number;
  45524. set touchAngularSensibility(value: number);
  45525. /**
  45526. * Defines the touch sensibility for move.
  45527. * The higher the faster.
  45528. */
  45529. get touchMoveSensibility(): number;
  45530. set touchMoveSensibility(value: number);
  45531. /**
  45532. * Instantiates a new touch camera.
  45533. * This represents a FPS type of camera controlled by touch.
  45534. * This is like a universal camera minus the Gamepad controls.
  45535. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  45536. * @param name Define the name of the camera in the scene
  45537. * @param position Define the start position of the camera in the scene
  45538. * @param scene Define the scene the camera belongs to
  45539. */
  45540. constructor(name: string, position: Vector3, scene: Scene);
  45541. /**
  45542. * Gets the current object class name.
  45543. * @return the class name
  45544. */
  45545. getClassName(): string;
  45546. /** @hidden */
  45547. _setupInputs(): void;
  45548. }
  45549. }
  45550. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  45551. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  45552. import { Scene } from "babylonjs/scene";
  45553. import { Vector3 } from "babylonjs/Maths/math.vector";
  45554. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  45555. import { Axis } from "babylonjs/Maths/math.axis";
  45556. /**
  45557. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  45558. * being tilted forward or back and left or right.
  45559. */
  45560. export class DeviceOrientationCamera extends FreeCamera {
  45561. private _initialQuaternion;
  45562. private _quaternionCache;
  45563. private _tmpDragQuaternion;
  45564. private _disablePointerInputWhenUsingDeviceOrientation;
  45565. /**
  45566. * Creates a new device orientation camera
  45567. * @param name The name of the camera
  45568. * @param position The start position camera
  45569. * @param scene The scene the camera belongs to
  45570. */
  45571. constructor(name: string, position: Vector3, scene: Scene);
  45572. /**
  45573. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  45574. */
  45575. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  45576. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  45577. private _dragFactor;
  45578. /**
  45579. * Enabled turning on the y axis when the orientation sensor is active
  45580. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  45581. */
  45582. enableHorizontalDragging(dragFactor?: number): void;
  45583. /**
  45584. * Gets the current instance class name ("DeviceOrientationCamera").
  45585. * This helps avoiding instanceof at run time.
  45586. * @returns the class name
  45587. */
  45588. getClassName(): string;
  45589. /**
  45590. * @hidden
  45591. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  45592. */
  45593. _checkInputs(): void;
  45594. /**
  45595. * Reset the camera to its default orientation on the specified axis only.
  45596. * @param axis The axis to reset
  45597. */
  45598. resetToCurrentRotation(axis?: Axis): void;
  45599. }
  45600. }
  45601. declare module "babylonjs/Gamepads/xboxGamepad" {
  45602. import { Observable } from "babylonjs/Misc/observable";
  45603. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  45604. /**
  45605. * Defines supported buttons for XBox360 compatible gamepads
  45606. */
  45607. export enum Xbox360Button {
  45608. /** A */
  45609. A = 0,
  45610. /** B */
  45611. B = 1,
  45612. /** X */
  45613. X = 2,
  45614. /** Y */
  45615. Y = 3,
  45616. /** Left button */
  45617. LB = 4,
  45618. /** Right button */
  45619. RB = 5,
  45620. /** Back */
  45621. Back = 8,
  45622. /** Start */
  45623. Start = 9,
  45624. /** Left stick */
  45625. LeftStick = 10,
  45626. /** Right stick */
  45627. RightStick = 11
  45628. }
  45629. /** Defines values for XBox360 DPad */
  45630. export enum Xbox360Dpad {
  45631. /** Up */
  45632. Up = 12,
  45633. /** Down */
  45634. Down = 13,
  45635. /** Left */
  45636. Left = 14,
  45637. /** Right */
  45638. Right = 15
  45639. }
  45640. /**
  45641. * Defines a XBox360 gamepad
  45642. */
  45643. export class Xbox360Pad extends Gamepad {
  45644. private _leftTrigger;
  45645. private _rightTrigger;
  45646. private _onlefttriggerchanged;
  45647. private _onrighttriggerchanged;
  45648. private _onbuttondown;
  45649. private _onbuttonup;
  45650. private _ondpaddown;
  45651. private _ondpadup;
  45652. /** Observable raised when a button is pressed */
  45653. onButtonDownObservable: Observable<Xbox360Button>;
  45654. /** Observable raised when a button is released */
  45655. onButtonUpObservable: Observable<Xbox360Button>;
  45656. /** Observable raised when a pad is pressed */
  45657. onPadDownObservable: Observable<Xbox360Dpad>;
  45658. /** Observable raised when a pad is released */
  45659. onPadUpObservable: Observable<Xbox360Dpad>;
  45660. private _buttonA;
  45661. private _buttonB;
  45662. private _buttonX;
  45663. private _buttonY;
  45664. private _buttonBack;
  45665. private _buttonStart;
  45666. private _buttonLB;
  45667. private _buttonRB;
  45668. private _buttonLeftStick;
  45669. private _buttonRightStick;
  45670. private _dPadUp;
  45671. private _dPadDown;
  45672. private _dPadLeft;
  45673. private _dPadRight;
  45674. private _isXboxOnePad;
  45675. /**
  45676. * Creates a new XBox360 gamepad object
  45677. * @param id defines the id of this gamepad
  45678. * @param index defines its index
  45679. * @param gamepad defines the internal HTML gamepad object
  45680. * @param xboxOne defines if it is a XBox One gamepad
  45681. */
  45682. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  45683. /**
  45684. * Defines the callback to call when left trigger is pressed
  45685. * @param callback defines the callback to use
  45686. */
  45687. onlefttriggerchanged(callback: (value: number) => void): void;
  45688. /**
  45689. * Defines the callback to call when right trigger is pressed
  45690. * @param callback defines the callback to use
  45691. */
  45692. onrighttriggerchanged(callback: (value: number) => void): void;
  45693. /**
  45694. * Gets the left trigger value
  45695. */
  45696. get leftTrigger(): number;
  45697. /**
  45698. * Sets the left trigger value
  45699. */
  45700. set leftTrigger(newValue: number);
  45701. /**
  45702. * Gets the right trigger value
  45703. */
  45704. get rightTrigger(): number;
  45705. /**
  45706. * Sets the right trigger value
  45707. */
  45708. set rightTrigger(newValue: number);
  45709. /**
  45710. * Defines the callback to call when a button is pressed
  45711. * @param callback defines the callback to use
  45712. */
  45713. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  45714. /**
  45715. * Defines the callback to call when a button is released
  45716. * @param callback defines the callback to use
  45717. */
  45718. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  45719. /**
  45720. * Defines the callback to call when a pad is pressed
  45721. * @param callback defines the callback to use
  45722. */
  45723. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  45724. /**
  45725. * Defines the callback to call when a pad is released
  45726. * @param callback defines the callback to use
  45727. */
  45728. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  45729. private _setButtonValue;
  45730. private _setDPadValue;
  45731. /**
  45732. * Gets the value of the `A` button
  45733. */
  45734. get buttonA(): number;
  45735. /**
  45736. * Sets the value of the `A` button
  45737. */
  45738. set buttonA(value: number);
  45739. /**
  45740. * Gets the value of the `B` button
  45741. */
  45742. get buttonB(): number;
  45743. /**
  45744. * Sets the value of the `B` button
  45745. */
  45746. set buttonB(value: number);
  45747. /**
  45748. * Gets the value of the `X` button
  45749. */
  45750. get buttonX(): number;
  45751. /**
  45752. * Sets the value of the `X` button
  45753. */
  45754. set buttonX(value: number);
  45755. /**
  45756. * Gets the value of the `Y` button
  45757. */
  45758. get buttonY(): number;
  45759. /**
  45760. * Sets the value of the `Y` button
  45761. */
  45762. set buttonY(value: number);
  45763. /**
  45764. * Gets the value of the `Start` button
  45765. */
  45766. get buttonStart(): number;
  45767. /**
  45768. * Sets the value of the `Start` button
  45769. */
  45770. set buttonStart(value: number);
  45771. /**
  45772. * Gets the value of the `Back` button
  45773. */
  45774. get buttonBack(): number;
  45775. /**
  45776. * Sets the value of the `Back` button
  45777. */
  45778. set buttonBack(value: number);
  45779. /**
  45780. * Gets the value of the `Left` button
  45781. */
  45782. get buttonLB(): number;
  45783. /**
  45784. * Sets the value of the `Left` button
  45785. */
  45786. set buttonLB(value: number);
  45787. /**
  45788. * Gets the value of the `Right` button
  45789. */
  45790. get buttonRB(): number;
  45791. /**
  45792. * Sets the value of the `Right` button
  45793. */
  45794. set buttonRB(value: number);
  45795. /**
  45796. * Gets the value of the Left joystick
  45797. */
  45798. get buttonLeftStick(): number;
  45799. /**
  45800. * Sets the value of the Left joystick
  45801. */
  45802. set buttonLeftStick(value: number);
  45803. /**
  45804. * Gets the value of the Right joystick
  45805. */
  45806. get buttonRightStick(): number;
  45807. /**
  45808. * Sets the value of the Right joystick
  45809. */
  45810. set buttonRightStick(value: number);
  45811. /**
  45812. * Gets the value of D-pad up
  45813. */
  45814. get dPadUp(): number;
  45815. /**
  45816. * Sets the value of D-pad up
  45817. */
  45818. set dPadUp(value: number);
  45819. /**
  45820. * Gets the value of D-pad down
  45821. */
  45822. get dPadDown(): number;
  45823. /**
  45824. * Sets the value of D-pad down
  45825. */
  45826. set dPadDown(value: number);
  45827. /**
  45828. * Gets the value of D-pad left
  45829. */
  45830. get dPadLeft(): number;
  45831. /**
  45832. * Sets the value of D-pad left
  45833. */
  45834. set dPadLeft(value: number);
  45835. /**
  45836. * Gets the value of D-pad right
  45837. */
  45838. get dPadRight(): number;
  45839. /**
  45840. * Sets the value of D-pad right
  45841. */
  45842. set dPadRight(value: number);
  45843. /**
  45844. * Force the gamepad to synchronize with device values
  45845. */
  45846. update(): void;
  45847. /**
  45848. * Disposes the gamepad
  45849. */
  45850. dispose(): void;
  45851. }
  45852. }
  45853. declare module "babylonjs/Gamepads/dualShockGamepad" {
  45854. import { Observable } from "babylonjs/Misc/observable";
  45855. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  45856. /**
  45857. * Defines supported buttons for DualShock compatible gamepads
  45858. */
  45859. export enum DualShockButton {
  45860. /** Cross */
  45861. Cross = 0,
  45862. /** Circle */
  45863. Circle = 1,
  45864. /** Square */
  45865. Square = 2,
  45866. /** Triangle */
  45867. Triangle = 3,
  45868. /** L1 */
  45869. L1 = 4,
  45870. /** R1 */
  45871. R1 = 5,
  45872. /** Share */
  45873. Share = 8,
  45874. /** Options */
  45875. Options = 9,
  45876. /** Left stick */
  45877. LeftStick = 10,
  45878. /** Right stick */
  45879. RightStick = 11
  45880. }
  45881. /** Defines values for DualShock DPad */
  45882. export enum DualShockDpad {
  45883. /** Up */
  45884. Up = 12,
  45885. /** Down */
  45886. Down = 13,
  45887. /** Left */
  45888. Left = 14,
  45889. /** Right */
  45890. Right = 15
  45891. }
  45892. /**
  45893. * Defines a DualShock gamepad
  45894. */
  45895. export class DualShockPad extends Gamepad {
  45896. private _leftTrigger;
  45897. private _rightTrigger;
  45898. private _onlefttriggerchanged;
  45899. private _onrighttriggerchanged;
  45900. private _onbuttondown;
  45901. private _onbuttonup;
  45902. private _ondpaddown;
  45903. private _ondpadup;
  45904. /** Observable raised when a button is pressed */
  45905. onButtonDownObservable: Observable<DualShockButton>;
  45906. /** Observable raised when a button is released */
  45907. onButtonUpObservable: Observable<DualShockButton>;
  45908. /** Observable raised when a pad is pressed */
  45909. onPadDownObservable: Observable<DualShockDpad>;
  45910. /** Observable raised when a pad is released */
  45911. onPadUpObservable: Observable<DualShockDpad>;
  45912. private _buttonCross;
  45913. private _buttonCircle;
  45914. private _buttonSquare;
  45915. private _buttonTriangle;
  45916. private _buttonShare;
  45917. private _buttonOptions;
  45918. private _buttonL1;
  45919. private _buttonR1;
  45920. private _buttonLeftStick;
  45921. private _buttonRightStick;
  45922. private _dPadUp;
  45923. private _dPadDown;
  45924. private _dPadLeft;
  45925. private _dPadRight;
  45926. /**
  45927. * Creates a new DualShock gamepad object
  45928. * @param id defines the id of this gamepad
  45929. * @param index defines its index
  45930. * @param gamepad defines the internal HTML gamepad object
  45931. */
  45932. constructor(id: string, index: number, gamepad: any);
  45933. /**
  45934. * Defines the callback to call when left trigger is pressed
  45935. * @param callback defines the callback to use
  45936. */
  45937. onlefttriggerchanged(callback: (value: number) => void): void;
  45938. /**
  45939. * Defines the callback to call when right trigger is pressed
  45940. * @param callback defines the callback to use
  45941. */
  45942. onrighttriggerchanged(callback: (value: number) => void): void;
  45943. /**
  45944. * Gets the left trigger value
  45945. */
  45946. get leftTrigger(): number;
  45947. /**
  45948. * Sets the left trigger value
  45949. */
  45950. set leftTrigger(newValue: number);
  45951. /**
  45952. * Gets the right trigger value
  45953. */
  45954. get rightTrigger(): number;
  45955. /**
  45956. * Sets the right trigger value
  45957. */
  45958. set rightTrigger(newValue: number);
  45959. /**
  45960. * Defines the callback to call when a button is pressed
  45961. * @param callback defines the callback to use
  45962. */
  45963. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  45964. /**
  45965. * Defines the callback to call when a button is released
  45966. * @param callback defines the callback to use
  45967. */
  45968. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  45969. /**
  45970. * Defines the callback to call when a pad is pressed
  45971. * @param callback defines the callback to use
  45972. */
  45973. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  45974. /**
  45975. * Defines the callback to call when a pad is released
  45976. * @param callback defines the callback to use
  45977. */
  45978. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  45979. private _setButtonValue;
  45980. private _setDPadValue;
  45981. /**
  45982. * Gets the value of the `Cross` button
  45983. */
  45984. get buttonCross(): number;
  45985. /**
  45986. * Sets the value of the `Cross` button
  45987. */
  45988. set buttonCross(value: number);
  45989. /**
  45990. * Gets the value of the `Circle` button
  45991. */
  45992. get buttonCircle(): number;
  45993. /**
  45994. * Sets the value of the `Circle` button
  45995. */
  45996. set buttonCircle(value: number);
  45997. /**
  45998. * Gets the value of the `Square` button
  45999. */
  46000. get buttonSquare(): number;
  46001. /**
  46002. * Sets the value of the `Square` button
  46003. */
  46004. set buttonSquare(value: number);
  46005. /**
  46006. * Gets the value of the `Triangle` button
  46007. */
  46008. get buttonTriangle(): number;
  46009. /**
  46010. * Sets the value of the `Triangle` button
  46011. */
  46012. set buttonTriangle(value: number);
  46013. /**
  46014. * Gets the value of the `Options` button
  46015. */
  46016. get buttonOptions(): number;
  46017. /**
  46018. * Sets the value of the `Options` button
  46019. */
  46020. set buttonOptions(value: number);
  46021. /**
  46022. * Gets the value of the `Share` button
  46023. */
  46024. get buttonShare(): number;
  46025. /**
  46026. * Sets the value of the `Share` button
  46027. */
  46028. set buttonShare(value: number);
  46029. /**
  46030. * Gets the value of the `L1` button
  46031. */
  46032. get buttonL1(): number;
  46033. /**
  46034. * Sets the value of the `L1` button
  46035. */
  46036. set buttonL1(value: number);
  46037. /**
  46038. * Gets the value of the `R1` button
  46039. */
  46040. get buttonR1(): number;
  46041. /**
  46042. * Sets the value of the `R1` button
  46043. */
  46044. set buttonR1(value: number);
  46045. /**
  46046. * Gets the value of the Left joystick
  46047. */
  46048. get buttonLeftStick(): number;
  46049. /**
  46050. * Sets the value of the Left joystick
  46051. */
  46052. set buttonLeftStick(value: number);
  46053. /**
  46054. * Gets the value of the Right joystick
  46055. */
  46056. get buttonRightStick(): number;
  46057. /**
  46058. * Sets the value of the Right joystick
  46059. */
  46060. set buttonRightStick(value: number);
  46061. /**
  46062. * Gets the value of D-pad up
  46063. */
  46064. get dPadUp(): number;
  46065. /**
  46066. * Sets the value of D-pad up
  46067. */
  46068. set dPadUp(value: number);
  46069. /**
  46070. * Gets the value of D-pad down
  46071. */
  46072. get dPadDown(): number;
  46073. /**
  46074. * Sets the value of D-pad down
  46075. */
  46076. set dPadDown(value: number);
  46077. /**
  46078. * Gets the value of D-pad left
  46079. */
  46080. get dPadLeft(): number;
  46081. /**
  46082. * Sets the value of D-pad left
  46083. */
  46084. set dPadLeft(value: number);
  46085. /**
  46086. * Gets the value of D-pad right
  46087. */
  46088. get dPadRight(): number;
  46089. /**
  46090. * Sets the value of D-pad right
  46091. */
  46092. set dPadRight(value: number);
  46093. /**
  46094. * Force the gamepad to synchronize with device values
  46095. */
  46096. update(): void;
  46097. /**
  46098. * Disposes the gamepad
  46099. */
  46100. dispose(): void;
  46101. }
  46102. }
  46103. declare module "babylonjs/Gamepads/gamepadManager" {
  46104. import { Observable } from "babylonjs/Misc/observable";
  46105. import { Nullable } from "babylonjs/types";
  46106. import { Scene } from "babylonjs/scene";
  46107. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  46108. /**
  46109. * Manager for handling gamepads
  46110. */
  46111. export class GamepadManager {
  46112. private _scene?;
  46113. private _babylonGamepads;
  46114. private _oneGamepadConnected;
  46115. /** @hidden */
  46116. _isMonitoring: boolean;
  46117. private _gamepadEventSupported;
  46118. private _gamepadSupport?;
  46119. /**
  46120. * observable to be triggered when the gamepad controller has been connected
  46121. */
  46122. onGamepadConnectedObservable: Observable<Gamepad>;
  46123. /**
  46124. * observable to be triggered when the gamepad controller has been disconnected
  46125. */
  46126. onGamepadDisconnectedObservable: Observable<Gamepad>;
  46127. private _onGamepadConnectedEvent;
  46128. private _onGamepadDisconnectedEvent;
  46129. /**
  46130. * Initializes the gamepad manager
  46131. * @param _scene BabylonJS scene
  46132. */
  46133. constructor(_scene?: Scene | undefined);
  46134. /**
  46135. * The gamepads in the game pad manager
  46136. */
  46137. get gamepads(): Gamepad[];
  46138. /**
  46139. * Get the gamepad controllers based on type
  46140. * @param type The type of gamepad controller
  46141. * @returns Nullable gamepad
  46142. */
  46143. getGamepadByType(type?: number): Nullable<Gamepad>;
  46144. /**
  46145. * Disposes the gamepad manager
  46146. */
  46147. dispose(): void;
  46148. private _addNewGamepad;
  46149. private _startMonitoringGamepads;
  46150. private _stopMonitoringGamepads;
  46151. /** @hidden */
  46152. _checkGamepadsStatus(): void;
  46153. private _updateGamepadObjects;
  46154. }
  46155. }
  46156. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  46157. import { Nullable } from "babylonjs/types";
  46158. import { Scene } from "babylonjs/scene";
  46159. import { ISceneComponent } from "babylonjs/sceneComponent";
  46160. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  46161. module "babylonjs/scene" {
  46162. interface Scene {
  46163. /** @hidden */
  46164. _gamepadManager: Nullable<GamepadManager>;
  46165. /**
  46166. * Gets the gamepad manager associated with the scene
  46167. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  46168. */
  46169. gamepadManager: GamepadManager;
  46170. }
  46171. }
  46172. module "babylonjs/Cameras/freeCameraInputsManager" {
  46173. /**
  46174. * Interface representing a free camera inputs manager
  46175. */
  46176. interface FreeCameraInputsManager {
  46177. /**
  46178. * Adds gamepad input support to the FreeCameraInputsManager.
  46179. * @returns the FreeCameraInputsManager
  46180. */
  46181. addGamepad(): FreeCameraInputsManager;
  46182. }
  46183. }
  46184. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  46185. /**
  46186. * Interface representing an arc rotate camera inputs manager
  46187. */
  46188. interface ArcRotateCameraInputsManager {
  46189. /**
  46190. * Adds gamepad input support to the ArcRotateCamera InputManager.
  46191. * @returns the camera inputs manager
  46192. */
  46193. addGamepad(): ArcRotateCameraInputsManager;
  46194. }
  46195. }
  46196. /**
  46197. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  46198. */
  46199. export class GamepadSystemSceneComponent implements ISceneComponent {
  46200. /**
  46201. * The component name helpfull to identify the component in the list of scene components.
  46202. */
  46203. readonly name: string;
  46204. /**
  46205. * The scene the component belongs to.
  46206. */
  46207. scene: Scene;
  46208. /**
  46209. * Creates a new instance of the component for the given scene
  46210. * @param scene Defines the scene to register the component in
  46211. */
  46212. constructor(scene: Scene);
  46213. /**
  46214. * Registers the component in a given scene
  46215. */
  46216. register(): void;
  46217. /**
  46218. * Rebuilds the elements related to this component in case of
  46219. * context lost for instance.
  46220. */
  46221. rebuild(): void;
  46222. /**
  46223. * Disposes the component and the associated ressources
  46224. */
  46225. dispose(): void;
  46226. private _beforeCameraUpdate;
  46227. }
  46228. }
  46229. declare module "babylonjs/Cameras/universalCamera" {
  46230. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  46231. import { Scene } from "babylonjs/scene";
  46232. import { Vector3 } from "babylonjs/Maths/math.vector";
  46233. import "babylonjs/Gamepads/gamepadSceneComponent";
  46234. /**
  46235. * 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,
  46236. * which still works and will still be found in many Playgrounds.
  46237. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  46238. */
  46239. export class UniversalCamera extends TouchCamera {
  46240. /**
  46241. * Defines the gamepad rotation sensiblity.
  46242. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  46243. */
  46244. get gamepadAngularSensibility(): number;
  46245. set gamepadAngularSensibility(value: number);
  46246. /**
  46247. * Defines the gamepad move sensiblity.
  46248. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  46249. */
  46250. get gamepadMoveSensibility(): number;
  46251. set gamepadMoveSensibility(value: number);
  46252. /**
  46253. * 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,
  46254. * which still works and will still be found in many Playgrounds.
  46255. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  46256. * @param name Define the name of the camera in the scene
  46257. * @param position Define the start position of the camera in the scene
  46258. * @param scene Define the scene the camera belongs to
  46259. */
  46260. constructor(name: string, position: Vector3, scene: Scene);
  46261. /**
  46262. * Gets the current object class name.
  46263. * @return the class name
  46264. */
  46265. getClassName(): string;
  46266. }
  46267. }
  46268. declare module "babylonjs/Cameras/gamepadCamera" {
  46269. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  46270. import { Scene } from "babylonjs/scene";
  46271. import { Vector3 } from "babylonjs/Maths/math.vector";
  46272. /**
  46273. * This represents a FPS type of camera. This is only here for back compat purpose.
  46274. * Please use the UniversalCamera instead as both are identical.
  46275. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  46276. */
  46277. export class GamepadCamera extends UniversalCamera {
  46278. /**
  46279. * Instantiates a new Gamepad Camera
  46280. * This represents a FPS type of camera. This is only here for back compat purpose.
  46281. * Please use the UniversalCamera instead as both are identical.
  46282. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  46283. * @param name Define the name of the camera in the scene
  46284. * @param position Define the start position of the camera in the scene
  46285. * @param scene Define the scene the camera belongs to
  46286. */
  46287. constructor(name: string, position: Vector3, scene: Scene);
  46288. /**
  46289. * Gets the current object class name.
  46290. * @return the class name
  46291. */
  46292. getClassName(): string;
  46293. }
  46294. }
  46295. declare module "babylonjs/Shaders/pass.fragment" {
  46296. /** @hidden */
  46297. export var passPixelShader: {
  46298. name: string;
  46299. shader: string;
  46300. };
  46301. }
  46302. declare module "babylonjs/Shaders/passCube.fragment" {
  46303. /** @hidden */
  46304. export var passCubePixelShader: {
  46305. name: string;
  46306. shader: string;
  46307. };
  46308. }
  46309. declare module "babylonjs/PostProcesses/passPostProcess" {
  46310. import { Nullable } from "babylonjs/types";
  46311. import { Camera } from "babylonjs/Cameras/camera";
  46312. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  46313. import { Engine } from "babylonjs/Engines/engine";
  46314. import "babylonjs/Shaders/pass.fragment";
  46315. import "babylonjs/Shaders/passCube.fragment";
  46316. /**
  46317. * PassPostProcess which produces an output the same as it's input
  46318. */
  46319. export class PassPostProcess extends PostProcess {
  46320. /**
  46321. * Creates the PassPostProcess
  46322. * @param name The name of the effect.
  46323. * @param options The required width/height ratio to downsize to before computing the render pass.
  46324. * @param camera The camera to apply the render pass to.
  46325. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  46326. * @param engine The engine which the post process will be applied. (default: current engine)
  46327. * @param reusable If the post process can be reused on the same frame. (default: false)
  46328. * @param textureType The type of texture to be used when performing the post processing.
  46329. * @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)
  46330. */
  46331. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  46332. }
  46333. /**
  46334. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  46335. */
  46336. export class PassCubePostProcess extends PostProcess {
  46337. private _face;
  46338. /**
  46339. * Gets or sets the cube face to display.
  46340. * * 0 is +X
  46341. * * 1 is -X
  46342. * * 2 is +Y
  46343. * * 3 is -Y
  46344. * * 4 is +Z
  46345. * * 5 is -Z
  46346. */
  46347. get face(): number;
  46348. set face(value: number);
  46349. /**
  46350. * Creates the PassCubePostProcess
  46351. * @param name The name of the effect.
  46352. * @param options The required width/height ratio to downsize to before computing the render pass.
  46353. * @param camera The camera to apply the render pass to.
  46354. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  46355. * @param engine The engine which the post process will be applied. (default: current engine)
  46356. * @param reusable If the post process can be reused on the same frame. (default: false)
  46357. * @param textureType The type of texture to be used when performing the post processing.
  46358. * @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)
  46359. */
  46360. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  46361. }
  46362. }
  46363. declare module "babylonjs/Shaders/anaglyph.fragment" {
  46364. /** @hidden */
  46365. export var anaglyphPixelShader: {
  46366. name: string;
  46367. shader: string;
  46368. };
  46369. }
  46370. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  46371. import { Engine } from "babylonjs/Engines/engine";
  46372. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  46373. import { Camera } from "babylonjs/Cameras/camera";
  46374. import "babylonjs/Shaders/anaglyph.fragment";
  46375. /**
  46376. * Postprocess used to generate anaglyphic rendering
  46377. */
  46378. export class AnaglyphPostProcess extends PostProcess {
  46379. private _passedProcess;
  46380. /**
  46381. * Creates a new AnaglyphPostProcess
  46382. * @param name defines postprocess name
  46383. * @param options defines creation options or target ratio scale
  46384. * @param rigCameras defines cameras using this postprocess
  46385. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  46386. * @param engine defines hosting engine
  46387. * @param reusable defines if the postprocess will be reused multiple times per frame
  46388. */
  46389. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  46390. }
  46391. }
  46392. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  46393. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  46394. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  46395. import { Scene } from "babylonjs/scene";
  46396. import { Vector3 } from "babylonjs/Maths/math.vector";
  46397. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  46398. /**
  46399. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  46400. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46401. */
  46402. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  46403. /**
  46404. * Creates a new AnaglyphArcRotateCamera
  46405. * @param name defines camera name
  46406. * @param alpha defines alpha angle (in radians)
  46407. * @param beta defines beta angle (in radians)
  46408. * @param radius defines radius
  46409. * @param target defines camera target
  46410. * @param interaxialDistance defines distance between each color axis
  46411. * @param scene defines the hosting scene
  46412. */
  46413. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  46414. /**
  46415. * Gets camera class name
  46416. * @returns AnaglyphArcRotateCamera
  46417. */
  46418. getClassName(): string;
  46419. }
  46420. }
  46421. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  46422. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46423. import { Scene } from "babylonjs/scene";
  46424. import { Vector3 } from "babylonjs/Maths/math.vector";
  46425. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  46426. /**
  46427. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  46428. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46429. */
  46430. export class AnaglyphFreeCamera extends FreeCamera {
  46431. /**
  46432. * Creates a new AnaglyphFreeCamera
  46433. * @param name defines camera name
  46434. * @param position defines initial position
  46435. * @param interaxialDistance defines distance between each color axis
  46436. * @param scene defines the hosting scene
  46437. */
  46438. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46439. /**
  46440. * Gets camera class name
  46441. * @returns AnaglyphFreeCamera
  46442. */
  46443. getClassName(): string;
  46444. }
  46445. }
  46446. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  46447. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  46448. import { Scene } from "babylonjs/scene";
  46449. import { Vector3 } from "babylonjs/Maths/math.vector";
  46450. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  46451. /**
  46452. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  46453. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46454. */
  46455. export class AnaglyphGamepadCamera extends GamepadCamera {
  46456. /**
  46457. * Creates a new AnaglyphGamepadCamera
  46458. * @param name defines camera name
  46459. * @param position defines initial position
  46460. * @param interaxialDistance defines distance between each color axis
  46461. * @param scene defines the hosting scene
  46462. */
  46463. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46464. /**
  46465. * Gets camera class name
  46466. * @returns AnaglyphGamepadCamera
  46467. */
  46468. getClassName(): string;
  46469. }
  46470. }
  46471. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  46472. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  46473. import { Scene } from "babylonjs/scene";
  46474. import { Vector3 } from "babylonjs/Maths/math.vector";
  46475. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  46476. /**
  46477. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  46478. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46479. */
  46480. export class AnaglyphUniversalCamera extends UniversalCamera {
  46481. /**
  46482. * Creates a new AnaglyphUniversalCamera
  46483. * @param name defines camera name
  46484. * @param position defines initial position
  46485. * @param interaxialDistance defines distance between each color axis
  46486. * @param scene defines the hosting scene
  46487. */
  46488. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46489. /**
  46490. * Gets camera class name
  46491. * @returns AnaglyphUniversalCamera
  46492. */
  46493. getClassName(): string;
  46494. }
  46495. }
  46496. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  46497. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  46498. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  46499. import { Scene } from "babylonjs/scene";
  46500. import { Vector3 } from "babylonjs/Maths/math.vector";
  46501. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  46502. /**
  46503. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  46504. * @see http://doc.babylonjs.com/features/cameras
  46505. */
  46506. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  46507. /**
  46508. * Creates a new StereoscopicArcRotateCamera
  46509. * @param name defines camera name
  46510. * @param alpha defines alpha angle (in radians)
  46511. * @param beta defines beta angle (in radians)
  46512. * @param radius defines radius
  46513. * @param target defines camera target
  46514. * @param interaxialDistance defines distance between each color axis
  46515. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46516. * @param scene defines the hosting scene
  46517. */
  46518. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46519. /**
  46520. * Gets camera class name
  46521. * @returns StereoscopicArcRotateCamera
  46522. */
  46523. getClassName(): string;
  46524. }
  46525. }
  46526. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  46527. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46528. import { Scene } from "babylonjs/scene";
  46529. import { Vector3 } from "babylonjs/Maths/math.vector";
  46530. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  46531. /**
  46532. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  46533. * @see http://doc.babylonjs.com/features/cameras
  46534. */
  46535. export class StereoscopicFreeCamera extends FreeCamera {
  46536. /**
  46537. * Creates a new StereoscopicFreeCamera
  46538. * @param name defines camera name
  46539. * @param position defines initial position
  46540. * @param interaxialDistance defines distance between each color axis
  46541. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46542. * @param scene defines the hosting scene
  46543. */
  46544. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46545. /**
  46546. * Gets camera class name
  46547. * @returns StereoscopicFreeCamera
  46548. */
  46549. getClassName(): string;
  46550. }
  46551. }
  46552. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  46553. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  46554. import { Scene } from "babylonjs/scene";
  46555. import { Vector3 } from "babylonjs/Maths/math.vector";
  46556. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  46557. /**
  46558. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  46559. * @see http://doc.babylonjs.com/features/cameras
  46560. */
  46561. export class StereoscopicGamepadCamera extends GamepadCamera {
  46562. /**
  46563. * Creates a new StereoscopicGamepadCamera
  46564. * @param name defines camera name
  46565. * @param position defines initial position
  46566. * @param interaxialDistance defines distance between each color axis
  46567. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46568. * @param scene defines the hosting scene
  46569. */
  46570. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46571. /**
  46572. * Gets camera class name
  46573. * @returns StereoscopicGamepadCamera
  46574. */
  46575. getClassName(): string;
  46576. }
  46577. }
  46578. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  46579. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  46580. import { Scene } from "babylonjs/scene";
  46581. import { Vector3 } from "babylonjs/Maths/math.vector";
  46582. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  46583. /**
  46584. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  46585. * @see http://doc.babylonjs.com/features/cameras
  46586. */
  46587. export class StereoscopicUniversalCamera extends UniversalCamera {
  46588. /**
  46589. * Creates a new StereoscopicUniversalCamera
  46590. * @param name defines camera name
  46591. * @param position defines initial position
  46592. * @param interaxialDistance defines distance between each color axis
  46593. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46594. * @param scene defines the hosting scene
  46595. */
  46596. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46597. /**
  46598. * Gets camera class name
  46599. * @returns StereoscopicUniversalCamera
  46600. */
  46601. getClassName(): string;
  46602. }
  46603. }
  46604. declare module "babylonjs/Cameras/Stereoscopic/index" {
  46605. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  46606. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  46607. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  46608. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  46609. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  46610. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  46611. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  46612. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  46613. }
  46614. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  46615. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46616. import { Scene } from "babylonjs/scene";
  46617. import { Vector3 } from "babylonjs/Maths/math.vector";
  46618. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  46619. /**
  46620. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  46621. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  46622. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  46623. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  46624. */
  46625. export class VirtualJoysticksCamera extends FreeCamera {
  46626. /**
  46627. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  46628. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  46629. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  46630. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  46631. * @param name Define the name of the camera in the scene
  46632. * @param position Define the start position of the camera in the scene
  46633. * @param scene Define the scene the camera belongs to
  46634. */
  46635. constructor(name: string, position: Vector3, scene: Scene);
  46636. /**
  46637. * Gets the current object class name.
  46638. * @return the class name
  46639. */
  46640. getClassName(): string;
  46641. }
  46642. }
  46643. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  46644. import { Matrix } from "babylonjs/Maths/math.vector";
  46645. /**
  46646. * This represents all the required metrics to create a VR camera.
  46647. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  46648. */
  46649. export class VRCameraMetrics {
  46650. /**
  46651. * Define the horizontal resolution off the screen.
  46652. */
  46653. hResolution: number;
  46654. /**
  46655. * Define the vertical resolution off the screen.
  46656. */
  46657. vResolution: number;
  46658. /**
  46659. * Define the horizontal screen size.
  46660. */
  46661. hScreenSize: number;
  46662. /**
  46663. * Define the vertical screen size.
  46664. */
  46665. vScreenSize: number;
  46666. /**
  46667. * Define the vertical screen center position.
  46668. */
  46669. vScreenCenter: number;
  46670. /**
  46671. * Define the distance of the eyes to the screen.
  46672. */
  46673. eyeToScreenDistance: number;
  46674. /**
  46675. * Define the distance between both lenses
  46676. */
  46677. lensSeparationDistance: number;
  46678. /**
  46679. * Define the distance between both viewer's eyes.
  46680. */
  46681. interpupillaryDistance: number;
  46682. /**
  46683. * Define the distortion factor of the VR postprocess.
  46684. * Please, touch with care.
  46685. */
  46686. distortionK: number[];
  46687. /**
  46688. * Define the chromatic aberration correction factors for the VR post process.
  46689. */
  46690. chromaAbCorrection: number[];
  46691. /**
  46692. * Define the scale factor of the post process.
  46693. * The smaller the better but the slower.
  46694. */
  46695. postProcessScaleFactor: number;
  46696. /**
  46697. * Define an offset for the lens center.
  46698. */
  46699. lensCenterOffset: number;
  46700. /**
  46701. * Define if the current vr camera should compensate the distortion of the lense or not.
  46702. */
  46703. compensateDistortion: boolean;
  46704. /**
  46705. * Defines if multiview should be enabled when rendering (Default: false)
  46706. */
  46707. multiviewEnabled: boolean;
  46708. /**
  46709. * Gets the rendering aspect ratio based on the provided resolutions.
  46710. */
  46711. get aspectRatio(): number;
  46712. /**
  46713. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  46714. */
  46715. get aspectRatioFov(): number;
  46716. /**
  46717. * @hidden
  46718. */
  46719. get leftHMatrix(): Matrix;
  46720. /**
  46721. * @hidden
  46722. */
  46723. get rightHMatrix(): Matrix;
  46724. /**
  46725. * @hidden
  46726. */
  46727. get leftPreViewMatrix(): Matrix;
  46728. /**
  46729. * @hidden
  46730. */
  46731. get rightPreViewMatrix(): Matrix;
  46732. /**
  46733. * Get the default VRMetrics based on the most generic setup.
  46734. * @returns the default vr metrics
  46735. */
  46736. static GetDefault(): VRCameraMetrics;
  46737. }
  46738. }
  46739. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  46740. /** @hidden */
  46741. export var vrDistortionCorrectionPixelShader: {
  46742. name: string;
  46743. shader: string;
  46744. };
  46745. }
  46746. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  46747. import { Camera } from "babylonjs/Cameras/camera";
  46748. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  46749. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  46750. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  46751. /**
  46752. * VRDistortionCorrectionPostProcess used for mobile VR
  46753. */
  46754. export class VRDistortionCorrectionPostProcess extends PostProcess {
  46755. private _isRightEye;
  46756. private _distortionFactors;
  46757. private _postProcessScaleFactor;
  46758. private _lensCenterOffset;
  46759. private _scaleIn;
  46760. private _scaleFactor;
  46761. private _lensCenter;
  46762. /**
  46763. * Initializes the VRDistortionCorrectionPostProcess
  46764. * @param name The name of the effect.
  46765. * @param camera The camera to apply the render pass to.
  46766. * @param isRightEye If this is for the right eye distortion
  46767. * @param vrMetrics All the required metrics for the VR camera
  46768. */
  46769. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  46770. }
  46771. }
  46772. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  46773. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  46774. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  46775. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  46776. import { Scene } from "babylonjs/scene";
  46777. import { Vector3 } from "babylonjs/Maths/math.vector";
  46778. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  46779. import "babylonjs/Cameras/RigModes/vrRigMode";
  46780. /**
  46781. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  46782. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46783. */
  46784. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  46785. /**
  46786. * Creates a new VRDeviceOrientationArcRotateCamera
  46787. * @param name defines camera name
  46788. * @param alpha defines the camera rotation along the logitudinal axis
  46789. * @param beta defines the camera rotation along the latitudinal axis
  46790. * @param radius defines the camera distance from its target
  46791. * @param target defines the camera target
  46792. * @param scene defines the scene the camera belongs to
  46793. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46794. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46795. */
  46796. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46797. /**
  46798. * Gets camera class name
  46799. * @returns VRDeviceOrientationArcRotateCamera
  46800. */
  46801. getClassName(): string;
  46802. }
  46803. }
  46804. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  46805. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  46806. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  46807. import { Scene } from "babylonjs/scene";
  46808. import { Vector3 } from "babylonjs/Maths/math.vector";
  46809. import "babylonjs/Cameras/RigModes/vrRigMode";
  46810. /**
  46811. * Camera used to simulate VR rendering (based on FreeCamera)
  46812. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46813. */
  46814. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  46815. /**
  46816. * Creates a new VRDeviceOrientationFreeCamera
  46817. * @param name defines camera name
  46818. * @param position defines the start position of the camera
  46819. * @param scene defines the scene the camera belongs to
  46820. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46821. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46822. */
  46823. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46824. /**
  46825. * Gets camera class name
  46826. * @returns VRDeviceOrientationFreeCamera
  46827. */
  46828. getClassName(): string;
  46829. }
  46830. }
  46831. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  46832. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  46833. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  46834. import { Scene } from "babylonjs/scene";
  46835. import { Vector3 } from "babylonjs/Maths/math.vector";
  46836. import "babylonjs/Gamepads/gamepadSceneComponent";
  46837. /**
  46838. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  46839. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46840. */
  46841. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  46842. /**
  46843. * Creates a new VRDeviceOrientationGamepadCamera
  46844. * @param name defines camera name
  46845. * @param position defines the start position of the camera
  46846. * @param scene defines the scene the camera belongs to
  46847. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46848. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46849. */
  46850. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46851. /**
  46852. * Gets camera class name
  46853. * @returns VRDeviceOrientationGamepadCamera
  46854. */
  46855. getClassName(): string;
  46856. }
  46857. }
  46858. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  46859. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  46860. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46861. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  46862. /** @hidden */
  46863. export var imageProcessingPixelShader: {
  46864. name: string;
  46865. shader: string;
  46866. };
  46867. }
  46868. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  46869. import { Nullable } from "babylonjs/types";
  46870. import { Color4 } from "babylonjs/Maths/math.color";
  46871. import { Camera } from "babylonjs/Cameras/camera";
  46872. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46873. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  46874. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  46875. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  46876. import { Engine } from "babylonjs/Engines/engine";
  46877. import "babylonjs/Shaders/imageProcessing.fragment";
  46878. import "babylonjs/Shaders/postprocess.vertex";
  46879. /**
  46880. * ImageProcessingPostProcess
  46881. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  46882. */
  46883. export class ImageProcessingPostProcess extends PostProcess {
  46884. /**
  46885. * Default configuration related to image processing available in the PBR Material.
  46886. */
  46887. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  46888. /**
  46889. * Gets the image processing configuration used either in this material.
  46890. */
  46891. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  46892. /**
  46893. * Sets the Default image processing configuration used either in the this material.
  46894. *
  46895. * If sets to null, the scene one is in use.
  46896. */
  46897. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  46898. /**
  46899. * Keep track of the image processing observer to allow dispose and replace.
  46900. */
  46901. private _imageProcessingObserver;
  46902. /**
  46903. * Attaches a new image processing configuration to the PBR Material.
  46904. * @param configuration
  46905. */
  46906. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  46907. /**
  46908. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  46909. */
  46910. get colorCurves(): Nullable<ColorCurves>;
  46911. /**
  46912. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  46913. */
  46914. set colorCurves(value: Nullable<ColorCurves>);
  46915. /**
  46916. * Gets wether the color curves effect is enabled.
  46917. */
  46918. get colorCurvesEnabled(): boolean;
  46919. /**
  46920. * Sets wether the color curves effect is enabled.
  46921. */
  46922. set colorCurvesEnabled(value: boolean);
  46923. /**
  46924. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  46925. */
  46926. get colorGradingTexture(): Nullable<BaseTexture>;
  46927. /**
  46928. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  46929. */
  46930. set colorGradingTexture(value: Nullable<BaseTexture>);
  46931. /**
  46932. * Gets wether the color grading effect is enabled.
  46933. */
  46934. get colorGradingEnabled(): boolean;
  46935. /**
  46936. * Gets wether the color grading effect is enabled.
  46937. */
  46938. set colorGradingEnabled(value: boolean);
  46939. /**
  46940. * Gets exposure used in the effect.
  46941. */
  46942. get exposure(): number;
  46943. /**
  46944. * Sets exposure used in the effect.
  46945. */
  46946. set exposure(value: number);
  46947. /**
  46948. * Gets wether tonemapping is enabled or not.
  46949. */
  46950. get toneMappingEnabled(): boolean;
  46951. /**
  46952. * Sets wether tonemapping is enabled or not
  46953. */
  46954. set toneMappingEnabled(value: boolean);
  46955. /**
  46956. * Gets the type of tone mapping effect.
  46957. */
  46958. get toneMappingType(): number;
  46959. /**
  46960. * Sets the type of tone mapping effect.
  46961. */
  46962. set toneMappingType(value: number);
  46963. /**
  46964. * Gets contrast used in the effect.
  46965. */
  46966. get contrast(): number;
  46967. /**
  46968. * Sets contrast used in the effect.
  46969. */
  46970. set contrast(value: number);
  46971. /**
  46972. * Gets Vignette stretch size.
  46973. */
  46974. get vignetteStretch(): number;
  46975. /**
  46976. * Sets Vignette stretch size.
  46977. */
  46978. set vignetteStretch(value: number);
  46979. /**
  46980. * Gets Vignette centre X Offset.
  46981. */
  46982. get vignetteCentreX(): number;
  46983. /**
  46984. * Sets Vignette centre X Offset.
  46985. */
  46986. set vignetteCentreX(value: number);
  46987. /**
  46988. * Gets Vignette centre Y Offset.
  46989. */
  46990. get vignetteCentreY(): number;
  46991. /**
  46992. * Sets Vignette centre Y Offset.
  46993. */
  46994. set vignetteCentreY(value: number);
  46995. /**
  46996. * Gets Vignette weight or intensity of the vignette effect.
  46997. */
  46998. get vignetteWeight(): number;
  46999. /**
  47000. * Sets Vignette weight or intensity of the vignette effect.
  47001. */
  47002. set vignetteWeight(value: number);
  47003. /**
  47004. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  47005. * if vignetteEnabled is set to true.
  47006. */
  47007. get vignetteColor(): Color4;
  47008. /**
  47009. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  47010. * if vignetteEnabled is set to true.
  47011. */
  47012. set vignetteColor(value: Color4);
  47013. /**
  47014. * Gets Camera field of view used by the Vignette effect.
  47015. */
  47016. get vignetteCameraFov(): number;
  47017. /**
  47018. * Sets Camera field of view used by the Vignette effect.
  47019. */
  47020. set vignetteCameraFov(value: number);
  47021. /**
  47022. * Gets the vignette blend mode allowing different kind of effect.
  47023. */
  47024. get vignetteBlendMode(): number;
  47025. /**
  47026. * Sets the vignette blend mode allowing different kind of effect.
  47027. */
  47028. set vignetteBlendMode(value: number);
  47029. /**
  47030. * Gets wether the vignette effect is enabled.
  47031. */
  47032. get vignetteEnabled(): boolean;
  47033. /**
  47034. * Sets wether the vignette effect is enabled.
  47035. */
  47036. set vignetteEnabled(value: boolean);
  47037. private _fromLinearSpace;
  47038. /**
  47039. * Gets wether the input of the processing is in Gamma or Linear Space.
  47040. */
  47041. get fromLinearSpace(): boolean;
  47042. /**
  47043. * Sets wether the input of the processing is in Gamma or Linear Space.
  47044. */
  47045. set fromLinearSpace(value: boolean);
  47046. /**
  47047. * Defines cache preventing GC.
  47048. */
  47049. private _defines;
  47050. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  47051. /**
  47052. * "ImageProcessingPostProcess"
  47053. * @returns "ImageProcessingPostProcess"
  47054. */
  47055. getClassName(): string;
  47056. protected _updateParameters(): void;
  47057. dispose(camera?: Camera): void;
  47058. }
  47059. }
  47060. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  47061. import { Scene } from "babylonjs/scene";
  47062. import { Color3 } from "babylonjs/Maths/math.color";
  47063. import { Mesh } from "babylonjs/Meshes/mesh";
  47064. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  47065. import { Nullable } from "babylonjs/types";
  47066. /**
  47067. * Class containing static functions to help procedurally build meshes
  47068. */
  47069. export class GroundBuilder {
  47070. /**
  47071. * Creates a ground mesh
  47072. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  47073. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  47074. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47075. * @param name defines the name of the mesh
  47076. * @param options defines the options used to create the mesh
  47077. * @param scene defines the hosting scene
  47078. * @returns the ground mesh
  47079. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  47080. */
  47081. static CreateGround(name: string, options: {
  47082. width?: number;
  47083. height?: number;
  47084. subdivisions?: number;
  47085. subdivisionsX?: number;
  47086. subdivisionsY?: number;
  47087. updatable?: boolean;
  47088. }, scene: any): Mesh;
  47089. /**
  47090. * Creates a tiled ground mesh
  47091. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  47092. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  47093. * * 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
  47094. * * 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
  47095. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47096. * @param name defines the name of the mesh
  47097. * @param options defines the options used to create the mesh
  47098. * @param scene defines the hosting scene
  47099. * @returns the tiled ground mesh
  47100. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  47101. */
  47102. static CreateTiledGround(name: string, options: {
  47103. xmin: number;
  47104. zmin: number;
  47105. xmax: number;
  47106. zmax: number;
  47107. subdivisions?: {
  47108. w: number;
  47109. h: number;
  47110. };
  47111. precision?: {
  47112. w: number;
  47113. h: number;
  47114. };
  47115. updatable?: boolean;
  47116. }, scene?: Nullable<Scene>): Mesh;
  47117. /**
  47118. * Creates a ground mesh from a height map
  47119. * * The parameter `url` sets the URL of the height map image resource.
  47120. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  47121. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  47122. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  47123. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  47124. * * 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.
  47125. * * 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).
  47126. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  47127. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47128. * @param name defines the name of the mesh
  47129. * @param url defines the url to the height map
  47130. * @param options defines the options used to create the mesh
  47131. * @param scene defines the hosting scene
  47132. * @returns the ground mesh
  47133. * @see https://doc.babylonjs.com/babylon101/height_map
  47134. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  47135. */
  47136. static CreateGroundFromHeightMap(name: string, url: string, options: {
  47137. width?: number;
  47138. height?: number;
  47139. subdivisions?: number;
  47140. minHeight?: number;
  47141. maxHeight?: number;
  47142. colorFilter?: Color3;
  47143. alphaFilter?: number;
  47144. updatable?: boolean;
  47145. onReady?: (mesh: GroundMesh) => void;
  47146. }, scene?: Nullable<Scene>): GroundMesh;
  47147. }
  47148. }
  47149. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  47150. import { Vector4 } from "babylonjs/Maths/math.vector";
  47151. import { Mesh } from "babylonjs/Meshes/mesh";
  47152. /**
  47153. * Class containing static functions to help procedurally build meshes
  47154. */
  47155. export class TorusBuilder {
  47156. /**
  47157. * Creates a torus mesh
  47158. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  47159. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  47160. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  47161. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47162. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47163. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47164. * @param name defines the name of the mesh
  47165. * @param options defines the options used to create the mesh
  47166. * @param scene defines the hosting scene
  47167. * @returns the torus mesh
  47168. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  47169. */
  47170. static CreateTorus(name: string, options: {
  47171. diameter?: number;
  47172. thickness?: number;
  47173. tessellation?: number;
  47174. updatable?: boolean;
  47175. sideOrientation?: number;
  47176. frontUVs?: Vector4;
  47177. backUVs?: Vector4;
  47178. }, scene: any): Mesh;
  47179. }
  47180. }
  47181. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  47182. import { Vector4 } from "babylonjs/Maths/math.vector";
  47183. import { Color4 } from "babylonjs/Maths/math.color";
  47184. import { Mesh } from "babylonjs/Meshes/mesh";
  47185. /**
  47186. * Class containing static functions to help procedurally build meshes
  47187. */
  47188. export class CylinderBuilder {
  47189. /**
  47190. * Creates a cylinder or a cone mesh
  47191. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  47192. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  47193. * * 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.
  47194. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  47195. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  47196. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  47197. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  47198. * * 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).
  47199. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  47200. * * 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).
  47201. * * 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
  47202. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  47203. * * 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
  47204. * * 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.
  47205. * * If `enclose` is false, a ring surface is one element.
  47206. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  47207. * * 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
  47208. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47209. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47210. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47211. * @param name defines the name of the mesh
  47212. * @param options defines the options used to create the mesh
  47213. * @param scene defines the hosting scene
  47214. * @returns the cylinder mesh
  47215. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  47216. */
  47217. static CreateCylinder(name: string, options: {
  47218. height?: number;
  47219. diameterTop?: number;
  47220. diameterBottom?: number;
  47221. diameter?: number;
  47222. tessellation?: number;
  47223. subdivisions?: number;
  47224. arc?: number;
  47225. faceColors?: Color4[];
  47226. faceUV?: Vector4[];
  47227. updatable?: boolean;
  47228. hasRings?: boolean;
  47229. enclose?: boolean;
  47230. cap?: number;
  47231. sideOrientation?: number;
  47232. frontUVs?: Vector4;
  47233. backUVs?: Vector4;
  47234. }, scene: any): Mesh;
  47235. }
  47236. }
  47237. declare module "babylonjs/XR/webXRTypes" {
  47238. import { Nullable } from "babylonjs/types";
  47239. import { IDisposable } from "babylonjs/scene";
  47240. /**
  47241. * States of the webXR experience
  47242. */
  47243. export enum WebXRState {
  47244. /**
  47245. * Transitioning to being in XR mode
  47246. */
  47247. ENTERING_XR = 0,
  47248. /**
  47249. * Transitioning to non XR mode
  47250. */
  47251. EXITING_XR = 1,
  47252. /**
  47253. * In XR mode and presenting
  47254. */
  47255. IN_XR = 2,
  47256. /**
  47257. * Not entered XR mode
  47258. */
  47259. NOT_IN_XR = 3
  47260. }
  47261. /**
  47262. * Abstraction of the XR render target
  47263. */
  47264. export interface WebXRRenderTarget extends IDisposable {
  47265. /**
  47266. * xrpresent context of the canvas which can be used to display/mirror xr content
  47267. */
  47268. canvasContext: WebGLRenderingContext;
  47269. /**
  47270. * xr layer for the canvas
  47271. */
  47272. xrLayer: Nullable<XRWebGLLayer>;
  47273. /**
  47274. * Initializes the xr layer for the session
  47275. * @param xrSession xr session
  47276. * @returns a promise that will resolve once the XR Layer has been created
  47277. */
  47278. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  47279. }
  47280. }
  47281. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  47282. import { Nullable } from "babylonjs/types";
  47283. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  47284. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  47285. /**
  47286. * COnfiguration object for WebXR output canvas
  47287. */
  47288. export class WebXRManagedOutputCanvasOptions {
  47289. /**
  47290. * An optional canvas in case you wish to create it yourself and provide it here.
  47291. * If not provided, a new canvas will be created
  47292. */
  47293. canvasElement?: HTMLCanvasElement;
  47294. /**
  47295. * Options for this XR Layer output
  47296. */
  47297. canvasOptions?: XRWebGLLayerOptions;
  47298. /**
  47299. * CSS styling for a newly created canvas (if not provided)
  47300. */
  47301. newCanvasCssStyle?: string;
  47302. /**
  47303. * Get the default values of the configuration object
  47304. * @returns default values of this configuration object
  47305. */
  47306. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  47307. }
  47308. /**
  47309. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  47310. */
  47311. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  47312. private _options;
  47313. private _canvas;
  47314. private _engine;
  47315. /**
  47316. * Rendering context of the canvas which can be used to display/mirror xr content
  47317. */
  47318. canvasContext: WebGLRenderingContext;
  47319. /**
  47320. * xr layer for the canvas
  47321. */
  47322. xrLayer: Nullable<XRWebGLLayer>;
  47323. /**
  47324. * Initializes the canvas to be added/removed upon entering/exiting xr
  47325. * @param _xrSessionManager The XR Session manager
  47326. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  47327. */
  47328. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  47329. /**
  47330. * Disposes of the object
  47331. */
  47332. dispose(): void;
  47333. /**
  47334. * Initializes the xr layer for the session
  47335. * @param xrSession xr session
  47336. * @returns a promise that will resolve once the XR Layer has been created
  47337. */
  47338. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  47339. private _addCanvas;
  47340. private _removeCanvas;
  47341. private _setManagedOutputCanvas;
  47342. }
  47343. }
  47344. declare module "babylonjs/XR/webXRSessionManager" {
  47345. import { Observable } from "babylonjs/Misc/observable";
  47346. import { Nullable } from "babylonjs/types";
  47347. import { IDisposable, Scene } from "babylonjs/scene";
  47348. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  47349. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  47350. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  47351. /**
  47352. * Manages an XRSession to work with Babylon's engine
  47353. * @see https://doc.babylonjs.com/how_to/webxr
  47354. */
  47355. export class WebXRSessionManager implements IDisposable {
  47356. /** The scene which the session should be created for */
  47357. scene: Scene;
  47358. private _referenceSpace;
  47359. private _rttProvider;
  47360. private _sessionEnded;
  47361. private _xrNavigator;
  47362. private baseLayer;
  47363. /**
  47364. * The base reference space from which the session started. good if you want to reset your
  47365. * reference space
  47366. */
  47367. baseReferenceSpace: XRReferenceSpace;
  47368. /**
  47369. * Current XR frame
  47370. */
  47371. currentFrame: Nullable<XRFrame>;
  47372. /** WebXR timestamp updated every frame */
  47373. currentTimestamp: number;
  47374. /**
  47375. * Used just in case of a failure to initialize an immersive session.
  47376. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  47377. */
  47378. defaultHeightCompensation: number;
  47379. /**
  47380. * Fires every time a new xrFrame arrives which can be used to update the camera
  47381. */
  47382. onXRFrameObservable: Observable<XRFrame>;
  47383. /**
  47384. * Fires when the reference space changed
  47385. */
  47386. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  47387. /**
  47388. * Fires when the xr session is ended either by the device or manually done
  47389. */
  47390. onXRSessionEnded: Observable<any>;
  47391. /**
  47392. * Fires when the xr session is ended either by the device or manually done
  47393. */
  47394. onXRSessionInit: Observable<XRSession>;
  47395. /**
  47396. * Underlying xr session
  47397. */
  47398. session: XRSession;
  47399. /**
  47400. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  47401. * or get the offset the player is currently at.
  47402. */
  47403. viewerReferenceSpace: XRReferenceSpace;
  47404. /**
  47405. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  47406. * @param scene The scene which the session should be created for
  47407. */
  47408. constructor(
  47409. /** The scene which the session should be created for */
  47410. scene: Scene);
  47411. /**
  47412. * The current reference space used in this session. This reference space can constantly change!
  47413. * It is mainly used to offset the camera's position.
  47414. */
  47415. get referenceSpace(): XRReferenceSpace;
  47416. /**
  47417. * Set a new reference space and triggers the observable
  47418. */
  47419. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  47420. /**
  47421. * Disposes of the session manager
  47422. */
  47423. dispose(): void;
  47424. /**
  47425. * Stops the xrSession and restores the render loop
  47426. * @returns Promise which resolves after it exits XR
  47427. */
  47428. exitXRAsync(): Promise<void>;
  47429. /**
  47430. * Gets the correct render target texture to be rendered this frame for this eye
  47431. * @param eye the eye for which to get the render target
  47432. * @returns the render target for the specified eye
  47433. */
  47434. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  47435. /**
  47436. * Creates a WebXRRenderTarget object for the XR session
  47437. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  47438. * @param options optional options to provide when creating a new render target
  47439. * @returns a WebXR render target to which the session can render
  47440. */
  47441. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  47442. /**
  47443. * Initializes the manager
  47444. * After initialization enterXR can be called to start an XR session
  47445. * @returns Promise which resolves after it is initialized
  47446. */
  47447. initializeAsync(): Promise<void>;
  47448. /**
  47449. * Initializes an xr session
  47450. * @param xrSessionMode mode to initialize
  47451. * @param xrSessionInit defines optional and required values to pass to the session builder
  47452. * @returns a promise which will resolve once the session has been initialized
  47453. */
  47454. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  47455. /**
  47456. * Checks if a session would be supported for the creation options specified
  47457. * @param sessionMode session mode to check if supported eg. immersive-vr
  47458. * @returns A Promise that resolves to true if supported and false if not
  47459. */
  47460. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  47461. /**
  47462. * Resets the reference space to the one started the session
  47463. */
  47464. resetReferenceSpace(): void;
  47465. /**
  47466. * Starts rendering to the xr layer
  47467. */
  47468. runXRRenderLoop(): void;
  47469. /**
  47470. * Sets the reference space on the xr session
  47471. * @param referenceSpaceType space to set
  47472. * @returns a promise that will resolve once the reference space has been set
  47473. */
  47474. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  47475. /**
  47476. * Updates the render state of the session
  47477. * @param state state to set
  47478. * @returns a promise that resolves once the render state has been updated
  47479. */
  47480. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  47481. /**
  47482. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  47483. * @param sessionMode defines the session to test
  47484. * @returns a promise with boolean as final value
  47485. */
  47486. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  47487. private _createRenderTargetTexture;
  47488. }
  47489. }
  47490. declare module "babylonjs/XR/webXRCamera" {
  47491. import { Matrix } from "babylonjs/Maths/math.vector";
  47492. import { Scene } from "babylonjs/scene";
  47493. import { Camera } from "babylonjs/Cameras/camera";
  47494. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47495. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  47496. /**
  47497. * WebXR Camera which holds the views for the xrSession
  47498. * @see https://doc.babylonjs.com/how_to/webxr_camera
  47499. */
  47500. export class WebXRCamera extends FreeCamera {
  47501. private _xrSessionManager;
  47502. private _firstFrame;
  47503. private _referenceQuaternion;
  47504. private _referencedPosition;
  47505. private _xrInvPositionCache;
  47506. private _xrInvQuaternionCache;
  47507. /**
  47508. * Should position compensation execute on first frame.
  47509. * This is used when copying the position from a native (non XR) camera
  47510. */
  47511. compensateOnFirstFrame: boolean;
  47512. /**
  47513. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  47514. * @param name the name of the camera
  47515. * @param scene the scene to add the camera to
  47516. * @param _xrSessionManager a constructed xr session manager
  47517. */
  47518. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  47519. /**
  47520. * Return the user's height, unrelated to the current ground.
  47521. * This will be the y position of this camera, when ground level is 0.
  47522. */
  47523. get realWorldHeight(): number;
  47524. /** @hidden */
  47525. _updateForDualEyeDebugging(): void;
  47526. /**
  47527. * Sets this camera's transformation based on a non-vr camera
  47528. * @param otherCamera the non-vr camera to copy the transformation from
  47529. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  47530. */
  47531. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  47532. /**
  47533. * Gets the current instance class name ("WebXRCamera").
  47534. * @returns the class name
  47535. */
  47536. getClassName(): string;
  47537. /**
  47538. * Overriding the _getViewMatrix function, as it is computed by WebXR
  47539. */
  47540. _getViewMatrix(): Matrix;
  47541. private _updateFromXRSession;
  47542. private _updateNumberOfRigCameras;
  47543. private _updateReferenceSpace;
  47544. private _updateReferenceSpaceOffset;
  47545. }
  47546. }
  47547. declare module "babylonjs/XR/webXRFeaturesManager" {
  47548. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  47549. import { IDisposable } from "babylonjs/scene";
  47550. /**
  47551. * Defining the interface required for a (webxr) feature
  47552. */
  47553. export interface IWebXRFeature extends IDisposable {
  47554. /**
  47555. * Is this feature attached
  47556. */
  47557. attached: boolean;
  47558. /**
  47559. * Should auto-attach be disabled?
  47560. */
  47561. disableAutoAttach: boolean;
  47562. /**
  47563. * Attach the feature to the session
  47564. * Will usually be called by the features manager
  47565. *
  47566. * @param force should attachment be forced (even when already attached)
  47567. * @returns true if successful.
  47568. */
  47569. attach(force?: boolean): boolean;
  47570. /**
  47571. * Detach the feature from the session
  47572. * Will usually be called by the features manager
  47573. *
  47574. * @returns true if successful.
  47575. */
  47576. detach(): boolean;
  47577. }
  47578. /**
  47579. * A list of the currently available features without referencing them
  47580. */
  47581. export class WebXRFeatureName {
  47582. /**
  47583. * The name of the anchor system feature
  47584. */
  47585. static ANCHOR_SYSTEM: string;
  47586. /**
  47587. * The name of the background remover feature
  47588. */
  47589. static BACKGROUND_REMOVER: string;
  47590. /**
  47591. * The name of the hit test feature
  47592. */
  47593. static HIT_TEST: string;
  47594. /**
  47595. * physics impostors for xr controllers feature
  47596. */
  47597. static PHYSICS_CONTROLLERS: string;
  47598. /**
  47599. * The name of the plane detection feature
  47600. */
  47601. static PLANE_DETECTION: string;
  47602. /**
  47603. * The name of the pointer selection feature
  47604. */
  47605. static POINTER_SELECTION: string;
  47606. /**
  47607. * The name of the teleportation feature
  47608. */
  47609. static TELEPORTATION: string;
  47610. }
  47611. /**
  47612. * Defining the constructor of a feature. Used to register the modules.
  47613. */
  47614. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  47615. /**
  47616. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  47617. * It is mainly used in AR sessions.
  47618. *
  47619. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  47620. */
  47621. export class WebXRFeaturesManager implements IDisposable {
  47622. private _xrSessionManager;
  47623. private static readonly _AvailableFeatures;
  47624. private _features;
  47625. /**
  47626. * constructs a new features manages.
  47627. *
  47628. * @param _xrSessionManager an instance of WebXRSessionManager
  47629. */
  47630. constructor(_xrSessionManager: WebXRSessionManager);
  47631. /**
  47632. * Used to register a module. After calling this function a developer can use this feature in the scene.
  47633. * Mainly used internally.
  47634. *
  47635. * @param featureName the name of the feature to register
  47636. * @param constructorFunction the function used to construct the module
  47637. * @param version the (babylon) version of the module
  47638. * @param stable is that a stable version of this module
  47639. */
  47640. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  47641. /**
  47642. * Returns a constructor of a specific feature.
  47643. *
  47644. * @param featureName the name of the feature to construct
  47645. * @param version the version of the feature to load
  47646. * @param xrSessionManager the xrSessionManager. Used to construct the module
  47647. * @param options optional options provided to the module.
  47648. * @returns a function that, when called, will return a new instance of this feature
  47649. */
  47650. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  47651. /**
  47652. * Can be used to return the list of features currently registered
  47653. *
  47654. * @returns an Array of available features
  47655. */
  47656. static GetAvailableFeatures(): string[];
  47657. /**
  47658. * Gets the versions available for a specific feature
  47659. * @param featureName the name of the feature
  47660. * @returns an array with the available versions
  47661. */
  47662. static GetAvailableVersions(featureName: string): string[];
  47663. /**
  47664. * Return the latest unstable version of this feature
  47665. * @param featureName the name of the feature to search
  47666. * @returns the version number. if not found will return -1
  47667. */
  47668. static GetLatestVersionOfFeature(featureName: string): number;
  47669. /**
  47670. * Return the latest stable version of this feature
  47671. * @param featureName the name of the feature to search
  47672. * @returns the version number. if not found will return -1
  47673. */
  47674. static GetStableVersionOfFeature(featureName: string): number;
  47675. /**
  47676. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  47677. * Can be used during a session to start a feature
  47678. * @param featureName the name of feature to attach
  47679. */
  47680. attachFeature(featureName: string): void;
  47681. /**
  47682. * Can be used inside a session or when the session ends to detach a specific feature
  47683. * @param featureName the name of the feature to detach
  47684. */
  47685. detachFeature(featureName: string): void;
  47686. /**
  47687. * Used to disable an already-enabled feature
  47688. * The feature will be disposed and will be recreated once enabled.
  47689. * @param featureName the feature to disable
  47690. * @returns true if disable was successful
  47691. */
  47692. disableFeature(featureName: string | {
  47693. Name: string;
  47694. }): boolean;
  47695. /**
  47696. * dispose this features manager
  47697. */
  47698. dispose(): void;
  47699. /**
  47700. * 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.
  47701. * 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.
  47702. *
  47703. * @param featureName the name of the feature to load or the class of the feature
  47704. * @param version optional version to load. if not provided the latest version will be enabled
  47705. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  47706. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  47707. * @returns a new constructed feature or throws an error if feature not found.
  47708. */
  47709. enableFeature(featureName: string | {
  47710. Name: string;
  47711. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  47712. /**
  47713. * get the implementation of an enabled feature.
  47714. * @param featureName the name of the feature to load
  47715. * @returns the feature class, if found
  47716. */
  47717. getEnabledFeature(featureName: string): IWebXRFeature;
  47718. /**
  47719. * Get the list of enabled features
  47720. * @returns an array of enabled features
  47721. */
  47722. getEnabledFeatures(): string[];
  47723. }
  47724. }
  47725. declare module "babylonjs/XR/webXRExperienceHelper" {
  47726. import { Observable } from "babylonjs/Misc/observable";
  47727. import { IDisposable, Scene } from "babylonjs/scene";
  47728. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  47729. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  47730. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  47731. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  47732. /**
  47733. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  47734. * @see https://doc.babylonjs.com/how_to/webxr
  47735. */
  47736. export class WebXRExperienceHelper implements IDisposable {
  47737. private scene;
  47738. private _nonVRCamera;
  47739. private _originalSceneAutoClear;
  47740. private _supported;
  47741. /**
  47742. * Camera used to render xr content
  47743. */
  47744. camera: WebXRCamera;
  47745. /** A features manager for this xr session */
  47746. featuresManager: WebXRFeaturesManager;
  47747. /**
  47748. * Observers registered here will be triggered after the camera's initial transformation is set
  47749. * This can be used to set a different ground level or an extra rotation.
  47750. *
  47751. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  47752. * to the position set after this observable is done executing.
  47753. */
  47754. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  47755. /**
  47756. * Fires when the state of the experience helper has changed
  47757. */
  47758. onStateChangedObservable: Observable<WebXRState>;
  47759. /** Session manager used to keep track of xr session */
  47760. sessionManager: WebXRSessionManager;
  47761. /**
  47762. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  47763. */
  47764. state: WebXRState;
  47765. /**
  47766. * Creates a WebXRExperienceHelper
  47767. * @param scene The scene the helper should be created in
  47768. */
  47769. private constructor();
  47770. /**
  47771. * Creates the experience helper
  47772. * @param scene the scene to attach the experience helper to
  47773. * @returns a promise for the experience helper
  47774. */
  47775. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  47776. /**
  47777. * Disposes of the experience helper
  47778. */
  47779. dispose(): void;
  47780. /**
  47781. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  47782. * @param sessionMode options for the XR session
  47783. * @param referenceSpaceType frame of reference of the XR session
  47784. * @param renderTarget the output canvas that will be used to enter XR mode
  47785. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  47786. * @returns promise that resolves after xr mode has entered
  47787. */
  47788. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  47789. /**
  47790. * Exits XR mode and returns the scene to its original state
  47791. * @returns promise that resolves after xr mode has exited
  47792. */
  47793. exitXRAsync(): Promise<void>;
  47794. private _nonXRToXRCamera;
  47795. private _setState;
  47796. }
  47797. }
  47798. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  47799. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  47800. import { Observable } from "babylonjs/Misc/observable";
  47801. import { IDisposable } from "babylonjs/scene";
  47802. /**
  47803. * X-Y values for axes in WebXR
  47804. */
  47805. export interface IWebXRMotionControllerAxesValue {
  47806. /**
  47807. * The value of the x axis
  47808. */
  47809. x: number;
  47810. /**
  47811. * The value of the y-axis
  47812. */
  47813. y: number;
  47814. }
  47815. /**
  47816. * changed / previous values for the values of this component
  47817. */
  47818. export interface IWebXRMotionControllerComponentChangesValues<T> {
  47819. /**
  47820. * current (this frame) value
  47821. */
  47822. current: T;
  47823. /**
  47824. * previous (last change) value
  47825. */
  47826. previous: T;
  47827. }
  47828. /**
  47829. * Represents changes in the component between current frame and last values recorded
  47830. */
  47831. export interface IWebXRMotionControllerComponentChanges {
  47832. /**
  47833. * will be populated with previous and current values if axes changed
  47834. */
  47835. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  47836. /**
  47837. * will be populated with previous and current values if pressed changed
  47838. */
  47839. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  47840. /**
  47841. * will be populated with previous and current values if touched changed
  47842. */
  47843. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  47844. /**
  47845. * will be populated with previous and current values if value changed
  47846. */
  47847. value?: IWebXRMotionControllerComponentChangesValues<number>;
  47848. }
  47849. /**
  47850. * This class represents a single component (for example button or thumbstick) of a motion controller
  47851. */
  47852. export class WebXRControllerComponent implements IDisposable {
  47853. /**
  47854. * the id of this component
  47855. */
  47856. id: string;
  47857. /**
  47858. * the type of the component
  47859. */
  47860. type: MotionControllerComponentType;
  47861. private _buttonIndex;
  47862. private _axesIndices;
  47863. private _axes;
  47864. private _changes;
  47865. private _currentValue;
  47866. private _hasChanges;
  47867. private _pressed;
  47868. private _touched;
  47869. /**
  47870. * button component type
  47871. */
  47872. static BUTTON_TYPE: MotionControllerComponentType;
  47873. /**
  47874. * squeeze component type
  47875. */
  47876. static SQUEEZE_TYPE: MotionControllerComponentType;
  47877. /**
  47878. * Thumbstick component type
  47879. */
  47880. static THUMBSTICK_TYPE: MotionControllerComponentType;
  47881. /**
  47882. * Touchpad component type
  47883. */
  47884. static TOUCHPAD_TYPE: MotionControllerComponentType;
  47885. /**
  47886. * trigger component type
  47887. */
  47888. static TRIGGER_TYPE: MotionControllerComponentType;
  47889. /**
  47890. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  47891. * the axes data changes
  47892. */
  47893. onAxisValueChangedObservable: Observable<{
  47894. x: number;
  47895. y: number;
  47896. }>;
  47897. /**
  47898. * Observers registered here will be triggered when the state of a button changes
  47899. * State change is either pressed / touched / value
  47900. */
  47901. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  47902. /**
  47903. * Creates a new component for a motion controller.
  47904. * It is created by the motion controller itself
  47905. *
  47906. * @param id the id of this component
  47907. * @param type the type of the component
  47908. * @param _buttonIndex index in the buttons array of the gamepad
  47909. * @param _axesIndices indices of the values in the axes array of the gamepad
  47910. */
  47911. constructor(
  47912. /**
  47913. * the id of this component
  47914. */
  47915. id: string,
  47916. /**
  47917. * the type of the component
  47918. */
  47919. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  47920. /**
  47921. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  47922. */
  47923. get axes(): IWebXRMotionControllerAxesValue;
  47924. /**
  47925. * Get the changes. Elements will be populated only if they changed with their previous and current value
  47926. */
  47927. get changes(): IWebXRMotionControllerComponentChanges;
  47928. /**
  47929. * Return whether or not the component changed the last frame
  47930. */
  47931. get hasChanges(): boolean;
  47932. /**
  47933. * is the button currently pressed
  47934. */
  47935. get pressed(): boolean;
  47936. /**
  47937. * is the button currently touched
  47938. */
  47939. get touched(): boolean;
  47940. /**
  47941. * Get the current value of this component
  47942. */
  47943. get value(): number;
  47944. /**
  47945. * Dispose this component
  47946. */
  47947. dispose(): void;
  47948. /**
  47949. * Are there axes correlating to this component
  47950. * @return true is axes data is available
  47951. */
  47952. isAxes(): boolean;
  47953. /**
  47954. * Is this component a button (hence - pressable)
  47955. * @returns true if can be pressed
  47956. */
  47957. isButton(): boolean;
  47958. /**
  47959. * update this component using the gamepad object it is in. Called on every frame
  47960. * @param nativeController the native gamepad controller object
  47961. */
  47962. update(nativeController: IMinimalMotionControllerObject): void;
  47963. }
  47964. }
  47965. declare module "babylonjs/Loading/sceneLoader" {
  47966. import { Observable } from "babylonjs/Misc/observable";
  47967. import { Nullable } from "babylonjs/types";
  47968. import { Scene } from "babylonjs/scene";
  47969. import { Engine } from "babylonjs/Engines/engine";
  47970. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47971. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  47972. import { AssetContainer } from "babylonjs/assetContainer";
  47973. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  47974. import { Skeleton } from "babylonjs/Bones/skeleton";
  47975. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  47976. import { WebRequest } from "babylonjs/Misc/webRequest";
  47977. /**
  47978. * Class used to represent data loading progression
  47979. */
  47980. export class SceneLoaderProgressEvent {
  47981. /** defines if data length to load can be evaluated */
  47982. readonly lengthComputable: boolean;
  47983. /** defines the loaded data length */
  47984. readonly loaded: number;
  47985. /** defines the data length to load */
  47986. readonly total: number;
  47987. /**
  47988. * Create a new progress event
  47989. * @param lengthComputable defines if data length to load can be evaluated
  47990. * @param loaded defines the loaded data length
  47991. * @param total defines the data length to load
  47992. */
  47993. constructor(
  47994. /** defines if data length to load can be evaluated */
  47995. lengthComputable: boolean,
  47996. /** defines the loaded data length */
  47997. loaded: number,
  47998. /** defines the data length to load */
  47999. total: number);
  48000. /**
  48001. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  48002. * @param event defines the source event
  48003. * @returns a new SceneLoaderProgressEvent
  48004. */
  48005. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  48006. }
  48007. /**
  48008. * Interface used by SceneLoader plugins to define supported file extensions
  48009. */
  48010. export interface ISceneLoaderPluginExtensions {
  48011. /**
  48012. * Defines the list of supported extensions
  48013. */
  48014. [extension: string]: {
  48015. isBinary: boolean;
  48016. };
  48017. }
  48018. /**
  48019. * Interface used by SceneLoader plugin factory
  48020. */
  48021. export interface ISceneLoaderPluginFactory {
  48022. /**
  48023. * Defines the name of the factory
  48024. */
  48025. name: string;
  48026. /**
  48027. * Function called to create a new plugin
  48028. * @return the new plugin
  48029. */
  48030. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  48031. /**
  48032. * The callback that returns true if the data can be directly loaded.
  48033. * @param data string containing the file data
  48034. * @returns if the data can be loaded directly
  48035. */
  48036. canDirectLoad?(data: string): boolean;
  48037. }
  48038. /**
  48039. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  48040. */
  48041. export interface ISceneLoaderPluginBase {
  48042. /**
  48043. * The friendly name of this plugin.
  48044. */
  48045. name: string;
  48046. /**
  48047. * The file extensions supported by this plugin.
  48048. */
  48049. extensions: string | ISceneLoaderPluginExtensions;
  48050. /**
  48051. * The callback called when loading from a url.
  48052. * @param scene scene loading this url
  48053. * @param url url to load
  48054. * @param onSuccess callback called when the file successfully loads
  48055. * @param onProgress callback called while file is loading (if the server supports this mode)
  48056. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  48057. * @param onError callback called when the file fails to load
  48058. * @returns a file request object
  48059. */
  48060. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  48061. /**
  48062. * The callback called when loading from a file object.
  48063. * @param scene scene loading this file
  48064. * @param file defines the file to load
  48065. * @param onSuccess defines the callback to call when data is loaded
  48066. * @param onProgress defines the callback to call during loading process
  48067. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  48068. * @param onError defines the callback to call when an error occurs
  48069. * @returns a file request object
  48070. */
  48071. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  48072. /**
  48073. * The callback that returns true if the data can be directly loaded.
  48074. * @param data string containing the file data
  48075. * @returns if the data can be loaded directly
  48076. */
  48077. canDirectLoad?(data: string): boolean;
  48078. /**
  48079. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  48080. * @param scene scene loading this data
  48081. * @param data string containing the data
  48082. * @returns data to pass to the plugin
  48083. */
  48084. directLoad?(scene: Scene, data: string): any;
  48085. /**
  48086. * The callback that allows custom handling of the root url based on the response url.
  48087. * @param rootUrl the original root url
  48088. * @param responseURL the response url if available
  48089. * @returns the new root url
  48090. */
  48091. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  48092. }
  48093. /**
  48094. * Interface used to define a SceneLoader plugin
  48095. */
  48096. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  48097. /**
  48098. * Import meshes into a scene.
  48099. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48100. * @param scene The scene to import into
  48101. * @param data The data to import
  48102. * @param rootUrl The root url for scene and resources
  48103. * @param meshes The meshes array to import into
  48104. * @param particleSystems The particle systems array to import into
  48105. * @param skeletons The skeletons array to import into
  48106. * @param onError The callback when import fails
  48107. * @returns True if successful or false otherwise
  48108. */
  48109. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  48110. /**
  48111. * Load into a scene.
  48112. * @param scene The scene to load into
  48113. * @param data The data to import
  48114. * @param rootUrl The root url for scene and resources
  48115. * @param onError The callback when import fails
  48116. * @returns True if successful or false otherwise
  48117. */
  48118. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  48119. /**
  48120. * Load into an asset container.
  48121. * @param scene The scene to load into
  48122. * @param data The data to import
  48123. * @param rootUrl The root url for scene and resources
  48124. * @param onError The callback when import fails
  48125. * @returns The loaded asset container
  48126. */
  48127. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  48128. }
  48129. /**
  48130. * Interface used to define an async SceneLoader plugin
  48131. */
  48132. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  48133. /**
  48134. * Import meshes into a scene.
  48135. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48136. * @param scene The scene to import into
  48137. * @param data The data to import
  48138. * @param rootUrl The root url for scene and resources
  48139. * @param onProgress The callback when the load progresses
  48140. * @param fileName Defines the name of the file to load
  48141. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  48142. */
  48143. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  48144. meshes: AbstractMesh[];
  48145. particleSystems: IParticleSystem[];
  48146. skeletons: Skeleton[];
  48147. animationGroups: AnimationGroup[];
  48148. }>;
  48149. /**
  48150. * Load into a scene.
  48151. * @param scene The scene to load into
  48152. * @param data The data to import
  48153. * @param rootUrl The root url for scene and resources
  48154. * @param onProgress The callback when the load progresses
  48155. * @param fileName Defines the name of the file to load
  48156. * @returns Nothing
  48157. */
  48158. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  48159. /**
  48160. * Load into an asset container.
  48161. * @param scene The scene to load into
  48162. * @param data The data to import
  48163. * @param rootUrl The root url for scene and resources
  48164. * @param onProgress The callback when the load progresses
  48165. * @param fileName Defines the name of the file to load
  48166. * @returns The loaded asset container
  48167. */
  48168. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  48169. }
  48170. /**
  48171. * Mode that determines how to handle old animation groups before loading new ones.
  48172. */
  48173. export enum SceneLoaderAnimationGroupLoadingMode {
  48174. /**
  48175. * Reset all old animations to initial state then dispose them.
  48176. */
  48177. Clean = 0,
  48178. /**
  48179. * Stop all old animations.
  48180. */
  48181. Stop = 1,
  48182. /**
  48183. * Restart old animations from first frame.
  48184. */
  48185. Sync = 2,
  48186. /**
  48187. * Old animations remains untouched.
  48188. */
  48189. NoSync = 3
  48190. }
  48191. /**
  48192. * Class used to load scene from various file formats using registered plugins
  48193. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  48194. */
  48195. export class SceneLoader {
  48196. /**
  48197. * No logging while loading
  48198. */
  48199. static readonly NO_LOGGING: number;
  48200. /**
  48201. * Minimal logging while loading
  48202. */
  48203. static readonly MINIMAL_LOGGING: number;
  48204. /**
  48205. * Summary logging while loading
  48206. */
  48207. static readonly SUMMARY_LOGGING: number;
  48208. /**
  48209. * Detailled logging while loading
  48210. */
  48211. static readonly DETAILED_LOGGING: number;
  48212. /**
  48213. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  48214. */
  48215. static get ForceFullSceneLoadingForIncremental(): boolean;
  48216. static set ForceFullSceneLoadingForIncremental(value: boolean);
  48217. /**
  48218. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  48219. */
  48220. static get ShowLoadingScreen(): boolean;
  48221. static set ShowLoadingScreen(value: boolean);
  48222. /**
  48223. * Defines the current logging level (while loading the scene)
  48224. * @ignorenaming
  48225. */
  48226. static get loggingLevel(): number;
  48227. static set loggingLevel(value: number);
  48228. /**
  48229. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  48230. */
  48231. static get CleanBoneMatrixWeights(): boolean;
  48232. static set CleanBoneMatrixWeights(value: boolean);
  48233. /**
  48234. * Event raised when a plugin is used to load a scene
  48235. */
  48236. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  48237. private static _registeredPlugins;
  48238. private static _getDefaultPlugin;
  48239. private static _getPluginForExtension;
  48240. private static _getPluginForDirectLoad;
  48241. private static _getPluginForFilename;
  48242. private static _getDirectLoad;
  48243. private static _loadData;
  48244. private static _getFileInfo;
  48245. /**
  48246. * Gets a plugin that can load the given extension
  48247. * @param extension defines the extension to load
  48248. * @returns a plugin or null if none works
  48249. */
  48250. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  48251. /**
  48252. * Gets a boolean indicating that the given extension can be loaded
  48253. * @param extension defines the extension to load
  48254. * @returns true if the extension is supported
  48255. */
  48256. static IsPluginForExtensionAvailable(extension: string): boolean;
  48257. /**
  48258. * Adds a new plugin to the list of registered plugins
  48259. * @param plugin defines the plugin to add
  48260. */
  48261. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  48262. /**
  48263. * Import meshes into a scene
  48264. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48265. * @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)
  48266. * @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)
  48267. * @param scene the instance of BABYLON.Scene to append to
  48268. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  48269. * @param onProgress a callback with a progress event for each file being loaded
  48270. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48271. * @param pluginExtension the extension used to determine the plugin
  48272. * @returns The loaded plugin
  48273. */
  48274. 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>;
  48275. /**
  48276. * Import meshes into a scene
  48277. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48278. * @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)
  48279. * @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)
  48280. * @param scene the instance of BABYLON.Scene to append to
  48281. * @param onProgress a callback with a progress event for each file being loaded
  48282. * @param pluginExtension the extension used to determine the plugin
  48283. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  48284. */
  48285. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  48286. meshes: AbstractMesh[];
  48287. particleSystems: IParticleSystem[];
  48288. skeletons: Skeleton[];
  48289. animationGroups: AnimationGroup[];
  48290. }>;
  48291. /**
  48292. * Load a scene
  48293. * @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)
  48294. * @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)
  48295. * @param engine is the instance of BABYLON.Engine to use to create the scene
  48296. * @param onSuccess a callback with the scene when import succeeds
  48297. * @param onProgress a callback with a progress event for each file being loaded
  48298. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48299. * @param pluginExtension the extension used to determine the plugin
  48300. * @returns The loaded plugin
  48301. */
  48302. 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>;
  48303. /**
  48304. * Load a scene
  48305. * @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)
  48306. * @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)
  48307. * @param engine is the instance of BABYLON.Engine to use to create the scene
  48308. * @param onProgress a callback with a progress event for each file being loaded
  48309. * @param pluginExtension the extension used to determine the plugin
  48310. * @returns The loaded scene
  48311. */
  48312. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  48313. /**
  48314. * Append a scene
  48315. * @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)
  48316. * @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)
  48317. * @param scene is the instance of BABYLON.Scene to append to
  48318. * @param onSuccess a callback with the scene when import succeeds
  48319. * @param onProgress a callback with a progress event for each file being loaded
  48320. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48321. * @param pluginExtension the extension used to determine the plugin
  48322. * @returns The loaded plugin
  48323. */
  48324. 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>;
  48325. /**
  48326. * Append a scene
  48327. * @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)
  48328. * @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)
  48329. * @param scene is the instance of BABYLON.Scene to append to
  48330. * @param onProgress a callback with a progress event for each file being loaded
  48331. * @param pluginExtension the extension used to determine the plugin
  48332. * @returns The given scene
  48333. */
  48334. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  48335. /**
  48336. * Load a scene into an asset container
  48337. * @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)
  48338. * @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)
  48339. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48340. * @param onSuccess a callback with the scene when import succeeds
  48341. * @param onProgress a callback with a progress event for each file being loaded
  48342. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48343. * @param pluginExtension the extension used to determine the plugin
  48344. * @returns The loaded plugin
  48345. */
  48346. 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>;
  48347. /**
  48348. * Load a scene into an asset container
  48349. * @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)
  48350. * @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)
  48351. * @param scene is the instance of Scene to append to
  48352. * @param onProgress a callback with a progress event for each file being loaded
  48353. * @param pluginExtension the extension used to determine the plugin
  48354. * @returns The loaded asset container
  48355. */
  48356. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  48357. /**
  48358. * Import animations from a file into a scene
  48359. * @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)
  48360. * @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)
  48361. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48362. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  48363. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  48364. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  48365. * @param onSuccess a callback with the scene when import succeeds
  48366. * @param onProgress a callback with a progress event for each file being loaded
  48367. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48368. */
  48369. 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;
  48370. /**
  48371. * Import animations from a file into a scene
  48372. * @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)
  48373. * @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)
  48374. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48375. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  48376. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  48377. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  48378. * @param onSuccess a callback with the scene when import succeeds
  48379. * @param onProgress a callback with a progress event for each file being loaded
  48380. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48381. * @returns the updated scene with imported animations
  48382. */
  48383. 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>;
  48384. }
  48385. }
  48386. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  48387. import { IDisposable, Scene } from "babylonjs/scene";
  48388. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  48389. import { Observable } from "babylonjs/Misc/observable";
  48390. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48391. import { Nullable } from "babylonjs/types";
  48392. /**
  48393. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  48394. */
  48395. export type MotionControllerHandedness = "none" | "left" | "right";
  48396. /**
  48397. * The type of components available in motion controllers.
  48398. * This is not the name of the component.
  48399. */
  48400. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  48401. /**
  48402. * The state of a controller component
  48403. */
  48404. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  48405. /**
  48406. * The schema of motion controller layout.
  48407. * No object will be initialized using this interface
  48408. * This is used just to define the profile.
  48409. */
  48410. export interface IMotionControllerLayout {
  48411. /**
  48412. * Path to load the assets. Usually relative to the base path
  48413. */
  48414. assetPath: string;
  48415. /**
  48416. * Available components (unsorted)
  48417. */
  48418. components: {
  48419. /**
  48420. * A map of component Ids
  48421. */
  48422. [componentId: string]: {
  48423. /**
  48424. * The type of input the component outputs
  48425. */
  48426. type: MotionControllerComponentType;
  48427. /**
  48428. * The indices of this component in the gamepad object
  48429. */
  48430. gamepadIndices: {
  48431. /**
  48432. * Index of button
  48433. */
  48434. button?: number;
  48435. /**
  48436. * If available, index of x-axis
  48437. */
  48438. xAxis?: number;
  48439. /**
  48440. * If available, index of y-axis
  48441. */
  48442. yAxis?: number;
  48443. };
  48444. /**
  48445. * The mesh's root node name
  48446. */
  48447. rootNodeName: string;
  48448. /**
  48449. * Animation definitions for this model
  48450. */
  48451. visualResponses: {
  48452. [stateKey: string]: {
  48453. /**
  48454. * What property will be animated
  48455. */
  48456. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  48457. /**
  48458. * What states influence this visual response
  48459. */
  48460. states: MotionControllerComponentStateType[];
  48461. /**
  48462. * Type of animation - movement or visibility
  48463. */
  48464. valueNodeProperty: "transform" | "visibility";
  48465. /**
  48466. * Base node name to move. Its position will be calculated according to the min and max nodes
  48467. */
  48468. valueNodeName?: string;
  48469. /**
  48470. * Minimum movement node
  48471. */
  48472. minNodeName?: string;
  48473. /**
  48474. * Max movement node
  48475. */
  48476. maxNodeName?: string;
  48477. };
  48478. };
  48479. /**
  48480. * If touch enabled, what is the name of node to display user feedback
  48481. */
  48482. touchPointNodeName?: string;
  48483. };
  48484. };
  48485. /**
  48486. * Is it xr standard mapping or not
  48487. */
  48488. gamepadMapping: "" | "xr-standard";
  48489. /**
  48490. * Base root node of this entire model
  48491. */
  48492. rootNodeName: string;
  48493. /**
  48494. * Defines the main button component id
  48495. */
  48496. selectComponentId: string;
  48497. }
  48498. /**
  48499. * A definition for the layout map in the input profile
  48500. */
  48501. export interface IMotionControllerLayoutMap {
  48502. /**
  48503. * Layouts with handedness type as a key
  48504. */
  48505. [handedness: string]: IMotionControllerLayout;
  48506. }
  48507. /**
  48508. * The XR Input profile schema
  48509. * Profiles can be found here:
  48510. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  48511. */
  48512. export interface IMotionControllerProfile {
  48513. /**
  48514. * fallback profiles for this profileId
  48515. */
  48516. fallbackProfileIds: string[];
  48517. /**
  48518. * The layout map, with handedness as key
  48519. */
  48520. layouts: IMotionControllerLayoutMap;
  48521. /**
  48522. * The id of this profile
  48523. * correlates to the profile(s) in the xrInput.profiles array
  48524. */
  48525. profileId: string;
  48526. }
  48527. /**
  48528. * A helper-interface for the 3 meshes needed for controller button animation
  48529. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  48530. */
  48531. export interface IMotionControllerButtonMeshMap {
  48532. /**
  48533. * the mesh that defines the pressed value mesh position.
  48534. * This is used to find the max-position of this button
  48535. */
  48536. pressedMesh: AbstractMesh;
  48537. /**
  48538. * the mesh that defines the unpressed value mesh position.
  48539. * This is used to find the min (or initial) position of this button
  48540. */
  48541. unpressedMesh: AbstractMesh;
  48542. /**
  48543. * The mesh that will be changed when value changes
  48544. */
  48545. valueMesh: AbstractMesh;
  48546. }
  48547. /**
  48548. * A helper-interface for the 3 meshes needed for controller axis animation.
  48549. * This will be expanded when touchpad animations are fully supported
  48550. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  48551. */
  48552. export interface IMotionControllerMeshMap {
  48553. /**
  48554. * the mesh that defines the maximum value mesh position.
  48555. */
  48556. maxMesh?: AbstractMesh;
  48557. /**
  48558. * the mesh that defines the minimum value mesh position.
  48559. */
  48560. minMesh?: AbstractMesh;
  48561. /**
  48562. * The mesh that will be changed when axis value changes
  48563. */
  48564. valueMesh: AbstractMesh;
  48565. }
  48566. /**
  48567. * The elements needed for change-detection of the gamepad objects in motion controllers
  48568. */
  48569. export interface IMinimalMotionControllerObject {
  48570. /**
  48571. * Available axes of this controller
  48572. */
  48573. axes: number[];
  48574. /**
  48575. * An array of available buttons
  48576. */
  48577. buttons: Array<{
  48578. /**
  48579. * Value of the button/trigger
  48580. */
  48581. value: number;
  48582. /**
  48583. * If the button/trigger is currently touched
  48584. */
  48585. touched: boolean;
  48586. /**
  48587. * If the button/trigger is currently pressed
  48588. */
  48589. pressed: boolean;
  48590. }>;
  48591. /**
  48592. * EXPERIMENTAL haptic support.
  48593. */
  48594. hapticActuators?: Array<{
  48595. pulse: (value: number, duration: number) => Promise<boolean>;
  48596. }>;
  48597. }
  48598. /**
  48599. * An Abstract Motion controller
  48600. * This class receives an xrInput and a profile layout and uses those to initialize the components
  48601. * Each component has an observable to check for changes in value and state
  48602. */
  48603. export abstract class WebXRAbstractMotionController implements IDisposable {
  48604. protected scene: Scene;
  48605. protected layout: IMotionControllerLayout;
  48606. /**
  48607. * The gamepad object correlating to this controller
  48608. */
  48609. gamepadObject: IMinimalMotionControllerObject;
  48610. /**
  48611. * handedness (left/right/none) of this controller
  48612. */
  48613. handedness: MotionControllerHandedness;
  48614. private _initComponent;
  48615. private _modelReady;
  48616. /**
  48617. * A map of components (WebXRControllerComponent) in this motion controller
  48618. * Components have a ComponentType and can also have both button and axis definitions
  48619. */
  48620. readonly components: {
  48621. [id: string]: WebXRControllerComponent;
  48622. };
  48623. /**
  48624. * Disable the model's animation. Can be set at any time.
  48625. */
  48626. disableAnimation: boolean;
  48627. /**
  48628. * Observers registered here will be triggered when the model of this controller is done loading
  48629. */
  48630. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  48631. /**
  48632. * The profile id of this motion controller
  48633. */
  48634. abstract profileId: string;
  48635. /**
  48636. * The root mesh of the model. It is null if the model was not yet initialized
  48637. */
  48638. rootMesh: Nullable<AbstractMesh>;
  48639. /**
  48640. * constructs a new abstract motion controller
  48641. * @param scene the scene to which the model of the controller will be added
  48642. * @param layout The profile layout to load
  48643. * @param gamepadObject The gamepad object correlating to this controller
  48644. * @param handedness handedness (left/right/none) of this controller
  48645. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  48646. */
  48647. constructor(scene: Scene, layout: IMotionControllerLayout,
  48648. /**
  48649. * The gamepad object correlating to this controller
  48650. */
  48651. gamepadObject: IMinimalMotionControllerObject,
  48652. /**
  48653. * handedness (left/right/none) of this controller
  48654. */
  48655. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  48656. /**
  48657. * Dispose this controller, the model mesh and all its components
  48658. */
  48659. dispose(): void;
  48660. /**
  48661. * Returns all components of specific type
  48662. * @param type the type to search for
  48663. * @return an array of components with this type
  48664. */
  48665. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  48666. /**
  48667. * get a component based an its component id as defined in layout.components
  48668. * @param id the id of the component
  48669. * @returns the component correlates to the id or undefined if not found
  48670. */
  48671. getComponent(id: string): WebXRControllerComponent;
  48672. /**
  48673. * Get the list of components available in this motion controller
  48674. * @returns an array of strings correlating to available components
  48675. */
  48676. getComponentIds(): string[];
  48677. /**
  48678. * Get the first component of specific type
  48679. * @param type type of component to find
  48680. * @return a controller component or null if not found
  48681. */
  48682. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  48683. /**
  48684. * Get the main (Select) component of this controller as defined in the layout
  48685. * @returns the main component of this controller
  48686. */
  48687. getMainComponent(): WebXRControllerComponent;
  48688. /**
  48689. * Loads the model correlating to this controller
  48690. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  48691. * @returns A promise fulfilled with the result of the model loading
  48692. */
  48693. loadModel(): Promise<boolean>;
  48694. /**
  48695. * Update this model using the current XRFrame
  48696. * @param xrFrame the current xr frame to use and update the model
  48697. */
  48698. updateFromXRFrame(xrFrame: XRFrame): void;
  48699. /**
  48700. * Backwards compatibility due to a deeply-integrated typo
  48701. */
  48702. get handness(): XREye;
  48703. /**
  48704. * Pulse (vibrate) this controller
  48705. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  48706. * Consecutive calls to this function will cancel the last pulse call
  48707. *
  48708. * @param value the strength of the pulse in 0.0...1.0 range
  48709. * @param duration Duration of the pulse in milliseconds
  48710. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  48711. * @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
  48712. */
  48713. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  48714. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  48715. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  48716. /**
  48717. * Moves the axis on the controller mesh based on its current state
  48718. * @param axis the index of the axis
  48719. * @param axisValue the value of the axis which determines the meshes new position
  48720. * @hidden
  48721. */
  48722. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  48723. /**
  48724. * Update the model itself with the current frame data
  48725. * @param xrFrame the frame to use for updating the model mesh
  48726. */
  48727. protected updateModel(xrFrame: XRFrame): void;
  48728. /**
  48729. * Get the filename and path for this controller's model
  48730. * @returns a map of filename and path
  48731. */
  48732. protected abstract _getFilenameAndPath(): {
  48733. filename: string;
  48734. path: string;
  48735. };
  48736. /**
  48737. * This function is called before the mesh is loaded. It checks for loading constraints.
  48738. * For example, this function can check if the GLB loader is available
  48739. * If this function returns false, the generic controller will be loaded instead
  48740. * @returns Is the client ready to load the mesh
  48741. */
  48742. protected abstract _getModelLoadingConstraints(): boolean;
  48743. /**
  48744. * This function will be called after the model was successfully loaded and can be used
  48745. * for mesh transformations before it is available for the user
  48746. * @param meshes the loaded meshes
  48747. */
  48748. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  48749. /**
  48750. * Set the root mesh for this controller. Important for the WebXR controller class
  48751. * @param meshes the loaded meshes
  48752. */
  48753. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  48754. /**
  48755. * A function executed each frame that updates the mesh (if needed)
  48756. * @param xrFrame the current xrFrame
  48757. */
  48758. protected abstract _updateModel(xrFrame: XRFrame): void;
  48759. private _getGenericFilenameAndPath;
  48760. private _getGenericParentMesh;
  48761. }
  48762. }
  48763. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  48764. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  48765. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48766. import { Scene } from "babylonjs/scene";
  48767. /**
  48768. * A generic trigger-only motion controller for WebXR
  48769. */
  48770. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  48771. /**
  48772. * Static version of the profile id of this controller
  48773. */
  48774. static ProfileId: string;
  48775. profileId: string;
  48776. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  48777. protected _getFilenameAndPath(): {
  48778. filename: string;
  48779. path: string;
  48780. };
  48781. protected _getModelLoadingConstraints(): boolean;
  48782. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  48783. protected _setRootMesh(meshes: AbstractMesh[]): void;
  48784. protected _updateModel(): void;
  48785. }
  48786. }
  48787. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  48788. import { Vector4 } from "babylonjs/Maths/math.vector";
  48789. import { Mesh } from "babylonjs/Meshes/mesh";
  48790. import { Scene } from "babylonjs/scene";
  48791. import { Nullable } from "babylonjs/types";
  48792. /**
  48793. * Class containing static functions to help procedurally build meshes
  48794. */
  48795. export class SphereBuilder {
  48796. /**
  48797. * Creates a sphere mesh
  48798. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  48799. * * 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`)
  48800. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  48801. * * 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
  48802. * * 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)
  48803. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48804. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48805. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48806. * @param name defines the name of the mesh
  48807. * @param options defines the options used to create the mesh
  48808. * @param scene defines the hosting scene
  48809. * @returns the sphere mesh
  48810. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  48811. */
  48812. static CreateSphere(name: string, options: {
  48813. segments?: number;
  48814. diameter?: number;
  48815. diameterX?: number;
  48816. diameterY?: number;
  48817. diameterZ?: number;
  48818. arc?: number;
  48819. slice?: number;
  48820. sideOrientation?: number;
  48821. frontUVs?: Vector4;
  48822. backUVs?: Vector4;
  48823. updatable?: boolean;
  48824. }, scene?: Nullable<Scene>): Mesh;
  48825. }
  48826. }
  48827. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  48828. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48829. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  48830. import { Scene } from "babylonjs/scene";
  48831. /**
  48832. * A profiled motion controller has its profile loaded from an online repository.
  48833. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  48834. */
  48835. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  48836. private _repositoryUrl;
  48837. private _buttonMeshMapping;
  48838. private _touchDots;
  48839. /**
  48840. * The profile ID of this controller. Will be populated when the controller initializes.
  48841. */
  48842. profileId: string;
  48843. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  48844. dispose(): void;
  48845. protected _getFilenameAndPath(): {
  48846. filename: string;
  48847. path: string;
  48848. };
  48849. protected _getModelLoadingConstraints(): boolean;
  48850. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  48851. protected _setRootMesh(meshes: AbstractMesh[]): void;
  48852. protected _updateModel(_xrFrame: XRFrame): void;
  48853. }
  48854. }
  48855. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  48856. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  48857. import { Scene } from "babylonjs/scene";
  48858. /**
  48859. * A construction function type to create a new controller based on an xrInput object
  48860. */
  48861. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  48862. /**
  48863. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  48864. *
  48865. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  48866. * it should be replaced with auto-loaded controllers.
  48867. *
  48868. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  48869. */
  48870. export class WebXRMotionControllerManager {
  48871. private static _AvailableControllers;
  48872. private static _Fallbacks;
  48873. private static _ProfileLoadingPromises;
  48874. private static _ProfilesList;
  48875. /**
  48876. * The base URL of the online controller repository. Can be changed at any time.
  48877. */
  48878. static BaseRepositoryUrl: string;
  48879. /**
  48880. * Which repository gets priority - local or online
  48881. */
  48882. static PrioritizeOnlineRepository: boolean;
  48883. /**
  48884. * Use the online repository, or use only locally-defined controllers
  48885. */
  48886. static UseOnlineRepository: boolean;
  48887. /**
  48888. * Clear the cache used for profile loading and reload when requested again
  48889. */
  48890. static ClearProfilesCache(): void;
  48891. /**
  48892. * Register the default fallbacks.
  48893. * This function is called automatically when this file is imported.
  48894. */
  48895. static DefaultFallbacks(): void;
  48896. /**
  48897. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  48898. * @param profileId the profile to which a fallback needs to be found
  48899. * @return an array with corresponding fallback profiles
  48900. */
  48901. static FindFallbackWithProfileId(profileId: string): string[];
  48902. /**
  48903. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  48904. * The order of search:
  48905. *
  48906. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  48907. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  48908. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  48909. * 4) return the generic trigger controller if none were found
  48910. *
  48911. * @param xrInput the xrInput to which a new controller is initialized
  48912. * @param scene the scene to which the model will be added
  48913. * @param forceProfile force a certain profile for this controller
  48914. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  48915. */
  48916. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  48917. /**
  48918. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  48919. *
  48920. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  48921. *
  48922. * @param type the profile type to register
  48923. * @param constructFunction the function to be called when loading this profile
  48924. */
  48925. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  48926. /**
  48927. * Register a fallback to a specific profile.
  48928. * @param profileId the profileId that will receive the fallbacks
  48929. * @param fallbacks A list of fallback profiles
  48930. */
  48931. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  48932. /**
  48933. * Will update the list of profiles available in the repository
  48934. * @return a promise that resolves to a map of profiles available online
  48935. */
  48936. static UpdateProfilesList(): Promise<{
  48937. [profile: string]: string;
  48938. }>;
  48939. private static _LoadProfileFromRepository;
  48940. private static _LoadProfilesFromAvailableControllers;
  48941. }
  48942. }
  48943. declare module "babylonjs/XR/webXRInputSource" {
  48944. import { Observable } from "babylonjs/Misc/observable";
  48945. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48946. import { Ray } from "babylonjs/Culling/ray";
  48947. import { Scene } from "babylonjs/scene";
  48948. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  48949. /**
  48950. * Configuration options for the WebXR controller creation
  48951. */
  48952. export interface IWebXRControllerOptions {
  48953. /**
  48954. * Should the controller mesh be animated when a user interacts with it
  48955. * The pressed buttons / thumbstick and touchpad animations will be disabled
  48956. */
  48957. disableMotionControllerAnimation?: boolean;
  48958. /**
  48959. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  48960. */
  48961. doNotLoadControllerMesh?: boolean;
  48962. /**
  48963. * Force a specific controller type for this controller.
  48964. * This can be used when creating your own profile or when testing different controllers
  48965. */
  48966. forceControllerProfile?: string;
  48967. /**
  48968. * Defines a rendering group ID for meshes that will be loaded.
  48969. * This is for the default controllers only.
  48970. */
  48971. renderingGroupId?: number;
  48972. }
  48973. /**
  48974. * Represents an XR controller
  48975. */
  48976. export class WebXRInputSource {
  48977. private _scene;
  48978. /** The underlying input source for the controller */
  48979. inputSource: XRInputSource;
  48980. private _options;
  48981. private _tmpVector;
  48982. private _uniqueId;
  48983. /**
  48984. * 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
  48985. */
  48986. grip?: AbstractMesh;
  48987. /**
  48988. * If available, this is the gamepad object related to this controller.
  48989. * Using this object it is possible to get click events and trackpad changes of the
  48990. * webxr controller that is currently being used.
  48991. */
  48992. motionController?: WebXRAbstractMotionController;
  48993. /**
  48994. * Event that fires when the controller is removed/disposed.
  48995. * The object provided as event data is this controller, after associated assets were disposed.
  48996. * uniqueId is still available.
  48997. */
  48998. onDisposeObservable: Observable<WebXRInputSource>;
  48999. /**
  49000. * Will be triggered when the mesh associated with the motion controller is done loading.
  49001. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  49002. * A shortened version of controller -> motion controller -> on mesh loaded.
  49003. */
  49004. onMeshLoadedObservable: Observable<AbstractMesh>;
  49005. /**
  49006. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  49007. */
  49008. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  49009. /**
  49010. * Pointer which can be used to select objects or attach a visible laser to
  49011. */
  49012. pointer: AbstractMesh;
  49013. /**
  49014. * Creates the controller
  49015. * @see https://doc.babylonjs.com/how_to/webxr
  49016. * @param _scene the scene which the controller should be associated to
  49017. * @param inputSource the underlying input source for the controller
  49018. * @param _options options for this controller creation
  49019. */
  49020. constructor(_scene: Scene,
  49021. /** The underlying input source for the controller */
  49022. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  49023. /**
  49024. * Get this controllers unique id
  49025. */
  49026. get uniqueId(): string;
  49027. /**
  49028. * Disposes of the object
  49029. */
  49030. dispose(): void;
  49031. /**
  49032. * Gets a world space ray coming from the pointer or grip
  49033. * @param result the resulting ray
  49034. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  49035. */
  49036. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  49037. /**
  49038. * Updates the controller pose based on the given XRFrame
  49039. * @param xrFrame xr frame to update the pose with
  49040. * @param referenceSpace reference space to use
  49041. */
  49042. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  49043. }
  49044. }
  49045. declare module "babylonjs/XR/webXRInput" {
  49046. import { Observable } from "babylonjs/Misc/observable";
  49047. import { IDisposable } from "babylonjs/scene";
  49048. import { WebXRInputSource, IWebXRControllerOptions } from "babylonjs/XR/webXRInputSource";
  49049. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  49050. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  49051. /**
  49052. * The schema for initialization options of the XR Input class
  49053. */
  49054. export interface IWebXRInputOptions {
  49055. /**
  49056. * If set to true no model will be automatically loaded
  49057. */
  49058. doNotLoadControllerMeshes?: boolean;
  49059. /**
  49060. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  49061. * If not found, the xr input profile data will be used.
  49062. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  49063. */
  49064. forceInputProfile?: string;
  49065. /**
  49066. * Do not send a request to the controller repository to load the profile.
  49067. *
  49068. * Instead, use the controllers available in babylon itself.
  49069. */
  49070. disableOnlineControllerRepository?: boolean;
  49071. /**
  49072. * A custom URL for the controllers repository
  49073. */
  49074. customControllersRepositoryURL?: string;
  49075. /**
  49076. * Should the controller model's components not move according to the user input
  49077. */
  49078. disableControllerAnimation?: boolean;
  49079. /**
  49080. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  49081. */
  49082. controllerOptions?: IWebXRControllerOptions;
  49083. }
  49084. /**
  49085. * XR input used to track XR inputs such as controllers/rays
  49086. */
  49087. export class WebXRInput implements IDisposable {
  49088. /**
  49089. * the xr session manager for this session
  49090. */
  49091. xrSessionManager: WebXRSessionManager;
  49092. /**
  49093. * the WebXR camera for this session. Mainly used for teleportation
  49094. */
  49095. xrCamera: WebXRCamera;
  49096. private readonly options;
  49097. /**
  49098. * XR controllers being tracked
  49099. */
  49100. controllers: Array<WebXRInputSource>;
  49101. private _frameObserver;
  49102. private _sessionEndedObserver;
  49103. private _sessionInitObserver;
  49104. /**
  49105. * Event when a controller has been connected/added
  49106. */
  49107. onControllerAddedObservable: Observable<WebXRInputSource>;
  49108. /**
  49109. * Event when a controller has been removed/disconnected
  49110. */
  49111. onControllerRemovedObservable: Observable<WebXRInputSource>;
  49112. /**
  49113. * Initializes the WebXRInput
  49114. * @param xrSessionManager the xr session manager for this session
  49115. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  49116. * @param options = initialization options for this xr input
  49117. */
  49118. constructor(
  49119. /**
  49120. * the xr session manager for this session
  49121. */
  49122. xrSessionManager: WebXRSessionManager,
  49123. /**
  49124. * the WebXR camera for this session. Mainly used for teleportation
  49125. */
  49126. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  49127. private _onInputSourcesChange;
  49128. private _addAndRemoveControllers;
  49129. /**
  49130. * Disposes of the object
  49131. */
  49132. dispose(): void;
  49133. }
  49134. }
  49135. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  49136. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  49137. import { Observable, EventState } from "babylonjs/Misc/observable";
  49138. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  49139. /**
  49140. * This is the base class for all WebXR features.
  49141. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  49142. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  49143. */
  49144. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  49145. protected _xrSessionManager: WebXRSessionManager;
  49146. private _attached;
  49147. private _removeOnDetach;
  49148. /**
  49149. * Should auto-attach be disabled?
  49150. */
  49151. disableAutoAttach: boolean;
  49152. /**
  49153. * Construct a new (abstract) WebXR feature
  49154. * @param _xrSessionManager the xr session manager for this feature
  49155. */
  49156. constructor(_xrSessionManager: WebXRSessionManager);
  49157. /**
  49158. * Is this feature attached
  49159. */
  49160. get attached(): boolean;
  49161. /**
  49162. * attach this feature
  49163. *
  49164. * @param force should attachment be forced (even when already attached)
  49165. * @returns true if successful, false is failed or already attached
  49166. */
  49167. attach(force?: boolean): boolean;
  49168. /**
  49169. * detach this feature.
  49170. *
  49171. * @returns true if successful, false if failed or already detached
  49172. */
  49173. detach(): boolean;
  49174. /**
  49175. * Dispose this feature and all of the resources attached
  49176. */
  49177. dispose(): void;
  49178. /**
  49179. * This is used to register callbacks that will automatically be removed when detach is called.
  49180. * @param observable the observable to which the observer will be attached
  49181. * @param callback the callback to register
  49182. */
  49183. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  49184. /**
  49185. * Code in this function will be executed on each xrFrame received from the browser.
  49186. * This function will not execute after the feature is detached.
  49187. * @param _xrFrame the current frame
  49188. */
  49189. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  49190. }
  49191. }
  49192. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  49193. import { IDisposable, Scene } from "babylonjs/scene";
  49194. import { Nullable } from "babylonjs/types";
  49195. import { Observable } from "babylonjs/Misc/observable";
  49196. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49197. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  49198. import { Camera } from "babylonjs/Cameras/camera";
  49199. /**
  49200. * Renders a layer on top of an existing scene
  49201. */
  49202. export class UtilityLayerRenderer implements IDisposable {
  49203. /** the original scene that will be rendered on top of */
  49204. originalScene: Scene;
  49205. private _pointerCaptures;
  49206. private _lastPointerEvents;
  49207. private static _DefaultUtilityLayer;
  49208. private static _DefaultKeepDepthUtilityLayer;
  49209. private _sharedGizmoLight;
  49210. private _renderCamera;
  49211. /**
  49212. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  49213. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  49214. * @returns the camera that is used when rendering the utility layer
  49215. */
  49216. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  49217. /**
  49218. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  49219. * @param cam the camera that should be used when rendering the utility layer
  49220. */
  49221. setRenderCamera(cam: Nullable<Camera>): void;
  49222. /**
  49223. * @hidden
  49224. * Light which used by gizmos to get light shading
  49225. */
  49226. _getSharedGizmoLight(): HemisphericLight;
  49227. /**
  49228. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  49229. */
  49230. pickUtilitySceneFirst: boolean;
  49231. /**
  49232. * 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)
  49233. */
  49234. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  49235. /**
  49236. * 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)
  49237. */
  49238. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  49239. /**
  49240. * The scene that is rendered on top of the original scene
  49241. */
  49242. utilityLayerScene: Scene;
  49243. /**
  49244. * If the utility layer should automatically be rendered on top of existing scene
  49245. */
  49246. shouldRender: boolean;
  49247. /**
  49248. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  49249. */
  49250. onlyCheckPointerDownEvents: boolean;
  49251. /**
  49252. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  49253. */
  49254. processAllEvents: boolean;
  49255. /**
  49256. * Observable raised when the pointer move from the utility layer scene to the main scene
  49257. */
  49258. onPointerOutObservable: Observable<number>;
  49259. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  49260. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  49261. private _afterRenderObserver;
  49262. private _sceneDisposeObserver;
  49263. private _originalPointerObserver;
  49264. /**
  49265. * Instantiates a UtilityLayerRenderer
  49266. * @param originalScene the original scene that will be rendered on top of
  49267. * @param handleEvents boolean indicating if the utility layer should handle events
  49268. */
  49269. constructor(
  49270. /** the original scene that will be rendered on top of */
  49271. originalScene: Scene, handleEvents?: boolean);
  49272. private _notifyObservers;
  49273. /**
  49274. * Renders the utility layers scene on top of the original scene
  49275. */
  49276. render(): void;
  49277. /**
  49278. * Disposes of the renderer
  49279. */
  49280. dispose(): void;
  49281. private _updateCamera;
  49282. }
  49283. }
  49284. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  49285. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  49286. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49287. import { WebXRInput } from "babylonjs/XR/webXRInput";
  49288. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  49289. import { Scene } from "babylonjs/scene";
  49290. import { Nullable } from "babylonjs/types";
  49291. import { Color3 } from "babylonjs/Maths/math.color";
  49292. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  49293. /**
  49294. * Options interface for the pointer selection module
  49295. */
  49296. export interface IWebXRControllerPointerSelectionOptions {
  49297. /**
  49298. * if provided, this scene will be used to render meshes.
  49299. */
  49300. customUtilityLayerScene?: Scene;
  49301. /**
  49302. * 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)
  49303. * If not disabled, the last picked point will be used to execute a pointer up event
  49304. * If disabled, pointer up event will be triggered right after the pointer down event.
  49305. * Used in screen and gaze target ray mode only
  49306. */
  49307. disablePointerUpOnTouchOut: boolean;
  49308. /**
  49309. * For gaze mode (time to select instead of press)
  49310. */
  49311. forceGazeMode: boolean;
  49312. /**
  49313. * 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
  49314. * to start a new countdown to the pointer down event.
  49315. * Defaults to 1.
  49316. */
  49317. gazeModePointerMovedFactor?: number;
  49318. /**
  49319. * Different button type to use instead of the main component
  49320. */
  49321. overrideButtonId?: string;
  49322. /**
  49323. * use this rendering group id for the meshes (optional)
  49324. */
  49325. renderingGroupId?: number;
  49326. /**
  49327. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  49328. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  49329. * 3000 means 3 seconds between pointing at something and selecting it
  49330. */
  49331. timeToSelect?: number;
  49332. /**
  49333. * Should meshes created here be added to a utility layer or the main scene
  49334. */
  49335. useUtilityLayer?: boolean;
  49336. /**
  49337. * the xr input to use with this pointer selection
  49338. */
  49339. xrInput: WebXRInput;
  49340. }
  49341. /**
  49342. * A module that will enable pointer selection for motion controllers of XR Input Sources
  49343. */
  49344. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  49345. private readonly _options;
  49346. private static _idCounter;
  49347. private _attachController;
  49348. private _controllers;
  49349. private _scene;
  49350. private _tmpVectorForPickCompare;
  49351. /**
  49352. * The module's name
  49353. */
  49354. static readonly Name: string;
  49355. /**
  49356. * The (Babylon) version of this module.
  49357. * This is an integer representing the implementation version.
  49358. * This number does not correspond to the WebXR specs version
  49359. */
  49360. static readonly Version: number;
  49361. /**
  49362. * Disable lighting on the laser pointer (so it will always be visible)
  49363. */
  49364. disablePointerLighting: boolean;
  49365. /**
  49366. * Disable lighting on the selection mesh (so it will always be visible)
  49367. */
  49368. disableSelectionMeshLighting: boolean;
  49369. /**
  49370. * Should the laser pointer be displayed
  49371. */
  49372. displayLaserPointer: boolean;
  49373. /**
  49374. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  49375. */
  49376. displaySelectionMesh: boolean;
  49377. /**
  49378. * This color will be set to the laser pointer when selection is triggered
  49379. */
  49380. laserPointerPickedColor: Color3;
  49381. /**
  49382. * Default color of the laser pointer
  49383. */
  49384. lasterPointerDefaultColor: Color3;
  49385. /**
  49386. * default color of the selection ring
  49387. */
  49388. selectionMeshDefaultColor: Color3;
  49389. /**
  49390. * This color will be applied to the selection ring when selection is triggered
  49391. */
  49392. selectionMeshPickedColor: Color3;
  49393. /**
  49394. * Optional filter to be used for ray selection. This predicate shares behavior with
  49395. * scene.pointerMovePredicate which takes priority if it is also assigned.
  49396. */
  49397. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  49398. /**
  49399. * constructs a new background remover module
  49400. * @param _xrSessionManager the session manager for this module
  49401. * @param _options read-only options to be used in this module
  49402. */
  49403. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  49404. /**
  49405. * attach this feature
  49406. * Will usually be called by the features manager
  49407. *
  49408. * @returns true if successful.
  49409. */
  49410. attach(): boolean;
  49411. /**
  49412. * detach this feature.
  49413. * Will usually be called by the features manager
  49414. *
  49415. * @returns true if successful.
  49416. */
  49417. detach(): boolean;
  49418. /**
  49419. * Will get the mesh under a specific pointer.
  49420. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  49421. * @param controllerId the controllerId to check
  49422. * @returns The mesh under pointer or null if no mesh is under the pointer
  49423. */
  49424. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  49425. /**
  49426. * Get the xr controller that correlates to the pointer id in the pointer event
  49427. *
  49428. * @param id the pointer id to search for
  49429. * @returns the controller that correlates to this id or null if not found
  49430. */
  49431. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  49432. protected _onXRFrame(_xrFrame: XRFrame): void;
  49433. private _attachGazeMode;
  49434. private _attachScreenRayMode;
  49435. private _attachTrackedPointerRayMode;
  49436. private _convertNormalToDirectionOfRay;
  49437. private _detachController;
  49438. private _generateNewMeshPair;
  49439. private _pickingMoved;
  49440. private _updatePointerDistance;
  49441. }
  49442. }
  49443. declare module "babylonjs/XR/webXREnterExitUI" {
  49444. import { Nullable } from "babylonjs/types";
  49445. import { Observable } from "babylonjs/Misc/observable";
  49446. import { IDisposable, Scene } from "babylonjs/scene";
  49447. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  49448. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  49449. /**
  49450. * Button which can be used to enter a different mode of XR
  49451. */
  49452. export class WebXREnterExitUIButton {
  49453. /** button element */
  49454. element: HTMLElement;
  49455. /** XR initialization options for the button */
  49456. sessionMode: XRSessionMode;
  49457. /** Reference space type */
  49458. referenceSpaceType: XRReferenceSpaceType;
  49459. /**
  49460. * Creates a WebXREnterExitUIButton
  49461. * @param element button element
  49462. * @param sessionMode XR initialization session mode
  49463. * @param referenceSpaceType the type of reference space to be used
  49464. */
  49465. constructor(
  49466. /** button element */
  49467. element: HTMLElement,
  49468. /** XR initialization options for the button */
  49469. sessionMode: XRSessionMode,
  49470. /** Reference space type */
  49471. referenceSpaceType: XRReferenceSpaceType);
  49472. /**
  49473. * Extendable function which can be used to update the button's visuals when the state changes
  49474. * @param activeButton the current active button in the UI
  49475. */
  49476. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  49477. }
  49478. /**
  49479. * Options to create the webXR UI
  49480. */
  49481. export class WebXREnterExitUIOptions {
  49482. /**
  49483. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  49484. */
  49485. customButtons?: Array<WebXREnterExitUIButton>;
  49486. /**
  49487. * A reference space type to use when creating the default button.
  49488. * Default is local-floor
  49489. */
  49490. referenceSpaceType?: XRReferenceSpaceType;
  49491. /**
  49492. * Context to enter xr with
  49493. */
  49494. renderTarget?: Nullable<WebXRRenderTarget>;
  49495. /**
  49496. * A session mode to use when creating the default button.
  49497. * Default is immersive-vr
  49498. */
  49499. sessionMode?: XRSessionMode;
  49500. /**
  49501. * A list of optional features to init the session with
  49502. */
  49503. optionalFeatures?: string[];
  49504. }
  49505. /**
  49506. * UI to allow the user to enter/exit XR mode
  49507. */
  49508. export class WebXREnterExitUI implements IDisposable {
  49509. private scene;
  49510. /** version of the options passed to this UI */
  49511. options: WebXREnterExitUIOptions;
  49512. private _activeButton;
  49513. private _buttons;
  49514. private _overlay;
  49515. /**
  49516. * Fired every time the active button is changed.
  49517. *
  49518. * When xr is entered via a button that launches xr that button will be the callback parameter
  49519. *
  49520. * When exiting xr the callback parameter will be null)
  49521. */
  49522. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  49523. /**
  49524. *
  49525. * @param scene babylon scene object to use
  49526. * @param options (read-only) version of the options passed to this UI
  49527. */
  49528. private constructor();
  49529. /**
  49530. * Creates UI to allow the user to enter/exit XR mode
  49531. * @param scene the scene to add the ui to
  49532. * @param helper the xr experience helper to enter/exit xr with
  49533. * @param options options to configure the UI
  49534. * @returns the created ui
  49535. */
  49536. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  49537. /**
  49538. * Disposes of the XR UI component
  49539. */
  49540. dispose(): void;
  49541. private _updateButtons;
  49542. }
  49543. }
  49544. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  49545. import { Vector3 } from "babylonjs/Maths/math.vector";
  49546. import { Color4 } from "babylonjs/Maths/math.color";
  49547. import { Nullable } from "babylonjs/types";
  49548. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  49549. import { Scene } from "babylonjs/scene";
  49550. /**
  49551. * Class containing static functions to help procedurally build meshes
  49552. */
  49553. export class LinesBuilder {
  49554. /**
  49555. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  49556. * * 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
  49557. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  49558. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  49559. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  49560. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  49561. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  49562. * * 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
  49563. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  49564. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49565. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  49566. * @param name defines the name of the new line system
  49567. * @param options defines the options used to create the line system
  49568. * @param scene defines the hosting scene
  49569. * @returns a new line system mesh
  49570. */
  49571. static CreateLineSystem(name: string, options: {
  49572. lines: Vector3[][];
  49573. updatable?: boolean;
  49574. instance?: Nullable<LinesMesh>;
  49575. colors?: Nullable<Color4[][]>;
  49576. useVertexAlpha?: boolean;
  49577. }, scene: Nullable<Scene>): LinesMesh;
  49578. /**
  49579. * Creates a line mesh
  49580. * 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
  49581. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49582. * * The parameter `points` is an array successive Vector3
  49583. * * 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
  49584. * * The optional parameter `colors` is an array of successive Color4, one per line point
  49585. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  49586. * * When updating an instance, remember that only point positions can change, not the number of points
  49587. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49588. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  49589. * @param name defines the name of the new line system
  49590. * @param options defines the options used to create the line system
  49591. * @param scene defines the hosting scene
  49592. * @returns a new line mesh
  49593. */
  49594. static CreateLines(name: string, options: {
  49595. points: Vector3[];
  49596. updatable?: boolean;
  49597. instance?: Nullable<LinesMesh>;
  49598. colors?: Color4[];
  49599. useVertexAlpha?: boolean;
  49600. }, scene?: Nullable<Scene>): LinesMesh;
  49601. /**
  49602. * Creates a dashed line mesh
  49603. * * 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
  49604. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49605. * * The parameter `points` is an array successive Vector3
  49606. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  49607. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  49608. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  49609. * * 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
  49610. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  49611. * * When updating an instance, remember that only point positions can change, not the number of points
  49612. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49613. * @param name defines the name of the mesh
  49614. * @param options defines the options used to create the mesh
  49615. * @param scene defines the hosting scene
  49616. * @returns the dashed line mesh
  49617. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  49618. */
  49619. static CreateDashedLines(name: string, options: {
  49620. points: Vector3[];
  49621. dashSize?: number;
  49622. gapSize?: number;
  49623. dashNb?: number;
  49624. updatable?: boolean;
  49625. instance?: LinesMesh;
  49626. useVertexAlpha?: boolean;
  49627. }, scene?: Nullable<Scene>): LinesMesh;
  49628. }
  49629. }
  49630. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  49631. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  49632. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  49633. import { WebXRInput } from "babylonjs/XR/webXRInput";
  49634. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49635. import { Vector3 } from "babylonjs/Maths/math.vector";
  49636. import { Material } from "babylonjs/Materials/material";
  49637. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  49638. import { Scene } from "babylonjs/scene";
  49639. /**
  49640. * The options container for the teleportation module
  49641. */
  49642. export interface IWebXRTeleportationOptions {
  49643. /**
  49644. * if provided, this scene will be used to render meshes.
  49645. */
  49646. customUtilityLayerScene?: Scene;
  49647. /**
  49648. * Values to configure the default target mesh
  49649. */
  49650. defaultTargetMeshOptions?: {
  49651. /**
  49652. * Fill color of the teleportation area
  49653. */
  49654. teleportationFillColor?: string;
  49655. /**
  49656. * Border color for the teleportation area
  49657. */
  49658. teleportationBorderColor?: string;
  49659. /**
  49660. * Disable the mesh's animation sequence
  49661. */
  49662. disableAnimation?: boolean;
  49663. /**
  49664. * Disable lighting on the material or the ring and arrow
  49665. */
  49666. disableLighting?: boolean;
  49667. /**
  49668. * Override the default material of the torus and arrow
  49669. */
  49670. torusArrowMaterial?: Material;
  49671. };
  49672. /**
  49673. * A list of meshes to use as floor meshes.
  49674. * Meshes can be added and removed after initializing the feature using the
  49675. * addFloorMesh and removeFloorMesh functions
  49676. * If empty, rotation will still work
  49677. */
  49678. floorMeshes?: AbstractMesh[];
  49679. /**
  49680. * use this rendering group id for the meshes (optional)
  49681. */
  49682. renderingGroupId?: number;
  49683. /**
  49684. * Should teleportation move only to snap points
  49685. */
  49686. snapPointsOnly?: boolean;
  49687. /**
  49688. * An array of points to which the teleportation will snap to.
  49689. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  49690. */
  49691. snapPositions?: Vector3[];
  49692. /**
  49693. * How close should the teleportation ray be in order to snap to position.
  49694. * Default to 0.8 units (meters)
  49695. */
  49696. snapToPositionRadius?: number;
  49697. /**
  49698. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  49699. * If you want to support rotation, make sure your mesh has a direction indicator.
  49700. *
  49701. * When left untouched, the default mesh will be initialized.
  49702. */
  49703. teleportationTargetMesh?: AbstractMesh;
  49704. /**
  49705. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  49706. */
  49707. timeToTeleport?: number;
  49708. /**
  49709. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  49710. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  49711. */
  49712. useMainComponentOnly?: boolean;
  49713. /**
  49714. * Should meshes created here be added to a utility layer or the main scene
  49715. */
  49716. useUtilityLayer?: boolean;
  49717. /**
  49718. * Babylon XR Input class for controller
  49719. */
  49720. xrInput: WebXRInput;
  49721. }
  49722. /**
  49723. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  49724. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  49725. * the input of the attached controllers.
  49726. */
  49727. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  49728. private _options;
  49729. private _controllers;
  49730. private _currentTeleportationControllerId;
  49731. private _floorMeshes;
  49732. private _quadraticBezierCurve;
  49733. private _selectionFeature;
  49734. private _snapToPositions;
  49735. private _snappedToPoint;
  49736. private _teleportationRingMaterial?;
  49737. private _tmpRay;
  49738. private _tmpVector;
  49739. /**
  49740. * The module's name
  49741. */
  49742. static readonly Name: string;
  49743. /**
  49744. * The (Babylon) version of this module.
  49745. * This is an integer representing the implementation version.
  49746. * This number does not correspond to the webxr specs version
  49747. */
  49748. static readonly Version: number;
  49749. /**
  49750. * Is movement backwards enabled
  49751. */
  49752. backwardsMovementEnabled: boolean;
  49753. /**
  49754. * Distance to travel when moving backwards
  49755. */
  49756. backwardsTeleportationDistance: number;
  49757. /**
  49758. * The distance from the user to the inspection point in the direction of the controller
  49759. * A higher number will allow the user to move further
  49760. * defaults to 5 (meters, in xr units)
  49761. */
  49762. parabolicCheckRadius: number;
  49763. /**
  49764. * Should the module support parabolic ray on top of direct ray
  49765. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  49766. * Very helpful when moving between floors / different heights
  49767. */
  49768. parabolicRayEnabled: boolean;
  49769. /**
  49770. * How much rotation should be applied when rotating right and left
  49771. */
  49772. rotationAngle: number;
  49773. /**
  49774. * Is rotation enabled when moving forward?
  49775. * Disabling this feature will prevent the user from deciding the direction when teleporting
  49776. */
  49777. rotationEnabled: boolean;
  49778. /**
  49779. * constructs a new anchor system
  49780. * @param _xrSessionManager an instance of WebXRSessionManager
  49781. * @param _options configuration object for this feature
  49782. */
  49783. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  49784. /**
  49785. * Get the snapPointsOnly flag
  49786. */
  49787. get snapPointsOnly(): boolean;
  49788. /**
  49789. * Sets the snapPointsOnly flag
  49790. * @param snapToPoints should teleportation be exclusively to snap points
  49791. */
  49792. set snapPointsOnly(snapToPoints: boolean);
  49793. /**
  49794. * Add a new mesh to the floor meshes array
  49795. * @param mesh the mesh to use as floor mesh
  49796. */
  49797. addFloorMesh(mesh: AbstractMesh): void;
  49798. /**
  49799. * Add a new snap-to point to fix teleportation to this position
  49800. * @param newSnapPoint The new Snap-To point
  49801. */
  49802. addSnapPoint(newSnapPoint: Vector3): void;
  49803. attach(): boolean;
  49804. detach(): boolean;
  49805. dispose(): void;
  49806. /**
  49807. * Remove a mesh from the floor meshes array
  49808. * @param mesh the mesh to remove
  49809. */
  49810. removeFloorMesh(mesh: AbstractMesh): void;
  49811. /**
  49812. * Remove a mesh from the floor meshes array using its name
  49813. * @param name the mesh name to remove
  49814. */
  49815. removeFloorMeshByName(name: string): void;
  49816. /**
  49817. * 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
  49818. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  49819. * @returns was the point found and removed or not
  49820. */
  49821. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  49822. /**
  49823. * This function sets a selection feature that will be disabled when
  49824. * the forward ray is shown and will be reattached when hidden.
  49825. * This is used to remove the selection rays when moving.
  49826. * @param selectionFeature the feature to disable when forward movement is enabled
  49827. */
  49828. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  49829. protected _onXRFrame(_xrFrame: XRFrame): void;
  49830. private _attachController;
  49831. private _createDefaultTargetMesh;
  49832. private _detachController;
  49833. private _findClosestSnapPointWithRadius;
  49834. private _setTargetMeshPosition;
  49835. private _setTargetMeshVisibility;
  49836. private _showParabolicPath;
  49837. private _teleportForward;
  49838. }
  49839. }
  49840. declare module "babylonjs/XR/webXRDefaultExperience" {
  49841. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  49842. import { Scene } from "babylonjs/scene";
  49843. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  49844. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  49845. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  49846. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  49847. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49848. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  49849. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  49850. /**
  49851. * Options for the default xr helper
  49852. */
  49853. export class WebXRDefaultExperienceOptions {
  49854. /**
  49855. * Enable or disable default UI to enter XR
  49856. */
  49857. disableDefaultUI?: boolean;
  49858. /**
  49859. * Should teleportation not initialize. defaults to false.
  49860. */
  49861. disableTeleportation?: boolean;
  49862. /**
  49863. * Floor meshes that will be used for teleport
  49864. */
  49865. floorMeshes?: Array<AbstractMesh>;
  49866. /**
  49867. * If set to true, the first frame will not be used to reset position
  49868. * The first frame is mainly used when copying transformation from the old camera
  49869. * Mainly used in AR
  49870. */
  49871. ignoreNativeCameraTransformation?: boolean;
  49872. /**
  49873. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  49874. */
  49875. inputOptions?: IWebXRInputOptions;
  49876. /**
  49877. * optional configuration for the output canvas
  49878. */
  49879. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  49880. /**
  49881. * optional UI options. This can be used among other to change session mode and reference space type
  49882. */
  49883. uiOptions?: WebXREnterExitUIOptions;
  49884. /**
  49885. * When loading teleportation and pointer select, use stable versions instead of latest.
  49886. */
  49887. useStablePlugins?: boolean;
  49888. /**
  49889. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  49890. */
  49891. renderingGroupId?: number;
  49892. /**
  49893. * A list of optional features to init the session with
  49894. * If set to true, all features we support will be added
  49895. */
  49896. optionalFeatures?: boolean | string[];
  49897. }
  49898. /**
  49899. * Default experience which provides a similar setup to the previous webVRExperience
  49900. */
  49901. export class WebXRDefaultExperience {
  49902. /**
  49903. * Base experience
  49904. */
  49905. baseExperience: WebXRExperienceHelper;
  49906. /**
  49907. * Enables ui for entering/exiting xr
  49908. */
  49909. enterExitUI: WebXREnterExitUI;
  49910. /**
  49911. * Input experience extension
  49912. */
  49913. input: WebXRInput;
  49914. /**
  49915. * Enables laser pointer and selection
  49916. */
  49917. pointerSelection: WebXRControllerPointerSelection;
  49918. /**
  49919. * Default target xr should render to
  49920. */
  49921. renderTarget: WebXRRenderTarget;
  49922. /**
  49923. * Enables teleportation
  49924. */
  49925. teleportation: WebXRMotionControllerTeleportation;
  49926. private constructor();
  49927. /**
  49928. * Creates the default xr experience
  49929. * @param scene scene
  49930. * @param options options for basic configuration
  49931. * @returns resulting WebXRDefaultExperience
  49932. */
  49933. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  49934. /**
  49935. * DIsposes of the experience helper
  49936. */
  49937. dispose(): void;
  49938. }
  49939. }
  49940. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  49941. import { Observable } from "babylonjs/Misc/observable";
  49942. import { Nullable } from "babylonjs/types";
  49943. import { Camera } from "babylonjs/Cameras/camera";
  49944. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  49945. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  49946. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  49947. import { Scene } from "babylonjs/scene";
  49948. import { Vector3 } from "babylonjs/Maths/math.vector";
  49949. import { Color3 } from "babylonjs/Maths/math.color";
  49950. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49951. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49952. import { Mesh } from "babylonjs/Meshes/mesh";
  49953. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  49954. import { EasingFunction } from "babylonjs/Animations/easing";
  49955. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  49956. import "babylonjs/Meshes/Builders/groundBuilder";
  49957. import "babylonjs/Meshes/Builders/torusBuilder";
  49958. import "babylonjs/Meshes/Builders/cylinderBuilder";
  49959. import "babylonjs/Gamepads/gamepadSceneComponent";
  49960. import "babylonjs/Animations/animatable";
  49961. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  49962. /**
  49963. * Options to modify the vr teleportation behavior.
  49964. */
  49965. export interface VRTeleportationOptions {
  49966. /**
  49967. * The name of the mesh which should be used as the teleportation floor. (default: null)
  49968. */
  49969. floorMeshName?: string;
  49970. /**
  49971. * A list of meshes to be used as the teleportation floor. (default: empty)
  49972. */
  49973. floorMeshes?: Mesh[];
  49974. /**
  49975. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  49976. */
  49977. teleportationMode?: number;
  49978. /**
  49979. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  49980. */
  49981. teleportationTime?: number;
  49982. /**
  49983. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  49984. */
  49985. teleportationSpeed?: number;
  49986. /**
  49987. * The easing function used in the animation or null for Linear. (default CircleEase)
  49988. */
  49989. easingFunction?: EasingFunction;
  49990. }
  49991. /**
  49992. * Options to modify the vr experience helper's behavior.
  49993. */
  49994. export interface VRExperienceHelperOptions extends WebVROptions {
  49995. /**
  49996. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  49997. */
  49998. createDeviceOrientationCamera?: boolean;
  49999. /**
  50000. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  50001. */
  50002. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  50003. /**
  50004. * Uses the main button on the controller to toggle the laser casted. (default: true)
  50005. */
  50006. laserToggle?: boolean;
  50007. /**
  50008. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  50009. */
  50010. floorMeshes?: Mesh[];
  50011. /**
  50012. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  50013. */
  50014. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  50015. /**
  50016. * Defines if WebXR should be used instead of WebVR (if available)
  50017. */
  50018. useXR?: boolean;
  50019. }
  50020. /**
  50021. * Event containing information after VR has been entered
  50022. */
  50023. export class OnAfterEnteringVRObservableEvent {
  50024. /**
  50025. * If entering vr was successful
  50026. */
  50027. success: boolean;
  50028. }
  50029. /**
  50030. * Helps to quickly add VR support to an existing scene.
  50031. * See http://doc.babylonjs.com/how_to/webvr_helper
  50032. */
  50033. export class VRExperienceHelper {
  50034. /** Options to modify the vr experience helper's behavior. */
  50035. webVROptions: VRExperienceHelperOptions;
  50036. private _scene;
  50037. private _position;
  50038. private _btnVR;
  50039. private _btnVRDisplayed;
  50040. private _webVRsupported;
  50041. private _webVRready;
  50042. private _webVRrequesting;
  50043. private _webVRpresenting;
  50044. private _hasEnteredVR;
  50045. private _fullscreenVRpresenting;
  50046. private _inputElement;
  50047. private _webVRCamera;
  50048. private _vrDeviceOrientationCamera;
  50049. private _deviceOrientationCamera;
  50050. private _existingCamera;
  50051. private _onKeyDown;
  50052. private _onVrDisplayPresentChange;
  50053. private _onVRDisplayChanged;
  50054. private _onVRRequestPresentStart;
  50055. private _onVRRequestPresentComplete;
  50056. /**
  50057. * 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)
  50058. */
  50059. enableGazeEvenWhenNoPointerLock: boolean;
  50060. /**
  50061. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  50062. */
  50063. exitVROnDoubleTap: boolean;
  50064. /**
  50065. * Observable raised right before entering VR.
  50066. */
  50067. onEnteringVRObservable: Observable<VRExperienceHelper>;
  50068. /**
  50069. * Observable raised when entering VR has completed.
  50070. */
  50071. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  50072. /**
  50073. * Observable raised when exiting VR.
  50074. */
  50075. onExitingVRObservable: Observable<VRExperienceHelper>;
  50076. /**
  50077. * Observable raised when controller mesh is loaded.
  50078. */
  50079. onControllerMeshLoadedObservable: Observable<WebVRController>;
  50080. /** Return this.onEnteringVRObservable
  50081. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  50082. */
  50083. get onEnteringVR(): Observable<VRExperienceHelper>;
  50084. /** Return this.onExitingVRObservable
  50085. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  50086. */
  50087. get onExitingVR(): Observable<VRExperienceHelper>;
  50088. /** Return this.onControllerMeshLoadedObservable
  50089. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  50090. */
  50091. get onControllerMeshLoaded(): Observable<WebVRController>;
  50092. private _rayLength;
  50093. private _useCustomVRButton;
  50094. private _teleportationRequested;
  50095. private _teleportActive;
  50096. private _floorMeshName;
  50097. private _floorMeshesCollection;
  50098. private _teleportationMode;
  50099. private _teleportationTime;
  50100. private _teleportationSpeed;
  50101. private _teleportationEasing;
  50102. private _rotationAllowed;
  50103. private _teleportBackwardsVector;
  50104. private _teleportationTarget;
  50105. private _isDefaultTeleportationTarget;
  50106. private _postProcessMove;
  50107. private _teleportationFillColor;
  50108. private _teleportationBorderColor;
  50109. private _rotationAngle;
  50110. private _haloCenter;
  50111. private _cameraGazer;
  50112. private _padSensibilityUp;
  50113. private _padSensibilityDown;
  50114. private _leftController;
  50115. private _rightController;
  50116. private _gazeColor;
  50117. private _laserColor;
  50118. private _pickedLaserColor;
  50119. private _pickedGazeColor;
  50120. /**
  50121. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  50122. */
  50123. onNewMeshSelected: Observable<AbstractMesh>;
  50124. /**
  50125. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  50126. * This observable will provide the mesh and the controller used to select the mesh
  50127. */
  50128. onMeshSelectedWithController: Observable<{
  50129. mesh: AbstractMesh;
  50130. controller: WebVRController;
  50131. }>;
  50132. /**
  50133. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  50134. */
  50135. onNewMeshPicked: Observable<PickingInfo>;
  50136. private _circleEase;
  50137. /**
  50138. * Observable raised before camera teleportation
  50139. */
  50140. onBeforeCameraTeleport: Observable<Vector3>;
  50141. /**
  50142. * Observable raised after camera teleportation
  50143. */
  50144. onAfterCameraTeleport: Observable<Vector3>;
  50145. /**
  50146. * Observable raised when current selected mesh gets unselected
  50147. */
  50148. onSelectedMeshUnselected: Observable<AbstractMesh>;
  50149. private _raySelectionPredicate;
  50150. /**
  50151. * To be optionaly changed by user to define custom ray selection
  50152. */
  50153. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  50154. /**
  50155. * To be optionaly changed by user to define custom selection logic (after ray selection)
  50156. */
  50157. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  50158. /**
  50159. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  50160. */
  50161. teleportationEnabled: boolean;
  50162. private _defaultHeight;
  50163. private _teleportationInitialized;
  50164. private _interactionsEnabled;
  50165. private _interactionsRequested;
  50166. private _displayGaze;
  50167. private _displayLaserPointer;
  50168. /**
  50169. * The mesh used to display where the user is going to teleport.
  50170. */
  50171. get teleportationTarget(): Mesh;
  50172. /**
  50173. * Sets the mesh to be used to display where the user is going to teleport.
  50174. */
  50175. set teleportationTarget(value: Mesh);
  50176. /**
  50177. * 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
  50178. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  50179. * See http://doc.babylonjs.com/resources/baking_transformations
  50180. */
  50181. get gazeTrackerMesh(): Mesh;
  50182. set gazeTrackerMesh(value: Mesh);
  50183. /**
  50184. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  50185. */
  50186. updateGazeTrackerScale: boolean;
  50187. /**
  50188. * If the gaze trackers color should be updated when selecting meshes
  50189. */
  50190. updateGazeTrackerColor: boolean;
  50191. /**
  50192. * If the controller laser color should be updated when selecting meshes
  50193. */
  50194. updateControllerLaserColor: boolean;
  50195. /**
  50196. * The gaze tracking mesh corresponding to the left controller
  50197. */
  50198. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  50199. /**
  50200. * The gaze tracking mesh corresponding to the right controller
  50201. */
  50202. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  50203. /**
  50204. * If the ray of the gaze should be displayed.
  50205. */
  50206. get displayGaze(): boolean;
  50207. /**
  50208. * Sets if the ray of the gaze should be displayed.
  50209. */
  50210. set displayGaze(value: boolean);
  50211. /**
  50212. * If the ray of the LaserPointer should be displayed.
  50213. */
  50214. get displayLaserPointer(): boolean;
  50215. /**
  50216. * Sets if the ray of the LaserPointer should be displayed.
  50217. */
  50218. set displayLaserPointer(value: boolean);
  50219. /**
  50220. * The deviceOrientationCamera used as the camera when not in VR.
  50221. */
  50222. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  50223. /**
  50224. * Based on the current WebVR support, returns the current VR camera used.
  50225. */
  50226. get currentVRCamera(): Nullable<Camera>;
  50227. /**
  50228. * The webVRCamera which is used when in VR.
  50229. */
  50230. get webVRCamera(): WebVRFreeCamera;
  50231. /**
  50232. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  50233. */
  50234. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  50235. /**
  50236. * The html button that is used to trigger entering into VR.
  50237. */
  50238. get vrButton(): Nullable<HTMLButtonElement>;
  50239. private get _teleportationRequestInitiated();
  50240. /**
  50241. * Defines whether or not Pointer lock should be requested when switching to
  50242. * full screen.
  50243. */
  50244. requestPointerLockOnFullScreen: boolean;
  50245. /**
  50246. * If asking to force XR, this will be populated with the default xr experience
  50247. */
  50248. xr: WebXRDefaultExperience;
  50249. /**
  50250. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  50251. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  50252. */
  50253. xrTestDone: boolean;
  50254. /**
  50255. * Instantiates a VRExperienceHelper.
  50256. * Helps to quickly add VR support to an existing scene.
  50257. * @param scene The scene the VRExperienceHelper belongs to.
  50258. * @param webVROptions Options to modify the vr experience helper's behavior.
  50259. */
  50260. constructor(scene: Scene,
  50261. /** Options to modify the vr experience helper's behavior. */
  50262. webVROptions?: VRExperienceHelperOptions);
  50263. private completeVRInit;
  50264. private _onDefaultMeshLoaded;
  50265. private _onResize;
  50266. private _onFullscreenChange;
  50267. /**
  50268. * Gets a value indicating if we are currently in VR mode.
  50269. */
  50270. get isInVRMode(): boolean;
  50271. private onVrDisplayPresentChange;
  50272. private onVRDisplayChanged;
  50273. private moveButtonToBottomRight;
  50274. private displayVRButton;
  50275. private updateButtonVisibility;
  50276. private _cachedAngularSensibility;
  50277. /**
  50278. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  50279. * Otherwise, will use the fullscreen API.
  50280. */
  50281. enterVR(): void;
  50282. /**
  50283. * Attempt to exit VR, or fullscreen.
  50284. */
  50285. exitVR(): void;
  50286. /**
  50287. * The position of the vr experience helper.
  50288. */
  50289. get position(): Vector3;
  50290. /**
  50291. * Sets the position of the vr experience helper.
  50292. */
  50293. set position(value: Vector3);
  50294. /**
  50295. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  50296. */
  50297. enableInteractions(): void;
  50298. private get _noControllerIsActive();
  50299. private beforeRender;
  50300. private _isTeleportationFloor;
  50301. /**
  50302. * Adds a floor mesh to be used for teleportation.
  50303. * @param floorMesh the mesh to be used for teleportation.
  50304. */
  50305. addFloorMesh(floorMesh: Mesh): void;
  50306. /**
  50307. * Removes a floor mesh from being used for teleportation.
  50308. * @param floorMesh the mesh to be removed.
  50309. */
  50310. removeFloorMesh(floorMesh: Mesh): void;
  50311. /**
  50312. * Enables interactions and teleportation using the VR controllers and gaze.
  50313. * @param vrTeleportationOptions options to modify teleportation behavior.
  50314. */
  50315. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  50316. private _onNewGamepadConnected;
  50317. private _tryEnableInteractionOnController;
  50318. private _onNewGamepadDisconnected;
  50319. private _enableInteractionOnController;
  50320. private _checkTeleportWithRay;
  50321. private _checkRotate;
  50322. private _checkTeleportBackwards;
  50323. private _enableTeleportationOnController;
  50324. private _createTeleportationCircles;
  50325. private _displayTeleportationTarget;
  50326. private _hideTeleportationTarget;
  50327. private _rotateCamera;
  50328. private _moveTeleportationSelectorTo;
  50329. private _workingVector;
  50330. private _workingQuaternion;
  50331. private _workingMatrix;
  50332. /**
  50333. * Time Constant Teleportation Mode
  50334. */
  50335. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  50336. /**
  50337. * Speed Constant Teleportation Mode
  50338. */
  50339. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  50340. /**
  50341. * Teleports the users feet to the desired location
  50342. * @param location The location where the user's feet should be placed
  50343. */
  50344. teleportCamera(location: Vector3): void;
  50345. private _convertNormalToDirectionOfRay;
  50346. private _castRayAndSelectObject;
  50347. private _notifySelectedMeshUnselected;
  50348. /**
  50349. * Permanently set new colors for the laser pointer
  50350. * @param color the new laser color
  50351. * @param pickedColor the new laser color when picked mesh detected
  50352. */
  50353. setLaserColor(color: Color3, pickedColor?: Color3): void;
  50354. /**
  50355. * Set lighting enabled / disabled on the laser pointer of both controllers
  50356. * @param enabled should the lighting be enabled on the laser pointer
  50357. */
  50358. setLaserLightingState(enabled?: boolean): void;
  50359. /**
  50360. * Permanently set new colors for the gaze pointer
  50361. * @param color the new gaze color
  50362. * @param pickedColor the new gaze color when picked mesh detected
  50363. */
  50364. setGazeColor(color: Color3, pickedColor?: Color3): void;
  50365. /**
  50366. * Sets the color of the laser ray from the vr controllers.
  50367. * @param color new color for the ray.
  50368. */
  50369. changeLaserColor(color: Color3): void;
  50370. /**
  50371. * Sets the color of the ray from the vr headsets gaze.
  50372. * @param color new color for the ray.
  50373. */
  50374. changeGazeColor(color: Color3): void;
  50375. /**
  50376. * Exits VR and disposes of the vr experience helper
  50377. */
  50378. dispose(): void;
  50379. /**
  50380. * Gets the name of the VRExperienceHelper class
  50381. * @returns "VRExperienceHelper"
  50382. */
  50383. getClassName(): string;
  50384. }
  50385. }
  50386. declare module "babylonjs/Cameras/VR/index" {
  50387. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  50388. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  50389. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  50390. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  50391. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  50392. export * from "babylonjs/Cameras/VR/webVRCamera";
  50393. }
  50394. declare module "babylonjs/Cameras/RigModes/index" {
  50395. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  50396. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  50397. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  50398. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  50399. }
  50400. declare module "babylonjs/Cameras/index" {
  50401. export * from "babylonjs/Cameras/Inputs/index";
  50402. export * from "babylonjs/Cameras/cameraInputsManager";
  50403. export * from "babylonjs/Cameras/camera";
  50404. export * from "babylonjs/Cameras/targetCamera";
  50405. export * from "babylonjs/Cameras/freeCamera";
  50406. export * from "babylonjs/Cameras/freeCameraInputsManager";
  50407. export * from "babylonjs/Cameras/touchCamera";
  50408. export * from "babylonjs/Cameras/arcRotateCamera";
  50409. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  50410. export * from "babylonjs/Cameras/deviceOrientationCamera";
  50411. export * from "babylonjs/Cameras/flyCamera";
  50412. export * from "babylonjs/Cameras/flyCameraInputsManager";
  50413. export * from "babylonjs/Cameras/followCamera";
  50414. export * from "babylonjs/Cameras/followCameraInputsManager";
  50415. export * from "babylonjs/Cameras/gamepadCamera";
  50416. export * from "babylonjs/Cameras/Stereoscopic/index";
  50417. export * from "babylonjs/Cameras/universalCamera";
  50418. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  50419. export * from "babylonjs/Cameras/VR/index";
  50420. export * from "babylonjs/Cameras/RigModes/index";
  50421. }
  50422. declare module "babylonjs/Collisions/index" {
  50423. export * from "babylonjs/Collisions/collider";
  50424. export * from "babylonjs/Collisions/collisionCoordinator";
  50425. export * from "babylonjs/Collisions/pickingInfo";
  50426. export * from "babylonjs/Collisions/intersectionInfo";
  50427. export * from "babylonjs/Collisions/meshCollisionData";
  50428. }
  50429. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  50430. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  50431. import { Vector3 } from "babylonjs/Maths/math.vector";
  50432. import { Ray } from "babylonjs/Culling/ray";
  50433. import { Plane } from "babylonjs/Maths/math.plane";
  50434. /**
  50435. * Contains an array of blocks representing the octree
  50436. */
  50437. export interface IOctreeContainer<T> {
  50438. /**
  50439. * Blocks within the octree
  50440. */
  50441. blocks: Array<OctreeBlock<T>>;
  50442. }
  50443. /**
  50444. * Class used to store a cell in an octree
  50445. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50446. */
  50447. export class OctreeBlock<T> {
  50448. /**
  50449. * Gets the content of the current block
  50450. */
  50451. entries: T[];
  50452. /**
  50453. * Gets the list of block children
  50454. */
  50455. blocks: Array<OctreeBlock<T>>;
  50456. private _depth;
  50457. private _maxDepth;
  50458. private _capacity;
  50459. private _minPoint;
  50460. private _maxPoint;
  50461. private _boundingVectors;
  50462. private _creationFunc;
  50463. /**
  50464. * Creates a new block
  50465. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  50466. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  50467. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  50468. * @param depth defines the current depth of this block in the octree
  50469. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  50470. * @param creationFunc defines a callback to call when an element is added to the block
  50471. */
  50472. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  50473. /**
  50474. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  50475. */
  50476. get capacity(): number;
  50477. /**
  50478. * Gets the minimum vector (in world space) of the block's bounding box
  50479. */
  50480. get minPoint(): Vector3;
  50481. /**
  50482. * Gets the maximum vector (in world space) of the block's bounding box
  50483. */
  50484. get maxPoint(): Vector3;
  50485. /**
  50486. * Add a new element to this block
  50487. * @param entry defines the element to add
  50488. */
  50489. addEntry(entry: T): void;
  50490. /**
  50491. * Remove an element from this block
  50492. * @param entry defines the element to remove
  50493. */
  50494. removeEntry(entry: T): void;
  50495. /**
  50496. * Add an array of elements to this block
  50497. * @param entries defines the array of elements to add
  50498. */
  50499. addEntries(entries: T[]): void;
  50500. /**
  50501. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  50502. * @param frustumPlanes defines the frustum planes to test
  50503. * @param selection defines the array to store current content if selection is positive
  50504. * @param allowDuplicate defines if the selection array can contains duplicated entries
  50505. */
  50506. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  50507. /**
  50508. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  50509. * @param sphereCenter defines the bounding sphere center
  50510. * @param sphereRadius defines the bounding sphere radius
  50511. * @param selection defines the array to store current content if selection is positive
  50512. * @param allowDuplicate defines if the selection array can contains duplicated entries
  50513. */
  50514. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  50515. /**
  50516. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  50517. * @param ray defines the ray to test with
  50518. * @param selection defines the array to store current content if selection is positive
  50519. */
  50520. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  50521. /**
  50522. * Subdivide the content into child blocks (this block will then be empty)
  50523. */
  50524. createInnerBlocks(): void;
  50525. /**
  50526. * @hidden
  50527. */
  50528. 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;
  50529. }
  50530. }
  50531. declare module "babylonjs/Culling/Octrees/octree" {
  50532. import { SmartArray } from "babylonjs/Misc/smartArray";
  50533. import { Vector3 } from "babylonjs/Maths/math.vector";
  50534. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50535. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50536. import { Ray } from "babylonjs/Culling/ray";
  50537. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  50538. import { Plane } from "babylonjs/Maths/math.plane";
  50539. /**
  50540. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  50541. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50542. */
  50543. export class Octree<T> {
  50544. /** 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.) */
  50545. maxDepth: number;
  50546. /**
  50547. * Blocks within the octree containing objects
  50548. */
  50549. blocks: Array<OctreeBlock<T>>;
  50550. /**
  50551. * Content stored in the octree
  50552. */
  50553. dynamicContent: T[];
  50554. private _maxBlockCapacity;
  50555. private _selectionContent;
  50556. private _creationFunc;
  50557. /**
  50558. * Creates a octree
  50559. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50560. * @param creationFunc function to be used to instatiate the octree
  50561. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  50562. * @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.)
  50563. */
  50564. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  50565. /** 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.) */
  50566. maxDepth?: number);
  50567. /**
  50568. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  50569. * @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);
  50570. * @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);
  50571. * @param entries meshes to be added to the octree blocks
  50572. */
  50573. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  50574. /**
  50575. * Adds a mesh to the octree
  50576. * @param entry Mesh to add to the octree
  50577. */
  50578. addMesh(entry: T): void;
  50579. /**
  50580. * Remove an element from the octree
  50581. * @param entry defines the element to remove
  50582. */
  50583. removeMesh(entry: T): void;
  50584. /**
  50585. * Selects an array of meshes within the frustum
  50586. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  50587. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  50588. * @returns array of meshes within the frustum
  50589. */
  50590. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  50591. /**
  50592. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  50593. * @param sphereCenter defines the bounding sphere center
  50594. * @param sphereRadius defines the bounding sphere radius
  50595. * @param allowDuplicate defines if the selection array can contains duplicated entries
  50596. * @returns an array of objects that intersect the sphere
  50597. */
  50598. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  50599. /**
  50600. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  50601. * @param ray defines the ray to test with
  50602. * @returns array of intersected objects
  50603. */
  50604. intersectsRay(ray: Ray): SmartArray<T>;
  50605. /**
  50606. * Adds a mesh into the octree block if it intersects the block
  50607. */
  50608. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  50609. /**
  50610. * Adds a submesh into the octree block if it intersects the block
  50611. */
  50612. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  50613. }
  50614. }
  50615. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  50616. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  50617. import { Scene } from "babylonjs/scene";
  50618. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50619. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50620. import { Ray } from "babylonjs/Culling/ray";
  50621. import { Octree } from "babylonjs/Culling/Octrees/octree";
  50622. import { Collider } from "babylonjs/Collisions/collider";
  50623. module "babylonjs/scene" {
  50624. interface Scene {
  50625. /**
  50626. * @hidden
  50627. * Backing Filed
  50628. */
  50629. _selectionOctree: Octree<AbstractMesh>;
  50630. /**
  50631. * Gets the octree used to boost mesh selection (picking)
  50632. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50633. */
  50634. selectionOctree: Octree<AbstractMesh>;
  50635. /**
  50636. * Creates or updates the octree used to boost selection (picking)
  50637. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50638. * @param maxCapacity defines the maximum capacity per leaf
  50639. * @param maxDepth defines the maximum depth of the octree
  50640. * @returns an octree of AbstractMesh
  50641. */
  50642. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  50643. }
  50644. }
  50645. module "babylonjs/Meshes/abstractMesh" {
  50646. interface AbstractMesh {
  50647. /**
  50648. * @hidden
  50649. * Backing Field
  50650. */
  50651. _submeshesOctree: Octree<SubMesh>;
  50652. /**
  50653. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  50654. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  50655. * @param maxCapacity defines the maximum size of each block (64 by default)
  50656. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  50657. * @returns the new octree
  50658. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  50659. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50660. */
  50661. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  50662. }
  50663. }
  50664. /**
  50665. * Defines the octree scene component responsible to manage any octrees
  50666. * in a given scene.
  50667. */
  50668. export class OctreeSceneComponent {
  50669. /**
  50670. * The component name help to identify the component in the list of scene components.
  50671. */
  50672. readonly name: string;
  50673. /**
  50674. * The scene the component belongs to.
  50675. */
  50676. scene: Scene;
  50677. /**
  50678. * Indicates if the meshes have been checked to make sure they are isEnabled()
  50679. */
  50680. readonly checksIsEnabled: boolean;
  50681. /**
  50682. * Creates a new instance of the component for the given scene
  50683. * @param scene Defines the scene to register the component in
  50684. */
  50685. constructor(scene: Scene);
  50686. /**
  50687. * Registers the component in a given scene
  50688. */
  50689. register(): void;
  50690. /**
  50691. * Return the list of active meshes
  50692. * @returns the list of active meshes
  50693. */
  50694. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  50695. /**
  50696. * Return the list of active sub meshes
  50697. * @param mesh The mesh to get the candidates sub meshes from
  50698. * @returns the list of active sub meshes
  50699. */
  50700. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  50701. private _tempRay;
  50702. /**
  50703. * Return the list of sub meshes intersecting with a given local ray
  50704. * @param mesh defines the mesh to find the submesh for
  50705. * @param localRay defines the ray in local space
  50706. * @returns the list of intersecting sub meshes
  50707. */
  50708. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  50709. /**
  50710. * Return the list of sub meshes colliding with a collider
  50711. * @param mesh defines the mesh to find the submesh for
  50712. * @param collider defines the collider to evaluate the collision against
  50713. * @returns the list of colliding sub meshes
  50714. */
  50715. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  50716. /**
  50717. * Rebuilds the elements related to this component in case of
  50718. * context lost for instance.
  50719. */
  50720. rebuild(): void;
  50721. /**
  50722. * Disposes the component and the associated ressources.
  50723. */
  50724. dispose(): void;
  50725. }
  50726. }
  50727. declare module "babylonjs/Culling/Octrees/index" {
  50728. export * from "babylonjs/Culling/Octrees/octree";
  50729. export * from "babylonjs/Culling/Octrees/octreeBlock";
  50730. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  50731. }
  50732. declare module "babylonjs/Culling/index" {
  50733. export * from "babylonjs/Culling/boundingBox";
  50734. export * from "babylonjs/Culling/boundingInfo";
  50735. export * from "babylonjs/Culling/boundingSphere";
  50736. export * from "babylonjs/Culling/Octrees/index";
  50737. export * from "babylonjs/Culling/ray";
  50738. }
  50739. declare module "babylonjs/Gizmos/gizmo" {
  50740. import { Nullable } from "babylonjs/types";
  50741. import { IDisposable } from "babylonjs/scene";
  50742. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50743. import { Mesh } from "babylonjs/Meshes/mesh";
  50744. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50745. /**
  50746. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  50747. */
  50748. export class Gizmo implements IDisposable {
  50749. /** The utility layer the gizmo will be added to */
  50750. gizmoLayer: UtilityLayerRenderer;
  50751. /**
  50752. * The root mesh of the gizmo
  50753. */
  50754. _rootMesh: Mesh;
  50755. private _attachedMesh;
  50756. /**
  50757. * Ratio for the scale of the gizmo (Default: 1)
  50758. */
  50759. scaleRatio: number;
  50760. /**
  50761. * If a custom mesh has been set (Default: false)
  50762. */
  50763. protected _customMeshSet: boolean;
  50764. /**
  50765. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  50766. * * When set, interactions will be enabled
  50767. */
  50768. get attachedMesh(): Nullable<AbstractMesh>;
  50769. set attachedMesh(value: Nullable<AbstractMesh>);
  50770. /**
  50771. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  50772. * @param mesh The mesh to replace the default mesh of the gizmo
  50773. */
  50774. setCustomMesh(mesh: Mesh): void;
  50775. /**
  50776. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  50777. */
  50778. updateGizmoRotationToMatchAttachedMesh: boolean;
  50779. /**
  50780. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  50781. */
  50782. updateGizmoPositionToMatchAttachedMesh: boolean;
  50783. /**
  50784. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  50785. */
  50786. updateScale: boolean;
  50787. protected _interactionsEnabled: boolean;
  50788. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50789. private _beforeRenderObserver;
  50790. private _tempVector;
  50791. /**
  50792. * Creates a gizmo
  50793. * @param gizmoLayer The utility layer the gizmo will be added to
  50794. */
  50795. constructor(
  50796. /** The utility layer the gizmo will be added to */
  50797. gizmoLayer?: UtilityLayerRenderer);
  50798. /**
  50799. * Updates the gizmo to match the attached mesh's position/rotation
  50800. */
  50801. protected _update(): void;
  50802. /**
  50803. * Disposes of the gizmo
  50804. */
  50805. dispose(): void;
  50806. }
  50807. }
  50808. declare module "babylonjs/Gizmos/planeDragGizmo" {
  50809. import { Observable } from "babylonjs/Misc/observable";
  50810. import { Nullable } from "babylonjs/types";
  50811. import { Vector3 } from "babylonjs/Maths/math.vector";
  50812. import { Color3 } from "babylonjs/Maths/math.color";
  50813. import { TransformNode } from "babylonjs/Meshes/transformNode";
  50814. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50815. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  50816. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50817. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50818. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  50819. import { Scene } from "babylonjs/scene";
  50820. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  50821. /**
  50822. * Single plane drag gizmo
  50823. */
  50824. export class PlaneDragGizmo extends Gizmo {
  50825. /**
  50826. * Drag behavior responsible for the gizmos dragging interactions
  50827. */
  50828. dragBehavior: PointerDragBehavior;
  50829. private _pointerObserver;
  50830. /**
  50831. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50832. */
  50833. snapDistance: number;
  50834. /**
  50835. * Event that fires each time the gizmo snaps to a new location.
  50836. * * snapDistance is the the change in distance
  50837. */
  50838. onSnapObservable: Observable<{
  50839. snapDistance: number;
  50840. }>;
  50841. private _plane;
  50842. private _coloredMaterial;
  50843. private _hoverMaterial;
  50844. private _isEnabled;
  50845. private _parent;
  50846. /** @hidden */
  50847. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  50848. /** @hidden */
  50849. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  50850. /**
  50851. * Creates a PlaneDragGizmo
  50852. * @param gizmoLayer The utility layer the gizmo will be added to
  50853. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  50854. * @param color The color of the gizmo
  50855. */
  50856. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  50857. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50858. /**
  50859. * If the gizmo is enabled
  50860. */
  50861. set isEnabled(value: boolean);
  50862. get isEnabled(): boolean;
  50863. /**
  50864. * Disposes of the gizmo
  50865. */
  50866. dispose(): void;
  50867. }
  50868. }
  50869. declare module "babylonjs/Gizmos/positionGizmo" {
  50870. import { Observable } from "babylonjs/Misc/observable";
  50871. import { Nullable } from "babylonjs/types";
  50872. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50873. import { Mesh } from "babylonjs/Meshes/mesh";
  50874. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50875. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  50876. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  50877. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50878. /**
  50879. * Gizmo that enables dragging a mesh along 3 axis
  50880. */
  50881. export class PositionGizmo extends Gizmo {
  50882. /**
  50883. * Internal gizmo used for interactions on the x axis
  50884. */
  50885. xGizmo: AxisDragGizmo;
  50886. /**
  50887. * Internal gizmo used for interactions on the y axis
  50888. */
  50889. yGizmo: AxisDragGizmo;
  50890. /**
  50891. * Internal gizmo used for interactions on the z axis
  50892. */
  50893. zGizmo: AxisDragGizmo;
  50894. /**
  50895. * Internal gizmo used for interactions on the yz plane
  50896. */
  50897. xPlaneGizmo: PlaneDragGizmo;
  50898. /**
  50899. * Internal gizmo used for interactions on the xz plane
  50900. */
  50901. yPlaneGizmo: PlaneDragGizmo;
  50902. /**
  50903. * Internal gizmo used for interactions on the xy plane
  50904. */
  50905. zPlaneGizmo: PlaneDragGizmo;
  50906. /**
  50907. * private variables
  50908. */
  50909. private _meshAttached;
  50910. private _updateGizmoRotationToMatchAttachedMesh;
  50911. private _snapDistance;
  50912. private _scaleRatio;
  50913. /** Fires an event when any of it's sub gizmos are dragged */
  50914. onDragStartObservable: Observable<unknown>;
  50915. /** Fires an event when any of it's sub gizmos are released from dragging */
  50916. onDragEndObservable: Observable<unknown>;
  50917. /**
  50918. * If set to true, planar drag is enabled
  50919. */
  50920. private _planarGizmoEnabled;
  50921. get attachedMesh(): Nullable<AbstractMesh>;
  50922. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50923. /**
  50924. * Creates a PositionGizmo
  50925. * @param gizmoLayer The utility layer the gizmo will be added to
  50926. */
  50927. constructor(gizmoLayer?: UtilityLayerRenderer);
  50928. /**
  50929. * If the planar drag gizmo is enabled
  50930. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  50931. */
  50932. set planarGizmoEnabled(value: boolean);
  50933. get planarGizmoEnabled(): boolean;
  50934. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50935. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50936. /**
  50937. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50938. */
  50939. set snapDistance(value: number);
  50940. get snapDistance(): number;
  50941. /**
  50942. * Ratio for the scale of the gizmo (Default: 1)
  50943. */
  50944. set scaleRatio(value: number);
  50945. get scaleRatio(): number;
  50946. /**
  50947. * Disposes of the gizmo
  50948. */
  50949. dispose(): void;
  50950. /**
  50951. * CustomMeshes are not supported by this gizmo
  50952. * @param mesh The mesh to replace the default mesh of the gizmo
  50953. */
  50954. setCustomMesh(mesh: Mesh): void;
  50955. }
  50956. }
  50957. declare module "babylonjs/Gizmos/axisDragGizmo" {
  50958. import { Observable } from "babylonjs/Misc/observable";
  50959. import { Nullable } from "babylonjs/types";
  50960. import { Vector3 } from "babylonjs/Maths/math.vector";
  50961. import { TransformNode } from "babylonjs/Meshes/transformNode";
  50962. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50963. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  50964. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50965. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50966. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  50967. import { Scene } from "babylonjs/scene";
  50968. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  50969. import { Color3 } from "babylonjs/Maths/math.color";
  50970. /**
  50971. * Single axis drag gizmo
  50972. */
  50973. export class AxisDragGizmo extends Gizmo {
  50974. /**
  50975. * Drag behavior responsible for the gizmos dragging interactions
  50976. */
  50977. dragBehavior: PointerDragBehavior;
  50978. private _pointerObserver;
  50979. /**
  50980. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50981. */
  50982. snapDistance: number;
  50983. /**
  50984. * Event that fires each time the gizmo snaps to a new location.
  50985. * * snapDistance is the the change in distance
  50986. */
  50987. onSnapObservable: Observable<{
  50988. snapDistance: number;
  50989. }>;
  50990. private _isEnabled;
  50991. private _parent;
  50992. private _arrow;
  50993. private _coloredMaterial;
  50994. private _hoverMaterial;
  50995. /** @hidden */
  50996. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  50997. /** @hidden */
  50998. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  50999. /**
  51000. * Creates an AxisDragGizmo
  51001. * @param gizmoLayer The utility layer the gizmo will be added to
  51002. * @param dragAxis The axis which the gizmo will be able to drag on
  51003. * @param color The color of the gizmo
  51004. */
  51005. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  51006. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  51007. /**
  51008. * If the gizmo is enabled
  51009. */
  51010. set isEnabled(value: boolean);
  51011. get isEnabled(): boolean;
  51012. /**
  51013. * Disposes of the gizmo
  51014. */
  51015. dispose(): void;
  51016. }
  51017. }
  51018. declare module "babylonjs/Debug/axesViewer" {
  51019. import { Vector3 } from "babylonjs/Maths/math.vector";
  51020. import { Nullable } from "babylonjs/types";
  51021. import { Scene } from "babylonjs/scene";
  51022. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51023. /**
  51024. * The Axes viewer will show 3 axes in a specific point in space
  51025. */
  51026. export class AxesViewer {
  51027. private _xAxis;
  51028. private _yAxis;
  51029. private _zAxis;
  51030. private _scaleLinesFactor;
  51031. private _instanced;
  51032. /**
  51033. * Gets the hosting scene
  51034. */
  51035. scene: Scene;
  51036. /**
  51037. * Gets or sets a number used to scale line length
  51038. */
  51039. scaleLines: number;
  51040. /** Gets the node hierarchy used to render x-axis */
  51041. get xAxis(): TransformNode;
  51042. /** Gets the node hierarchy used to render y-axis */
  51043. get yAxis(): TransformNode;
  51044. /** Gets the node hierarchy used to render z-axis */
  51045. get zAxis(): TransformNode;
  51046. /**
  51047. * Creates a new AxesViewer
  51048. * @param scene defines the hosting scene
  51049. * @param scaleLines defines a number used to scale line length (1 by default)
  51050. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  51051. * @param xAxis defines the node hierarchy used to render the x-axis
  51052. * @param yAxis defines the node hierarchy used to render the y-axis
  51053. * @param zAxis defines the node hierarchy used to render the z-axis
  51054. */
  51055. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  51056. /**
  51057. * Force the viewer to update
  51058. * @param position defines the position of the viewer
  51059. * @param xaxis defines the x axis of the viewer
  51060. * @param yaxis defines the y axis of the viewer
  51061. * @param zaxis defines the z axis of the viewer
  51062. */
  51063. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  51064. /**
  51065. * Creates an instance of this axes viewer.
  51066. * @returns a new axes viewer with instanced meshes
  51067. */
  51068. createInstance(): AxesViewer;
  51069. /** Releases resources */
  51070. dispose(): void;
  51071. private static _SetRenderingGroupId;
  51072. }
  51073. }
  51074. declare module "babylonjs/Debug/boneAxesViewer" {
  51075. import { Nullable } from "babylonjs/types";
  51076. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  51077. import { Vector3 } from "babylonjs/Maths/math.vector";
  51078. import { Mesh } from "babylonjs/Meshes/mesh";
  51079. import { Bone } from "babylonjs/Bones/bone";
  51080. import { Scene } from "babylonjs/scene";
  51081. /**
  51082. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  51083. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  51084. */
  51085. export class BoneAxesViewer extends AxesViewer {
  51086. /**
  51087. * Gets or sets the target mesh where to display the axes viewer
  51088. */
  51089. mesh: Nullable<Mesh>;
  51090. /**
  51091. * Gets or sets the target bone where to display the axes viewer
  51092. */
  51093. bone: Nullable<Bone>;
  51094. /** Gets current position */
  51095. pos: Vector3;
  51096. /** Gets direction of X axis */
  51097. xaxis: Vector3;
  51098. /** Gets direction of Y axis */
  51099. yaxis: Vector3;
  51100. /** Gets direction of Z axis */
  51101. zaxis: Vector3;
  51102. /**
  51103. * Creates a new BoneAxesViewer
  51104. * @param scene defines the hosting scene
  51105. * @param bone defines the target bone
  51106. * @param mesh defines the target mesh
  51107. * @param scaleLines defines a scaling factor for line length (1 by default)
  51108. */
  51109. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  51110. /**
  51111. * Force the viewer to update
  51112. */
  51113. update(): void;
  51114. /** Releases resources */
  51115. dispose(): void;
  51116. }
  51117. }
  51118. declare module "babylonjs/Debug/debugLayer" {
  51119. import { Scene } from "babylonjs/scene";
  51120. /**
  51121. * Interface used to define scene explorer extensibility option
  51122. */
  51123. export interface IExplorerExtensibilityOption {
  51124. /**
  51125. * Define the option label
  51126. */
  51127. label: string;
  51128. /**
  51129. * Defines the action to execute on click
  51130. */
  51131. action: (entity: any) => void;
  51132. }
  51133. /**
  51134. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  51135. */
  51136. export interface IExplorerExtensibilityGroup {
  51137. /**
  51138. * Defines a predicate to test if a given type mut be extended
  51139. */
  51140. predicate: (entity: any) => boolean;
  51141. /**
  51142. * Gets the list of options added to a type
  51143. */
  51144. entries: IExplorerExtensibilityOption[];
  51145. }
  51146. /**
  51147. * Interface used to define the options to use to create the Inspector
  51148. */
  51149. export interface IInspectorOptions {
  51150. /**
  51151. * Display in overlay mode (default: false)
  51152. */
  51153. overlay?: boolean;
  51154. /**
  51155. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  51156. */
  51157. globalRoot?: HTMLElement;
  51158. /**
  51159. * Display the Scene explorer
  51160. */
  51161. showExplorer?: boolean;
  51162. /**
  51163. * Display the property inspector
  51164. */
  51165. showInspector?: boolean;
  51166. /**
  51167. * Display in embed mode (both panes on the right)
  51168. */
  51169. embedMode?: boolean;
  51170. /**
  51171. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  51172. */
  51173. handleResize?: boolean;
  51174. /**
  51175. * Allow the panes to popup (default: true)
  51176. */
  51177. enablePopup?: boolean;
  51178. /**
  51179. * Allow the panes to be closed by users (default: true)
  51180. */
  51181. enableClose?: boolean;
  51182. /**
  51183. * Optional list of extensibility entries
  51184. */
  51185. explorerExtensibility?: IExplorerExtensibilityGroup[];
  51186. /**
  51187. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  51188. */
  51189. inspectorURL?: string;
  51190. /**
  51191. * Optional initial tab (default to DebugLayerTab.Properties)
  51192. */
  51193. initialTab?: DebugLayerTab;
  51194. }
  51195. module "babylonjs/scene" {
  51196. interface Scene {
  51197. /**
  51198. * @hidden
  51199. * Backing field
  51200. */
  51201. _debugLayer: DebugLayer;
  51202. /**
  51203. * Gets the debug layer (aka Inspector) associated with the scene
  51204. * @see http://doc.babylonjs.com/features/playground_debuglayer
  51205. */
  51206. debugLayer: DebugLayer;
  51207. }
  51208. }
  51209. /**
  51210. * Enum of inspector action tab
  51211. */
  51212. export enum DebugLayerTab {
  51213. /**
  51214. * Properties tag (default)
  51215. */
  51216. Properties = 0,
  51217. /**
  51218. * Debug tab
  51219. */
  51220. Debug = 1,
  51221. /**
  51222. * Statistics tab
  51223. */
  51224. Statistics = 2,
  51225. /**
  51226. * Tools tab
  51227. */
  51228. Tools = 3,
  51229. /**
  51230. * Settings tab
  51231. */
  51232. Settings = 4
  51233. }
  51234. /**
  51235. * The debug layer (aka Inspector) is the go to tool in order to better understand
  51236. * what is happening in your scene
  51237. * @see http://doc.babylonjs.com/features/playground_debuglayer
  51238. */
  51239. export class DebugLayer {
  51240. /**
  51241. * Define the url to get the inspector script from.
  51242. * By default it uses the babylonjs CDN.
  51243. * @ignoreNaming
  51244. */
  51245. static InspectorURL: string;
  51246. private _scene;
  51247. private BJSINSPECTOR;
  51248. private _onPropertyChangedObservable?;
  51249. /**
  51250. * Observable triggered when a property is changed through the inspector.
  51251. */
  51252. get onPropertyChangedObservable(): any;
  51253. /**
  51254. * Instantiates a new debug layer.
  51255. * The debug layer (aka Inspector) is the go to tool in order to better understand
  51256. * what is happening in your scene
  51257. * @see http://doc.babylonjs.com/features/playground_debuglayer
  51258. * @param scene Defines the scene to inspect
  51259. */
  51260. constructor(scene: Scene);
  51261. /** Creates the inspector window. */
  51262. private _createInspector;
  51263. /**
  51264. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  51265. * @param entity defines the entity to select
  51266. * @param lineContainerTitle defines the specific block to highlight
  51267. */
  51268. select(entity: any, lineContainerTitle?: string): void;
  51269. /** Get the inspector from bundle or global */
  51270. private _getGlobalInspector;
  51271. /**
  51272. * Get if the inspector is visible or not.
  51273. * @returns true if visible otherwise, false
  51274. */
  51275. isVisible(): boolean;
  51276. /**
  51277. * Hide the inspector and close its window.
  51278. */
  51279. hide(): void;
  51280. /**
  51281. * Update the scene in the inspector
  51282. */
  51283. setAsActiveScene(): void;
  51284. /**
  51285. * Launch the debugLayer.
  51286. * @param config Define the configuration of the inspector
  51287. * @return a promise fulfilled when the debug layer is visible
  51288. */
  51289. show(config?: IInspectorOptions): Promise<DebugLayer>;
  51290. }
  51291. }
  51292. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  51293. import { Nullable } from "babylonjs/types";
  51294. import { Scene } from "babylonjs/scene";
  51295. import { Vector4 } from "babylonjs/Maths/math.vector";
  51296. import { Color4 } from "babylonjs/Maths/math.color";
  51297. import { Mesh } from "babylonjs/Meshes/mesh";
  51298. /**
  51299. * Class containing static functions to help procedurally build meshes
  51300. */
  51301. export class BoxBuilder {
  51302. /**
  51303. * Creates a box mesh
  51304. * * The parameter `size` sets the size (float) of each box side (default 1)
  51305. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  51306. * * 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)
  51307. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  51308. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51309. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51310. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51311. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  51312. * @param name defines the name of the mesh
  51313. * @param options defines the options used to create the mesh
  51314. * @param scene defines the hosting scene
  51315. * @returns the box mesh
  51316. */
  51317. static CreateBox(name: string, options: {
  51318. size?: number;
  51319. width?: number;
  51320. height?: number;
  51321. depth?: number;
  51322. faceUV?: Vector4[];
  51323. faceColors?: Color4[];
  51324. sideOrientation?: number;
  51325. frontUVs?: Vector4;
  51326. backUVs?: Vector4;
  51327. wrap?: boolean;
  51328. topBaseAt?: number;
  51329. bottomBaseAt?: number;
  51330. updatable?: boolean;
  51331. }, scene?: Nullable<Scene>): Mesh;
  51332. }
  51333. }
  51334. declare module "babylonjs/Debug/physicsViewer" {
  51335. import { Nullable } from "babylonjs/types";
  51336. import { Scene } from "babylonjs/scene";
  51337. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51338. import { Mesh } from "babylonjs/Meshes/mesh";
  51339. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  51340. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51341. /**
  51342. * Used to show the physics impostor around the specific mesh
  51343. */
  51344. export class PhysicsViewer {
  51345. /** @hidden */
  51346. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  51347. /** @hidden */
  51348. protected _meshes: Array<Nullable<AbstractMesh>>;
  51349. /** @hidden */
  51350. protected _scene: Nullable<Scene>;
  51351. /** @hidden */
  51352. protected _numMeshes: number;
  51353. /** @hidden */
  51354. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  51355. private _renderFunction;
  51356. private _utilityLayer;
  51357. private _debugBoxMesh;
  51358. private _debugSphereMesh;
  51359. private _debugCylinderMesh;
  51360. private _debugMaterial;
  51361. private _debugMeshMeshes;
  51362. /**
  51363. * Creates a new PhysicsViewer
  51364. * @param scene defines the hosting scene
  51365. */
  51366. constructor(scene: Scene);
  51367. /** @hidden */
  51368. protected _updateDebugMeshes(): void;
  51369. /**
  51370. * Renders a specified physic impostor
  51371. * @param impostor defines the impostor to render
  51372. * @param targetMesh defines the mesh represented by the impostor
  51373. * @returns the new debug mesh used to render the impostor
  51374. */
  51375. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  51376. /**
  51377. * Hides a specified physic impostor
  51378. * @param impostor defines the impostor to hide
  51379. */
  51380. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  51381. private _getDebugMaterial;
  51382. private _getDebugBoxMesh;
  51383. private _getDebugSphereMesh;
  51384. private _getDebugCylinderMesh;
  51385. private _getDebugMeshMesh;
  51386. private _getDebugMesh;
  51387. /** Releases all resources */
  51388. dispose(): void;
  51389. }
  51390. }
  51391. declare module "babylonjs/Debug/rayHelper" {
  51392. import { Nullable } from "babylonjs/types";
  51393. import { Ray } from "babylonjs/Culling/ray";
  51394. import { Vector3 } from "babylonjs/Maths/math.vector";
  51395. import { Color3 } from "babylonjs/Maths/math.color";
  51396. import { Scene } from "babylonjs/scene";
  51397. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51398. import "babylonjs/Meshes/Builders/linesBuilder";
  51399. /**
  51400. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  51401. * in order to better appreciate the issue one might have.
  51402. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  51403. */
  51404. export class RayHelper {
  51405. /**
  51406. * Defines the ray we are currently tryin to visualize.
  51407. */
  51408. ray: Nullable<Ray>;
  51409. private _renderPoints;
  51410. private _renderLine;
  51411. private _renderFunction;
  51412. private _scene;
  51413. private _updateToMeshFunction;
  51414. private _attachedToMesh;
  51415. private _meshSpaceDirection;
  51416. private _meshSpaceOrigin;
  51417. /**
  51418. * Helper function to create a colored helper in a scene in one line.
  51419. * @param ray Defines the ray we are currently tryin to visualize
  51420. * @param scene Defines the scene the ray is used in
  51421. * @param color Defines the color we want to see the ray in
  51422. * @returns The newly created ray helper.
  51423. */
  51424. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  51425. /**
  51426. * Instantiate a new ray helper.
  51427. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  51428. * in order to better appreciate the issue one might have.
  51429. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  51430. * @param ray Defines the ray we are currently tryin to visualize
  51431. */
  51432. constructor(ray: Ray);
  51433. /**
  51434. * Shows the ray we are willing to debug.
  51435. * @param scene Defines the scene the ray needs to be rendered in
  51436. * @param color Defines the color the ray needs to be rendered in
  51437. */
  51438. show(scene: Scene, color?: Color3): void;
  51439. /**
  51440. * Hides the ray we are debugging.
  51441. */
  51442. hide(): void;
  51443. private _render;
  51444. /**
  51445. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  51446. * @param mesh Defines the mesh we want the helper attached to
  51447. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  51448. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  51449. * @param length Defines the length of the ray
  51450. */
  51451. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  51452. /**
  51453. * Detach the ray helper from the mesh it has previously been attached to.
  51454. */
  51455. detachFromMesh(): void;
  51456. private _updateToMesh;
  51457. /**
  51458. * Dispose the helper and release its associated resources.
  51459. */
  51460. dispose(): void;
  51461. }
  51462. }
  51463. declare module "babylonjs/Debug/skeletonViewer" {
  51464. import { Color3 } from "babylonjs/Maths/math.color";
  51465. import { Scene } from "babylonjs/scene";
  51466. import { Nullable } from "babylonjs/types";
  51467. import { Skeleton } from "babylonjs/Bones/skeleton";
  51468. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51469. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  51470. /**
  51471. * Class used to render a debug view of a given skeleton
  51472. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  51473. */
  51474. export class SkeletonViewer {
  51475. /** defines the skeleton to render */
  51476. skeleton: Skeleton;
  51477. /** defines the mesh attached to the skeleton */
  51478. mesh: AbstractMesh;
  51479. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  51480. autoUpdateBonesMatrices: boolean;
  51481. /** defines the rendering group id to use with the viewer */
  51482. renderingGroupId: number;
  51483. /** Gets or sets the color used to render the skeleton */
  51484. color: Color3;
  51485. private _scene;
  51486. private _debugLines;
  51487. private _debugMesh;
  51488. private _isEnabled;
  51489. private _renderFunction;
  51490. private _utilityLayer;
  51491. /**
  51492. * Returns the mesh used to render the bones
  51493. */
  51494. get debugMesh(): Nullable<LinesMesh>;
  51495. /**
  51496. * Creates a new SkeletonViewer
  51497. * @param skeleton defines the skeleton to render
  51498. * @param mesh defines the mesh attached to the skeleton
  51499. * @param scene defines the hosting scene
  51500. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  51501. * @param renderingGroupId defines the rendering group id to use with the viewer
  51502. */
  51503. constructor(
  51504. /** defines the skeleton to render */
  51505. skeleton: Skeleton,
  51506. /** defines the mesh attached to the skeleton */
  51507. mesh: AbstractMesh, scene: Scene,
  51508. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  51509. autoUpdateBonesMatrices?: boolean,
  51510. /** defines the rendering group id to use with the viewer */
  51511. renderingGroupId?: number);
  51512. /** Gets or sets a boolean indicating if the viewer is enabled */
  51513. set isEnabled(value: boolean);
  51514. get isEnabled(): boolean;
  51515. private _getBonePosition;
  51516. private _getLinesForBonesWithLength;
  51517. private _getLinesForBonesNoLength;
  51518. /** Update the viewer to sync with current skeleton state */
  51519. update(): void;
  51520. /** Release associated resources */
  51521. dispose(): void;
  51522. }
  51523. }
  51524. declare module "babylonjs/Debug/index" {
  51525. export * from "babylonjs/Debug/axesViewer";
  51526. export * from "babylonjs/Debug/boneAxesViewer";
  51527. export * from "babylonjs/Debug/debugLayer";
  51528. export * from "babylonjs/Debug/physicsViewer";
  51529. export * from "babylonjs/Debug/rayHelper";
  51530. export * from "babylonjs/Debug/skeletonViewer";
  51531. }
  51532. declare module "babylonjs/DeviceInput/InputDevices/deviceEnums" {
  51533. /**
  51534. * Enum for Device Types
  51535. */
  51536. export enum DeviceType {
  51537. /** Generic */
  51538. Generic = 0,
  51539. /** Keyboard */
  51540. Keyboard = 1,
  51541. /** Mouse */
  51542. Mouse = 2,
  51543. /** Touch Pointers */
  51544. Touch = 3,
  51545. /** PS4 Dual Shock */
  51546. DualShock = 4,
  51547. /** Xbox */
  51548. Xbox = 5,
  51549. /** Switch Controller */
  51550. Switch = 6
  51551. }
  51552. /**
  51553. * Enum for All Pointers (Touch/Mouse)
  51554. */
  51555. export enum PointerInput {
  51556. /** Horizontal Axis */
  51557. Horizontal = 0,
  51558. /** Vertical Axis */
  51559. Vertical = 1,
  51560. /** Left Click or Touch */
  51561. LeftClick = 2,
  51562. /** Middle Click */
  51563. MiddleClick = 3,
  51564. /** Right Click */
  51565. RightClick = 4,
  51566. /** Browser Back */
  51567. BrowserBack = 5,
  51568. /** Browser Forward */
  51569. BrowserForward = 6
  51570. }
  51571. /**
  51572. * Enum for Dual Shock Gamepad
  51573. */
  51574. export enum DualShockInput {
  51575. /** Cross */
  51576. Cross = 0,
  51577. /** Circle */
  51578. Circle = 1,
  51579. /** Square */
  51580. Square = 2,
  51581. /** Triangle */
  51582. Triangle = 3,
  51583. /** L1 */
  51584. L1 = 4,
  51585. /** R1 */
  51586. R1 = 5,
  51587. /** L2 */
  51588. L2 = 6,
  51589. /** R2 */
  51590. R2 = 7,
  51591. /** Share */
  51592. Share = 8,
  51593. /** Options */
  51594. Options = 9,
  51595. /** L3 */
  51596. L3 = 10,
  51597. /** R3 */
  51598. R3 = 11,
  51599. /** DPadUp */
  51600. DPadUp = 12,
  51601. /** DPadDown */
  51602. DPadDown = 13,
  51603. /** DPadLeft */
  51604. DPadLeft = 14,
  51605. /** DRight */
  51606. DPadRight = 15,
  51607. /** Home */
  51608. Home = 16,
  51609. /** TouchPad */
  51610. TouchPad = 17,
  51611. /** LStickXAxis */
  51612. LStickXAxis = 18,
  51613. /** LStickYAxis */
  51614. LStickYAxis = 19,
  51615. /** RStickXAxis */
  51616. RStickXAxis = 20,
  51617. /** RStickYAxis */
  51618. RStickYAxis = 21
  51619. }
  51620. /**
  51621. * Enum for Xbox Gamepad
  51622. */
  51623. export enum XboxInput {
  51624. /** A */
  51625. A = 0,
  51626. /** B */
  51627. B = 1,
  51628. /** X */
  51629. X = 2,
  51630. /** Y */
  51631. Y = 3,
  51632. /** LB */
  51633. LB = 4,
  51634. /** RB */
  51635. RB = 5,
  51636. /** LT */
  51637. LT = 6,
  51638. /** RT */
  51639. RT = 7,
  51640. /** Back */
  51641. Back = 8,
  51642. /** Start */
  51643. Start = 9,
  51644. /** LS */
  51645. LS = 10,
  51646. /** RS */
  51647. RS = 11,
  51648. /** DPadUp */
  51649. DPadUp = 12,
  51650. /** DPadDown */
  51651. DPadDown = 13,
  51652. /** DPadLeft */
  51653. DPadLeft = 14,
  51654. /** DRight */
  51655. DPadRight = 15,
  51656. /** Home */
  51657. Home = 16,
  51658. /** LStickXAxis */
  51659. LStickXAxis = 17,
  51660. /** LStickYAxis */
  51661. LStickYAxis = 18,
  51662. /** RStickXAxis */
  51663. RStickXAxis = 19,
  51664. /** RStickYAxis */
  51665. RStickYAxis = 20
  51666. }
  51667. /**
  51668. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  51669. */
  51670. export enum SwitchInput {
  51671. /** B */
  51672. B = 0,
  51673. /** A */
  51674. A = 1,
  51675. /** Y */
  51676. Y = 2,
  51677. /** X */
  51678. X = 3,
  51679. /** L */
  51680. L = 4,
  51681. /** R */
  51682. R = 5,
  51683. /** ZL */
  51684. ZL = 6,
  51685. /** ZR */
  51686. ZR = 7,
  51687. /** Minus */
  51688. Minus = 8,
  51689. /** Plus */
  51690. Plus = 9,
  51691. /** LS */
  51692. LS = 10,
  51693. /** RS */
  51694. RS = 11,
  51695. /** DPadUp */
  51696. DPadUp = 12,
  51697. /** DPadDown */
  51698. DPadDown = 13,
  51699. /** DPadLeft */
  51700. DPadLeft = 14,
  51701. /** DRight */
  51702. DPadRight = 15,
  51703. /** Home */
  51704. Home = 16,
  51705. /** Capture */
  51706. Capture = 17,
  51707. /** LStickXAxis */
  51708. LStickXAxis = 18,
  51709. /** LStickYAxis */
  51710. LStickYAxis = 19,
  51711. /** RStickXAxis */
  51712. RStickXAxis = 20,
  51713. /** RStickYAxis */
  51714. RStickYAxis = 21
  51715. }
  51716. }
  51717. declare module "babylonjs/DeviceInput/deviceInputSystem" {
  51718. import { Engine } from "babylonjs/Engines/engine";
  51719. import { IDisposable } from "babylonjs/scene";
  51720. import { Nullable } from "babylonjs/types";
  51721. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  51722. /**
  51723. * This class will take all inputs from Keyboard, Pointer, and
  51724. * any Gamepads and provide a polling system that all devices
  51725. * will use. This class assumes that there will only be one
  51726. * pointer device and one keyboard.
  51727. */
  51728. export class DeviceInputSystem implements IDisposable {
  51729. /**
  51730. * Callback to be triggered when a device is connected
  51731. */
  51732. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  51733. /**
  51734. * Callback to be triggered when a device is disconnected
  51735. */
  51736. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  51737. /**
  51738. * Callback to be triggered when event driven input is updated
  51739. */
  51740. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  51741. private _inputs;
  51742. private _gamepads;
  51743. private _keyboardActive;
  51744. private _pointerActive;
  51745. private _elementToAttachTo;
  51746. private _keyboardDownEvent;
  51747. private _keyboardUpEvent;
  51748. private _pointerMoveEvent;
  51749. private _pointerDownEvent;
  51750. private _pointerUpEvent;
  51751. private _gamepadConnectedEvent;
  51752. private _gamepadDisconnectedEvent;
  51753. private static _MAX_KEYCODES;
  51754. private static _MAX_POINTER_INPUTS;
  51755. private constructor();
  51756. /**
  51757. * Creates a new DeviceInputSystem instance
  51758. * @param engine Engine to pull input element from
  51759. * @returns The new instance
  51760. */
  51761. static Create(engine: Engine): DeviceInputSystem;
  51762. /**
  51763. * Checks for current device input value, given an id and input index
  51764. * @param deviceName Id of connected device
  51765. * @param inputIndex Index of device input
  51766. * @returns Current value of input
  51767. */
  51768. /**
  51769. * Checks for current device input value, given an id and input index
  51770. * @param deviceType Enum specifiying device type
  51771. * @param deviceSlot "Slot" or index that device is referenced in
  51772. * @param inputIndex Id of input to be checked
  51773. * @returns Current value of input
  51774. */
  51775. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): Nullable<number>;
  51776. /**
  51777. * Dispose of all the eventlisteners
  51778. */
  51779. dispose(): void;
  51780. /**
  51781. * Add device and inputs to device array
  51782. * @param deviceType Enum specifiying device type
  51783. * @param deviceSlot "Slot" or index that device is referenced in
  51784. * @param numberOfInputs Number of input entries to create for given device
  51785. */
  51786. private _registerDevice;
  51787. /**
  51788. * Given a specific device name, remove that device from the device map
  51789. * @param deviceType Enum specifiying device type
  51790. * @param deviceSlot "Slot" or index that device is referenced in
  51791. */
  51792. private _unregisterDevice;
  51793. /**
  51794. * Handle all actions that come from keyboard interaction
  51795. */
  51796. private _handleKeyActions;
  51797. /**
  51798. * Handle all actions that come from pointer interaction
  51799. */
  51800. private _handlePointerActions;
  51801. /**
  51802. * Handle all actions that come from gamepad interaction
  51803. */
  51804. private _handleGamepadActions;
  51805. /**
  51806. * Update all non-event based devices with each frame
  51807. * @param deviceType Enum specifiying device type
  51808. * @param deviceSlot "Slot" or index that device is referenced in
  51809. * @param inputIndex Id of input to be checked
  51810. */
  51811. private _updateDevice;
  51812. /**
  51813. * Gets DeviceType from the device name
  51814. * @param deviceName Name of Device from DeviceInputSystem
  51815. * @returns DeviceType enum value
  51816. */
  51817. private _getGamepadDeviceType;
  51818. }
  51819. }
  51820. declare module "babylonjs/DeviceInput/InputDevices/deviceTypes" {
  51821. import { DeviceType, PointerInput, DualShockInput, XboxInput, SwitchInput } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  51822. /**
  51823. * Type to handle enforcement of inputs
  51824. */
  51825. 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;
  51826. }
  51827. declare module "babylonjs/DeviceInput/InputDevices/deviceSourceManager" {
  51828. import { DeviceInputSystem } from "babylonjs/DeviceInput/deviceInputSystem";
  51829. import { Engine } from "babylonjs/Engines/engine";
  51830. import { IDisposable } from "babylonjs/scene";
  51831. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  51832. import { Nullable } from "babylonjs/types";
  51833. import { Observable } from "babylonjs/Misc/observable";
  51834. import { DeviceInput } from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  51835. /**
  51836. * Class that handles all input for a specific device
  51837. */
  51838. export class DeviceSource<T extends DeviceType> {
  51839. /** Type of device */
  51840. readonly deviceType: DeviceType;
  51841. /** "Slot" or index that device is referenced in */
  51842. readonly deviceSlot: number;
  51843. /**
  51844. * Observable to handle device input changes per device
  51845. */
  51846. readonly onInputChangedObservable: Observable<{
  51847. inputIndex: DeviceInput<T>;
  51848. previousState: Nullable<number>;
  51849. currentState: Nullable<number>;
  51850. }>;
  51851. private readonly _deviceInputSystem;
  51852. /**
  51853. * Default Constructor
  51854. * @param deviceInputSystem Reference to DeviceInputSystem
  51855. * @param deviceType Type of device
  51856. * @param deviceSlot "Slot" or index that device is referenced in
  51857. */
  51858. constructor(deviceInputSystem: DeviceInputSystem,
  51859. /** Type of device */
  51860. deviceType: DeviceType,
  51861. /** "Slot" or index that device is referenced in */
  51862. deviceSlot?: number);
  51863. /**
  51864. * Get input for specific input
  51865. * @param inputIndex index of specific input on device
  51866. * @returns Input value from DeviceInputSystem
  51867. */
  51868. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  51869. }
  51870. /**
  51871. * Class to keep track of devices
  51872. */
  51873. export class DeviceSourceManager implements IDisposable {
  51874. /**
  51875. * Observable to be triggered when before a device is connected
  51876. */
  51877. readonly onBeforeDeviceConnectedObservable: Observable<{
  51878. deviceType: DeviceType;
  51879. deviceSlot: number;
  51880. }>;
  51881. /**
  51882. * Observable to be triggered when before a device is disconnected
  51883. */
  51884. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  51885. deviceType: DeviceType;
  51886. deviceSlot: number;
  51887. }>;
  51888. /**
  51889. * Observable to be triggered when after a device is connected
  51890. */
  51891. readonly onAfterDeviceConnectedObservable: Observable<{
  51892. deviceType: DeviceType;
  51893. deviceSlot: number;
  51894. }>;
  51895. /**
  51896. * Observable to be triggered when after a device is disconnected
  51897. */
  51898. readonly onAfterDeviceDisconnectedObservable: Observable<{
  51899. deviceType: DeviceType;
  51900. deviceSlot: number;
  51901. }>;
  51902. private readonly _devices;
  51903. private readonly _firstDevice;
  51904. private readonly _deviceInputSystem;
  51905. /**
  51906. * Default Constructor
  51907. * @param engine engine to pull input element from
  51908. */
  51909. constructor(engine: Engine);
  51910. /**
  51911. * Gets a DeviceSource, given a type and slot
  51912. * @param deviceType Enum specifying device type
  51913. * @param deviceSlot "Slot" or index that device is referenced in
  51914. * @returns DeviceSource object
  51915. */
  51916. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  51917. /**
  51918. * Gets an array of DeviceSource objects for a given device type
  51919. * @param deviceType Enum specifying device type
  51920. * @returns Array of DeviceSource objects
  51921. */
  51922. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  51923. /**
  51924. * Dispose of DeviceInputSystem and other parts
  51925. */
  51926. dispose(): void;
  51927. /**
  51928. * Function to add device name to device list
  51929. * @param deviceType Enum specifying device type
  51930. * @param deviceSlot "Slot" or index that device is referenced in
  51931. */
  51932. private _addDevice;
  51933. /**
  51934. * Function to remove device name to device list
  51935. * @param deviceType Enum specifying device type
  51936. * @param deviceSlot "Slot" or index that device is referenced in
  51937. */
  51938. private _removeDevice;
  51939. /**
  51940. * Updates array storing first connected device of each type
  51941. * @param type Type of Device
  51942. */
  51943. private _updateFirstDevices;
  51944. }
  51945. }
  51946. declare module "babylonjs/DeviceInput/index" {
  51947. export * from "babylonjs/DeviceInput/deviceInputSystem";
  51948. export * from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  51949. export * from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  51950. import "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  51951. export * from "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  51952. }
  51953. declare module "babylonjs/Engines/nullEngine" {
  51954. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  51955. import { Engine } from "babylonjs/Engines/engine";
  51956. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  51957. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  51958. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51959. import { Effect } from "babylonjs/Materials/effect";
  51960. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  51961. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  51962. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  51963. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  51964. /**
  51965. * Options to create the null engine
  51966. */
  51967. export class NullEngineOptions {
  51968. /**
  51969. * Render width (Default: 512)
  51970. */
  51971. renderWidth: number;
  51972. /**
  51973. * Render height (Default: 256)
  51974. */
  51975. renderHeight: number;
  51976. /**
  51977. * Texture size (Default: 512)
  51978. */
  51979. textureSize: number;
  51980. /**
  51981. * If delta time between frames should be constant
  51982. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51983. */
  51984. deterministicLockstep: boolean;
  51985. /**
  51986. * Maximum about of steps between frames (Default: 4)
  51987. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51988. */
  51989. lockstepMaxSteps: number;
  51990. }
  51991. /**
  51992. * The null engine class provides support for headless version of babylon.js.
  51993. * This can be used in server side scenario or for testing purposes
  51994. */
  51995. export class NullEngine extends Engine {
  51996. private _options;
  51997. /**
  51998. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  51999. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  52000. * @returns true if engine is in deterministic lock step mode
  52001. */
  52002. isDeterministicLockStep(): boolean;
  52003. /**
  52004. * Gets the max steps when engine is running in deterministic lock step
  52005. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  52006. * @returns the max steps
  52007. */
  52008. getLockstepMaxSteps(): number;
  52009. /**
  52010. * Gets the current hardware scaling level.
  52011. * By default the hardware scaling level is computed from the window device ratio.
  52012. * 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.
  52013. * @returns a number indicating the current hardware scaling level
  52014. */
  52015. getHardwareScalingLevel(): number;
  52016. constructor(options?: NullEngineOptions);
  52017. /**
  52018. * Creates a vertex buffer
  52019. * @param vertices the data for the vertex buffer
  52020. * @returns the new WebGL static buffer
  52021. */
  52022. createVertexBuffer(vertices: FloatArray): DataBuffer;
  52023. /**
  52024. * Creates a new index buffer
  52025. * @param indices defines the content of the index buffer
  52026. * @param updatable defines if the index buffer must be updatable
  52027. * @returns a new webGL buffer
  52028. */
  52029. createIndexBuffer(indices: IndicesArray): DataBuffer;
  52030. /**
  52031. * Clear the current render buffer or the current render target (if any is set up)
  52032. * @param color defines the color to use
  52033. * @param backBuffer defines if the back buffer must be cleared
  52034. * @param depth defines if the depth buffer must be cleared
  52035. * @param stencil defines if the stencil buffer must be cleared
  52036. */
  52037. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  52038. /**
  52039. * Gets the current render width
  52040. * @param useScreen defines if screen size must be used (or the current render target if any)
  52041. * @returns a number defining the current render width
  52042. */
  52043. getRenderWidth(useScreen?: boolean): number;
  52044. /**
  52045. * Gets the current render height
  52046. * @param useScreen defines if screen size must be used (or the current render target if any)
  52047. * @returns a number defining the current render height
  52048. */
  52049. getRenderHeight(useScreen?: boolean): number;
  52050. /**
  52051. * Set the WebGL's viewport
  52052. * @param viewport defines the viewport element to be used
  52053. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  52054. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  52055. */
  52056. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  52057. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  52058. /**
  52059. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  52060. * @param pipelineContext defines the pipeline context to use
  52061. * @param uniformsNames defines the list of uniform names
  52062. * @returns an array of webGL uniform locations
  52063. */
  52064. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  52065. /**
  52066. * Gets the lsit of active attributes for a given webGL program
  52067. * @param pipelineContext defines the pipeline context to use
  52068. * @param attributesNames defines the list of attribute names to get
  52069. * @returns an array of indices indicating the offset of each attribute
  52070. */
  52071. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  52072. /**
  52073. * Binds an effect to the webGL context
  52074. * @param effect defines the effect to bind
  52075. */
  52076. bindSamplers(effect: Effect): void;
  52077. /**
  52078. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  52079. * @param effect defines the effect to activate
  52080. */
  52081. enableEffect(effect: Effect): void;
  52082. /**
  52083. * Set various states to the webGL context
  52084. * @param culling defines backface culling state
  52085. * @param zOffset defines the value to apply to zOffset (0 by default)
  52086. * @param force defines if states must be applied even if cache is up to date
  52087. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  52088. */
  52089. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  52090. /**
  52091. * Set the value of an uniform to an array of int32
  52092. * @param uniform defines the webGL uniform location where to store the value
  52093. * @param array defines the array of int32 to store
  52094. */
  52095. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  52096. /**
  52097. * Set the value of an uniform to an array of int32 (stored as vec2)
  52098. * @param uniform defines the webGL uniform location where to store the value
  52099. * @param array defines the array of int32 to store
  52100. */
  52101. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  52102. /**
  52103. * Set the value of an uniform to an array of int32 (stored as vec3)
  52104. * @param uniform defines the webGL uniform location where to store the value
  52105. * @param array defines the array of int32 to store
  52106. */
  52107. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  52108. /**
  52109. * Set the value of an uniform to an array of int32 (stored as vec4)
  52110. * @param uniform defines the webGL uniform location where to store the value
  52111. * @param array defines the array of int32 to store
  52112. */
  52113. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  52114. /**
  52115. * Set the value of an uniform to an array of float32
  52116. * @param uniform defines the webGL uniform location where to store the value
  52117. * @param array defines the array of float32 to store
  52118. */
  52119. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  52120. /**
  52121. * Set the value of an uniform to an array of float32 (stored as vec2)
  52122. * @param uniform defines the webGL uniform location where to store the value
  52123. * @param array defines the array of float32 to store
  52124. */
  52125. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  52126. /**
  52127. * Set the value of an uniform to an array of float32 (stored as vec3)
  52128. * @param uniform defines the webGL uniform location where to store the value
  52129. * @param array defines the array of float32 to store
  52130. */
  52131. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  52132. /**
  52133. * Set the value of an uniform to an array of float32 (stored as vec4)
  52134. * @param uniform defines the webGL uniform location where to store the value
  52135. * @param array defines the array of float32 to store
  52136. */
  52137. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  52138. /**
  52139. * Set the value of an uniform to an array of number
  52140. * @param uniform defines the webGL uniform location where to store the value
  52141. * @param array defines the array of number to store
  52142. */
  52143. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  52144. /**
  52145. * Set the value of an uniform to an array of number (stored as vec2)
  52146. * @param uniform defines the webGL uniform location where to store the value
  52147. * @param array defines the array of number to store
  52148. */
  52149. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  52150. /**
  52151. * Set the value of an uniform to an array of number (stored as vec3)
  52152. * @param uniform defines the webGL uniform location where to store the value
  52153. * @param array defines the array of number to store
  52154. */
  52155. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  52156. /**
  52157. * Set the value of an uniform to an array of number (stored as vec4)
  52158. * @param uniform defines the webGL uniform location where to store the value
  52159. * @param array defines the array of number to store
  52160. */
  52161. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  52162. /**
  52163. * Set the value of an uniform to an array of float32 (stored as matrices)
  52164. * @param uniform defines the webGL uniform location where to store the value
  52165. * @param matrices defines the array of float32 to store
  52166. */
  52167. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  52168. /**
  52169. * Set the value of an uniform to a matrix (3x3)
  52170. * @param uniform defines the webGL uniform location where to store the value
  52171. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  52172. */
  52173. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  52174. /**
  52175. * Set the value of an uniform to a matrix (2x2)
  52176. * @param uniform defines the webGL uniform location where to store the value
  52177. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  52178. */
  52179. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  52180. /**
  52181. * Set the value of an uniform to a number (float)
  52182. * @param uniform defines the webGL uniform location where to store the value
  52183. * @param value defines the float number to store
  52184. */
  52185. setFloat(uniform: WebGLUniformLocation, value: number): void;
  52186. /**
  52187. * Set the value of an uniform to a vec2
  52188. * @param uniform defines the webGL uniform location where to store the value
  52189. * @param x defines the 1st component of the value
  52190. * @param y defines the 2nd component of the value
  52191. */
  52192. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  52193. /**
  52194. * Set the value of an uniform to a vec3
  52195. * @param uniform defines the webGL uniform location where to store the value
  52196. * @param x defines the 1st component of the value
  52197. * @param y defines the 2nd component of the value
  52198. * @param z defines the 3rd component of the value
  52199. */
  52200. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  52201. /**
  52202. * Set the value of an uniform to a boolean
  52203. * @param uniform defines the webGL uniform location where to store the value
  52204. * @param bool defines the boolean to store
  52205. */
  52206. setBool(uniform: WebGLUniformLocation, bool: number): void;
  52207. /**
  52208. * Set the value of an uniform to a vec4
  52209. * @param uniform defines the webGL uniform location where to store the value
  52210. * @param x defines the 1st component of the value
  52211. * @param y defines the 2nd component of the value
  52212. * @param z defines the 3rd component of the value
  52213. * @param w defines the 4th component of the value
  52214. */
  52215. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  52216. /**
  52217. * Sets the current alpha mode
  52218. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  52219. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  52220. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  52221. */
  52222. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  52223. /**
  52224. * Bind webGl buffers directly to the webGL context
  52225. * @param vertexBuffers defines the vertex buffer to bind
  52226. * @param indexBuffer defines the index buffer to bind
  52227. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  52228. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  52229. * @param effect defines the effect associated with the vertex buffer
  52230. */
  52231. bindBuffers(vertexBuffers: {
  52232. [key: string]: VertexBuffer;
  52233. }, indexBuffer: DataBuffer, effect: Effect): void;
  52234. /**
  52235. * Force the entire cache to be cleared
  52236. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  52237. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  52238. */
  52239. wipeCaches(bruteForce?: boolean): void;
  52240. /**
  52241. * Send a draw order
  52242. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  52243. * @param indexStart defines the starting index
  52244. * @param indexCount defines the number of index to draw
  52245. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52246. */
  52247. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  52248. /**
  52249. * Draw a list of indexed primitives
  52250. * @param fillMode defines the primitive to use
  52251. * @param indexStart defines the starting index
  52252. * @param indexCount defines the number of index to draw
  52253. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52254. */
  52255. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  52256. /**
  52257. * Draw a list of unindexed primitives
  52258. * @param fillMode defines the primitive to use
  52259. * @param verticesStart defines the index of first vertex to draw
  52260. * @param verticesCount defines the count of vertices to draw
  52261. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52262. */
  52263. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  52264. /** @hidden */
  52265. _createTexture(): WebGLTexture;
  52266. /** @hidden */
  52267. _releaseTexture(texture: InternalTexture): void;
  52268. /**
  52269. * Usually called from Texture.ts.
  52270. * Passed information to create a WebGLTexture
  52271. * @param urlArg defines a value which contains one of the following:
  52272. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  52273. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  52274. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  52275. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  52276. * @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)
  52277. * @param scene needed for loading to the correct scene
  52278. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  52279. * @param onLoad optional callback to be called upon successful completion
  52280. * @param onError optional callback to be called upon failure
  52281. * @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
  52282. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  52283. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  52284. * @param forcedExtension defines the extension to use to pick the right loader
  52285. * @param mimeType defines an optional mime type
  52286. * @returns a InternalTexture for assignment back into BABYLON.Texture
  52287. */
  52288. 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;
  52289. /**
  52290. * Creates a new render target texture
  52291. * @param size defines the size of the texture
  52292. * @param options defines the options used to create the texture
  52293. * @returns a new render target texture stored in an InternalTexture
  52294. */
  52295. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  52296. /**
  52297. * Update the sampling mode of a given texture
  52298. * @param samplingMode defines the required sampling mode
  52299. * @param texture defines the texture to update
  52300. */
  52301. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  52302. /**
  52303. * Binds the frame buffer to the specified texture.
  52304. * @param texture The texture to render to or null for the default canvas
  52305. * @param faceIndex The face of the texture to render to in case of cube texture
  52306. * @param requiredWidth The width of the target to render to
  52307. * @param requiredHeight The height of the target to render to
  52308. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  52309. * @param lodLevel defines le lod level to bind to the frame buffer
  52310. */
  52311. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  52312. /**
  52313. * Unbind the current render target texture from the webGL context
  52314. * @param texture defines the render target texture to unbind
  52315. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  52316. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  52317. */
  52318. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  52319. /**
  52320. * Creates a dynamic vertex buffer
  52321. * @param vertices the data for the dynamic vertex buffer
  52322. * @returns the new WebGL dynamic buffer
  52323. */
  52324. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  52325. /**
  52326. * Update the content of a dynamic texture
  52327. * @param texture defines the texture to update
  52328. * @param canvas defines the canvas containing the source
  52329. * @param invertY defines if data must be stored with Y axis inverted
  52330. * @param premulAlpha defines if alpha is stored as premultiplied
  52331. * @param format defines the format of the data
  52332. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  52333. */
  52334. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  52335. /**
  52336. * Gets a boolean indicating if all created effects are ready
  52337. * @returns true if all effects are ready
  52338. */
  52339. areAllEffectsReady(): boolean;
  52340. /**
  52341. * @hidden
  52342. * Get the current error code of the webGL context
  52343. * @returns the error code
  52344. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  52345. */
  52346. getError(): number;
  52347. /** @hidden */
  52348. _getUnpackAlignement(): number;
  52349. /** @hidden */
  52350. _unpackFlipY(value: boolean): void;
  52351. /**
  52352. * Update a dynamic index buffer
  52353. * @param indexBuffer defines the target index buffer
  52354. * @param indices defines the data to update
  52355. * @param offset defines the offset in the target index buffer where update should start
  52356. */
  52357. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  52358. /**
  52359. * Updates a dynamic vertex buffer.
  52360. * @param vertexBuffer the vertex buffer to update
  52361. * @param vertices the data used to update the vertex buffer
  52362. * @param byteOffset the byte offset of the data (optional)
  52363. * @param byteLength the byte length of the data (optional)
  52364. */
  52365. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  52366. /** @hidden */
  52367. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  52368. /** @hidden */
  52369. _bindTexture(channel: number, texture: InternalTexture): void;
  52370. protected _deleteBuffer(buffer: WebGLBuffer): void;
  52371. /**
  52372. * 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
  52373. */
  52374. releaseEffects(): void;
  52375. displayLoadingUI(): void;
  52376. hideLoadingUI(): void;
  52377. /** @hidden */
  52378. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52379. /** @hidden */
  52380. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52381. /** @hidden */
  52382. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52383. /** @hidden */
  52384. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  52385. }
  52386. }
  52387. declare module "babylonjs/Instrumentation/timeToken" {
  52388. import { Nullable } from "babylonjs/types";
  52389. /**
  52390. * @hidden
  52391. **/
  52392. export class _TimeToken {
  52393. _startTimeQuery: Nullable<WebGLQuery>;
  52394. _endTimeQuery: Nullable<WebGLQuery>;
  52395. _timeElapsedQuery: Nullable<WebGLQuery>;
  52396. _timeElapsedQueryEnded: boolean;
  52397. }
  52398. }
  52399. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  52400. import { Nullable, int } from "babylonjs/types";
  52401. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  52402. /** @hidden */
  52403. export class _OcclusionDataStorage {
  52404. /** @hidden */
  52405. occlusionInternalRetryCounter: number;
  52406. /** @hidden */
  52407. isOcclusionQueryInProgress: boolean;
  52408. /** @hidden */
  52409. isOccluded: boolean;
  52410. /** @hidden */
  52411. occlusionRetryCount: number;
  52412. /** @hidden */
  52413. occlusionType: number;
  52414. /** @hidden */
  52415. occlusionQueryAlgorithmType: number;
  52416. }
  52417. module "babylonjs/Engines/engine" {
  52418. interface Engine {
  52419. /**
  52420. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  52421. * @return the new query
  52422. */
  52423. createQuery(): WebGLQuery;
  52424. /**
  52425. * Delete and release a webGL query
  52426. * @param query defines the query to delete
  52427. * @return the current engine
  52428. */
  52429. deleteQuery(query: WebGLQuery): Engine;
  52430. /**
  52431. * Check if a given query has resolved and got its value
  52432. * @param query defines the query to check
  52433. * @returns true if the query got its value
  52434. */
  52435. isQueryResultAvailable(query: WebGLQuery): boolean;
  52436. /**
  52437. * Gets the value of a given query
  52438. * @param query defines the query to check
  52439. * @returns the value of the query
  52440. */
  52441. getQueryResult(query: WebGLQuery): number;
  52442. /**
  52443. * Initiates an occlusion query
  52444. * @param algorithmType defines the algorithm to use
  52445. * @param query defines the query to use
  52446. * @returns the current engine
  52447. * @see http://doc.babylonjs.com/features/occlusionquery
  52448. */
  52449. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  52450. /**
  52451. * Ends an occlusion query
  52452. * @see http://doc.babylonjs.com/features/occlusionquery
  52453. * @param algorithmType defines the algorithm to use
  52454. * @returns the current engine
  52455. */
  52456. endOcclusionQuery(algorithmType: number): Engine;
  52457. /**
  52458. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  52459. * Please note that only one query can be issued at a time
  52460. * @returns a time token used to track the time span
  52461. */
  52462. startTimeQuery(): Nullable<_TimeToken>;
  52463. /**
  52464. * Ends a time query
  52465. * @param token defines the token used to measure the time span
  52466. * @returns the time spent (in ns)
  52467. */
  52468. endTimeQuery(token: _TimeToken): int;
  52469. /** @hidden */
  52470. _currentNonTimestampToken: Nullable<_TimeToken>;
  52471. /** @hidden */
  52472. _createTimeQuery(): WebGLQuery;
  52473. /** @hidden */
  52474. _deleteTimeQuery(query: WebGLQuery): void;
  52475. /** @hidden */
  52476. _getGlAlgorithmType(algorithmType: number): number;
  52477. /** @hidden */
  52478. _getTimeQueryResult(query: WebGLQuery): any;
  52479. /** @hidden */
  52480. _getTimeQueryAvailability(query: WebGLQuery): any;
  52481. }
  52482. }
  52483. module "babylonjs/Meshes/abstractMesh" {
  52484. interface AbstractMesh {
  52485. /**
  52486. * Backing filed
  52487. * @hidden
  52488. */
  52489. __occlusionDataStorage: _OcclusionDataStorage;
  52490. /**
  52491. * Access property
  52492. * @hidden
  52493. */
  52494. _occlusionDataStorage: _OcclusionDataStorage;
  52495. /**
  52496. * 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.
  52497. * The default value is -1 which means don't break the query and wait till the result
  52498. * @see http://doc.babylonjs.com/features/occlusionquery
  52499. */
  52500. occlusionRetryCount: number;
  52501. /**
  52502. * 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:
  52503. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  52504. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  52505. * * 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.
  52506. * @see http://doc.babylonjs.com/features/occlusionquery
  52507. */
  52508. occlusionType: number;
  52509. /**
  52510. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  52511. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  52512. * * 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.
  52513. * @see http://doc.babylonjs.com/features/occlusionquery
  52514. */
  52515. occlusionQueryAlgorithmType: number;
  52516. /**
  52517. * 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
  52518. * @see http://doc.babylonjs.com/features/occlusionquery
  52519. */
  52520. isOccluded: boolean;
  52521. /**
  52522. * Flag to check the progress status of the query
  52523. * @see http://doc.babylonjs.com/features/occlusionquery
  52524. */
  52525. isOcclusionQueryInProgress: boolean;
  52526. }
  52527. }
  52528. }
  52529. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  52530. import { Nullable } from "babylonjs/types";
  52531. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  52532. /** @hidden */
  52533. export var _forceTransformFeedbackToBundle: boolean;
  52534. module "babylonjs/Engines/engine" {
  52535. interface Engine {
  52536. /**
  52537. * Creates a webGL transform feedback object
  52538. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  52539. * @returns the webGL transform feedback object
  52540. */
  52541. createTransformFeedback(): WebGLTransformFeedback;
  52542. /**
  52543. * Delete a webGL transform feedback object
  52544. * @param value defines the webGL transform feedback object to delete
  52545. */
  52546. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  52547. /**
  52548. * Bind a webGL transform feedback object to the webgl context
  52549. * @param value defines the webGL transform feedback object to bind
  52550. */
  52551. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  52552. /**
  52553. * Begins a transform feedback operation
  52554. * @param usePoints defines if points or triangles must be used
  52555. */
  52556. beginTransformFeedback(usePoints: boolean): void;
  52557. /**
  52558. * Ends a transform feedback operation
  52559. */
  52560. endTransformFeedback(): void;
  52561. /**
  52562. * Specify the varyings to use with transform feedback
  52563. * @param program defines the associated webGL program
  52564. * @param value defines the list of strings representing the varying names
  52565. */
  52566. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  52567. /**
  52568. * Bind a webGL buffer for a transform feedback operation
  52569. * @param value defines the webGL buffer to bind
  52570. */
  52571. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  52572. }
  52573. }
  52574. }
  52575. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  52576. import { Scene } from "babylonjs/scene";
  52577. import { Engine } from "babylonjs/Engines/engine";
  52578. import { Texture } from "babylonjs/Materials/Textures/texture";
  52579. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52580. import "babylonjs/Engines/Extensions/engine.multiRender";
  52581. /**
  52582. * Creation options of the multi render target texture.
  52583. */
  52584. export interface IMultiRenderTargetOptions {
  52585. /**
  52586. * Define if the texture needs to create mip maps after render.
  52587. */
  52588. generateMipMaps?: boolean;
  52589. /**
  52590. * Define the types of all the draw buffers we want to create
  52591. */
  52592. types?: number[];
  52593. /**
  52594. * Define the sampling modes of all the draw buffers we want to create
  52595. */
  52596. samplingModes?: number[];
  52597. /**
  52598. * Define if a depth buffer is required
  52599. */
  52600. generateDepthBuffer?: boolean;
  52601. /**
  52602. * Define if a stencil buffer is required
  52603. */
  52604. generateStencilBuffer?: boolean;
  52605. /**
  52606. * Define if a depth texture is required instead of a depth buffer
  52607. */
  52608. generateDepthTexture?: boolean;
  52609. /**
  52610. * Define the number of desired draw buffers
  52611. */
  52612. textureCount?: number;
  52613. /**
  52614. * Define if aspect ratio should be adapted to the texture or stay the scene one
  52615. */
  52616. doNotChangeAspectRatio?: boolean;
  52617. /**
  52618. * Define the default type of the buffers we are creating
  52619. */
  52620. defaultType?: number;
  52621. }
  52622. /**
  52623. * A multi render target, like a render target provides the ability to render to a texture.
  52624. * Unlike the render target, it can render to several draw buffers in one draw.
  52625. * This is specially interesting in deferred rendering or for any effects requiring more than
  52626. * just one color from a single pass.
  52627. */
  52628. export class MultiRenderTarget extends RenderTargetTexture {
  52629. private _internalTextures;
  52630. private _textures;
  52631. private _multiRenderTargetOptions;
  52632. /**
  52633. * Get if draw buffers are currently supported by the used hardware and browser.
  52634. */
  52635. get isSupported(): boolean;
  52636. /**
  52637. * Get the list of textures generated by the multi render target.
  52638. */
  52639. get textures(): Texture[];
  52640. /**
  52641. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  52642. */
  52643. get depthTexture(): Texture;
  52644. /**
  52645. * Set the wrapping mode on U of all the textures we are rendering to.
  52646. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  52647. */
  52648. set wrapU(wrap: number);
  52649. /**
  52650. * Set the wrapping mode on V of all the textures we are rendering to.
  52651. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  52652. */
  52653. set wrapV(wrap: number);
  52654. /**
  52655. * Instantiate a new multi render target texture.
  52656. * A multi render target, like a render target provides the ability to render to a texture.
  52657. * Unlike the render target, it can render to several draw buffers in one draw.
  52658. * This is specially interesting in deferred rendering or for any effects requiring more than
  52659. * just one color from a single pass.
  52660. * @param name Define the name of the texture
  52661. * @param size Define the size of the buffers to render to
  52662. * @param count Define the number of target we are rendering into
  52663. * @param scene Define the scene the texture belongs to
  52664. * @param options Define the options used to create the multi render target
  52665. */
  52666. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  52667. /** @hidden */
  52668. _rebuild(): void;
  52669. private _createInternalTextures;
  52670. private _createTextures;
  52671. /**
  52672. * Define the number of samples used if MSAA is enabled.
  52673. */
  52674. get samples(): number;
  52675. set samples(value: number);
  52676. /**
  52677. * Resize all the textures in the multi render target.
  52678. * Be carrefull as it will recreate all the data in the new texture.
  52679. * @param size Define the new size
  52680. */
  52681. resize(size: any): void;
  52682. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  52683. /**
  52684. * Dispose the render targets and their associated resources
  52685. */
  52686. dispose(): void;
  52687. /**
  52688. * Release all the underlying texture used as draw buffers.
  52689. */
  52690. releaseInternalTextures(): void;
  52691. }
  52692. }
  52693. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  52694. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52695. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  52696. import { Nullable } from "babylonjs/types";
  52697. module "babylonjs/Engines/thinEngine" {
  52698. interface ThinEngine {
  52699. /**
  52700. * Unbind a list of render target textures from the webGL context
  52701. * This is used only when drawBuffer extension or webGL2 are active
  52702. * @param textures defines the render target textures to unbind
  52703. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  52704. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  52705. */
  52706. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  52707. /**
  52708. * Create a multi render target texture
  52709. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  52710. * @param size defines the size of the texture
  52711. * @param options defines the creation options
  52712. * @returns the cube texture as an InternalTexture
  52713. */
  52714. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  52715. /**
  52716. * Update the sample count for a given multiple render target texture
  52717. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  52718. * @param textures defines the textures to update
  52719. * @param samples defines the sample count to set
  52720. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  52721. */
  52722. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  52723. }
  52724. }
  52725. }
  52726. declare module "babylonjs/Engines/Extensions/engine.views" {
  52727. import { Camera } from "babylonjs/Cameras/camera";
  52728. import { Nullable } from "babylonjs/types";
  52729. /**
  52730. * Class used to define an additional view for the engine
  52731. * @see https://doc.babylonjs.com/how_to/multi_canvases
  52732. */
  52733. export class EngineView {
  52734. /** Defines the canvas where to render the view */
  52735. target: HTMLCanvasElement;
  52736. /** Defines an optional camera used to render the view (will use active camera else) */
  52737. camera?: Camera;
  52738. }
  52739. module "babylonjs/Engines/engine" {
  52740. interface Engine {
  52741. /**
  52742. * Gets or sets the HTML element to use for attaching events
  52743. */
  52744. inputElement: Nullable<HTMLElement>;
  52745. /**
  52746. * Gets the current engine view
  52747. * @see https://doc.babylonjs.com/how_to/multi_canvases
  52748. */
  52749. activeView: Nullable<EngineView>;
  52750. /** Gets or sets the list of views */
  52751. views: EngineView[];
  52752. /**
  52753. * Register a new child canvas
  52754. * @param canvas defines the canvas to register
  52755. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  52756. * @returns the associated view
  52757. */
  52758. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  52759. /**
  52760. * Remove a registered child canvas
  52761. * @param canvas defines the canvas to remove
  52762. * @returns the current engine
  52763. */
  52764. unRegisterView(canvas: HTMLCanvasElement): Engine;
  52765. }
  52766. }
  52767. }
  52768. declare module "babylonjs/Engines/Extensions/engine.textureSelector" {
  52769. import { Nullable } from "babylonjs/types";
  52770. module "babylonjs/Engines/engine" {
  52771. interface Engine {
  52772. /** @hidden */
  52773. _excludedCompressedTextures: string[];
  52774. /** @hidden */
  52775. _textureFormatInUse: string;
  52776. /**
  52777. * Gets the list of texture formats supported
  52778. */
  52779. readonly texturesSupported: Array<string>;
  52780. /**
  52781. * Gets the texture format in use
  52782. */
  52783. readonly textureFormatInUse: Nullable<string>;
  52784. /**
  52785. * Set the compressed texture extensions or file names to skip.
  52786. *
  52787. * @param skippedFiles defines the list of those texture files you want to skip
  52788. * Example: [".dds", ".env", "myfile.png"]
  52789. */
  52790. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  52791. /**
  52792. * Set the compressed texture format to use, based on the formats you have, and the formats
  52793. * supported by the hardware / browser.
  52794. *
  52795. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  52796. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  52797. * to API arguments needed to compressed textures. This puts the burden on the container
  52798. * generator to house the arcane code for determining these for current & future formats.
  52799. *
  52800. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  52801. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  52802. *
  52803. * Note: The result of this call is not taken into account when a texture is base64.
  52804. *
  52805. * @param formatsAvailable defines the list of those format families you have created
  52806. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  52807. *
  52808. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  52809. * @returns The extension selected.
  52810. */
  52811. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  52812. }
  52813. }
  52814. }
  52815. declare module "babylonjs/Engines/Extensions/index" {
  52816. export * from "babylonjs/Engines/Extensions/engine.alpha";
  52817. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  52818. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  52819. export * from "babylonjs/Engines/Extensions/engine.multiview";
  52820. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  52821. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  52822. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  52823. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  52824. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  52825. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  52826. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  52827. export * from "babylonjs/Engines/Extensions/engine.webVR";
  52828. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  52829. export * from "babylonjs/Engines/Extensions/engine.views";
  52830. export * from "babylonjs/Engines/Extensions/engine.readTexture";
  52831. import "babylonjs/Engines/Extensions/engine.textureSelector";
  52832. export * from "babylonjs/Engines/Extensions/engine.textureSelector";
  52833. }
  52834. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  52835. import { Nullable } from "babylonjs/types";
  52836. /**
  52837. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  52838. */
  52839. export interface CubeMapInfo {
  52840. /**
  52841. * The pixel array for the front face.
  52842. * This is stored in format, left to right, up to down format.
  52843. */
  52844. front: Nullable<ArrayBufferView>;
  52845. /**
  52846. * The pixel array for the back face.
  52847. * This is stored in format, left to right, up to down format.
  52848. */
  52849. back: Nullable<ArrayBufferView>;
  52850. /**
  52851. * The pixel array for the left face.
  52852. * This is stored in format, left to right, up to down format.
  52853. */
  52854. left: Nullable<ArrayBufferView>;
  52855. /**
  52856. * The pixel array for the right face.
  52857. * This is stored in format, left to right, up to down format.
  52858. */
  52859. right: Nullable<ArrayBufferView>;
  52860. /**
  52861. * The pixel array for the up face.
  52862. * This is stored in format, left to right, up to down format.
  52863. */
  52864. up: Nullable<ArrayBufferView>;
  52865. /**
  52866. * The pixel array for the down face.
  52867. * This is stored in format, left to right, up to down format.
  52868. */
  52869. down: Nullable<ArrayBufferView>;
  52870. /**
  52871. * The size of the cubemap stored.
  52872. *
  52873. * Each faces will be size * size pixels.
  52874. */
  52875. size: number;
  52876. /**
  52877. * The format of the texture.
  52878. *
  52879. * RGBA, RGB.
  52880. */
  52881. format: number;
  52882. /**
  52883. * The type of the texture data.
  52884. *
  52885. * UNSIGNED_INT, FLOAT.
  52886. */
  52887. type: number;
  52888. /**
  52889. * Specifies whether the texture is in gamma space.
  52890. */
  52891. gammaSpace: boolean;
  52892. }
  52893. /**
  52894. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  52895. */
  52896. export class PanoramaToCubeMapTools {
  52897. private static FACE_LEFT;
  52898. private static FACE_RIGHT;
  52899. private static FACE_FRONT;
  52900. private static FACE_BACK;
  52901. private static FACE_DOWN;
  52902. private static FACE_UP;
  52903. /**
  52904. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  52905. *
  52906. * @param float32Array The source data.
  52907. * @param inputWidth The width of the input panorama.
  52908. * @param inputHeight The height of the input panorama.
  52909. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  52910. * @return The cubemap data
  52911. */
  52912. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  52913. private static CreateCubemapTexture;
  52914. private static CalcProjectionSpherical;
  52915. }
  52916. }
  52917. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  52918. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  52919. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52920. import { Nullable } from "babylonjs/types";
  52921. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  52922. /**
  52923. * Helper class dealing with the extraction of spherical polynomial dataArray
  52924. * from a cube map.
  52925. */
  52926. export class CubeMapToSphericalPolynomialTools {
  52927. private static FileFaces;
  52928. /**
  52929. * Converts a texture to the according Spherical Polynomial data.
  52930. * This extracts the first 3 orders only as they are the only one used in the lighting.
  52931. *
  52932. * @param texture The texture to extract the information from.
  52933. * @return The Spherical Polynomial data.
  52934. */
  52935. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  52936. /**
  52937. * Converts a cubemap to the according Spherical Polynomial data.
  52938. * This extracts the first 3 orders only as they are the only one used in the lighting.
  52939. *
  52940. * @param cubeInfo The Cube map to extract the information from.
  52941. * @return The Spherical Polynomial data.
  52942. */
  52943. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  52944. }
  52945. }
  52946. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  52947. import { Nullable } from "babylonjs/types";
  52948. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  52949. module "babylonjs/Materials/Textures/baseTexture" {
  52950. interface BaseTexture {
  52951. /**
  52952. * Get the polynomial representation of the texture data.
  52953. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  52954. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  52955. */
  52956. sphericalPolynomial: Nullable<SphericalPolynomial>;
  52957. }
  52958. }
  52959. }
  52960. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  52961. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  52962. /** @hidden */
  52963. export var rgbdEncodePixelShader: {
  52964. name: string;
  52965. shader: string;
  52966. };
  52967. }
  52968. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  52969. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  52970. /** @hidden */
  52971. export var rgbdDecodePixelShader: {
  52972. name: string;
  52973. shader: string;
  52974. };
  52975. }
  52976. declare module "babylonjs/Misc/environmentTextureTools" {
  52977. import { Nullable } from "babylonjs/types";
  52978. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  52979. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52980. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52981. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  52982. import "babylonjs/Engines/Extensions/engine.readTexture";
  52983. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  52984. import "babylonjs/Shaders/rgbdEncode.fragment";
  52985. import "babylonjs/Shaders/rgbdDecode.fragment";
  52986. /**
  52987. * Raw texture data and descriptor sufficient for WebGL texture upload
  52988. */
  52989. export interface EnvironmentTextureInfo {
  52990. /**
  52991. * Version of the environment map
  52992. */
  52993. version: number;
  52994. /**
  52995. * Width of image
  52996. */
  52997. width: number;
  52998. /**
  52999. * Irradiance information stored in the file.
  53000. */
  53001. irradiance: any;
  53002. /**
  53003. * Specular information stored in the file.
  53004. */
  53005. specular: any;
  53006. }
  53007. /**
  53008. * Defines One Image in the file. It requires only the position in the file
  53009. * as well as the length.
  53010. */
  53011. interface BufferImageData {
  53012. /**
  53013. * Length of the image data.
  53014. */
  53015. length: number;
  53016. /**
  53017. * Position of the data from the null terminator delimiting the end of the JSON.
  53018. */
  53019. position: number;
  53020. }
  53021. /**
  53022. * Defines the specular data enclosed in the file.
  53023. * This corresponds to the version 1 of the data.
  53024. */
  53025. export interface EnvironmentTextureSpecularInfoV1 {
  53026. /**
  53027. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  53028. */
  53029. specularDataPosition?: number;
  53030. /**
  53031. * This contains all the images data needed to reconstruct the cubemap.
  53032. */
  53033. mipmaps: Array<BufferImageData>;
  53034. /**
  53035. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  53036. */
  53037. lodGenerationScale: number;
  53038. }
  53039. /**
  53040. * Sets of helpers addressing the serialization and deserialization of environment texture
  53041. * stored in a BabylonJS env file.
  53042. * Those files are usually stored as .env files.
  53043. */
  53044. export class EnvironmentTextureTools {
  53045. /**
  53046. * Magic number identifying the env file.
  53047. */
  53048. private static _MagicBytes;
  53049. /**
  53050. * Gets the environment info from an env file.
  53051. * @param data The array buffer containing the .env bytes.
  53052. * @returns the environment file info (the json header) if successfully parsed.
  53053. */
  53054. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  53055. /**
  53056. * Creates an environment texture from a loaded cube texture.
  53057. * @param texture defines the cube texture to convert in env file
  53058. * @return a promise containing the environment data if succesfull.
  53059. */
  53060. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  53061. /**
  53062. * Creates a JSON representation of the spherical data.
  53063. * @param texture defines the texture containing the polynomials
  53064. * @return the JSON representation of the spherical info
  53065. */
  53066. private static _CreateEnvTextureIrradiance;
  53067. /**
  53068. * Creates the ArrayBufferViews used for initializing environment texture image data.
  53069. * @param data the image data
  53070. * @param info parameters that determine what views will be created for accessing the underlying buffer
  53071. * @return the views described by info providing access to the underlying buffer
  53072. */
  53073. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  53074. /**
  53075. * Uploads the texture info contained in the env file to the GPU.
  53076. * @param texture defines the internal texture to upload to
  53077. * @param data defines the data to load
  53078. * @param info defines the texture info retrieved through the GetEnvInfo method
  53079. * @returns a promise
  53080. */
  53081. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  53082. private static _OnImageReadyAsync;
  53083. /**
  53084. * Uploads the levels of image data to the GPU.
  53085. * @param texture defines the internal texture to upload to
  53086. * @param imageData defines the array buffer views of image data [mipmap][face]
  53087. * @returns a promise
  53088. */
  53089. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  53090. /**
  53091. * Uploads spherical polynomials information to the texture.
  53092. * @param texture defines the texture we are trying to upload the information to
  53093. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  53094. */
  53095. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  53096. /** @hidden */
  53097. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  53098. }
  53099. }
  53100. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  53101. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  53102. /** @hidden */
  53103. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  53104. private _genericAttributeLocation;
  53105. private _varyingLocationCount;
  53106. private _varyingLocationMap;
  53107. private _replacements;
  53108. private _textureCount;
  53109. private _uniforms;
  53110. lineProcessor(line: string): string;
  53111. attributeProcessor(attribute: string): string;
  53112. varyingProcessor(varying: string, isFragment: boolean): string;
  53113. uniformProcessor(uniform: string): string;
  53114. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  53115. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  53116. }
  53117. }
  53118. declare module "babylonjs/Engines/Processors/shaderCodeInliner" {
  53119. /**
  53120. * Class used to inline functions in shader code
  53121. */
  53122. export class ShaderCodeInliner {
  53123. private static readonly _RegexpFindFunctionNameAndType;
  53124. private _sourceCode;
  53125. private _functionDescr;
  53126. private _numMaxIterations;
  53127. /** Gets or sets the token used to mark the functions to inline */
  53128. inlineToken: string;
  53129. /** Gets or sets the debug mode */
  53130. debug: boolean;
  53131. /** Gets the code after the inlining process */
  53132. get code(): string;
  53133. /**
  53134. * Initializes the inliner
  53135. * @param sourceCode shader code source to inline
  53136. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  53137. */
  53138. constructor(sourceCode: string, numMaxIterations?: number);
  53139. /**
  53140. * Start the processing of the shader code
  53141. */
  53142. processCode(): void;
  53143. private _collectFunctions;
  53144. private _processInlining;
  53145. private _extractBetweenMarkers;
  53146. private _skipWhitespaces;
  53147. private _removeComments;
  53148. private _replaceFunctionCallsByCode;
  53149. private _findBackward;
  53150. private _escapeRegExp;
  53151. private _replaceNames;
  53152. }
  53153. }
  53154. declare module "babylonjs/Engines/nativeEngine" {
  53155. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  53156. import { Engine } from "babylonjs/Engines/engine";
  53157. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  53158. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53159. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53160. import { Effect } from "babylonjs/Materials/effect";
  53161. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  53162. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  53163. import { IColor4Like } from "babylonjs/Maths/math.like";
  53164. import { Scene } from "babylonjs/scene";
  53165. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  53166. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  53167. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  53168. /**
  53169. * Container for accessors for natively-stored mesh data buffers.
  53170. */
  53171. class NativeDataBuffer extends DataBuffer {
  53172. /**
  53173. * Accessor value used to identify/retrieve a natively-stored index buffer.
  53174. */
  53175. nativeIndexBuffer?: any;
  53176. /**
  53177. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  53178. */
  53179. nativeVertexBuffer?: any;
  53180. }
  53181. /** @hidden */
  53182. class NativeTexture extends InternalTexture {
  53183. getInternalTexture(): InternalTexture;
  53184. getViewCount(): number;
  53185. }
  53186. /** @hidden */
  53187. export class NativeEngine extends Engine {
  53188. private readonly _native;
  53189. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  53190. private readonly INVALID_HANDLE;
  53191. getHardwareScalingLevel(): number;
  53192. constructor();
  53193. dispose(): void;
  53194. /**
  53195. * Can be used to override the current requestAnimationFrame requester.
  53196. * @hidden
  53197. */
  53198. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  53199. /**
  53200. * Override default engine behavior.
  53201. * @param color
  53202. * @param backBuffer
  53203. * @param depth
  53204. * @param stencil
  53205. */
  53206. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  53207. /**
  53208. * Gets host document
  53209. * @returns the host document object
  53210. */
  53211. getHostDocument(): Nullable<Document>;
  53212. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  53213. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  53214. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  53215. recordVertexArrayObject(vertexBuffers: {
  53216. [key: string]: VertexBuffer;
  53217. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  53218. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  53219. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  53220. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  53221. /**
  53222. * Draw a list of indexed primitives
  53223. * @param fillMode defines the primitive to use
  53224. * @param indexStart defines the starting index
  53225. * @param indexCount defines the number of index to draw
  53226. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  53227. */
  53228. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  53229. /**
  53230. * Draw a list of unindexed primitives
  53231. * @param fillMode defines the primitive to use
  53232. * @param verticesStart defines the index of first vertex to draw
  53233. * @param verticesCount defines the count of vertices to draw
  53234. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  53235. */
  53236. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  53237. createPipelineContext(): IPipelineContext;
  53238. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  53239. /** @hidden */
  53240. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  53241. /** @hidden */
  53242. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  53243. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  53244. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  53245. protected _setProgram(program: WebGLProgram): void;
  53246. _releaseEffect(effect: Effect): void;
  53247. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  53248. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  53249. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  53250. bindSamplers(effect: Effect): void;
  53251. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  53252. getRenderWidth(useScreen?: boolean): number;
  53253. getRenderHeight(useScreen?: boolean): number;
  53254. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  53255. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  53256. /**
  53257. * Set the z offset to apply to current rendering
  53258. * @param value defines the offset to apply
  53259. */
  53260. setZOffset(value: number): void;
  53261. /**
  53262. * Gets the current value of the zOffset
  53263. * @returns the current zOffset state
  53264. */
  53265. getZOffset(): number;
  53266. /**
  53267. * Enable or disable depth buffering
  53268. * @param enable defines the state to set
  53269. */
  53270. setDepthBuffer(enable: boolean): void;
  53271. /**
  53272. * Gets a boolean indicating if depth writing is enabled
  53273. * @returns the current depth writing state
  53274. */
  53275. getDepthWrite(): boolean;
  53276. /**
  53277. * Enable or disable depth writing
  53278. * @param enable defines the state to set
  53279. */
  53280. setDepthWrite(enable: boolean): void;
  53281. /**
  53282. * Enable or disable color writing
  53283. * @param enable defines the state to set
  53284. */
  53285. setColorWrite(enable: boolean): void;
  53286. /**
  53287. * Gets a boolean indicating if color writing is enabled
  53288. * @returns the current color writing state
  53289. */
  53290. getColorWrite(): boolean;
  53291. /**
  53292. * Sets alpha constants used by some alpha blending modes
  53293. * @param r defines the red component
  53294. * @param g defines the green component
  53295. * @param b defines the blue component
  53296. * @param a defines the alpha component
  53297. */
  53298. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  53299. /**
  53300. * Sets the current alpha mode
  53301. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  53302. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  53303. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  53304. */
  53305. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  53306. /**
  53307. * Gets the current alpha mode
  53308. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  53309. * @returns the current alpha mode
  53310. */
  53311. getAlphaMode(): number;
  53312. setInt(uniform: WebGLUniformLocation, int: number): void;
  53313. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  53314. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  53315. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  53316. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  53317. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  53318. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  53319. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  53320. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  53321. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  53322. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  53323. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  53324. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  53325. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  53326. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  53327. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  53328. setFloat(uniform: WebGLUniformLocation, value: number): void;
  53329. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  53330. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  53331. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  53332. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  53333. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  53334. wipeCaches(bruteForce?: boolean): void;
  53335. _createTexture(): WebGLTexture;
  53336. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  53337. /**
  53338. * Usually called from Texture.ts.
  53339. * Passed information to create a WebGLTexture
  53340. * @param url defines a value which contains one of the following:
  53341. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  53342. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  53343. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  53344. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  53345. * @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)
  53346. * @param scene needed for loading to the correct scene
  53347. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  53348. * @param onLoad optional callback to be called upon successful completion
  53349. * @param onError optional callback to be called upon failure
  53350. * @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
  53351. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  53352. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  53353. * @param forcedExtension defines the extension to use to pick the right loader
  53354. * @param mimeType defines an optional mime type
  53355. * @returns a InternalTexture for assignment back into BABYLON.Texture
  53356. */
  53357. 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;
  53358. /**
  53359. * Creates a cube texture
  53360. * @param rootUrl defines the url where the files to load is located
  53361. * @param scene defines the current scene
  53362. * @param files defines the list of files to load (1 per face)
  53363. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  53364. * @param onLoad defines an optional callback raised when the texture is loaded
  53365. * @param onError defines an optional callback raised if there is an issue to load the texture
  53366. * @param format defines the format of the data
  53367. * @param forcedExtension defines the extension to use to pick the right loader
  53368. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  53369. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  53370. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  53371. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  53372. * @returns the cube texture as an InternalTexture
  53373. */
  53374. 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;
  53375. private _getSamplingFilter;
  53376. private static _GetNativeTextureFormat;
  53377. createRenderTargetTexture(size: number | {
  53378. width: number;
  53379. height: number;
  53380. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  53381. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  53382. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  53383. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  53384. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  53385. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  53386. /**
  53387. * Updates a dynamic vertex buffer.
  53388. * @param vertexBuffer the vertex buffer to update
  53389. * @param data the data used to update the vertex buffer
  53390. * @param byteOffset the byte offset of the data (optional)
  53391. * @param byteLength the byte length of the data (optional)
  53392. */
  53393. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  53394. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  53395. private _updateAnisotropicLevel;
  53396. private _getAddressMode;
  53397. /** @hidden */
  53398. _bindTexture(channel: number, texture: InternalTexture): void;
  53399. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  53400. releaseEffects(): void;
  53401. /** @hidden */
  53402. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53403. /** @hidden */
  53404. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53405. /** @hidden */
  53406. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53407. /** @hidden */
  53408. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  53409. }
  53410. }
  53411. declare module "babylonjs/Engines/index" {
  53412. export * from "babylonjs/Engines/constants";
  53413. export * from "babylonjs/Engines/engineCapabilities";
  53414. export * from "babylonjs/Engines/instancingAttributeInfo";
  53415. export * from "babylonjs/Engines/thinEngine";
  53416. export * from "babylonjs/Engines/engine";
  53417. export * from "babylonjs/Engines/engineStore";
  53418. export * from "babylonjs/Engines/nullEngine";
  53419. export * from "babylonjs/Engines/Extensions/index";
  53420. export * from "babylonjs/Engines/IPipelineContext";
  53421. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  53422. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  53423. export * from "babylonjs/Engines/nativeEngine";
  53424. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  53425. }
  53426. declare module "babylonjs/Events/clipboardEvents" {
  53427. /**
  53428. * Gather the list of clipboard event types as constants.
  53429. */
  53430. export class ClipboardEventTypes {
  53431. /**
  53432. * The clipboard event is fired when a copy command is active (pressed).
  53433. */
  53434. static readonly COPY: number;
  53435. /**
  53436. * The clipboard event is fired when a cut command is active (pressed).
  53437. */
  53438. static readonly CUT: number;
  53439. /**
  53440. * The clipboard event is fired when a paste command is active (pressed).
  53441. */
  53442. static readonly PASTE: number;
  53443. }
  53444. /**
  53445. * This class is used to store clipboard related info for the onClipboardObservable event.
  53446. */
  53447. export class ClipboardInfo {
  53448. /**
  53449. * Defines the type of event (BABYLON.ClipboardEventTypes)
  53450. */
  53451. type: number;
  53452. /**
  53453. * Defines the related dom event
  53454. */
  53455. event: ClipboardEvent;
  53456. /**
  53457. *Creates an instance of ClipboardInfo.
  53458. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  53459. * @param event Defines the related dom event
  53460. */
  53461. constructor(
  53462. /**
  53463. * Defines the type of event (BABYLON.ClipboardEventTypes)
  53464. */
  53465. type: number,
  53466. /**
  53467. * Defines the related dom event
  53468. */
  53469. event: ClipboardEvent);
  53470. /**
  53471. * Get the clipboard event's type from the keycode.
  53472. * @param keyCode Defines the keyCode for the current keyboard event.
  53473. * @return {number}
  53474. */
  53475. static GetTypeFromCharacter(keyCode: number): number;
  53476. }
  53477. }
  53478. declare module "babylonjs/Events/index" {
  53479. export * from "babylonjs/Events/keyboardEvents";
  53480. export * from "babylonjs/Events/pointerEvents";
  53481. export * from "babylonjs/Events/clipboardEvents";
  53482. }
  53483. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  53484. import { Scene } from "babylonjs/scene";
  53485. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53486. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  53487. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  53488. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  53489. /**
  53490. * Google Daydream controller
  53491. */
  53492. export class DaydreamController extends WebVRController {
  53493. /**
  53494. * Base Url for the controller model.
  53495. */
  53496. static MODEL_BASE_URL: string;
  53497. /**
  53498. * File name for the controller model.
  53499. */
  53500. static MODEL_FILENAME: string;
  53501. /**
  53502. * Gamepad Id prefix used to identify Daydream Controller.
  53503. */
  53504. static readonly GAMEPAD_ID_PREFIX: string;
  53505. /**
  53506. * Creates a new DaydreamController from a gamepad
  53507. * @param vrGamepad the gamepad that the controller should be created from
  53508. */
  53509. constructor(vrGamepad: any);
  53510. /**
  53511. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53512. * @param scene scene in which to add meshes
  53513. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53514. */
  53515. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53516. /**
  53517. * Called once for each button that changed state since the last frame
  53518. * @param buttonIdx Which button index changed
  53519. * @param state New state of the button
  53520. * @param changes Which properties on the state changed since last frame
  53521. */
  53522. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53523. }
  53524. }
  53525. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  53526. import { Scene } from "babylonjs/scene";
  53527. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53528. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  53529. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  53530. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  53531. /**
  53532. * Gear VR Controller
  53533. */
  53534. export class GearVRController extends WebVRController {
  53535. /**
  53536. * Base Url for the controller model.
  53537. */
  53538. static MODEL_BASE_URL: string;
  53539. /**
  53540. * File name for the controller model.
  53541. */
  53542. static MODEL_FILENAME: string;
  53543. /**
  53544. * Gamepad Id prefix used to identify this controller.
  53545. */
  53546. static readonly GAMEPAD_ID_PREFIX: string;
  53547. private readonly _buttonIndexToObservableNameMap;
  53548. /**
  53549. * Creates a new GearVRController from a gamepad
  53550. * @param vrGamepad the gamepad that the controller should be created from
  53551. */
  53552. constructor(vrGamepad: any);
  53553. /**
  53554. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53555. * @param scene scene in which to add meshes
  53556. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53557. */
  53558. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53559. /**
  53560. * Called once for each button that changed state since the last frame
  53561. * @param buttonIdx Which button index changed
  53562. * @param state New state of the button
  53563. * @param changes Which properties on the state changed since last frame
  53564. */
  53565. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53566. }
  53567. }
  53568. declare module "babylonjs/Gamepads/Controllers/genericController" {
  53569. import { Scene } from "babylonjs/scene";
  53570. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53571. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  53572. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  53573. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  53574. /**
  53575. * Generic Controller
  53576. */
  53577. export class GenericController extends WebVRController {
  53578. /**
  53579. * Base Url for the controller model.
  53580. */
  53581. static readonly MODEL_BASE_URL: string;
  53582. /**
  53583. * File name for the controller model.
  53584. */
  53585. static readonly MODEL_FILENAME: string;
  53586. /**
  53587. * Creates a new GenericController from a gamepad
  53588. * @param vrGamepad the gamepad that the controller should be created from
  53589. */
  53590. constructor(vrGamepad: any);
  53591. /**
  53592. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53593. * @param scene scene in which to add meshes
  53594. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53595. */
  53596. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53597. /**
  53598. * Called once for each button that changed state since the last frame
  53599. * @param buttonIdx Which button index changed
  53600. * @param state New state of the button
  53601. * @param changes Which properties on the state changed since last frame
  53602. */
  53603. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53604. }
  53605. }
  53606. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  53607. import { Observable } from "babylonjs/Misc/observable";
  53608. import { Scene } from "babylonjs/scene";
  53609. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53610. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  53611. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  53612. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  53613. /**
  53614. * Oculus Touch Controller
  53615. */
  53616. export class OculusTouchController extends WebVRController {
  53617. /**
  53618. * Base Url for the controller model.
  53619. */
  53620. static MODEL_BASE_URL: string;
  53621. /**
  53622. * File name for the left controller model.
  53623. */
  53624. static MODEL_LEFT_FILENAME: string;
  53625. /**
  53626. * File name for the right controller model.
  53627. */
  53628. static MODEL_RIGHT_FILENAME: string;
  53629. /**
  53630. * Base Url for the Quest controller model.
  53631. */
  53632. static QUEST_MODEL_BASE_URL: string;
  53633. /**
  53634. * @hidden
  53635. * If the controllers are running on a device that needs the updated Quest controller models
  53636. */
  53637. static _IsQuest: boolean;
  53638. /**
  53639. * Fired when the secondary trigger on this controller is modified
  53640. */
  53641. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  53642. /**
  53643. * Fired when the thumb rest on this controller is modified
  53644. */
  53645. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  53646. /**
  53647. * Creates a new OculusTouchController from a gamepad
  53648. * @param vrGamepad the gamepad that the controller should be created from
  53649. */
  53650. constructor(vrGamepad: any);
  53651. /**
  53652. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53653. * @param scene scene in which to add meshes
  53654. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53655. */
  53656. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53657. /**
  53658. * Fired when the A button on this controller is modified
  53659. */
  53660. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53661. /**
  53662. * Fired when the B button on this controller is modified
  53663. */
  53664. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53665. /**
  53666. * Fired when the X button on this controller is modified
  53667. */
  53668. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53669. /**
  53670. * Fired when the Y button on this controller is modified
  53671. */
  53672. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53673. /**
  53674. * Called once for each button that changed state since the last frame
  53675. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  53676. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  53677. * 2) secondary trigger (same)
  53678. * 3) A (right) X (left), touch, pressed = value
  53679. * 4) B / Y
  53680. * 5) thumb rest
  53681. * @param buttonIdx Which button index changed
  53682. * @param state New state of the button
  53683. * @param changes Which properties on the state changed since last frame
  53684. */
  53685. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53686. }
  53687. }
  53688. declare module "babylonjs/Gamepads/Controllers/viveController" {
  53689. import { Scene } from "babylonjs/scene";
  53690. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53691. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  53692. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  53693. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  53694. import { Observable } from "babylonjs/Misc/observable";
  53695. /**
  53696. * Vive Controller
  53697. */
  53698. export class ViveController extends WebVRController {
  53699. /**
  53700. * Base Url for the controller model.
  53701. */
  53702. static MODEL_BASE_URL: string;
  53703. /**
  53704. * File name for the controller model.
  53705. */
  53706. static MODEL_FILENAME: string;
  53707. /**
  53708. * Creates a new ViveController from a gamepad
  53709. * @param vrGamepad the gamepad that the controller should be created from
  53710. */
  53711. constructor(vrGamepad: any);
  53712. /**
  53713. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53714. * @param scene scene in which to add meshes
  53715. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53716. */
  53717. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53718. /**
  53719. * Fired when the left button on this controller is modified
  53720. */
  53721. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53722. /**
  53723. * Fired when the right button on this controller is modified
  53724. */
  53725. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53726. /**
  53727. * Fired when the menu button on this controller is modified
  53728. */
  53729. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53730. /**
  53731. * Called once for each button that changed state since the last frame
  53732. * Vive mapping:
  53733. * 0: touchpad
  53734. * 1: trigger
  53735. * 2: left AND right buttons
  53736. * 3: menu button
  53737. * @param buttonIdx Which button index changed
  53738. * @param state New state of the button
  53739. * @param changes Which properties on the state changed since last frame
  53740. */
  53741. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53742. }
  53743. }
  53744. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  53745. import { Observable } from "babylonjs/Misc/observable";
  53746. import { Scene } from "babylonjs/scene";
  53747. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53748. import { Ray } from "babylonjs/Culling/ray";
  53749. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  53750. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  53751. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  53752. /**
  53753. * Defines the WindowsMotionController object that the state of the windows motion controller
  53754. */
  53755. export class WindowsMotionController extends WebVRController {
  53756. /**
  53757. * The base url used to load the left and right controller models
  53758. */
  53759. static MODEL_BASE_URL: string;
  53760. /**
  53761. * The name of the left controller model file
  53762. */
  53763. static MODEL_LEFT_FILENAME: string;
  53764. /**
  53765. * The name of the right controller model file
  53766. */
  53767. static MODEL_RIGHT_FILENAME: string;
  53768. /**
  53769. * The controller name prefix for this controller type
  53770. */
  53771. static readonly GAMEPAD_ID_PREFIX: string;
  53772. /**
  53773. * The controller id pattern for this controller type
  53774. */
  53775. private static readonly GAMEPAD_ID_PATTERN;
  53776. private _loadedMeshInfo;
  53777. protected readonly _mapping: {
  53778. buttons: string[];
  53779. buttonMeshNames: {
  53780. trigger: string;
  53781. menu: string;
  53782. grip: string;
  53783. thumbstick: string;
  53784. trackpad: string;
  53785. };
  53786. buttonObservableNames: {
  53787. trigger: string;
  53788. menu: string;
  53789. grip: string;
  53790. thumbstick: string;
  53791. trackpad: string;
  53792. };
  53793. axisMeshNames: string[];
  53794. pointingPoseMeshName: string;
  53795. };
  53796. /**
  53797. * Fired when the trackpad on this controller is clicked
  53798. */
  53799. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  53800. /**
  53801. * Fired when the trackpad on this controller is modified
  53802. */
  53803. onTrackpadValuesChangedObservable: Observable<StickValues>;
  53804. /**
  53805. * The current x and y values of this controller's trackpad
  53806. */
  53807. trackpad: StickValues;
  53808. /**
  53809. * Creates a new WindowsMotionController from a gamepad
  53810. * @param vrGamepad the gamepad that the controller should be created from
  53811. */
  53812. constructor(vrGamepad: any);
  53813. /**
  53814. * Fired when the trigger on this controller is modified
  53815. */
  53816. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53817. /**
  53818. * Fired when the menu button on this controller is modified
  53819. */
  53820. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53821. /**
  53822. * Fired when the grip button on this controller is modified
  53823. */
  53824. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53825. /**
  53826. * Fired when the thumbstick button on this controller is modified
  53827. */
  53828. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53829. /**
  53830. * Fired when the touchpad button on this controller is modified
  53831. */
  53832. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53833. /**
  53834. * Fired when the touchpad values on this controller are modified
  53835. */
  53836. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  53837. protected _updateTrackpad(): void;
  53838. /**
  53839. * Called once per frame by the engine.
  53840. */
  53841. update(): void;
  53842. /**
  53843. * Called once for each button that changed state since the last frame
  53844. * @param buttonIdx Which button index changed
  53845. * @param state New state of the button
  53846. * @param changes Which properties on the state changed since last frame
  53847. */
  53848. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53849. /**
  53850. * Moves the buttons on the controller mesh based on their current state
  53851. * @param buttonName the name of the button to move
  53852. * @param buttonValue the value of the button which determines the buttons new position
  53853. */
  53854. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  53855. /**
  53856. * Moves the axis on the controller mesh based on its current state
  53857. * @param axis the index of the axis
  53858. * @param axisValue the value of the axis which determines the meshes new position
  53859. * @hidden
  53860. */
  53861. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  53862. /**
  53863. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53864. * @param scene scene in which to add meshes
  53865. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53866. */
  53867. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  53868. /**
  53869. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  53870. * can be transformed by button presses and axes values, based on this._mapping.
  53871. *
  53872. * @param scene scene in which the meshes exist
  53873. * @param meshes list of meshes that make up the controller model to process
  53874. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  53875. */
  53876. private processModel;
  53877. private createMeshInfo;
  53878. /**
  53879. * Gets the ray of the controller in the direction the controller is pointing
  53880. * @param length the length the resulting ray should be
  53881. * @returns a ray in the direction the controller is pointing
  53882. */
  53883. getForwardRay(length?: number): Ray;
  53884. /**
  53885. * Disposes of the controller
  53886. */
  53887. dispose(): void;
  53888. }
  53889. /**
  53890. * This class represents a new windows motion controller in XR.
  53891. */
  53892. export class XRWindowsMotionController extends WindowsMotionController {
  53893. /**
  53894. * Changing the original WIndowsMotionController mapping to fir the new mapping
  53895. */
  53896. protected readonly _mapping: {
  53897. buttons: string[];
  53898. buttonMeshNames: {
  53899. trigger: string;
  53900. menu: string;
  53901. grip: string;
  53902. thumbstick: string;
  53903. trackpad: string;
  53904. };
  53905. buttonObservableNames: {
  53906. trigger: string;
  53907. menu: string;
  53908. grip: string;
  53909. thumbstick: string;
  53910. trackpad: string;
  53911. };
  53912. axisMeshNames: string[];
  53913. pointingPoseMeshName: string;
  53914. };
  53915. /**
  53916. * Construct a new XR-Based windows motion controller
  53917. *
  53918. * @param gamepadInfo the gamepad object from the browser
  53919. */
  53920. constructor(gamepadInfo: any);
  53921. /**
  53922. * holds the thumbstick values (X,Y)
  53923. */
  53924. thumbstickValues: StickValues;
  53925. /**
  53926. * Fired when the thumbstick on this controller is clicked
  53927. */
  53928. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  53929. /**
  53930. * Fired when the thumbstick on this controller is modified
  53931. */
  53932. onThumbstickValuesChangedObservable: Observable<StickValues>;
  53933. /**
  53934. * Fired when the touchpad button on this controller is modified
  53935. */
  53936. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  53937. /**
  53938. * Fired when the touchpad values on this controller are modified
  53939. */
  53940. onTrackpadValuesChangedObservable: Observable<StickValues>;
  53941. /**
  53942. * Fired when the thumbstick button on this controller is modified
  53943. * here to prevent breaking changes
  53944. */
  53945. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53946. /**
  53947. * updating the thumbstick(!) and not the trackpad.
  53948. * This is named this way due to the difference between WebVR and XR and to avoid
  53949. * changing the parent class.
  53950. */
  53951. protected _updateTrackpad(): void;
  53952. /**
  53953. * Disposes the class with joy
  53954. */
  53955. dispose(): void;
  53956. }
  53957. }
  53958. declare module "babylonjs/Gamepads/Controllers/index" {
  53959. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  53960. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  53961. export * from "babylonjs/Gamepads/Controllers/genericController";
  53962. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  53963. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  53964. export * from "babylonjs/Gamepads/Controllers/viveController";
  53965. export * from "babylonjs/Gamepads/Controllers/webVRController";
  53966. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  53967. }
  53968. declare module "babylonjs/Gamepads/index" {
  53969. export * from "babylonjs/Gamepads/Controllers/index";
  53970. export * from "babylonjs/Gamepads/gamepad";
  53971. export * from "babylonjs/Gamepads/gamepadManager";
  53972. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  53973. export * from "babylonjs/Gamepads/xboxGamepad";
  53974. export * from "babylonjs/Gamepads/dualShockGamepad";
  53975. }
  53976. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  53977. import { Scene } from "babylonjs/scene";
  53978. import { Vector4 } from "babylonjs/Maths/math.vector";
  53979. import { Color4 } from "babylonjs/Maths/math.color";
  53980. import { Mesh } from "babylonjs/Meshes/mesh";
  53981. import { Nullable } from "babylonjs/types";
  53982. /**
  53983. * Class containing static functions to help procedurally build meshes
  53984. */
  53985. export class PolyhedronBuilder {
  53986. /**
  53987. * Creates a polyhedron mesh
  53988. * * 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
  53989. * * The parameter `size` (positive float, default 1) sets the polygon size
  53990. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  53991. * * 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`
  53992. * * 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
  53993. * * 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)`)
  53994. * * 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
  53995. * * 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
  53996. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53997. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53998. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53999. * @param name defines the name of the mesh
  54000. * @param options defines the options used to create the mesh
  54001. * @param scene defines the hosting scene
  54002. * @returns the polyhedron mesh
  54003. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  54004. */
  54005. static CreatePolyhedron(name: string, options: {
  54006. type?: number;
  54007. size?: number;
  54008. sizeX?: number;
  54009. sizeY?: number;
  54010. sizeZ?: number;
  54011. custom?: any;
  54012. faceUV?: Vector4[];
  54013. faceColors?: Color4[];
  54014. flat?: boolean;
  54015. updatable?: boolean;
  54016. sideOrientation?: number;
  54017. frontUVs?: Vector4;
  54018. backUVs?: Vector4;
  54019. }, scene?: Nullable<Scene>): Mesh;
  54020. }
  54021. }
  54022. declare module "babylonjs/Gizmos/scaleGizmo" {
  54023. import { Observable } from "babylonjs/Misc/observable";
  54024. import { Nullable } from "babylonjs/types";
  54025. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54026. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54027. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  54028. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54029. /**
  54030. * Gizmo that enables scaling a mesh along 3 axis
  54031. */
  54032. export class ScaleGizmo extends Gizmo {
  54033. /**
  54034. * Internal gizmo used for interactions on the x axis
  54035. */
  54036. xGizmo: AxisScaleGizmo;
  54037. /**
  54038. * Internal gizmo used for interactions on the y axis
  54039. */
  54040. yGizmo: AxisScaleGizmo;
  54041. /**
  54042. * Internal gizmo used for interactions on the z axis
  54043. */
  54044. zGizmo: AxisScaleGizmo;
  54045. /**
  54046. * Internal gizmo used to scale all axis equally
  54047. */
  54048. uniformScaleGizmo: AxisScaleGizmo;
  54049. private _meshAttached;
  54050. private _updateGizmoRotationToMatchAttachedMesh;
  54051. private _snapDistance;
  54052. private _scaleRatio;
  54053. private _uniformScalingMesh;
  54054. private _octahedron;
  54055. private _sensitivity;
  54056. /** Fires an event when any of it's sub gizmos are dragged */
  54057. onDragStartObservable: Observable<unknown>;
  54058. /** Fires an event when any of it's sub gizmos are released from dragging */
  54059. onDragEndObservable: Observable<unknown>;
  54060. get attachedMesh(): Nullable<AbstractMesh>;
  54061. set attachedMesh(mesh: Nullable<AbstractMesh>);
  54062. /**
  54063. * Creates a ScaleGizmo
  54064. * @param gizmoLayer The utility layer the gizmo will be added to
  54065. */
  54066. constructor(gizmoLayer?: UtilityLayerRenderer);
  54067. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  54068. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  54069. /**
  54070. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54071. */
  54072. set snapDistance(value: number);
  54073. get snapDistance(): number;
  54074. /**
  54075. * Ratio for the scale of the gizmo (Default: 1)
  54076. */
  54077. set scaleRatio(value: number);
  54078. get scaleRatio(): number;
  54079. /**
  54080. * Sensitivity factor for dragging (Default: 1)
  54081. */
  54082. set sensitivity(value: number);
  54083. get sensitivity(): number;
  54084. /**
  54085. * Disposes of the gizmo
  54086. */
  54087. dispose(): void;
  54088. }
  54089. }
  54090. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  54091. import { Observable } from "babylonjs/Misc/observable";
  54092. import { Nullable } from "babylonjs/types";
  54093. import { Vector3 } from "babylonjs/Maths/math.vector";
  54094. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54095. import { Mesh } from "babylonjs/Meshes/mesh";
  54096. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  54097. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54098. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54099. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  54100. import { Color3 } from "babylonjs/Maths/math.color";
  54101. /**
  54102. * Single axis scale gizmo
  54103. */
  54104. export class AxisScaleGizmo extends Gizmo {
  54105. /**
  54106. * Drag behavior responsible for the gizmos dragging interactions
  54107. */
  54108. dragBehavior: PointerDragBehavior;
  54109. private _pointerObserver;
  54110. /**
  54111. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54112. */
  54113. snapDistance: number;
  54114. /**
  54115. * Event that fires each time the gizmo snaps to a new location.
  54116. * * snapDistance is the the change in distance
  54117. */
  54118. onSnapObservable: Observable<{
  54119. snapDistance: number;
  54120. }>;
  54121. /**
  54122. * If the scaling operation should be done on all axis (default: false)
  54123. */
  54124. uniformScaling: boolean;
  54125. /**
  54126. * Custom sensitivity value for the drag strength
  54127. */
  54128. sensitivity: number;
  54129. private _isEnabled;
  54130. private _parent;
  54131. private _arrow;
  54132. private _coloredMaterial;
  54133. private _hoverMaterial;
  54134. /**
  54135. * Creates an AxisScaleGizmo
  54136. * @param gizmoLayer The utility layer the gizmo will be added to
  54137. * @param dragAxis The axis which the gizmo will be able to scale on
  54138. * @param color The color of the gizmo
  54139. */
  54140. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  54141. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  54142. /**
  54143. * If the gizmo is enabled
  54144. */
  54145. set isEnabled(value: boolean);
  54146. get isEnabled(): boolean;
  54147. /**
  54148. * Disposes of the gizmo
  54149. */
  54150. dispose(): void;
  54151. /**
  54152. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  54153. * @param mesh The mesh to replace the default mesh of the gizmo
  54154. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  54155. */
  54156. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  54157. }
  54158. }
  54159. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  54160. import { Observable } from "babylonjs/Misc/observable";
  54161. import { Nullable } from "babylonjs/types";
  54162. import { Vector3 } from "babylonjs/Maths/math.vector";
  54163. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54164. import { Mesh } from "babylonjs/Meshes/mesh";
  54165. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54166. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54167. import { Color3 } from "babylonjs/Maths/math.color";
  54168. import "babylonjs/Meshes/Builders/boxBuilder";
  54169. /**
  54170. * Bounding box gizmo
  54171. */
  54172. export class BoundingBoxGizmo extends Gizmo {
  54173. private _lineBoundingBox;
  54174. private _rotateSpheresParent;
  54175. private _scaleBoxesParent;
  54176. private _boundingDimensions;
  54177. private _renderObserver;
  54178. private _pointerObserver;
  54179. private _scaleDragSpeed;
  54180. private _tmpQuaternion;
  54181. private _tmpVector;
  54182. private _tmpRotationMatrix;
  54183. /**
  54184. * 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)
  54185. */
  54186. ignoreChildren: boolean;
  54187. /**
  54188. * 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)
  54189. */
  54190. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  54191. /**
  54192. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  54193. */
  54194. rotationSphereSize: number;
  54195. /**
  54196. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  54197. */
  54198. scaleBoxSize: number;
  54199. /**
  54200. * 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)
  54201. */
  54202. fixedDragMeshScreenSize: boolean;
  54203. /**
  54204. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  54205. */
  54206. fixedDragMeshScreenSizeDistanceFactor: number;
  54207. /**
  54208. * Fired when a rotation sphere or scale box is dragged
  54209. */
  54210. onDragStartObservable: Observable<{}>;
  54211. /**
  54212. * Fired when a scale box is dragged
  54213. */
  54214. onScaleBoxDragObservable: Observable<{}>;
  54215. /**
  54216. * Fired when a scale box drag is ended
  54217. */
  54218. onScaleBoxDragEndObservable: Observable<{}>;
  54219. /**
  54220. * Fired when a rotation sphere is dragged
  54221. */
  54222. onRotationSphereDragObservable: Observable<{}>;
  54223. /**
  54224. * Fired when a rotation sphere drag is ended
  54225. */
  54226. onRotationSphereDragEndObservable: Observable<{}>;
  54227. /**
  54228. * 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)
  54229. */
  54230. scalePivot: Nullable<Vector3>;
  54231. /**
  54232. * Mesh used as a pivot to rotate the attached mesh
  54233. */
  54234. private _anchorMesh;
  54235. private _existingMeshScale;
  54236. private _dragMesh;
  54237. private pointerDragBehavior;
  54238. private coloredMaterial;
  54239. private hoverColoredMaterial;
  54240. /**
  54241. * Sets the color of the bounding box gizmo
  54242. * @param color the color to set
  54243. */
  54244. setColor(color: Color3): void;
  54245. /**
  54246. * Creates an BoundingBoxGizmo
  54247. * @param gizmoLayer The utility layer the gizmo will be added to
  54248. * @param color The color of the gizmo
  54249. */
  54250. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  54251. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  54252. private _selectNode;
  54253. /**
  54254. * Updates the bounding box information for the Gizmo
  54255. */
  54256. updateBoundingBox(): void;
  54257. private _updateRotationSpheres;
  54258. private _updateScaleBoxes;
  54259. /**
  54260. * Enables rotation on the specified axis and disables rotation on the others
  54261. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  54262. */
  54263. setEnabledRotationAxis(axis: string): void;
  54264. /**
  54265. * Enables/disables scaling
  54266. * @param enable if scaling should be enabled
  54267. * @param homogeneousScaling defines if scaling should only be homogeneous
  54268. */
  54269. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  54270. private _updateDummy;
  54271. /**
  54272. * Enables a pointer drag behavior on the bounding box of the gizmo
  54273. */
  54274. enableDragBehavior(): void;
  54275. /**
  54276. * Disposes of the gizmo
  54277. */
  54278. dispose(): void;
  54279. /**
  54280. * 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)
  54281. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  54282. * @returns the bounding box mesh with the passed in mesh as a child
  54283. */
  54284. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  54285. /**
  54286. * CustomMeshes are not supported by this gizmo
  54287. * @param mesh The mesh to replace the default mesh of the gizmo
  54288. */
  54289. setCustomMesh(mesh: Mesh): void;
  54290. }
  54291. }
  54292. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  54293. import { Observable } from "babylonjs/Misc/observable";
  54294. import { Nullable } from "babylonjs/types";
  54295. import { Vector3 } from "babylonjs/Maths/math.vector";
  54296. import { Color3 } from "babylonjs/Maths/math.color";
  54297. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54298. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  54299. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54300. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54301. import "babylonjs/Meshes/Builders/linesBuilder";
  54302. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  54303. /**
  54304. * Single plane rotation gizmo
  54305. */
  54306. export class PlaneRotationGizmo extends Gizmo {
  54307. /**
  54308. * Drag behavior responsible for the gizmos dragging interactions
  54309. */
  54310. dragBehavior: PointerDragBehavior;
  54311. private _pointerObserver;
  54312. /**
  54313. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  54314. */
  54315. snapDistance: number;
  54316. /**
  54317. * Event that fires each time the gizmo snaps to a new location.
  54318. * * snapDistance is the the change in distance
  54319. */
  54320. onSnapObservable: Observable<{
  54321. snapDistance: number;
  54322. }>;
  54323. private _isEnabled;
  54324. private _parent;
  54325. /**
  54326. * Creates a PlaneRotationGizmo
  54327. * @param gizmoLayer The utility layer the gizmo will be added to
  54328. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  54329. * @param color The color of the gizmo
  54330. * @param tessellation Amount of tessellation to be used when creating rotation circles
  54331. * @param useEulerRotation Use and update Euler angle instead of quaternion
  54332. */
  54333. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  54334. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  54335. /**
  54336. * If the gizmo is enabled
  54337. */
  54338. set isEnabled(value: boolean);
  54339. get isEnabled(): boolean;
  54340. /**
  54341. * Disposes of the gizmo
  54342. */
  54343. dispose(): void;
  54344. }
  54345. }
  54346. declare module "babylonjs/Gizmos/rotationGizmo" {
  54347. import { Observable } from "babylonjs/Misc/observable";
  54348. import { Nullable } from "babylonjs/types";
  54349. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54350. import { Mesh } from "babylonjs/Meshes/mesh";
  54351. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54352. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  54353. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54354. /**
  54355. * Gizmo that enables rotating a mesh along 3 axis
  54356. */
  54357. export class RotationGizmo extends Gizmo {
  54358. /**
  54359. * Internal gizmo used for interactions on the x axis
  54360. */
  54361. xGizmo: PlaneRotationGizmo;
  54362. /**
  54363. * Internal gizmo used for interactions on the y axis
  54364. */
  54365. yGizmo: PlaneRotationGizmo;
  54366. /**
  54367. * Internal gizmo used for interactions on the z axis
  54368. */
  54369. zGizmo: PlaneRotationGizmo;
  54370. /** Fires an event when any of it's sub gizmos are dragged */
  54371. onDragStartObservable: Observable<unknown>;
  54372. /** Fires an event when any of it's sub gizmos are released from dragging */
  54373. onDragEndObservable: Observable<unknown>;
  54374. private _meshAttached;
  54375. get attachedMesh(): Nullable<AbstractMesh>;
  54376. set attachedMesh(mesh: Nullable<AbstractMesh>);
  54377. /**
  54378. * Creates a RotationGizmo
  54379. * @param gizmoLayer The utility layer the gizmo will be added to
  54380. * @param tessellation Amount of tessellation to be used when creating rotation circles
  54381. * @param useEulerRotation Use and update Euler angle instead of quaternion
  54382. */
  54383. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  54384. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  54385. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  54386. /**
  54387. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54388. */
  54389. set snapDistance(value: number);
  54390. get snapDistance(): number;
  54391. /**
  54392. * Ratio for the scale of the gizmo (Default: 1)
  54393. */
  54394. set scaleRatio(value: number);
  54395. get scaleRatio(): number;
  54396. /**
  54397. * Disposes of the gizmo
  54398. */
  54399. dispose(): void;
  54400. /**
  54401. * CustomMeshes are not supported by this gizmo
  54402. * @param mesh The mesh to replace the default mesh of the gizmo
  54403. */
  54404. setCustomMesh(mesh: Mesh): void;
  54405. }
  54406. }
  54407. declare module "babylonjs/Gizmos/gizmoManager" {
  54408. import { Observable } from "babylonjs/Misc/observable";
  54409. import { Nullable } from "babylonjs/types";
  54410. import { Scene, IDisposable } from "babylonjs/scene";
  54411. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54412. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54413. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  54414. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  54415. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  54416. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  54417. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  54418. /**
  54419. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  54420. */
  54421. export class GizmoManager implements IDisposable {
  54422. private scene;
  54423. /**
  54424. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  54425. */
  54426. gizmos: {
  54427. positionGizmo: Nullable<PositionGizmo>;
  54428. rotationGizmo: Nullable<RotationGizmo>;
  54429. scaleGizmo: Nullable<ScaleGizmo>;
  54430. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  54431. };
  54432. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  54433. clearGizmoOnEmptyPointerEvent: boolean;
  54434. /** Fires an event when the manager is attached to a mesh */
  54435. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  54436. private _gizmosEnabled;
  54437. private _pointerObserver;
  54438. private _attachedMesh;
  54439. private _boundingBoxColor;
  54440. private _defaultUtilityLayer;
  54441. private _defaultKeepDepthUtilityLayer;
  54442. /**
  54443. * When bounding box gizmo is enabled, this can be used to track drag/end events
  54444. */
  54445. boundingBoxDragBehavior: SixDofDragBehavior;
  54446. /**
  54447. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  54448. */
  54449. attachableMeshes: Nullable<Array<AbstractMesh>>;
  54450. /**
  54451. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  54452. */
  54453. usePointerToAttachGizmos: boolean;
  54454. /**
  54455. * Utility layer that the bounding box gizmo belongs to
  54456. */
  54457. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  54458. /**
  54459. * Utility layer that all gizmos besides bounding box belong to
  54460. */
  54461. get utilityLayer(): UtilityLayerRenderer;
  54462. /**
  54463. * Instatiates a gizmo manager
  54464. * @param scene the scene to overlay the gizmos on top of
  54465. */
  54466. constructor(scene: Scene);
  54467. /**
  54468. * Attaches a set of gizmos to the specified mesh
  54469. * @param mesh The mesh the gizmo's should be attached to
  54470. */
  54471. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  54472. /**
  54473. * If the position gizmo is enabled
  54474. */
  54475. set positionGizmoEnabled(value: boolean);
  54476. get positionGizmoEnabled(): boolean;
  54477. /**
  54478. * If the rotation gizmo is enabled
  54479. */
  54480. set rotationGizmoEnabled(value: boolean);
  54481. get rotationGizmoEnabled(): boolean;
  54482. /**
  54483. * If the scale gizmo is enabled
  54484. */
  54485. set scaleGizmoEnabled(value: boolean);
  54486. get scaleGizmoEnabled(): boolean;
  54487. /**
  54488. * If the boundingBox gizmo is enabled
  54489. */
  54490. set boundingBoxGizmoEnabled(value: boolean);
  54491. get boundingBoxGizmoEnabled(): boolean;
  54492. /**
  54493. * Disposes of the gizmo manager
  54494. */
  54495. dispose(): void;
  54496. }
  54497. }
  54498. declare module "babylonjs/Lights/directionalLight" {
  54499. import { Camera } from "babylonjs/Cameras/camera";
  54500. import { Scene } from "babylonjs/scene";
  54501. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  54502. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54503. import { Light } from "babylonjs/Lights/light";
  54504. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  54505. import { Effect } from "babylonjs/Materials/effect";
  54506. /**
  54507. * A directional light is defined by a direction (what a surprise!).
  54508. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  54509. * 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.
  54510. * Documentation: https://doc.babylonjs.com/babylon101/lights
  54511. */
  54512. export class DirectionalLight extends ShadowLight {
  54513. private _shadowFrustumSize;
  54514. /**
  54515. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  54516. */
  54517. get shadowFrustumSize(): number;
  54518. /**
  54519. * Specifies a fix frustum size for the shadow generation.
  54520. */
  54521. set shadowFrustumSize(value: number);
  54522. private _shadowOrthoScale;
  54523. /**
  54524. * Gets the shadow projection scale against the optimal computed one.
  54525. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  54526. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  54527. */
  54528. get shadowOrthoScale(): number;
  54529. /**
  54530. * Sets the shadow projection scale against the optimal computed one.
  54531. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  54532. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  54533. */
  54534. set shadowOrthoScale(value: number);
  54535. /**
  54536. * Automatically compute the projection matrix to best fit (including all the casters)
  54537. * on each frame.
  54538. */
  54539. autoUpdateExtends: boolean;
  54540. /**
  54541. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  54542. * on each frame. autoUpdateExtends must be set to true for this to work
  54543. */
  54544. autoCalcShadowZBounds: boolean;
  54545. private _orthoLeft;
  54546. private _orthoRight;
  54547. private _orthoTop;
  54548. private _orthoBottom;
  54549. /**
  54550. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  54551. * The directional light is emitted from everywhere in the given direction.
  54552. * It can cast shadows.
  54553. * Documentation : https://doc.babylonjs.com/babylon101/lights
  54554. * @param name The friendly name of the light
  54555. * @param direction The direction of the light
  54556. * @param scene The scene the light belongs to
  54557. */
  54558. constructor(name: string, direction: Vector3, scene: Scene);
  54559. /**
  54560. * Returns the string "DirectionalLight".
  54561. * @return The class name
  54562. */
  54563. getClassName(): string;
  54564. /**
  54565. * Returns the integer 1.
  54566. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  54567. */
  54568. getTypeID(): number;
  54569. /**
  54570. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  54571. * Returns the DirectionalLight Shadow projection matrix.
  54572. */
  54573. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54574. /**
  54575. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  54576. * Returns the DirectionalLight Shadow projection matrix.
  54577. */
  54578. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  54579. /**
  54580. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  54581. * Returns the DirectionalLight Shadow projection matrix.
  54582. */
  54583. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54584. protected _buildUniformLayout(): void;
  54585. /**
  54586. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  54587. * @param effect The effect to update
  54588. * @param lightIndex The index of the light in the effect to update
  54589. * @returns The directional light
  54590. */
  54591. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  54592. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  54593. /**
  54594. * Gets the minZ used for shadow according to both the scene and the light.
  54595. *
  54596. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  54597. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  54598. * @param activeCamera The camera we are returning the min for
  54599. * @returns the depth min z
  54600. */
  54601. getDepthMinZ(activeCamera: Camera): number;
  54602. /**
  54603. * Gets the maxZ used for shadow according to both the scene and the light.
  54604. *
  54605. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  54606. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  54607. * @param activeCamera The camera we are returning the max for
  54608. * @returns the depth max z
  54609. */
  54610. getDepthMaxZ(activeCamera: Camera): number;
  54611. /**
  54612. * Prepares the list of defines specific to the light type.
  54613. * @param defines the list of defines
  54614. * @param lightIndex defines the index of the light for the effect
  54615. */
  54616. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  54617. }
  54618. }
  54619. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  54620. import { Mesh } from "babylonjs/Meshes/mesh";
  54621. /**
  54622. * Class containing static functions to help procedurally build meshes
  54623. */
  54624. export class HemisphereBuilder {
  54625. /**
  54626. * Creates a hemisphere mesh
  54627. * @param name defines the name of the mesh
  54628. * @param options defines the options used to create the mesh
  54629. * @param scene defines the hosting scene
  54630. * @returns the hemisphere mesh
  54631. */
  54632. static CreateHemisphere(name: string, options: {
  54633. segments?: number;
  54634. diameter?: number;
  54635. sideOrientation?: number;
  54636. }, scene: any): Mesh;
  54637. }
  54638. }
  54639. declare module "babylonjs/Lights/spotLight" {
  54640. import { Nullable } from "babylonjs/types";
  54641. import { Scene } from "babylonjs/scene";
  54642. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  54643. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54644. import { Effect } from "babylonjs/Materials/effect";
  54645. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54646. import { Light } from "babylonjs/Lights/light";
  54647. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  54648. /**
  54649. * A spot light is defined by a position, a direction, an angle, and an exponent.
  54650. * These values define a cone of light starting from the position, emitting toward the direction.
  54651. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  54652. * and the exponent defines the speed of the decay of the light with distance (reach).
  54653. * Documentation: https://doc.babylonjs.com/babylon101/lights
  54654. */
  54655. export class SpotLight extends ShadowLight {
  54656. private _angle;
  54657. private _innerAngle;
  54658. private _cosHalfAngle;
  54659. private _lightAngleScale;
  54660. private _lightAngleOffset;
  54661. /**
  54662. * Gets the cone angle of the spot light in Radians.
  54663. */
  54664. get angle(): number;
  54665. /**
  54666. * Sets the cone angle of the spot light in Radians.
  54667. */
  54668. set angle(value: number);
  54669. /**
  54670. * Only used in gltf falloff mode, this defines the angle where
  54671. * the directional falloff will start before cutting at angle which could be seen
  54672. * as outer angle.
  54673. */
  54674. get innerAngle(): number;
  54675. /**
  54676. * Only used in gltf falloff mode, this defines the angle where
  54677. * the directional falloff will start before cutting at angle which could be seen
  54678. * as outer angle.
  54679. */
  54680. set innerAngle(value: number);
  54681. private _shadowAngleScale;
  54682. /**
  54683. * Allows scaling the angle of the light for shadow generation only.
  54684. */
  54685. get shadowAngleScale(): number;
  54686. /**
  54687. * Allows scaling the angle of the light for shadow generation only.
  54688. */
  54689. set shadowAngleScale(value: number);
  54690. /**
  54691. * The light decay speed with the distance from the emission spot.
  54692. */
  54693. exponent: number;
  54694. private _projectionTextureMatrix;
  54695. /**
  54696. * Allows reading the projecton texture
  54697. */
  54698. get projectionTextureMatrix(): Matrix;
  54699. protected _projectionTextureLightNear: number;
  54700. /**
  54701. * Gets the near clip of the Spotlight for texture projection.
  54702. */
  54703. get projectionTextureLightNear(): number;
  54704. /**
  54705. * Sets the near clip of the Spotlight for texture projection.
  54706. */
  54707. set projectionTextureLightNear(value: number);
  54708. protected _projectionTextureLightFar: number;
  54709. /**
  54710. * Gets the far clip of the Spotlight for texture projection.
  54711. */
  54712. get projectionTextureLightFar(): number;
  54713. /**
  54714. * Sets the far clip of the Spotlight for texture projection.
  54715. */
  54716. set projectionTextureLightFar(value: number);
  54717. protected _projectionTextureUpDirection: Vector3;
  54718. /**
  54719. * Gets the Up vector of the Spotlight for texture projection.
  54720. */
  54721. get projectionTextureUpDirection(): Vector3;
  54722. /**
  54723. * Sets the Up vector of the Spotlight for texture projection.
  54724. */
  54725. set projectionTextureUpDirection(value: Vector3);
  54726. private _projectionTexture;
  54727. /**
  54728. * Gets the projection texture of the light.
  54729. */
  54730. get projectionTexture(): Nullable<BaseTexture>;
  54731. /**
  54732. * Sets the projection texture of the light.
  54733. */
  54734. set projectionTexture(value: Nullable<BaseTexture>);
  54735. private _projectionTextureViewLightDirty;
  54736. private _projectionTextureProjectionLightDirty;
  54737. private _projectionTextureDirty;
  54738. private _projectionTextureViewTargetVector;
  54739. private _projectionTextureViewLightMatrix;
  54740. private _projectionTextureProjectionLightMatrix;
  54741. private _projectionTextureScalingMatrix;
  54742. /**
  54743. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  54744. * It can cast shadows.
  54745. * Documentation : https://doc.babylonjs.com/babylon101/lights
  54746. * @param name The light friendly name
  54747. * @param position The position of the spot light in the scene
  54748. * @param direction The direction of the light in the scene
  54749. * @param angle The cone angle of the light in Radians
  54750. * @param exponent The light decay speed with the distance from the emission spot
  54751. * @param scene The scene the lights belongs to
  54752. */
  54753. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  54754. /**
  54755. * Returns the string "SpotLight".
  54756. * @returns the class name
  54757. */
  54758. getClassName(): string;
  54759. /**
  54760. * Returns the integer 2.
  54761. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  54762. */
  54763. getTypeID(): number;
  54764. /**
  54765. * Overrides the direction setter to recompute the projection texture view light Matrix.
  54766. */
  54767. protected _setDirection(value: Vector3): void;
  54768. /**
  54769. * Overrides the position setter to recompute the projection texture view light Matrix.
  54770. */
  54771. protected _setPosition(value: Vector3): void;
  54772. /**
  54773. * 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.
  54774. * Returns the SpotLight.
  54775. */
  54776. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54777. protected _computeProjectionTextureViewLightMatrix(): void;
  54778. protected _computeProjectionTextureProjectionLightMatrix(): void;
  54779. /**
  54780. * Main function for light texture projection matrix computing.
  54781. */
  54782. protected _computeProjectionTextureMatrix(): void;
  54783. protected _buildUniformLayout(): void;
  54784. private _computeAngleValues;
  54785. /**
  54786. * Sets the passed Effect "effect" with the Light textures.
  54787. * @param effect The effect to update
  54788. * @param lightIndex The index of the light in the effect to update
  54789. * @returns The light
  54790. */
  54791. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  54792. /**
  54793. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  54794. * @param effect The effect to update
  54795. * @param lightIndex The index of the light in the effect to update
  54796. * @returns The spot light
  54797. */
  54798. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  54799. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  54800. /**
  54801. * Disposes the light and the associated resources.
  54802. */
  54803. dispose(): void;
  54804. /**
  54805. * Prepares the list of defines specific to the light type.
  54806. * @param defines the list of defines
  54807. * @param lightIndex defines the index of the light for the effect
  54808. */
  54809. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  54810. }
  54811. }
  54812. declare module "babylonjs/Gizmos/lightGizmo" {
  54813. import { Nullable } from "babylonjs/types";
  54814. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54815. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54816. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  54817. import { Light } from "babylonjs/Lights/light";
  54818. /**
  54819. * Gizmo that enables viewing a light
  54820. */
  54821. export class LightGizmo extends Gizmo {
  54822. private _lightMesh;
  54823. private _material;
  54824. private _cachedPosition;
  54825. private _cachedForward;
  54826. private _attachedMeshParent;
  54827. /**
  54828. * Creates a LightGizmo
  54829. * @param gizmoLayer The utility layer the gizmo will be added to
  54830. */
  54831. constructor(gizmoLayer?: UtilityLayerRenderer);
  54832. private _light;
  54833. /**
  54834. * The light that the gizmo is attached to
  54835. */
  54836. set light(light: Nullable<Light>);
  54837. get light(): Nullable<Light>;
  54838. /**
  54839. * Gets the material used to render the light gizmo
  54840. */
  54841. get material(): StandardMaterial;
  54842. /**
  54843. * @hidden
  54844. * Updates the gizmo to match the attached mesh's position/rotation
  54845. */
  54846. protected _update(): void;
  54847. private static _Scale;
  54848. /**
  54849. * Creates the lines for a light mesh
  54850. */
  54851. private static _CreateLightLines;
  54852. /**
  54853. * Disposes of the light gizmo
  54854. */
  54855. dispose(): void;
  54856. private static _CreateHemisphericLightMesh;
  54857. private static _CreatePointLightMesh;
  54858. private static _CreateSpotLightMesh;
  54859. private static _CreateDirectionalLightMesh;
  54860. }
  54861. }
  54862. declare module "babylonjs/Gizmos/index" {
  54863. export * from "babylonjs/Gizmos/axisDragGizmo";
  54864. export * from "babylonjs/Gizmos/axisScaleGizmo";
  54865. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  54866. export * from "babylonjs/Gizmos/gizmo";
  54867. export * from "babylonjs/Gizmos/gizmoManager";
  54868. export * from "babylonjs/Gizmos/planeRotationGizmo";
  54869. export * from "babylonjs/Gizmos/positionGizmo";
  54870. export * from "babylonjs/Gizmos/rotationGizmo";
  54871. export * from "babylonjs/Gizmos/scaleGizmo";
  54872. export * from "babylonjs/Gizmos/lightGizmo";
  54873. export * from "babylonjs/Gizmos/planeDragGizmo";
  54874. }
  54875. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  54876. /** @hidden */
  54877. export var backgroundFragmentDeclaration: {
  54878. name: string;
  54879. shader: string;
  54880. };
  54881. }
  54882. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  54883. /** @hidden */
  54884. export var backgroundUboDeclaration: {
  54885. name: string;
  54886. shader: string;
  54887. };
  54888. }
  54889. declare module "babylonjs/Shaders/background.fragment" {
  54890. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  54891. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  54892. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  54893. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  54894. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  54895. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  54896. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54897. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  54898. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  54899. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  54900. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  54901. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  54902. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  54903. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  54904. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  54905. /** @hidden */
  54906. export var backgroundPixelShader: {
  54907. name: string;
  54908. shader: string;
  54909. };
  54910. }
  54911. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  54912. /** @hidden */
  54913. export var backgroundVertexDeclaration: {
  54914. name: string;
  54915. shader: string;
  54916. };
  54917. }
  54918. declare module "babylonjs/Shaders/background.vertex" {
  54919. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  54920. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  54921. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54922. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  54923. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  54924. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  54925. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  54926. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  54927. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  54928. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  54929. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  54930. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  54931. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  54932. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  54933. /** @hidden */
  54934. export var backgroundVertexShader: {
  54935. name: string;
  54936. shader: string;
  54937. };
  54938. }
  54939. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  54940. import { Nullable, int, float } from "babylonjs/types";
  54941. import { Scene } from "babylonjs/scene";
  54942. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  54943. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54944. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54945. import { Mesh } from "babylonjs/Meshes/mesh";
  54946. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  54947. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  54948. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  54949. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54950. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  54951. import { Color3 } from "babylonjs/Maths/math.color";
  54952. import "babylonjs/Shaders/background.fragment";
  54953. import "babylonjs/Shaders/background.vertex";
  54954. /**
  54955. * Background material used to create an efficient environement around your scene.
  54956. */
  54957. export class BackgroundMaterial extends PushMaterial {
  54958. /**
  54959. * Standard reflectance value at parallel view angle.
  54960. */
  54961. static StandardReflectance0: number;
  54962. /**
  54963. * Standard reflectance value at grazing angle.
  54964. */
  54965. static StandardReflectance90: number;
  54966. protected _primaryColor: Color3;
  54967. /**
  54968. * Key light Color (multiply against the environement texture)
  54969. */
  54970. primaryColor: Color3;
  54971. protected __perceptualColor: Nullable<Color3>;
  54972. /**
  54973. * Experimental Internal Use Only.
  54974. *
  54975. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  54976. * This acts as a helper to set the primary color to a more "human friendly" value.
  54977. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  54978. * output color as close as possible from the chosen value.
  54979. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  54980. * part of lighting setup.)
  54981. */
  54982. get _perceptualColor(): Nullable<Color3>;
  54983. set _perceptualColor(value: Nullable<Color3>);
  54984. protected _primaryColorShadowLevel: float;
  54985. /**
  54986. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  54987. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  54988. */
  54989. get primaryColorShadowLevel(): float;
  54990. set primaryColorShadowLevel(value: float);
  54991. protected _primaryColorHighlightLevel: float;
  54992. /**
  54993. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  54994. * The primary color is used at the level chosen to define what the white area would look.
  54995. */
  54996. get primaryColorHighlightLevel(): float;
  54997. set primaryColorHighlightLevel(value: float);
  54998. protected _reflectionTexture: Nullable<BaseTexture>;
  54999. /**
  55000. * Reflection Texture used in the material.
  55001. * Should be author in a specific way for the best result (refer to the documentation).
  55002. */
  55003. reflectionTexture: Nullable<BaseTexture>;
  55004. protected _reflectionBlur: float;
  55005. /**
  55006. * Reflection Texture level of blur.
  55007. *
  55008. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  55009. * texture twice.
  55010. */
  55011. reflectionBlur: float;
  55012. protected _diffuseTexture: Nullable<BaseTexture>;
  55013. /**
  55014. * Diffuse Texture used in the material.
  55015. * Should be author in a specific way for the best result (refer to the documentation).
  55016. */
  55017. diffuseTexture: Nullable<BaseTexture>;
  55018. protected _shadowLights: Nullable<IShadowLight[]>;
  55019. /**
  55020. * Specify the list of lights casting shadow on the material.
  55021. * All scene shadow lights will be included if null.
  55022. */
  55023. shadowLights: Nullable<IShadowLight[]>;
  55024. protected _shadowLevel: float;
  55025. /**
  55026. * Helps adjusting the shadow to a softer level if required.
  55027. * 0 means black shadows and 1 means no shadows.
  55028. */
  55029. shadowLevel: float;
  55030. protected _sceneCenter: Vector3;
  55031. /**
  55032. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  55033. * It is usually zero but might be interesting to modify according to your setup.
  55034. */
  55035. sceneCenter: Vector3;
  55036. protected _opacityFresnel: boolean;
  55037. /**
  55038. * This helps specifying that the material is falling off to the sky box at grazing angle.
  55039. * This helps ensuring a nice transition when the camera goes under the ground.
  55040. */
  55041. opacityFresnel: boolean;
  55042. protected _reflectionFresnel: boolean;
  55043. /**
  55044. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  55045. * This helps adding a mirror texture on the ground.
  55046. */
  55047. reflectionFresnel: boolean;
  55048. protected _reflectionFalloffDistance: number;
  55049. /**
  55050. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  55051. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  55052. */
  55053. reflectionFalloffDistance: number;
  55054. protected _reflectionAmount: number;
  55055. /**
  55056. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  55057. */
  55058. reflectionAmount: number;
  55059. protected _reflectionReflectance0: number;
  55060. /**
  55061. * This specifies the weight of the reflection at grazing angle.
  55062. */
  55063. reflectionReflectance0: number;
  55064. protected _reflectionReflectance90: number;
  55065. /**
  55066. * This specifies the weight of the reflection at a perpendicular point of view.
  55067. */
  55068. reflectionReflectance90: number;
  55069. /**
  55070. * Sets the reflection reflectance fresnel values according to the default standard
  55071. * empirically know to work well :-)
  55072. */
  55073. set reflectionStandardFresnelWeight(value: number);
  55074. protected _useRGBColor: boolean;
  55075. /**
  55076. * Helps to directly use the maps channels instead of their level.
  55077. */
  55078. useRGBColor: boolean;
  55079. protected _enableNoise: boolean;
  55080. /**
  55081. * This helps reducing the banding effect that could occur on the background.
  55082. */
  55083. enableNoise: boolean;
  55084. /**
  55085. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  55086. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  55087. * Recommended to be keep at 1.0 except for special cases.
  55088. */
  55089. get fovMultiplier(): number;
  55090. set fovMultiplier(value: number);
  55091. private _fovMultiplier;
  55092. /**
  55093. * Enable the FOV adjustment feature controlled by fovMultiplier.
  55094. */
  55095. useEquirectangularFOV: boolean;
  55096. private _maxSimultaneousLights;
  55097. /**
  55098. * Number of Simultaneous lights allowed on the material.
  55099. */
  55100. maxSimultaneousLights: int;
  55101. /**
  55102. * Default configuration related to image processing available in the Background Material.
  55103. */
  55104. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  55105. /**
  55106. * Keep track of the image processing observer to allow dispose and replace.
  55107. */
  55108. private _imageProcessingObserver;
  55109. /**
  55110. * Attaches a new image processing configuration to the PBR Material.
  55111. * @param configuration (if null the scene configuration will be use)
  55112. */
  55113. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  55114. /**
  55115. * Gets the image processing configuration used either in this material.
  55116. */
  55117. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  55118. /**
  55119. * Sets the Default image processing configuration used either in the this material.
  55120. *
  55121. * If sets to null, the scene one is in use.
  55122. */
  55123. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  55124. /**
  55125. * Gets wether the color curves effect is enabled.
  55126. */
  55127. get cameraColorCurvesEnabled(): boolean;
  55128. /**
  55129. * Sets wether the color curves effect is enabled.
  55130. */
  55131. set cameraColorCurvesEnabled(value: boolean);
  55132. /**
  55133. * Gets wether the color grading effect is enabled.
  55134. */
  55135. get cameraColorGradingEnabled(): boolean;
  55136. /**
  55137. * Gets wether the color grading effect is enabled.
  55138. */
  55139. set cameraColorGradingEnabled(value: boolean);
  55140. /**
  55141. * Gets wether tonemapping is enabled or not.
  55142. */
  55143. get cameraToneMappingEnabled(): boolean;
  55144. /**
  55145. * Sets wether tonemapping is enabled or not
  55146. */
  55147. set cameraToneMappingEnabled(value: boolean);
  55148. /**
  55149. * The camera exposure used on this material.
  55150. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  55151. * This corresponds to a photographic exposure.
  55152. */
  55153. get cameraExposure(): float;
  55154. /**
  55155. * The camera exposure used on this material.
  55156. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  55157. * This corresponds to a photographic exposure.
  55158. */
  55159. set cameraExposure(value: float);
  55160. /**
  55161. * Gets The camera contrast used on this material.
  55162. */
  55163. get cameraContrast(): float;
  55164. /**
  55165. * Sets The camera contrast used on this material.
  55166. */
  55167. set cameraContrast(value: float);
  55168. /**
  55169. * Gets the Color Grading 2D Lookup Texture.
  55170. */
  55171. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  55172. /**
  55173. * Sets the Color Grading 2D Lookup Texture.
  55174. */
  55175. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  55176. /**
  55177. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  55178. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  55179. * 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;
  55180. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  55181. */
  55182. get cameraColorCurves(): Nullable<ColorCurves>;
  55183. /**
  55184. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  55185. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  55186. * 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;
  55187. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  55188. */
  55189. set cameraColorCurves(value: Nullable<ColorCurves>);
  55190. /**
  55191. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  55192. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  55193. */
  55194. switchToBGR: boolean;
  55195. private _renderTargets;
  55196. private _reflectionControls;
  55197. private _white;
  55198. private _primaryShadowColor;
  55199. private _primaryHighlightColor;
  55200. /**
  55201. * Instantiates a Background Material in the given scene
  55202. * @param name The friendly name of the material
  55203. * @param scene The scene to add the material to
  55204. */
  55205. constructor(name: string, scene: Scene);
  55206. /**
  55207. * Gets a boolean indicating that current material needs to register RTT
  55208. */
  55209. get hasRenderTargetTextures(): boolean;
  55210. /**
  55211. * The entire material has been created in order to prevent overdraw.
  55212. * @returns false
  55213. */
  55214. needAlphaTesting(): boolean;
  55215. /**
  55216. * The entire material has been created in order to prevent overdraw.
  55217. * @returns true if blending is enable
  55218. */
  55219. needAlphaBlending(): boolean;
  55220. /**
  55221. * Checks wether the material is ready to be rendered for a given mesh.
  55222. * @param mesh The mesh to render
  55223. * @param subMesh The submesh to check against
  55224. * @param useInstances Specify wether or not the material is used with instances
  55225. * @returns true if all the dependencies are ready (Textures, Effects...)
  55226. */
  55227. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  55228. /**
  55229. * Compute the primary color according to the chosen perceptual color.
  55230. */
  55231. private _computePrimaryColorFromPerceptualColor;
  55232. /**
  55233. * Compute the highlights and shadow colors according to their chosen levels.
  55234. */
  55235. private _computePrimaryColors;
  55236. /**
  55237. * Build the uniform buffer used in the material.
  55238. */
  55239. buildUniformLayout(): void;
  55240. /**
  55241. * Unbind the material.
  55242. */
  55243. unbind(): void;
  55244. /**
  55245. * Bind only the world matrix to the material.
  55246. * @param world The world matrix to bind.
  55247. */
  55248. bindOnlyWorldMatrix(world: Matrix): void;
  55249. /**
  55250. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  55251. * @param world The world matrix to bind.
  55252. * @param subMesh The submesh to bind for.
  55253. */
  55254. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  55255. /**
  55256. * Checks to see if a texture is used in the material.
  55257. * @param texture - Base texture to use.
  55258. * @returns - Boolean specifying if a texture is used in the material.
  55259. */
  55260. hasTexture(texture: BaseTexture): boolean;
  55261. /**
  55262. * Dispose the material.
  55263. * @param forceDisposeEffect Force disposal of the associated effect.
  55264. * @param forceDisposeTextures Force disposal of the associated textures.
  55265. */
  55266. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  55267. /**
  55268. * Clones the material.
  55269. * @param name The cloned name.
  55270. * @returns The cloned material.
  55271. */
  55272. clone(name: string): BackgroundMaterial;
  55273. /**
  55274. * Serializes the current material to its JSON representation.
  55275. * @returns The JSON representation.
  55276. */
  55277. serialize(): any;
  55278. /**
  55279. * Gets the class name of the material
  55280. * @returns "BackgroundMaterial"
  55281. */
  55282. getClassName(): string;
  55283. /**
  55284. * Parse a JSON input to create back a background material.
  55285. * @param source The JSON data to parse
  55286. * @param scene The scene to create the parsed material in
  55287. * @param rootUrl The root url of the assets the material depends upon
  55288. * @returns the instantiated BackgroundMaterial.
  55289. */
  55290. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  55291. }
  55292. }
  55293. declare module "babylonjs/Helpers/environmentHelper" {
  55294. import { Observable } from "babylonjs/Misc/observable";
  55295. import { Nullable } from "babylonjs/types";
  55296. import { Scene } from "babylonjs/scene";
  55297. import { Vector3 } from "babylonjs/Maths/math.vector";
  55298. import { Color3 } from "babylonjs/Maths/math.color";
  55299. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55300. import { Mesh } from "babylonjs/Meshes/mesh";
  55301. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55302. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  55303. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  55304. import "babylonjs/Meshes/Builders/planeBuilder";
  55305. import "babylonjs/Meshes/Builders/boxBuilder";
  55306. /**
  55307. * Represents the different options available during the creation of
  55308. * a Environment helper.
  55309. *
  55310. * This can control the default ground, skybox and image processing setup of your scene.
  55311. */
  55312. export interface IEnvironmentHelperOptions {
  55313. /**
  55314. * Specifies whether or not to create a ground.
  55315. * True by default.
  55316. */
  55317. createGround: boolean;
  55318. /**
  55319. * Specifies the ground size.
  55320. * 15 by default.
  55321. */
  55322. groundSize: number;
  55323. /**
  55324. * The texture used on the ground for the main color.
  55325. * Comes from the BabylonJS CDN by default.
  55326. *
  55327. * Remarks: Can be either a texture or a url.
  55328. */
  55329. groundTexture: string | BaseTexture;
  55330. /**
  55331. * The color mixed in the ground texture by default.
  55332. * BabylonJS clearColor by default.
  55333. */
  55334. groundColor: Color3;
  55335. /**
  55336. * Specifies the ground opacity.
  55337. * 1 by default.
  55338. */
  55339. groundOpacity: number;
  55340. /**
  55341. * Enables the ground to receive shadows.
  55342. * True by default.
  55343. */
  55344. enableGroundShadow: boolean;
  55345. /**
  55346. * Helps preventing the shadow to be fully black on the ground.
  55347. * 0.5 by default.
  55348. */
  55349. groundShadowLevel: number;
  55350. /**
  55351. * Creates a mirror texture attach to the ground.
  55352. * false by default.
  55353. */
  55354. enableGroundMirror: boolean;
  55355. /**
  55356. * Specifies the ground mirror size ratio.
  55357. * 0.3 by default as the default kernel is 64.
  55358. */
  55359. groundMirrorSizeRatio: number;
  55360. /**
  55361. * Specifies the ground mirror blur kernel size.
  55362. * 64 by default.
  55363. */
  55364. groundMirrorBlurKernel: number;
  55365. /**
  55366. * Specifies the ground mirror visibility amount.
  55367. * 1 by default
  55368. */
  55369. groundMirrorAmount: number;
  55370. /**
  55371. * Specifies the ground mirror reflectance weight.
  55372. * This uses the standard weight of the background material to setup the fresnel effect
  55373. * of the mirror.
  55374. * 1 by default.
  55375. */
  55376. groundMirrorFresnelWeight: number;
  55377. /**
  55378. * Specifies the ground mirror Falloff distance.
  55379. * This can helps reducing the size of the reflection.
  55380. * 0 by Default.
  55381. */
  55382. groundMirrorFallOffDistance: number;
  55383. /**
  55384. * Specifies the ground mirror texture type.
  55385. * Unsigned Int by Default.
  55386. */
  55387. groundMirrorTextureType: number;
  55388. /**
  55389. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  55390. * the shown objects.
  55391. */
  55392. groundYBias: number;
  55393. /**
  55394. * Specifies whether or not to create a skybox.
  55395. * True by default.
  55396. */
  55397. createSkybox: boolean;
  55398. /**
  55399. * Specifies the skybox size.
  55400. * 20 by default.
  55401. */
  55402. skyboxSize: number;
  55403. /**
  55404. * The texture used on the skybox for the main color.
  55405. * Comes from the BabylonJS CDN by default.
  55406. *
  55407. * Remarks: Can be either a texture or a url.
  55408. */
  55409. skyboxTexture: string | BaseTexture;
  55410. /**
  55411. * The color mixed in the skybox texture by default.
  55412. * BabylonJS clearColor by default.
  55413. */
  55414. skyboxColor: Color3;
  55415. /**
  55416. * The background rotation around the Y axis of the scene.
  55417. * This helps aligning the key lights of your scene with the background.
  55418. * 0 by default.
  55419. */
  55420. backgroundYRotation: number;
  55421. /**
  55422. * Compute automatically the size of the elements to best fit with the scene.
  55423. */
  55424. sizeAuto: boolean;
  55425. /**
  55426. * Default position of the rootMesh if autoSize is not true.
  55427. */
  55428. rootPosition: Vector3;
  55429. /**
  55430. * Sets up the image processing in the scene.
  55431. * true by default.
  55432. */
  55433. setupImageProcessing: boolean;
  55434. /**
  55435. * The texture used as your environment texture in the scene.
  55436. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  55437. *
  55438. * Remarks: Can be either a texture or a url.
  55439. */
  55440. environmentTexture: string | BaseTexture;
  55441. /**
  55442. * The value of the exposure to apply to the scene.
  55443. * 0.6 by default if setupImageProcessing is true.
  55444. */
  55445. cameraExposure: number;
  55446. /**
  55447. * The value of the contrast to apply to the scene.
  55448. * 1.6 by default if setupImageProcessing is true.
  55449. */
  55450. cameraContrast: number;
  55451. /**
  55452. * Specifies whether or not tonemapping should be enabled in the scene.
  55453. * true by default if setupImageProcessing is true.
  55454. */
  55455. toneMappingEnabled: boolean;
  55456. }
  55457. /**
  55458. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  55459. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  55460. * It also helps with the default setup of your imageProcessing configuration.
  55461. */
  55462. export class EnvironmentHelper {
  55463. /**
  55464. * Default ground texture URL.
  55465. */
  55466. private static _groundTextureCDNUrl;
  55467. /**
  55468. * Default skybox texture URL.
  55469. */
  55470. private static _skyboxTextureCDNUrl;
  55471. /**
  55472. * Default environment texture URL.
  55473. */
  55474. private static _environmentTextureCDNUrl;
  55475. /**
  55476. * Creates the default options for the helper.
  55477. */
  55478. private static _getDefaultOptions;
  55479. private _rootMesh;
  55480. /**
  55481. * Gets the root mesh created by the helper.
  55482. */
  55483. get rootMesh(): Mesh;
  55484. private _skybox;
  55485. /**
  55486. * Gets the skybox created by the helper.
  55487. */
  55488. get skybox(): Nullable<Mesh>;
  55489. private _skyboxTexture;
  55490. /**
  55491. * Gets the skybox texture created by the helper.
  55492. */
  55493. get skyboxTexture(): Nullable<BaseTexture>;
  55494. private _skyboxMaterial;
  55495. /**
  55496. * Gets the skybox material created by the helper.
  55497. */
  55498. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  55499. private _ground;
  55500. /**
  55501. * Gets the ground mesh created by the helper.
  55502. */
  55503. get ground(): Nullable<Mesh>;
  55504. private _groundTexture;
  55505. /**
  55506. * Gets the ground texture created by the helper.
  55507. */
  55508. get groundTexture(): Nullable<BaseTexture>;
  55509. private _groundMirror;
  55510. /**
  55511. * Gets the ground mirror created by the helper.
  55512. */
  55513. get groundMirror(): Nullable<MirrorTexture>;
  55514. /**
  55515. * Gets the ground mirror render list to helps pushing the meshes
  55516. * you wish in the ground reflection.
  55517. */
  55518. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  55519. private _groundMaterial;
  55520. /**
  55521. * Gets the ground material created by the helper.
  55522. */
  55523. get groundMaterial(): Nullable<BackgroundMaterial>;
  55524. /**
  55525. * Stores the creation options.
  55526. */
  55527. private readonly _scene;
  55528. private _options;
  55529. /**
  55530. * This observable will be notified with any error during the creation of the environment,
  55531. * mainly texture creation errors.
  55532. */
  55533. onErrorObservable: Observable<{
  55534. message?: string;
  55535. exception?: any;
  55536. }>;
  55537. /**
  55538. * constructor
  55539. * @param options Defines the options we want to customize the helper
  55540. * @param scene The scene to add the material to
  55541. */
  55542. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  55543. /**
  55544. * Updates the background according to the new options
  55545. * @param options
  55546. */
  55547. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  55548. /**
  55549. * Sets the primary color of all the available elements.
  55550. * @param color the main color to affect to the ground and the background
  55551. */
  55552. setMainColor(color: Color3): void;
  55553. /**
  55554. * Setup the image processing according to the specified options.
  55555. */
  55556. private _setupImageProcessing;
  55557. /**
  55558. * Setup the environment texture according to the specified options.
  55559. */
  55560. private _setupEnvironmentTexture;
  55561. /**
  55562. * Setup the background according to the specified options.
  55563. */
  55564. private _setupBackground;
  55565. /**
  55566. * Get the scene sizes according to the setup.
  55567. */
  55568. private _getSceneSize;
  55569. /**
  55570. * Setup the ground according to the specified options.
  55571. */
  55572. private _setupGround;
  55573. /**
  55574. * Setup the ground material according to the specified options.
  55575. */
  55576. private _setupGroundMaterial;
  55577. /**
  55578. * Setup the ground diffuse texture according to the specified options.
  55579. */
  55580. private _setupGroundDiffuseTexture;
  55581. /**
  55582. * Setup the ground mirror texture according to the specified options.
  55583. */
  55584. private _setupGroundMirrorTexture;
  55585. /**
  55586. * Setup the ground to receive the mirror texture.
  55587. */
  55588. private _setupMirrorInGroundMaterial;
  55589. /**
  55590. * Setup the skybox according to the specified options.
  55591. */
  55592. private _setupSkybox;
  55593. /**
  55594. * Setup the skybox material according to the specified options.
  55595. */
  55596. private _setupSkyboxMaterial;
  55597. /**
  55598. * Setup the skybox reflection texture according to the specified options.
  55599. */
  55600. private _setupSkyboxReflectionTexture;
  55601. private _errorHandler;
  55602. /**
  55603. * Dispose all the elements created by the Helper.
  55604. */
  55605. dispose(): void;
  55606. }
  55607. }
  55608. declare module "babylonjs/Helpers/photoDome" {
  55609. import { Observable } from "babylonjs/Misc/observable";
  55610. import { Nullable } from "babylonjs/types";
  55611. import { Scene } from "babylonjs/scene";
  55612. import { TransformNode } from "babylonjs/Meshes/transformNode";
  55613. import { Mesh } from "babylonjs/Meshes/mesh";
  55614. import { Texture } from "babylonjs/Materials/Textures/texture";
  55615. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  55616. import "babylonjs/Meshes/Builders/sphereBuilder";
  55617. /**
  55618. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  55619. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  55620. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  55621. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  55622. */
  55623. export class PhotoDome extends TransformNode {
  55624. /**
  55625. * Define the image as a Monoscopic panoramic 360 image.
  55626. */
  55627. static readonly MODE_MONOSCOPIC: number;
  55628. /**
  55629. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  55630. */
  55631. static readonly MODE_TOPBOTTOM: number;
  55632. /**
  55633. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  55634. */
  55635. static readonly MODE_SIDEBYSIDE: number;
  55636. private _useDirectMapping;
  55637. /**
  55638. * The texture being displayed on the sphere
  55639. */
  55640. protected _photoTexture: Texture;
  55641. /**
  55642. * Gets or sets the texture being displayed on the sphere
  55643. */
  55644. get photoTexture(): Texture;
  55645. set photoTexture(value: Texture);
  55646. /**
  55647. * Observable raised when an error occured while loading the 360 image
  55648. */
  55649. onLoadErrorObservable: Observable<string>;
  55650. /**
  55651. * The skybox material
  55652. */
  55653. protected _material: BackgroundMaterial;
  55654. /**
  55655. * The surface used for the skybox
  55656. */
  55657. protected _mesh: Mesh;
  55658. /**
  55659. * Gets the mesh used for the skybox.
  55660. */
  55661. get mesh(): Mesh;
  55662. /**
  55663. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  55664. * Also see the options.resolution property.
  55665. */
  55666. get fovMultiplier(): number;
  55667. set fovMultiplier(value: number);
  55668. private _imageMode;
  55669. /**
  55670. * Gets or set the current video mode for the video. It can be:
  55671. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  55672. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  55673. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  55674. */
  55675. get imageMode(): number;
  55676. set imageMode(value: number);
  55677. /**
  55678. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  55679. * @param name Element's name, child elements will append suffixes for their own names.
  55680. * @param urlsOfPhoto defines the url of the photo to display
  55681. * @param options defines an object containing optional or exposed sub element properties
  55682. * @param onError defines a callback called when an error occured while loading the texture
  55683. */
  55684. constructor(name: string, urlOfPhoto: string, options: {
  55685. resolution?: number;
  55686. size?: number;
  55687. useDirectMapping?: boolean;
  55688. faceForward?: boolean;
  55689. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  55690. private _onBeforeCameraRenderObserver;
  55691. private _changeImageMode;
  55692. /**
  55693. * Releases resources associated with this node.
  55694. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  55695. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  55696. */
  55697. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  55698. }
  55699. }
  55700. declare module "babylonjs/Misc/rgbdTextureTools" {
  55701. import "babylonjs/Shaders/rgbdDecode.fragment";
  55702. import "babylonjs/Engines/Extensions/engine.renderTarget";
  55703. import { Texture } from "babylonjs/Materials/Textures/texture";
  55704. /**
  55705. * Class used to host RGBD texture specific utilities
  55706. */
  55707. export class RGBDTextureTools {
  55708. /**
  55709. * Expand the RGBD Texture from RGBD to Half Float if possible.
  55710. * @param texture the texture to expand.
  55711. */
  55712. static ExpandRGBDTexture(texture: Texture): void;
  55713. }
  55714. }
  55715. declare module "babylonjs/Misc/brdfTextureTools" {
  55716. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55717. import { Scene } from "babylonjs/scene";
  55718. /**
  55719. * Class used to host texture specific utilities
  55720. */
  55721. export class BRDFTextureTools {
  55722. /**
  55723. * Prevents texture cache collision
  55724. */
  55725. private static _instanceNumber;
  55726. /**
  55727. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  55728. * @param scene defines the hosting scene
  55729. * @returns the environment BRDF texture
  55730. */
  55731. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  55732. private static _environmentBRDFBase64Texture;
  55733. }
  55734. }
  55735. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  55736. import { Nullable } from "babylonjs/types";
  55737. import { Color3 } from "babylonjs/Maths/math.color";
  55738. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55739. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  55740. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  55741. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  55742. import { Engine } from "babylonjs/Engines/engine";
  55743. import { Scene } from "babylonjs/scene";
  55744. /**
  55745. * @hidden
  55746. */
  55747. export interface IMaterialClearCoatDefines {
  55748. CLEARCOAT: boolean;
  55749. CLEARCOAT_DEFAULTIOR: boolean;
  55750. CLEARCOAT_TEXTURE: boolean;
  55751. CLEARCOAT_TEXTUREDIRECTUV: number;
  55752. CLEARCOAT_BUMP: boolean;
  55753. CLEARCOAT_BUMPDIRECTUV: number;
  55754. CLEARCOAT_TINT: boolean;
  55755. CLEARCOAT_TINT_TEXTURE: boolean;
  55756. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  55757. /** @hidden */
  55758. _areTexturesDirty: boolean;
  55759. }
  55760. /**
  55761. * Define the code related to the clear coat parameters of the pbr material.
  55762. */
  55763. export class PBRClearCoatConfiguration {
  55764. /**
  55765. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  55766. * The default fits with a polyurethane material.
  55767. */
  55768. private static readonly _DefaultIndexOfRefraction;
  55769. private _isEnabled;
  55770. /**
  55771. * Defines if the clear coat is enabled in the material.
  55772. */
  55773. isEnabled: boolean;
  55774. /**
  55775. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  55776. */
  55777. intensity: number;
  55778. /**
  55779. * Defines the clear coat layer roughness.
  55780. */
  55781. roughness: number;
  55782. private _indexOfRefraction;
  55783. /**
  55784. * Defines the index of refraction of the clear coat.
  55785. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  55786. * The default fits with a polyurethane material.
  55787. * Changing the default value is more performance intensive.
  55788. */
  55789. indexOfRefraction: number;
  55790. private _texture;
  55791. /**
  55792. * Stores the clear coat values in a texture.
  55793. */
  55794. texture: Nullable<BaseTexture>;
  55795. private _bumpTexture;
  55796. /**
  55797. * Define the clear coat specific bump texture.
  55798. */
  55799. bumpTexture: Nullable<BaseTexture>;
  55800. private _isTintEnabled;
  55801. /**
  55802. * Defines if the clear coat tint is enabled in the material.
  55803. */
  55804. isTintEnabled: boolean;
  55805. /**
  55806. * Defines the clear coat tint of the material.
  55807. * This is only use if tint is enabled
  55808. */
  55809. tintColor: Color3;
  55810. /**
  55811. * Defines the distance at which the tint color should be found in the
  55812. * clear coat media.
  55813. * This is only use if tint is enabled
  55814. */
  55815. tintColorAtDistance: number;
  55816. /**
  55817. * Defines the clear coat layer thickness.
  55818. * This is only use if tint is enabled
  55819. */
  55820. tintThickness: number;
  55821. private _tintTexture;
  55822. /**
  55823. * Stores the clear tint values in a texture.
  55824. * rgb is tint
  55825. * a is a thickness factor
  55826. */
  55827. tintTexture: Nullable<BaseTexture>;
  55828. /** @hidden */
  55829. private _internalMarkAllSubMeshesAsTexturesDirty;
  55830. /** @hidden */
  55831. _markAllSubMeshesAsTexturesDirty(): void;
  55832. /**
  55833. * Instantiate a new istance of clear coat configuration.
  55834. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55835. */
  55836. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  55837. /**
  55838. * Gets wehter the submesh is ready to be used or not.
  55839. * @param defines the list of "defines" to update.
  55840. * @param scene defines the scene the material belongs to.
  55841. * @param engine defines the engine the material belongs to.
  55842. * @param disableBumpMap defines wether the material disables bump or not.
  55843. * @returns - boolean indicating that the submesh is ready or not.
  55844. */
  55845. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  55846. /**
  55847. * Checks to see if a texture is used in the material.
  55848. * @param defines the list of "defines" to update.
  55849. * @param scene defines the scene to the material belongs to.
  55850. */
  55851. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  55852. /**
  55853. * Binds the material data.
  55854. * @param uniformBuffer defines the Uniform buffer to fill in.
  55855. * @param scene defines the scene the material belongs to.
  55856. * @param engine defines the engine the material belongs to.
  55857. * @param disableBumpMap defines wether the material disables bump or not.
  55858. * @param isFrozen defines wether the material is frozen or not.
  55859. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  55860. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  55861. */
  55862. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  55863. /**
  55864. * Checks to see if a texture is used in the material.
  55865. * @param texture - Base texture to use.
  55866. * @returns - Boolean specifying if a texture is used in the material.
  55867. */
  55868. hasTexture(texture: BaseTexture): boolean;
  55869. /**
  55870. * Returns an array of the actively used textures.
  55871. * @param activeTextures Array of BaseTextures
  55872. */
  55873. getActiveTextures(activeTextures: BaseTexture[]): void;
  55874. /**
  55875. * Returns the animatable textures.
  55876. * @param animatables Array of animatable textures.
  55877. */
  55878. getAnimatables(animatables: IAnimatable[]): void;
  55879. /**
  55880. * Disposes the resources of the material.
  55881. * @param forceDisposeTextures - Forces the disposal of all textures.
  55882. */
  55883. dispose(forceDisposeTextures?: boolean): void;
  55884. /**
  55885. * Get the current class name of the texture useful for serialization or dynamic coding.
  55886. * @returns "PBRClearCoatConfiguration"
  55887. */
  55888. getClassName(): string;
  55889. /**
  55890. * Add fallbacks to the effect fallbacks list.
  55891. * @param defines defines the Base texture to use.
  55892. * @param fallbacks defines the current fallback list.
  55893. * @param currentRank defines the current fallback rank.
  55894. * @returns the new fallback rank.
  55895. */
  55896. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  55897. /**
  55898. * Add the required uniforms to the current list.
  55899. * @param uniforms defines the current uniform list.
  55900. */
  55901. static AddUniforms(uniforms: string[]): void;
  55902. /**
  55903. * Add the required samplers to the current list.
  55904. * @param samplers defines the current sampler list.
  55905. */
  55906. static AddSamplers(samplers: string[]): void;
  55907. /**
  55908. * Add the required uniforms to the current buffer.
  55909. * @param uniformBuffer defines the current uniform buffer.
  55910. */
  55911. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  55912. /**
  55913. * Makes a duplicate of the current configuration into another one.
  55914. * @param clearCoatConfiguration define the config where to copy the info
  55915. */
  55916. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  55917. /**
  55918. * Serializes this clear coat configuration.
  55919. * @returns - An object with the serialized config.
  55920. */
  55921. serialize(): any;
  55922. /**
  55923. * Parses a anisotropy Configuration from a serialized object.
  55924. * @param source - Serialized object.
  55925. * @param scene Defines the scene we are parsing for
  55926. * @param rootUrl Defines the rootUrl to load from
  55927. */
  55928. parse(source: any, scene: Scene, rootUrl: string): void;
  55929. }
  55930. }
  55931. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  55932. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  55933. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55934. import { Vector2 } from "babylonjs/Maths/math.vector";
  55935. import { Scene } from "babylonjs/scene";
  55936. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55937. import { Nullable } from "babylonjs/types";
  55938. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  55939. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  55940. /**
  55941. * @hidden
  55942. */
  55943. export interface IMaterialAnisotropicDefines {
  55944. ANISOTROPIC: boolean;
  55945. ANISOTROPIC_TEXTURE: boolean;
  55946. ANISOTROPIC_TEXTUREDIRECTUV: number;
  55947. MAINUV1: boolean;
  55948. _areTexturesDirty: boolean;
  55949. _needUVs: boolean;
  55950. }
  55951. /**
  55952. * Define the code related to the anisotropic parameters of the pbr material.
  55953. */
  55954. export class PBRAnisotropicConfiguration {
  55955. private _isEnabled;
  55956. /**
  55957. * Defines if the anisotropy is enabled in the material.
  55958. */
  55959. isEnabled: boolean;
  55960. /**
  55961. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  55962. */
  55963. intensity: number;
  55964. /**
  55965. * Defines if the effect is along the tangents, bitangents or in between.
  55966. * By default, the effect is "strectching" the highlights along the tangents.
  55967. */
  55968. direction: Vector2;
  55969. private _texture;
  55970. /**
  55971. * Stores the anisotropy values in a texture.
  55972. * rg is direction (like normal from -1 to 1)
  55973. * b is a intensity
  55974. */
  55975. texture: Nullable<BaseTexture>;
  55976. /** @hidden */
  55977. private _internalMarkAllSubMeshesAsTexturesDirty;
  55978. /** @hidden */
  55979. _markAllSubMeshesAsTexturesDirty(): void;
  55980. /**
  55981. * Instantiate a new istance of anisotropy configuration.
  55982. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55983. */
  55984. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  55985. /**
  55986. * Specifies that the submesh is ready to be used.
  55987. * @param defines the list of "defines" to update.
  55988. * @param scene defines the scene the material belongs to.
  55989. * @returns - boolean indicating that the submesh is ready or not.
  55990. */
  55991. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  55992. /**
  55993. * Checks to see if a texture is used in the material.
  55994. * @param defines the list of "defines" to update.
  55995. * @param mesh the mesh we are preparing the defines for.
  55996. * @param scene defines the scene the material belongs to.
  55997. */
  55998. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  55999. /**
  56000. * Binds the material data.
  56001. * @param uniformBuffer defines the Uniform buffer to fill in.
  56002. * @param scene defines the scene the material belongs to.
  56003. * @param isFrozen defines wether the material is frozen or not.
  56004. */
  56005. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  56006. /**
  56007. * Checks to see if a texture is used in the material.
  56008. * @param texture - Base texture to use.
  56009. * @returns - Boolean specifying if a texture is used in the material.
  56010. */
  56011. hasTexture(texture: BaseTexture): boolean;
  56012. /**
  56013. * Returns an array of the actively used textures.
  56014. * @param activeTextures Array of BaseTextures
  56015. */
  56016. getActiveTextures(activeTextures: BaseTexture[]): void;
  56017. /**
  56018. * Returns the animatable textures.
  56019. * @param animatables Array of animatable textures.
  56020. */
  56021. getAnimatables(animatables: IAnimatable[]): void;
  56022. /**
  56023. * Disposes the resources of the material.
  56024. * @param forceDisposeTextures - Forces the disposal of all textures.
  56025. */
  56026. dispose(forceDisposeTextures?: boolean): void;
  56027. /**
  56028. * Get the current class name of the texture useful for serialization or dynamic coding.
  56029. * @returns "PBRAnisotropicConfiguration"
  56030. */
  56031. getClassName(): string;
  56032. /**
  56033. * Add fallbacks to the effect fallbacks list.
  56034. * @param defines defines the Base texture to use.
  56035. * @param fallbacks defines the current fallback list.
  56036. * @param currentRank defines the current fallback rank.
  56037. * @returns the new fallback rank.
  56038. */
  56039. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  56040. /**
  56041. * Add the required uniforms to the current list.
  56042. * @param uniforms defines the current uniform list.
  56043. */
  56044. static AddUniforms(uniforms: string[]): void;
  56045. /**
  56046. * Add the required uniforms to the current buffer.
  56047. * @param uniformBuffer defines the current uniform buffer.
  56048. */
  56049. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  56050. /**
  56051. * Add the required samplers to the current list.
  56052. * @param samplers defines the current sampler list.
  56053. */
  56054. static AddSamplers(samplers: string[]): void;
  56055. /**
  56056. * Makes a duplicate of the current configuration into another one.
  56057. * @param anisotropicConfiguration define the config where to copy the info
  56058. */
  56059. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  56060. /**
  56061. * Serializes this anisotropy configuration.
  56062. * @returns - An object with the serialized config.
  56063. */
  56064. serialize(): any;
  56065. /**
  56066. * Parses a anisotropy Configuration from a serialized object.
  56067. * @param source - Serialized object.
  56068. * @param scene Defines the scene we are parsing for
  56069. * @param rootUrl Defines the rootUrl to load from
  56070. */
  56071. parse(source: any, scene: Scene, rootUrl: string): void;
  56072. }
  56073. }
  56074. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  56075. import { Scene } from "babylonjs/scene";
  56076. /**
  56077. * @hidden
  56078. */
  56079. export interface IMaterialBRDFDefines {
  56080. BRDF_V_HEIGHT_CORRELATED: boolean;
  56081. MS_BRDF_ENERGY_CONSERVATION: boolean;
  56082. SPHERICAL_HARMONICS: boolean;
  56083. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  56084. /** @hidden */
  56085. _areMiscDirty: boolean;
  56086. }
  56087. /**
  56088. * Define the code related to the BRDF parameters of the pbr material.
  56089. */
  56090. export class PBRBRDFConfiguration {
  56091. /**
  56092. * Default value used for the energy conservation.
  56093. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  56094. */
  56095. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  56096. /**
  56097. * Default value used for the Smith Visibility Height Correlated mode.
  56098. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  56099. */
  56100. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  56101. /**
  56102. * Default value used for the IBL diffuse part.
  56103. * This can help switching back to the polynomials mode globally which is a tiny bit
  56104. * less GPU intensive at the drawback of a lower quality.
  56105. */
  56106. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  56107. /**
  56108. * Default value used for activating energy conservation for the specular workflow.
  56109. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  56110. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  56111. */
  56112. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  56113. private _useEnergyConservation;
  56114. /**
  56115. * Defines if the material uses energy conservation.
  56116. */
  56117. useEnergyConservation: boolean;
  56118. private _useSmithVisibilityHeightCorrelated;
  56119. /**
  56120. * LEGACY Mode set to false
  56121. * Defines if the material uses height smith correlated visibility term.
  56122. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  56123. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  56124. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  56125. * Not relying on height correlated will also disable energy conservation.
  56126. */
  56127. useSmithVisibilityHeightCorrelated: boolean;
  56128. private _useSphericalHarmonics;
  56129. /**
  56130. * LEGACY Mode set to false
  56131. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  56132. * diffuse part of the IBL.
  56133. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  56134. * to the ground truth.
  56135. */
  56136. useSphericalHarmonics: boolean;
  56137. private _useSpecularGlossinessInputEnergyConservation;
  56138. /**
  56139. * Defines if the material uses energy conservation, when the specular workflow is active.
  56140. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  56141. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  56142. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  56143. */
  56144. useSpecularGlossinessInputEnergyConservation: boolean;
  56145. /** @hidden */
  56146. private _internalMarkAllSubMeshesAsMiscDirty;
  56147. /** @hidden */
  56148. _markAllSubMeshesAsMiscDirty(): void;
  56149. /**
  56150. * Instantiate a new istance of clear coat configuration.
  56151. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  56152. */
  56153. constructor(markAllSubMeshesAsMiscDirty: () => void);
  56154. /**
  56155. * Checks to see if a texture is used in the material.
  56156. * @param defines the list of "defines" to update.
  56157. */
  56158. prepareDefines(defines: IMaterialBRDFDefines): void;
  56159. /**
  56160. * Get the current class name of the texture useful for serialization or dynamic coding.
  56161. * @returns "PBRClearCoatConfiguration"
  56162. */
  56163. getClassName(): string;
  56164. /**
  56165. * Makes a duplicate of the current configuration into another one.
  56166. * @param brdfConfiguration define the config where to copy the info
  56167. */
  56168. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  56169. /**
  56170. * Serializes this BRDF configuration.
  56171. * @returns - An object with the serialized config.
  56172. */
  56173. serialize(): any;
  56174. /**
  56175. * Parses a anisotropy Configuration from a serialized object.
  56176. * @param source - Serialized object.
  56177. * @param scene Defines the scene we are parsing for
  56178. * @param rootUrl Defines the rootUrl to load from
  56179. */
  56180. parse(source: any, scene: Scene, rootUrl: string): void;
  56181. }
  56182. }
  56183. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  56184. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  56185. import { Color3 } from "babylonjs/Maths/math.color";
  56186. import { Scene } from "babylonjs/scene";
  56187. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56188. import { Nullable } from "babylonjs/types";
  56189. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  56190. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56191. /**
  56192. * @hidden
  56193. */
  56194. export interface IMaterialSheenDefines {
  56195. SHEEN: boolean;
  56196. SHEEN_TEXTURE: boolean;
  56197. SHEEN_TEXTUREDIRECTUV: number;
  56198. SHEEN_LINKWITHALBEDO: boolean;
  56199. SHEEN_ROUGHNESS: boolean;
  56200. SHEEN_ALBEDOSCALING: boolean;
  56201. /** @hidden */
  56202. _areTexturesDirty: boolean;
  56203. }
  56204. /**
  56205. * Define the code related to the Sheen parameters of the pbr material.
  56206. */
  56207. export class PBRSheenConfiguration {
  56208. private _isEnabled;
  56209. /**
  56210. * Defines if the material uses sheen.
  56211. */
  56212. isEnabled: boolean;
  56213. private _linkSheenWithAlbedo;
  56214. /**
  56215. * Defines if the sheen is linked to the sheen color.
  56216. */
  56217. linkSheenWithAlbedo: boolean;
  56218. /**
  56219. * Defines the sheen intensity.
  56220. */
  56221. intensity: number;
  56222. /**
  56223. * Defines the sheen color.
  56224. */
  56225. color: Color3;
  56226. private _texture;
  56227. /**
  56228. * Stores the sheen tint values in a texture.
  56229. * rgb is tint
  56230. * a is a intensity
  56231. */
  56232. texture: Nullable<BaseTexture>;
  56233. private _roughness;
  56234. /**
  56235. * Defines the sheen roughness.
  56236. * It is not taken into account if linkSheenWithAlbedo is true.
  56237. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  56238. */
  56239. roughness: Nullable<number>;
  56240. private _albedoScaling;
  56241. /**
  56242. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  56243. * It allows the strength of the sheen effect to not depend on the base color of the material,
  56244. * making it easier to setup and tweak the effect
  56245. */
  56246. albedoScaling: boolean;
  56247. /** @hidden */
  56248. private _internalMarkAllSubMeshesAsTexturesDirty;
  56249. /** @hidden */
  56250. _markAllSubMeshesAsTexturesDirty(): void;
  56251. /**
  56252. * Instantiate a new istance of clear coat configuration.
  56253. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  56254. */
  56255. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  56256. /**
  56257. * Specifies that the submesh is ready to be used.
  56258. * @param defines the list of "defines" to update.
  56259. * @param scene defines the scene the material belongs to.
  56260. * @returns - boolean indicating that the submesh is ready or not.
  56261. */
  56262. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  56263. /**
  56264. * Checks to see if a texture is used in the material.
  56265. * @param defines the list of "defines" to update.
  56266. * @param scene defines the scene the material belongs to.
  56267. */
  56268. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  56269. /**
  56270. * Binds the material data.
  56271. * @param uniformBuffer defines the Uniform buffer to fill in.
  56272. * @param scene defines the scene the material belongs to.
  56273. * @param isFrozen defines wether the material is frozen or not.
  56274. */
  56275. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  56276. /**
  56277. * Checks to see if a texture is used in the material.
  56278. * @param texture - Base texture to use.
  56279. * @returns - Boolean specifying if a texture is used in the material.
  56280. */
  56281. hasTexture(texture: BaseTexture): boolean;
  56282. /**
  56283. * Returns an array of the actively used textures.
  56284. * @param activeTextures Array of BaseTextures
  56285. */
  56286. getActiveTextures(activeTextures: BaseTexture[]): void;
  56287. /**
  56288. * Returns the animatable textures.
  56289. * @param animatables Array of animatable textures.
  56290. */
  56291. getAnimatables(animatables: IAnimatable[]): void;
  56292. /**
  56293. * Disposes the resources of the material.
  56294. * @param forceDisposeTextures - Forces the disposal of all textures.
  56295. */
  56296. dispose(forceDisposeTextures?: boolean): void;
  56297. /**
  56298. * Get the current class name of the texture useful for serialization or dynamic coding.
  56299. * @returns "PBRSheenConfiguration"
  56300. */
  56301. getClassName(): string;
  56302. /**
  56303. * Add fallbacks to the effect fallbacks list.
  56304. * @param defines defines the Base texture to use.
  56305. * @param fallbacks defines the current fallback list.
  56306. * @param currentRank defines the current fallback rank.
  56307. * @returns the new fallback rank.
  56308. */
  56309. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  56310. /**
  56311. * Add the required uniforms to the current list.
  56312. * @param uniforms defines the current uniform list.
  56313. */
  56314. static AddUniforms(uniforms: string[]): void;
  56315. /**
  56316. * Add the required uniforms to the current buffer.
  56317. * @param uniformBuffer defines the current uniform buffer.
  56318. */
  56319. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  56320. /**
  56321. * Add the required samplers to the current list.
  56322. * @param samplers defines the current sampler list.
  56323. */
  56324. static AddSamplers(samplers: string[]): void;
  56325. /**
  56326. * Makes a duplicate of the current configuration into another one.
  56327. * @param sheenConfiguration define the config where to copy the info
  56328. */
  56329. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  56330. /**
  56331. * Serializes this BRDF configuration.
  56332. * @returns - An object with the serialized config.
  56333. */
  56334. serialize(): any;
  56335. /**
  56336. * Parses a anisotropy Configuration from a serialized object.
  56337. * @param source - Serialized object.
  56338. * @param scene Defines the scene we are parsing for
  56339. * @param rootUrl Defines the rootUrl to load from
  56340. */
  56341. parse(source: any, scene: Scene, rootUrl: string): void;
  56342. }
  56343. }
  56344. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  56345. import { Nullable } from "babylonjs/types";
  56346. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  56347. import { Color3 } from "babylonjs/Maths/math.color";
  56348. import { SmartArray } from "babylonjs/Misc/smartArray";
  56349. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56350. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56351. import { Effect } from "babylonjs/Materials/effect";
  56352. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  56353. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56354. import { Engine } from "babylonjs/Engines/engine";
  56355. import { Scene } from "babylonjs/scene";
  56356. /**
  56357. * @hidden
  56358. */
  56359. export interface IMaterialSubSurfaceDefines {
  56360. SUBSURFACE: boolean;
  56361. SS_REFRACTION: boolean;
  56362. SS_TRANSLUCENCY: boolean;
  56363. SS_SCATERRING: boolean;
  56364. SS_THICKNESSANDMASK_TEXTURE: boolean;
  56365. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  56366. SS_REFRACTIONMAP_3D: boolean;
  56367. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  56368. SS_LODINREFRACTIONALPHA: boolean;
  56369. SS_GAMMAREFRACTION: boolean;
  56370. SS_RGBDREFRACTION: boolean;
  56371. SS_LINEARSPECULARREFRACTION: boolean;
  56372. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  56373. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  56374. /** @hidden */
  56375. _areTexturesDirty: boolean;
  56376. }
  56377. /**
  56378. * Define the code related to the sub surface parameters of the pbr material.
  56379. */
  56380. export class PBRSubSurfaceConfiguration {
  56381. private _isRefractionEnabled;
  56382. /**
  56383. * Defines if the refraction is enabled in the material.
  56384. */
  56385. isRefractionEnabled: boolean;
  56386. private _isTranslucencyEnabled;
  56387. /**
  56388. * Defines if the translucency is enabled in the material.
  56389. */
  56390. isTranslucencyEnabled: boolean;
  56391. private _isScatteringEnabled;
  56392. /**
  56393. * Defines the refraction intensity of the material.
  56394. * The refraction when enabled replaces the Diffuse part of the material.
  56395. * The intensity helps transitionning between diffuse and refraction.
  56396. */
  56397. refractionIntensity: number;
  56398. /**
  56399. * Defines the translucency intensity of the material.
  56400. * When translucency has been enabled, this defines how much of the "translucency"
  56401. * is addded to the diffuse part of the material.
  56402. */
  56403. translucencyIntensity: number;
  56404. /**
  56405. * Defines the scattering intensity of the material.
  56406. * When scattering has been enabled, this defines how much of the "scattered light"
  56407. * is addded to the diffuse part of the material.
  56408. */
  56409. scatteringIntensity: number;
  56410. private _thicknessTexture;
  56411. /**
  56412. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  56413. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  56414. * 0 would mean minimumThickness
  56415. * 1 would mean maximumThickness
  56416. * The other channels might be use as a mask to vary the different effects intensity.
  56417. */
  56418. thicknessTexture: Nullable<BaseTexture>;
  56419. private _refractionTexture;
  56420. /**
  56421. * Defines the texture to use for refraction.
  56422. */
  56423. refractionTexture: Nullable<BaseTexture>;
  56424. private _indexOfRefraction;
  56425. /**
  56426. * Index of refraction of the material base layer.
  56427. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  56428. *
  56429. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  56430. *
  56431. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  56432. */
  56433. indexOfRefraction: number;
  56434. private _invertRefractionY;
  56435. /**
  56436. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  56437. */
  56438. invertRefractionY: boolean;
  56439. private _linkRefractionWithTransparency;
  56440. /**
  56441. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  56442. * Materials half opaque for instance using refraction could benefit from this control.
  56443. */
  56444. linkRefractionWithTransparency: boolean;
  56445. /**
  56446. * Defines the minimum thickness stored in the thickness map.
  56447. * If no thickness map is defined, this value will be used to simulate thickness.
  56448. */
  56449. minimumThickness: number;
  56450. /**
  56451. * Defines the maximum thickness stored in the thickness map.
  56452. */
  56453. maximumThickness: number;
  56454. /**
  56455. * Defines the volume tint of the material.
  56456. * This is used for both translucency and scattering.
  56457. */
  56458. tintColor: Color3;
  56459. /**
  56460. * Defines the distance at which the tint color should be found in the media.
  56461. * This is used for refraction only.
  56462. */
  56463. tintColorAtDistance: number;
  56464. /**
  56465. * Defines how far each channel transmit through the media.
  56466. * It is defined as a color to simplify it selection.
  56467. */
  56468. diffusionDistance: Color3;
  56469. private _useMaskFromThicknessTexture;
  56470. /**
  56471. * Stores the intensity of the different subsurface effects in the thickness texture.
  56472. * * the green channel is the translucency intensity.
  56473. * * the blue channel is the scattering intensity.
  56474. * * the alpha channel is the refraction intensity.
  56475. */
  56476. useMaskFromThicknessTexture: boolean;
  56477. /** @hidden */
  56478. private _internalMarkAllSubMeshesAsTexturesDirty;
  56479. /** @hidden */
  56480. _markAllSubMeshesAsTexturesDirty(): void;
  56481. /**
  56482. * Instantiate a new istance of sub surface configuration.
  56483. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  56484. */
  56485. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  56486. /**
  56487. * Gets wehter the submesh is ready to be used or not.
  56488. * @param defines the list of "defines" to update.
  56489. * @param scene defines the scene the material belongs to.
  56490. * @returns - boolean indicating that the submesh is ready or not.
  56491. */
  56492. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  56493. /**
  56494. * Checks to see if a texture is used in the material.
  56495. * @param defines the list of "defines" to update.
  56496. * @param scene defines the scene to the material belongs to.
  56497. */
  56498. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  56499. /**
  56500. * Binds the material data.
  56501. * @param uniformBuffer defines the Uniform buffer to fill in.
  56502. * @param scene defines the scene the material belongs to.
  56503. * @param engine defines the engine the material belongs to.
  56504. * @param isFrozen defines whether the material is frozen or not.
  56505. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  56506. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  56507. */
  56508. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  56509. /**
  56510. * Unbinds the material from the mesh.
  56511. * @param activeEffect defines the effect that should be unbound from.
  56512. * @returns true if unbound, otherwise false
  56513. */
  56514. unbind(activeEffect: Effect): boolean;
  56515. /**
  56516. * Returns the texture used for refraction or null if none is used.
  56517. * @param scene defines the scene the material belongs to.
  56518. * @returns - Refraction texture if present. If no refraction texture and refraction
  56519. * is linked with transparency, returns environment texture. Otherwise, returns null.
  56520. */
  56521. private _getRefractionTexture;
  56522. /**
  56523. * Returns true if alpha blending should be disabled.
  56524. */
  56525. get disableAlphaBlending(): boolean;
  56526. /**
  56527. * Fills the list of render target textures.
  56528. * @param renderTargets the list of render targets to update
  56529. */
  56530. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  56531. /**
  56532. * Checks to see if a texture is used in the material.
  56533. * @param texture - Base texture to use.
  56534. * @returns - Boolean specifying if a texture is used in the material.
  56535. */
  56536. hasTexture(texture: BaseTexture): boolean;
  56537. /**
  56538. * Gets a boolean indicating that current material needs to register RTT
  56539. * @returns true if this uses a render target otherwise false.
  56540. */
  56541. hasRenderTargetTextures(): boolean;
  56542. /**
  56543. * Returns an array of the actively used textures.
  56544. * @param activeTextures Array of BaseTextures
  56545. */
  56546. getActiveTextures(activeTextures: BaseTexture[]): void;
  56547. /**
  56548. * Returns the animatable textures.
  56549. * @param animatables Array of animatable textures.
  56550. */
  56551. getAnimatables(animatables: IAnimatable[]): void;
  56552. /**
  56553. * Disposes the resources of the material.
  56554. * @param forceDisposeTextures - Forces the disposal of all textures.
  56555. */
  56556. dispose(forceDisposeTextures?: boolean): void;
  56557. /**
  56558. * Get the current class name of the texture useful for serialization or dynamic coding.
  56559. * @returns "PBRSubSurfaceConfiguration"
  56560. */
  56561. getClassName(): string;
  56562. /**
  56563. * Add fallbacks to the effect fallbacks list.
  56564. * @param defines defines the Base texture to use.
  56565. * @param fallbacks defines the current fallback list.
  56566. * @param currentRank defines the current fallback rank.
  56567. * @returns the new fallback rank.
  56568. */
  56569. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  56570. /**
  56571. * Add the required uniforms to the current list.
  56572. * @param uniforms defines the current uniform list.
  56573. */
  56574. static AddUniforms(uniforms: string[]): void;
  56575. /**
  56576. * Add the required samplers to the current list.
  56577. * @param samplers defines the current sampler list.
  56578. */
  56579. static AddSamplers(samplers: string[]): void;
  56580. /**
  56581. * Add the required uniforms to the current buffer.
  56582. * @param uniformBuffer defines the current uniform buffer.
  56583. */
  56584. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  56585. /**
  56586. * Makes a duplicate of the current configuration into another one.
  56587. * @param configuration define the config where to copy the info
  56588. */
  56589. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  56590. /**
  56591. * Serializes this Sub Surface configuration.
  56592. * @returns - An object with the serialized config.
  56593. */
  56594. serialize(): any;
  56595. /**
  56596. * Parses a anisotropy Configuration from a serialized object.
  56597. * @param source - Serialized object.
  56598. * @param scene Defines the scene we are parsing for
  56599. * @param rootUrl Defines the rootUrl to load from
  56600. */
  56601. parse(source: any, scene: Scene, rootUrl: string): void;
  56602. }
  56603. }
  56604. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  56605. /** @hidden */
  56606. export var pbrFragmentDeclaration: {
  56607. name: string;
  56608. shader: string;
  56609. };
  56610. }
  56611. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  56612. /** @hidden */
  56613. export var pbrUboDeclaration: {
  56614. name: string;
  56615. shader: string;
  56616. };
  56617. }
  56618. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  56619. /** @hidden */
  56620. export var pbrFragmentExtraDeclaration: {
  56621. name: string;
  56622. shader: string;
  56623. };
  56624. }
  56625. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  56626. /** @hidden */
  56627. export var pbrFragmentSamplersDeclaration: {
  56628. name: string;
  56629. shader: string;
  56630. };
  56631. }
  56632. declare module "babylonjs/Shaders/ShadersInclude/importanceSampling" {
  56633. /** @hidden */
  56634. export var importanceSampling: {
  56635. name: string;
  56636. shader: string;
  56637. };
  56638. }
  56639. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  56640. /** @hidden */
  56641. export var pbrHelperFunctions: {
  56642. name: string;
  56643. shader: string;
  56644. };
  56645. }
  56646. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  56647. /** @hidden */
  56648. export var harmonicsFunctions: {
  56649. name: string;
  56650. shader: string;
  56651. };
  56652. }
  56653. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  56654. /** @hidden */
  56655. export var pbrDirectLightingSetupFunctions: {
  56656. name: string;
  56657. shader: string;
  56658. };
  56659. }
  56660. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  56661. /** @hidden */
  56662. export var pbrDirectLightingFalloffFunctions: {
  56663. name: string;
  56664. shader: string;
  56665. };
  56666. }
  56667. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  56668. /** @hidden */
  56669. export var pbrBRDFFunctions: {
  56670. name: string;
  56671. shader: string;
  56672. };
  56673. }
  56674. declare module "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions" {
  56675. /** @hidden */
  56676. export var hdrFilteringFunctions: {
  56677. name: string;
  56678. shader: string;
  56679. };
  56680. }
  56681. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  56682. /** @hidden */
  56683. export var pbrDirectLightingFunctions: {
  56684. name: string;
  56685. shader: string;
  56686. };
  56687. }
  56688. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  56689. /** @hidden */
  56690. export var pbrIBLFunctions: {
  56691. name: string;
  56692. shader: string;
  56693. };
  56694. }
  56695. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity" {
  56696. /** @hidden */
  56697. export var pbrBlockAlbedoOpacity: {
  56698. name: string;
  56699. shader: string;
  56700. };
  56701. }
  56702. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity" {
  56703. /** @hidden */
  56704. export var pbrBlockReflectivity: {
  56705. name: string;
  56706. shader: string;
  56707. };
  56708. }
  56709. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion" {
  56710. /** @hidden */
  56711. export var pbrBlockAmbientOcclusion: {
  56712. name: string;
  56713. shader: string;
  56714. };
  56715. }
  56716. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel" {
  56717. /** @hidden */
  56718. export var pbrBlockAlphaFresnel: {
  56719. name: string;
  56720. shader: string;
  56721. };
  56722. }
  56723. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic" {
  56724. /** @hidden */
  56725. export var pbrBlockAnisotropic: {
  56726. name: string;
  56727. shader: string;
  56728. };
  56729. }
  56730. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflection" {
  56731. /** @hidden */
  56732. export var pbrBlockReflection: {
  56733. name: string;
  56734. shader: string;
  56735. };
  56736. }
  56737. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSheen" {
  56738. /** @hidden */
  56739. export var pbrBlockSheen: {
  56740. name: string;
  56741. shader: string;
  56742. };
  56743. }
  56744. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat" {
  56745. /** @hidden */
  56746. export var pbrBlockClearcoat: {
  56747. name: string;
  56748. shader: string;
  56749. };
  56750. }
  56751. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface" {
  56752. /** @hidden */
  56753. export var pbrBlockSubSurface: {
  56754. name: string;
  56755. shader: string;
  56756. };
  56757. }
  56758. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric" {
  56759. /** @hidden */
  56760. export var pbrBlockNormalGeometric: {
  56761. name: string;
  56762. shader: string;
  56763. };
  56764. }
  56765. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal" {
  56766. /** @hidden */
  56767. export var pbrBlockNormalFinal: {
  56768. name: string;
  56769. shader: string;
  56770. };
  56771. }
  56772. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo" {
  56773. /** @hidden */
  56774. export var pbrBlockGeometryInfo: {
  56775. name: string;
  56776. shader: string;
  56777. };
  56778. }
  56779. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0" {
  56780. /** @hidden */
  56781. export var pbrBlockReflectance0: {
  56782. name: string;
  56783. shader: string;
  56784. };
  56785. }
  56786. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance" {
  56787. /** @hidden */
  56788. export var pbrBlockReflectance: {
  56789. name: string;
  56790. shader: string;
  56791. };
  56792. }
  56793. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting" {
  56794. /** @hidden */
  56795. export var pbrBlockDirectLighting: {
  56796. name: string;
  56797. shader: string;
  56798. };
  56799. }
  56800. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents" {
  56801. /** @hidden */
  56802. export var pbrBlockFinalLitComponents: {
  56803. name: string;
  56804. shader: string;
  56805. };
  56806. }
  56807. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents" {
  56808. /** @hidden */
  56809. export var pbrBlockFinalUnlitComponents: {
  56810. name: string;
  56811. shader: string;
  56812. };
  56813. }
  56814. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition" {
  56815. /** @hidden */
  56816. export var pbrBlockFinalColorComposition: {
  56817. name: string;
  56818. shader: string;
  56819. };
  56820. }
  56821. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing" {
  56822. /** @hidden */
  56823. export var pbrBlockImageProcessing: {
  56824. name: string;
  56825. shader: string;
  56826. };
  56827. }
  56828. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  56829. /** @hidden */
  56830. export var pbrDebug: {
  56831. name: string;
  56832. shader: string;
  56833. };
  56834. }
  56835. declare module "babylonjs/Shaders/pbr.fragment" {
  56836. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  56837. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  56838. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  56839. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  56840. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  56841. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  56842. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  56843. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  56844. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  56845. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  56846. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56847. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  56848. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  56849. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  56850. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  56851. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  56852. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  56853. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  56854. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  56855. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  56856. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  56857. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  56858. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  56859. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  56860. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  56861. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity";
  56862. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity";
  56863. import "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion";
  56864. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel";
  56865. import "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic";
  56866. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflection";
  56867. import "babylonjs/Shaders/ShadersInclude/pbrBlockSheen";
  56868. import "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat";
  56869. import "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface";
  56870. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  56871. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric";
  56872. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  56873. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal";
  56874. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  56875. import "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo";
  56876. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0";
  56877. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance";
  56878. import "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting";
  56879. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  56880. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents";
  56881. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents";
  56882. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition";
  56883. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  56884. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  56885. import "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing";
  56886. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  56887. /** @hidden */
  56888. export var pbrPixelShader: {
  56889. name: string;
  56890. shader: string;
  56891. };
  56892. }
  56893. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  56894. /** @hidden */
  56895. export var pbrVertexDeclaration: {
  56896. name: string;
  56897. shader: string;
  56898. };
  56899. }
  56900. declare module "babylonjs/Shaders/pbr.vertex" {
  56901. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  56902. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  56903. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56904. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56905. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  56906. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  56907. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  56908. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  56909. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  56910. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  56911. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  56912. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  56913. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  56914. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  56915. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  56916. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  56917. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56918. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  56919. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  56920. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  56921. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  56922. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  56923. /** @hidden */
  56924. export var pbrVertexShader: {
  56925. name: string;
  56926. shader: string;
  56927. };
  56928. }
  56929. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  56930. import { Nullable } from "babylonjs/types";
  56931. import { Scene } from "babylonjs/scene";
  56932. import { Matrix } from "babylonjs/Maths/math.vector";
  56933. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56934. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56935. import { Mesh } from "babylonjs/Meshes/mesh";
  56936. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  56937. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  56938. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  56939. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  56940. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  56941. import { Color3 } from "babylonjs/Maths/math.color";
  56942. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  56943. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  56944. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  56945. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  56946. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56947. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  56948. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  56949. import "babylonjs/Shaders/pbr.fragment";
  56950. import "babylonjs/Shaders/pbr.vertex";
  56951. /**
  56952. * Manages the defines for the PBR Material.
  56953. * @hidden
  56954. */
  56955. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  56956. PBR: boolean;
  56957. NUM_SAMPLES: string;
  56958. REALTIME_FILTERING: boolean;
  56959. MAINUV1: boolean;
  56960. MAINUV2: boolean;
  56961. UV1: boolean;
  56962. UV2: boolean;
  56963. ALBEDO: boolean;
  56964. GAMMAALBEDO: boolean;
  56965. ALBEDODIRECTUV: number;
  56966. VERTEXCOLOR: boolean;
  56967. AMBIENT: boolean;
  56968. AMBIENTDIRECTUV: number;
  56969. AMBIENTINGRAYSCALE: boolean;
  56970. OPACITY: boolean;
  56971. VERTEXALPHA: boolean;
  56972. OPACITYDIRECTUV: number;
  56973. OPACITYRGB: boolean;
  56974. ALPHATEST: boolean;
  56975. DEPTHPREPASS: boolean;
  56976. ALPHABLEND: boolean;
  56977. ALPHAFROMALBEDO: boolean;
  56978. ALPHATESTVALUE: string;
  56979. SPECULAROVERALPHA: boolean;
  56980. RADIANCEOVERALPHA: boolean;
  56981. ALPHAFRESNEL: boolean;
  56982. LINEARALPHAFRESNEL: boolean;
  56983. PREMULTIPLYALPHA: boolean;
  56984. EMISSIVE: boolean;
  56985. EMISSIVEDIRECTUV: number;
  56986. REFLECTIVITY: boolean;
  56987. REFLECTIVITYDIRECTUV: number;
  56988. SPECULARTERM: boolean;
  56989. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  56990. MICROSURFACEAUTOMATIC: boolean;
  56991. LODBASEDMICROSFURACE: boolean;
  56992. MICROSURFACEMAP: boolean;
  56993. MICROSURFACEMAPDIRECTUV: number;
  56994. METALLICWORKFLOW: boolean;
  56995. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  56996. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  56997. METALLNESSSTOREINMETALMAPBLUE: boolean;
  56998. AOSTOREINMETALMAPRED: boolean;
  56999. METALLIC_REFLECTANCE: boolean;
  57000. METALLIC_REFLECTANCEDIRECTUV: number;
  57001. ENVIRONMENTBRDF: boolean;
  57002. ENVIRONMENTBRDF_RGBD: boolean;
  57003. NORMAL: boolean;
  57004. TANGENT: boolean;
  57005. BUMP: boolean;
  57006. BUMPDIRECTUV: number;
  57007. OBJECTSPACE_NORMALMAP: boolean;
  57008. PARALLAX: boolean;
  57009. PARALLAXOCCLUSION: boolean;
  57010. NORMALXYSCALE: boolean;
  57011. LIGHTMAP: boolean;
  57012. LIGHTMAPDIRECTUV: number;
  57013. USELIGHTMAPASSHADOWMAP: boolean;
  57014. GAMMALIGHTMAP: boolean;
  57015. RGBDLIGHTMAP: boolean;
  57016. REFLECTION: boolean;
  57017. REFLECTIONMAP_3D: boolean;
  57018. REFLECTIONMAP_SPHERICAL: boolean;
  57019. REFLECTIONMAP_PLANAR: boolean;
  57020. REFLECTIONMAP_CUBIC: boolean;
  57021. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  57022. REFLECTIONMAP_PROJECTION: boolean;
  57023. REFLECTIONMAP_SKYBOX: boolean;
  57024. REFLECTIONMAP_EXPLICIT: boolean;
  57025. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  57026. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  57027. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  57028. INVERTCUBICMAP: boolean;
  57029. USESPHERICALFROMREFLECTIONMAP: boolean;
  57030. USEIRRADIANCEMAP: boolean;
  57031. SPHERICAL_HARMONICS: boolean;
  57032. USESPHERICALINVERTEX: boolean;
  57033. REFLECTIONMAP_OPPOSITEZ: boolean;
  57034. LODINREFLECTIONALPHA: boolean;
  57035. GAMMAREFLECTION: boolean;
  57036. RGBDREFLECTION: boolean;
  57037. LINEARSPECULARREFLECTION: boolean;
  57038. RADIANCEOCCLUSION: boolean;
  57039. HORIZONOCCLUSION: boolean;
  57040. INSTANCES: boolean;
  57041. THIN_INSTANCES: boolean;
  57042. NUM_BONE_INFLUENCERS: number;
  57043. BonesPerMesh: number;
  57044. BONETEXTURE: boolean;
  57045. NONUNIFORMSCALING: boolean;
  57046. MORPHTARGETS: boolean;
  57047. MORPHTARGETS_NORMAL: boolean;
  57048. MORPHTARGETS_TANGENT: boolean;
  57049. MORPHTARGETS_UV: boolean;
  57050. NUM_MORPH_INFLUENCERS: number;
  57051. IMAGEPROCESSING: boolean;
  57052. VIGNETTE: boolean;
  57053. VIGNETTEBLENDMODEMULTIPLY: boolean;
  57054. VIGNETTEBLENDMODEOPAQUE: boolean;
  57055. TONEMAPPING: boolean;
  57056. TONEMAPPING_ACES: boolean;
  57057. CONTRAST: boolean;
  57058. COLORCURVES: boolean;
  57059. COLORGRADING: boolean;
  57060. COLORGRADING3D: boolean;
  57061. SAMPLER3DGREENDEPTH: boolean;
  57062. SAMPLER3DBGRMAP: boolean;
  57063. IMAGEPROCESSINGPOSTPROCESS: boolean;
  57064. EXPOSURE: boolean;
  57065. MULTIVIEW: boolean;
  57066. USEPHYSICALLIGHTFALLOFF: boolean;
  57067. USEGLTFLIGHTFALLOFF: boolean;
  57068. TWOSIDEDLIGHTING: boolean;
  57069. SHADOWFLOAT: boolean;
  57070. CLIPPLANE: boolean;
  57071. CLIPPLANE2: boolean;
  57072. CLIPPLANE3: boolean;
  57073. CLIPPLANE4: boolean;
  57074. CLIPPLANE5: boolean;
  57075. CLIPPLANE6: boolean;
  57076. POINTSIZE: boolean;
  57077. FOG: boolean;
  57078. LOGARITHMICDEPTH: boolean;
  57079. FORCENORMALFORWARD: boolean;
  57080. SPECULARAA: boolean;
  57081. CLEARCOAT: boolean;
  57082. CLEARCOAT_DEFAULTIOR: boolean;
  57083. CLEARCOAT_TEXTURE: boolean;
  57084. CLEARCOAT_TEXTUREDIRECTUV: number;
  57085. CLEARCOAT_BUMP: boolean;
  57086. CLEARCOAT_BUMPDIRECTUV: number;
  57087. CLEARCOAT_TINT: boolean;
  57088. CLEARCOAT_TINT_TEXTURE: boolean;
  57089. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  57090. ANISOTROPIC: boolean;
  57091. ANISOTROPIC_TEXTURE: boolean;
  57092. ANISOTROPIC_TEXTUREDIRECTUV: number;
  57093. BRDF_V_HEIGHT_CORRELATED: boolean;
  57094. MS_BRDF_ENERGY_CONSERVATION: boolean;
  57095. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  57096. SHEEN: boolean;
  57097. SHEEN_TEXTURE: boolean;
  57098. SHEEN_TEXTUREDIRECTUV: number;
  57099. SHEEN_LINKWITHALBEDO: boolean;
  57100. SHEEN_ROUGHNESS: boolean;
  57101. SHEEN_ALBEDOSCALING: boolean;
  57102. SUBSURFACE: boolean;
  57103. SS_REFRACTION: boolean;
  57104. SS_TRANSLUCENCY: boolean;
  57105. SS_SCATERRING: boolean;
  57106. SS_THICKNESSANDMASK_TEXTURE: boolean;
  57107. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  57108. SS_REFRACTIONMAP_3D: boolean;
  57109. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  57110. SS_LODINREFRACTIONALPHA: boolean;
  57111. SS_GAMMAREFRACTION: boolean;
  57112. SS_RGBDREFRACTION: boolean;
  57113. SS_LINEARSPECULARREFRACTION: boolean;
  57114. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  57115. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  57116. UNLIT: boolean;
  57117. DEBUGMODE: number;
  57118. /**
  57119. * Initializes the PBR Material defines.
  57120. */
  57121. constructor();
  57122. /**
  57123. * Resets the PBR Material defines.
  57124. */
  57125. reset(): void;
  57126. }
  57127. /**
  57128. * The Physically based material base class of BJS.
  57129. *
  57130. * This offers the main features of a standard PBR material.
  57131. * For more information, please refer to the documentation :
  57132. * https://doc.babylonjs.com/how_to/physically_based_rendering
  57133. */
  57134. export abstract class PBRBaseMaterial extends PushMaterial {
  57135. /**
  57136. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  57137. */
  57138. static readonly PBRMATERIAL_OPAQUE: number;
  57139. /**
  57140. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  57141. */
  57142. static readonly PBRMATERIAL_ALPHATEST: number;
  57143. /**
  57144. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  57145. */
  57146. static readonly PBRMATERIAL_ALPHABLEND: number;
  57147. /**
  57148. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  57149. * They are also discarded below the alpha cutoff threshold to improve performances.
  57150. */
  57151. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  57152. /**
  57153. * Defines the default value of how much AO map is occluding the analytical lights
  57154. * (point spot...).
  57155. */
  57156. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  57157. /**
  57158. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  57159. */
  57160. static readonly LIGHTFALLOFF_PHYSICAL: number;
  57161. /**
  57162. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  57163. * to enhance interoperability with other engines.
  57164. */
  57165. static readonly LIGHTFALLOFF_GLTF: number;
  57166. /**
  57167. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  57168. * to enhance interoperability with other materials.
  57169. */
  57170. static readonly LIGHTFALLOFF_STANDARD: number;
  57171. /**
  57172. * Intensity of the direct lights e.g. the four lights available in your scene.
  57173. * This impacts both the direct diffuse and specular highlights.
  57174. */
  57175. protected _directIntensity: number;
  57176. /**
  57177. * Intensity of the emissive part of the material.
  57178. * This helps controlling the emissive effect without modifying the emissive color.
  57179. */
  57180. protected _emissiveIntensity: number;
  57181. /**
  57182. * Intensity of the environment e.g. how much the environment will light the object
  57183. * either through harmonics for rough material or through the refelction for shiny ones.
  57184. */
  57185. protected _environmentIntensity: number;
  57186. /**
  57187. * This is a special control allowing the reduction of the specular highlights coming from the
  57188. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  57189. */
  57190. protected _specularIntensity: number;
  57191. /**
  57192. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  57193. */
  57194. private _lightingInfos;
  57195. /**
  57196. * Debug Control allowing disabling the bump map on this material.
  57197. */
  57198. protected _disableBumpMap: boolean;
  57199. /**
  57200. * AKA Diffuse Texture in standard nomenclature.
  57201. */
  57202. protected _albedoTexture: Nullable<BaseTexture>;
  57203. /**
  57204. * AKA Occlusion Texture in other nomenclature.
  57205. */
  57206. protected _ambientTexture: Nullable<BaseTexture>;
  57207. /**
  57208. * AKA Occlusion Texture Intensity in other nomenclature.
  57209. */
  57210. protected _ambientTextureStrength: number;
  57211. /**
  57212. * Defines how much the AO map is occluding the analytical lights (point spot...).
  57213. * 1 means it completely occludes it
  57214. * 0 mean it has no impact
  57215. */
  57216. protected _ambientTextureImpactOnAnalyticalLights: number;
  57217. /**
  57218. * Stores the alpha values in a texture.
  57219. */
  57220. protected _opacityTexture: Nullable<BaseTexture>;
  57221. /**
  57222. * Stores the reflection values in a texture.
  57223. */
  57224. protected _reflectionTexture: Nullable<BaseTexture>;
  57225. /**
  57226. * Stores the emissive values in a texture.
  57227. */
  57228. protected _emissiveTexture: Nullable<BaseTexture>;
  57229. /**
  57230. * AKA Specular texture in other nomenclature.
  57231. */
  57232. protected _reflectivityTexture: Nullable<BaseTexture>;
  57233. /**
  57234. * Used to switch from specular/glossiness to metallic/roughness workflow.
  57235. */
  57236. protected _metallicTexture: Nullable<BaseTexture>;
  57237. /**
  57238. * Specifies the metallic scalar of the metallic/roughness workflow.
  57239. * Can also be used to scale the metalness values of the metallic texture.
  57240. */
  57241. protected _metallic: Nullable<number>;
  57242. /**
  57243. * Specifies the roughness scalar of the metallic/roughness workflow.
  57244. * Can also be used to scale the roughness values of the metallic texture.
  57245. */
  57246. protected _roughness: Nullable<number>;
  57247. /**
  57248. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  57249. * By default the indexOfrefraction is used to compute F0;
  57250. *
  57251. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  57252. *
  57253. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  57254. * F90 = metallicReflectanceColor;
  57255. */
  57256. protected _metallicF0Factor: number;
  57257. /**
  57258. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  57259. * By default the F90 is always 1;
  57260. *
  57261. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  57262. *
  57263. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  57264. * F90 = metallicReflectanceColor;
  57265. */
  57266. protected _metallicReflectanceColor: Color3;
  57267. /**
  57268. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  57269. * This is multiply against the scalar values defined in the material.
  57270. */
  57271. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  57272. /**
  57273. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  57274. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  57275. */
  57276. protected _microSurfaceTexture: Nullable<BaseTexture>;
  57277. /**
  57278. * Stores surface normal data used to displace a mesh in a texture.
  57279. */
  57280. protected _bumpTexture: Nullable<BaseTexture>;
  57281. /**
  57282. * Stores the pre-calculated light information of a mesh in a texture.
  57283. */
  57284. protected _lightmapTexture: Nullable<BaseTexture>;
  57285. /**
  57286. * The color of a material in ambient lighting.
  57287. */
  57288. protected _ambientColor: Color3;
  57289. /**
  57290. * AKA Diffuse Color in other nomenclature.
  57291. */
  57292. protected _albedoColor: Color3;
  57293. /**
  57294. * AKA Specular Color in other nomenclature.
  57295. */
  57296. protected _reflectivityColor: Color3;
  57297. /**
  57298. * The color applied when light is reflected from a material.
  57299. */
  57300. protected _reflectionColor: Color3;
  57301. /**
  57302. * The color applied when light is emitted from a material.
  57303. */
  57304. protected _emissiveColor: Color3;
  57305. /**
  57306. * AKA Glossiness in other nomenclature.
  57307. */
  57308. protected _microSurface: number;
  57309. /**
  57310. * Specifies that the material will use the light map as a show map.
  57311. */
  57312. protected _useLightmapAsShadowmap: boolean;
  57313. /**
  57314. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  57315. * makes the reflect vector face the model (under horizon).
  57316. */
  57317. protected _useHorizonOcclusion: boolean;
  57318. /**
  57319. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  57320. * too much the area relying on ambient texture to define their ambient occlusion.
  57321. */
  57322. protected _useRadianceOcclusion: boolean;
  57323. /**
  57324. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  57325. */
  57326. protected _useAlphaFromAlbedoTexture: boolean;
  57327. /**
  57328. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  57329. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  57330. */
  57331. protected _useSpecularOverAlpha: boolean;
  57332. /**
  57333. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  57334. */
  57335. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  57336. /**
  57337. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  57338. */
  57339. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  57340. /**
  57341. * Specifies if the metallic texture contains the roughness information in its green channel.
  57342. */
  57343. protected _useRoughnessFromMetallicTextureGreen: boolean;
  57344. /**
  57345. * Specifies if the metallic texture contains the metallness information in its blue channel.
  57346. */
  57347. protected _useMetallnessFromMetallicTextureBlue: boolean;
  57348. /**
  57349. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  57350. */
  57351. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  57352. /**
  57353. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  57354. */
  57355. protected _useAmbientInGrayScale: boolean;
  57356. /**
  57357. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  57358. * The material will try to infer what glossiness each pixel should be.
  57359. */
  57360. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  57361. /**
  57362. * Defines the falloff type used in this material.
  57363. * It by default is Physical.
  57364. */
  57365. protected _lightFalloff: number;
  57366. /**
  57367. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  57368. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  57369. */
  57370. protected _useRadianceOverAlpha: boolean;
  57371. /**
  57372. * Allows using an object space normal map (instead of tangent space).
  57373. */
  57374. protected _useObjectSpaceNormalMap: boolean;
  57375. /**
  57376. * Allows using the bump map in parallax mode.
  57377. */
  57378. protected _useParallax: boolean;
  57379. /**
  57380. * Allows using the bump map in parallax occlusion mode.
  57381. */
  57382. protected _useParallaxOcclusion: boolean;
  57383. /**
  57384. * Controls the scale bias of the parallax mode.
  57385. */
  57386. protected _parallaxScaleBias: number;
  57387. /**
  57388. * If sets to true, disables all the lights affecting the material.
  57389. */
  57390. protected _disableLighting: boolean;
  57391. /**
  57392. * Number of Simultaneous lights allowed on the material.
  57393. */
  57394. protected _maxSimultaneousLights: number;
  57395. /**
  57396. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  57397. */
  57398. protected _invertNormalMapX: boolean;
  57399. /**
  57400. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  57401. */
  57402. protected _invertNormalMapY: boolean;
  57403. /**
  57404. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  57405. */
  57406. protected _twoSidedLighting: boolean;
  57407. /**
  57408. * Defines the alpha limits in alpha test mode.
  57409. */
  57410. protected _alphaCutOff: number;
  57411. /**
  57412. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  57413. */
  57414. protected _forceAlphaTest: boolean;
  57415. /**
  57416. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  57417. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  57418. */
  57419. protected _useAlphaFresnel: boolean;
  57420. /**
  57421. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  57422. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  57423. */
  57424. protected _useLinearAlphaFresnel: boolean;
  57425. /**
  57426. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  57427. * from cos thetav and roughness:
  57428. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  57429. */
  57430. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  57431. /**
  57432. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  57433. */
  57434. protected _forceIrradianceInFragment: boolean;
  57435. private _realTimeFiltering;
  57436. /**
  57437. * Enables realtime filtering on the texture.
  57438. */
  57439. get realTimeFiltering(): boolean;
  57440. set realTimeFiltering(b: boolean);
  57441. private _realTimeFilteringQuality;
  57442. /**
  57443. * Quality switch for realtime filtering
  57444. */
  57445. get realTimeFilteringQuality(): number;
  57446. set realTimeFilteringQuality(n: number);
  57447. /**
  57448. * Force normal to face away from face.
  57449. */
  57450. protected _forceNormalForward: boolean;
  57451. /**
  57452. * Enables specular anti aliasing in the PBR shader.
  57453. * It will both interacts on the Geometry for analytical and IBL lighting.
  57454. * It also prefilter the roughness map based on the bump values.
  57455. */
  57456. protected _enableSpecularAntiAliasing: boolean;
  57457. /**
  57458. * Default configuration related to image processing available in the PBR Material.
  57459. */
  57460. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  57461. /**
  57462. * Keep track of the image processing observer to allow dispose and replace.
  57463. */
  57464. private _imageProcessingObserver;
  57465. /**
  57466. * Attaches a new image processing configuration to the PBR Material.
  57467. * @param configuration
  57468. */
  57469. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  57470. /**
  57471. * Stores the available render targets.
  57472. */
  57473. private _renderTargets;
  57474. /**
  57475. * Sets the global ambient color for the material used in lighting calculations.
  57476. */
  57477. private _globalAmbientColor;
  57478. /**
  57479. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  57480. */
  57481. private _useLogarithmicDepth;
  57482. /**
  57483. * If set to true, no lighting calculations will be applied.
  57484. */
  57485. private _unlit;
  57486. private _debugMode;
  57487. /**
  57488. * @hidden
  57489. * This is reserved for the inspector.
  57490. * Defines the material debug mode.
  57491. * It helps seeing only some components of the material while troubleshooting.
  57492. */
  57493. debugMode: number;
  57494. /**
  57495. * @hidden
  57496. * This is reserved for the inspector.
  57497. * Specify from where on screen the debug mode should start.
  57498. * The value goes from -1 (full screen) to 1 (not visible)
  57499. * It helps with side by side comparison against the final render
  57500. * This defaults to -1
  57501. */
  57502. private debugLimit;
  57503. /**
  57504. * @hidden
  57505. * This is reserved for the inspector.
  57506. * As the default viewing range might not be enough (if the ambient is really small for instance)
  57507. * You can use the factor to better multiply the final value.
  57508. */
  57509. private debugFactor;
  57510. /**
  57511. * Defines the clear coat layer parameters for the material.
  57512. */
  57513. readonly clearCoat: PBRClearCoatConfiguration;
  57514. /**
  57515. * Defines the anisotropic parameters for the material.
  57516. */
  57517. readonly anisotropy: PBRAnisotropicConfiguration;
  57518. /**
  57519. * Defines the BRDF parameters for the material.
  57520. */
  57521. readonly brdf: PBRBRDFConfiguration;
  57522. /**
  57523. * Defines the Sheen parameters for the material.
  57524. */
  57525. readonly sheen: PBRSheenConfiguration;
  57526. /**
  57527. * Defines the SubSurface parameters for the material.
  57528. */
  57529. readonly subSurface: PBRSubSurfaceConfiguration;
  57530. protected _rebuildInParallel: boolean;
  57531. /**
  57532. * Instantiates a new PBRMaterial instance.
  57533. *
  57534. * @param name The material name
  57535. * @param scene The scene the material will be use in.
  57536. */
  57537. constructor(name: string, scene: Scene);
  57538. /**
  57539. * Gets a boolean indicating that current material needs to register RTT
  57540. */
  57541. get hasRenderTargetTextures(): boolean;
  57542. /**
  57543. * Gets the name of the material class.
  57544. */
  57545. getClassName(): string;
  57546. /**
  57547. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  57548. */
  57549. get useLogarithmicDepth(): boolean;
  57550. /**
  57551. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  57552. */
  57553. set useLogarithmicDepth(value: boolean);
  57554. /**
  57555. * Returns true if alpha blending should be disabled.
  57556. */
  57557. protected get _disableAlphaBlending(): boolean;
  57558. /**
  57559. * Specifies whether or not this material should be rendered in alpha blend mode.
  57560. */
  57561. needAlphaBlending(): boolean;
  57562. /**
  57563. * Specifies whether or not this material should be rendered in alpha test mode.
  57564. */
  57565. needAlphaTesting(): boolean;
  57566. /**
  57567. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  57568. */
  57569. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  57570. /**
  57571. * Gets the texture used for the alpha test.
  57572. */
  57573. getAlphaTestTexture(): Nullable<BaseTexture>;
  57574. /**
  57575. * Specifies that the submesh is ready to be used.
  57576. * @param mesh - BJS mesh.
  57577. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  57578. * @param useInstances - Specifies that instances should be used.
  57579. * @returns - boolean indicating that the submesh is ready or not.
  57580. */
  57581. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  57582. /**
  57583. * Specifies if the material uses metallic roughness workflow.
  57584. * @returns boolean specifiying if the material uses metallic roughness workflow.
  57585. */
  57586. isMetallicWorkflow(): boolean;
  57587. private _prepareEffect;
  57588. private _prepareDefines;
  57589. /**
  57590. * Force shader compilation
  57591. */
  57592. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  57593. /**
  57594. * Initializes the uniform buffer layout for the shader.
  57595. */
  57596. buildUniformLayout(): void;
  57597. /**
  57598. * Unbinds the material from the mesh
  57599. */
  57600. unbind(): void;
  57601. /**
  57602. * Binds the submesh data.
  57603. * @param world - The world matrix.
  57604. * @param mesh - The BJS mesh.
  57605. * @param subMesh - A submesh of the BJS mesh.
  57606. */
  57607. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  57608. /**
  57609. * Returns the animatable textures.
  57610. * @returns - Array of animatable textures.
  57611. */
  57612. getAnimatables(): IAnimatable[];
  57613. /**
  57614. * Returns the texture used for reflections.
  57615. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  57616. */
  57617. private _getReflectionTexture;
  57618. /**
  57619. * Returns an array of the actively used textures.
  57620. * @returns - Array of BaseTextures
  57621. */
  57622. getActiveTextures(): BaseTexture[];
  57623. /**
  57624. * Checks to see if a texture is used in the material.
  57625. * @param texture - Base texture to use.
  57626. * @returns - Boolean specifying if a texture is used in the material.
  57627. */
  57628. hasTexture(texture: BaseTexture): boolean;
  57629. /**
  57630. * Disposes the resources of the material.
  57631. * @param forceDisposeEffect - Forces the disposal of effects.
  57632. * @param forceDisposeTextures - Forces the disposal of all textures.
  57633. */
  57634. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  57635. }
  57636. }
  57637. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  57638. import { Nullable } from "babylonjs/types";
  57639. import { Scene } from "babylonjs/scene";
  57640. import { Color3 } from "babylonjs/Maths/math.color";
  57641. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  57642. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  57643. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57644. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  57645. /**
  57646. * The Physically based material of BJS.
  57647. *
  57648. * This offers the main features of a standard PBR material.
  57649. * For more information, please refer to the documentation :
  57650. * https://doc.babylonjs.com/how_to/physically_based_rendering
  57651. */
  57652. export class PBRMaterial extends PBRBaseMaterial {
  57653. /**
  57654. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  57655. */
  57656. static readonly PBRMATERIAL_OPAQUE: number;
  57657. /**
  57658. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  57659. */
  57660. static readonly PBRMATERIAL_ALPHATEST: number;
  57661. /**
  57662. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  57663. */
  57664. static readonly PBRMATERIAL_ALPHABLEND: number;
  57665. /**
  57666. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  57667. * They are also discarded below the alpha cutoff threshold to improve performances.
  57668. */
  57669. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  57670. /**
  57671. * Defines the default value of how much AO map is occluding the analytical lights
  57672. * (point spot...).
  57673. */
  57674. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  57675. /**
  57676. * Intensity of the direct lights e.g. the four lights available in your scene.
  57677. * This impacts both the direct diffuse and specular highlights.
  57678. */
  57679. directIntensity: number;
  57680. /**
  57681. * Intensity of the emissive part of the material.
  57682. * This helps controlling the emissive effect without modifying the emissive color.
  57683. */
  57684. emissiveIntensity: number;
  57685. /**
  57686. * Intensity of the environment e.g. how much the environment will light the object
  57687. * either through harmonics for rough material or through the refelction for shiny ones.
  57688. */
  57689. environmentIntensity: number;
  57690. /**
  57691. * This is a special control allowing the reduction of the specular highlights coming from the
  57692. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  57693. */
  57694. specularIntensity: number;
  57695. /**
  57696. * Debug Control allowing disabling the bump map on this material.
  57697. */
  57698. disableBumpMap: boolean;
  57699. /**
  57700. * AKA Diffuse Texture in standard nomenclature.
  57701. */
  57702. albedoTexture: BaseTexture;
  57703. /**
  57704. * AKA Occlusion Texture in other nomenclature.
  57705. */
  57706. ambientTexture: BaseTexture;
  57707. /**
  57708. * AKA Occlusion Texture Intensity in other nomenclature.
  57709. */
  57710. ambientTextureStrength: number;
  57711. /**
  57712. * Defines how much the AO map is occluding the analytical lights (point spot...).
  57713. * 1 means it completely occludes it
  57714. * 0 mean it has no impact
  57715. */
  57716. ambientTextureImpactOnAnalyticalLights: number;
  57717. /**
  57718. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  57719. */
  57720. opacityTexture: BaseTexture;
  57721. /**
  57722. * Stores the reflection values in a texture.
  57723. */
  57724. reflectionTexture: Nullable<BaseTexture>;
  57725. /**
  57726. * Stores the emissive values in a texture.
  57727. */
  57728. emissiveTexture: BaseTexture;
  57729. /**
  57730. * AKA Specular texture in other nomenclature.
  57731. */
  57732. reflectivityTexture: BaseTexture;
  57733. /**
  57734. * Used to switch from specular/glossiness to metallic/roughness workflow.
  57735. */
  57736. metallicTexture: BaseTexture;
  57737. /**
  57738. * Specifies the metallic scalar of the metallic/roughness workflow.
  57739. * Can also be used to scale the metalness values of the metallic texture.
  57740. */
  57741. metallic: Nullable<number>;
  57742. /**
  57743. * Specifies the roughness scalar of the metallic/roughness workflow.
  57744. * Can also be used to scale the roughness values of the metallic texture.
  57745. */
  57746. roughness: Nullable<number>;
  57747. /**
  57748. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  57749. * By default the indexOfrefraction is used to compute F0;
  57750. *
  57751. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  57752. *
  57753. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  57754. * F90 = metallicReflectanceColor;
  57755. */
  57756. metallicF0Factor: number;
  57757. /**
  57758. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  57759. * By default the F90 is always 1;
  57760. *
  57761. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  57762. *
  57763. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  57764. * F90 = metallicReflectanceColor;
  57765. */
  57766. metallicReflectanceColor: Color3;
  57767. /**
  57768. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  57769. * This is multiply against the scalar values defined in the material.
  57770. */
  57771. metallicReflectanceTexture: Nullable<BaseTexture>;
  57772. /**
  57773. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  57774. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  57775. */
  57776. microSurfaceTexture: BaseTexture;
  57777. /**
  57778. * Stores surface normal data used to displace a mesh in a texture.
  57779. */
  57780. bumpTexture: BaseTexture;
  57781. /**
  57782. * Stores the pre-calculated light information of a mesh in a texture.
  57783. */
  57784. lightmapTexture: BaseTexture;
  57785. /**
  57786. * Stores the refracted light information in a texture.
  57787. */
  57788. get refractionTexture(): Nullable<BaseTexture>;
  57789. set refractionTexture(value: Nullable<BaseTexture>);
  57790. /**
  57791. * The color of a material in ambient lighting.
  57792. */
  57793. ambientColor: Color3;
  57794. /**
  57795. * AKA Diffuse Color in other nomenclature.
  57796. */
  57797. albedoColor: Color3;
  57798. /**
  57799. * AKA Specular Color in other nomenclature.
  57800. */
  57801. reflectivityColor: Color3;
  57802. /**
  57803. * The color reflected from the material.
  57804. */
  57805. reflectionColor: Color3;
  57806. /**
  57807. * The color emitted from the material.
  57808. */
  57809. emissiveColor: Color3;
  57810. /**
  57811. * AKA Glossiness in other nomenclature.
  57812. */
  57813. microSurface: number;
  57814. /**
  57815. * Index of refraction of the material base layer.
  57816. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  57817. *
  57818. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  57819. *
  57820. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  57821. */
  57822. get indexOfRefraction(): number;
  57823. set indexOfRefraction(value: number);
  57824. /**
  57825. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  57826. */
  57827. get invertRefractionY(): boolean;
  57828. set invertRefractionY(value: boolean);
  57829. /**
  57830. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  57831. * Materials half opaque for instance using refraction could benefit from this control.
  57832. */
  57833. get linkRefractionWithTransparency(): boolean;
  57834. set linkRefractionWithTransparency(value: boolean);
  57835. /**
  57836. * If true, the light map contains occlusion information instead of lighting info.
  57837. */
  57838. useLightmapAsShadowmap: boolean;
  57839. /**
  57840. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  57841. */
  57842. useAlphaFromAlbedoTexture: boolean;
  57843. /**
  57844. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  57845. */
  57846. forceAlphaTest: boolean;
  57847. /**
  57848. * Defines the alpha limits in alpha test mode.
  57849. */
  57850. alphaCutOff: number;
  57851. /**
  57852. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  57853. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  57854. */
  57855. useSpecularOverAlpha: boolean;
  57856. /**
  57857. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  57858. */
  57859. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  57860. /**
  57861. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  57862. */
  57863. useRoughnessFromMetallicTextureAlpha: boolean;
  57864. /**
  57865. * Specifies if the metallic texture contains the roughness information in its green channel.
  57866. */
  57867. useRoughnessFromMetallicTextureGreen: boolean;
  57868. /**
  57869. * Specifies if the metallic texture contains the metallness information in its blue channel.
  57870. */
  57871. useMetallnessFromMetallicTextureBlue: boolean;
  57872. /**
  57873. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  57874. */
  57875. useAmbientOcclusionFromMetallicTextureRed: boolean;
  57876. /**
  57877. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  57878. */
  57879. useAmbientInGrayScale: boolean;
  57880. /**
  57881. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  57882. * The material will try to infer what glossiness each pixel should be.
  57883. */
  57884. useAutoMicroSurfaceFromReflectivityMap: boolean;
  57885. /**
  57886. * BJS is using an harcoded light falloff based on a manually sets up range.
  57887. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  57888. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  57889. */
  57890. get usePhysicalLightFalloff(): boolean;
  57891. /**
  57892. * BJS is using an harcoded light falloff based on a manually sets up range.
  57893. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  57894. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  57895. */
  57896. set usePhysicalLightFalloff(value: boolean);
  57897. /**
  57898. * In order to support the falloff compatibility with gltf, a special mode has been added
  57899. * to reproduce the gltf light falloff.
  57900. */
  57901. get useGLTFLightFalloff(): boolean;
  57902. /**
  57903. * In order to support the falloff compatibility with gltf, a special mode has been added
  57904. * to reproduce the gltf light falloff.
  57905. */
  57906. set useGLTFLightFalloff(value: boolean);
  57907. /**
  57908. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  57909. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  57910. */
  57911. useRadianceOverAlpha: boolean;
  57912. /**
  57913. * Allows using an object space normal map (instead of tangent space).
  57914. */
  57915. useObjectSpaceNormalMap: boolean;
  57916. /**
  57917. * Allows using the bump map in parallax mode.
  57918. */
  57919. useParallax: boolean;
  57920. /**
  57921. * Allows using the bump map in parallax occlusion mode.
  57922. */
  57923. useParallaxOcclusion: boolean;
  57924. /**
  57925. * Controls the scale bias of the parallax mode.
  57926. */
  57927. parallaxScaleBias: number;
  57928. /**
  57929. * If sets to true, disables all the lights affecting the material.
  57930. */
  57931. disableLighting: boolean;
  57932. /**
  57933. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  57934. */
  57935. forceIrradianceInFragment: boolean;
  57936. /**
  57937. * Number of Simultaneous lights allowed on the material.
  57938. */
  57939. maxSimultaneousLights: number;
  57940. /**
  57941. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  57942. */
  57943. invertNormalMapX: boolean;
  57944. /**
  57945. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  57946. */
  57947. invertNormalMapY: boolean;
  57948. /**
  57949. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  57950. */
  57951. twoSidedLighting: boolean;
  57952. /**
  57953. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  57954. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  57955. */
  57956. useAlphaFresnel: boolean;
  57957. /**
  57958. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  57959. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  57960. */
  57961. useLinearAlphaFresnel: boolean;
  57962. /**
  57963. * Let user defines the brdf lookup texture used for IBL.
  57964. * A default 8bit version is embedded but you could point at :
  57965. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  57966. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  57967. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  57968. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  57969. */
  57970. environmentBRDFTexture: Nullable<BaseTexture>;
  57971. /**
  57972. * Force normal to face away from face.
  57973. */
  57974. forceNormalForward: boolean;
  57975. /**
  57976. * Enables specular anti aliasing in the PBR shader.
  57977. * It will both interacts on the Geometry for analytical and IBL lighting.
  57978. * It also prefilter the roughness map based on the bump values.
  57979. */
  57980. enableSpecularAntiAliasing: boolean;
  57981. /**
  57982. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  57983. * makes the reflect vector face the model (under horizon).
  57984. */
  57985. useHorizonOcclusion: boolean;
  57986. /**
  57987. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  57988. * too much the area relying on ambient texture to define their ambient occlusion.
  57989. */
  57990. useRadianceOcclusion: boolean;
  57991. /**
  57992. * If set to true, no lighting calculations will be applied.
  57993. */
  57994. unlit: boolean;
  57995. /**
  57996. * Gets the image processing configuration used either in this material.
  57997. */
  57998. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  57999. /**
  58000. * Sets the Default image processing configuration used either in the this material.
  58001. *
  58002. * If sets to null, the scene one is in use.
  58003. */
  58004. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  58005. /**
  58006. * Gets wether the color curves effect is enabled.
  58007. */
  58008. get cameraColorCurvesEnabled(): boolean;
  58009. /**
  58010. * Sets wether the color curves effect is enabled.
  58011. */
  58012. set cameraColorCurvesEnabled(value: boolean);
  58013. /**
  58014. * Gets wether the color grading effect is enabled.
  58015. */
  58016. get cameraColorGradingEnabled(): boolean;
  58017. /**
  58018. * Gets wether the color grading effect is enabled.
  58019. */
  58020. set cameraColorGradingEnabled(value: boolean);
  58021. /**
  58022. * Gets wether tonemapping is enabled or not.
  58023. */
  58024. get cameraToneMappingEnabled(): boolean;
  58025. /**
  58026. * Sets wether tonemapping is enabled or not
  58027. */
  58028. set cameraToneMappingEnabled(value: boolean);
  58029. /**
  58030. * The camera exposure used on this material.
  58031. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  58032. * This corresponds to a photographic exposure.
  58033. */
  58034. get cameraExposure(): number;
  58035. /**
  58036. * The camera exposure used on this material.
  58037. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  58038. * This corresponds to a photographic exposure.
  58039. */
  58040. set cameraExposure(value: number);
  58041. /**
  58042. * Gets The camera contrast used on this material.
  58043. */
  58044. get cameraContrast(): number;
  58045. /**
  58046. * Sets The camera contrast used on this material.
  58047. */
  58048. set cameraContrast(value: number);
  58049. /**
  58050. * Gets the Color Grading 2D Lookup Texture.
  58051. */
  58052. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  58053. /**
  58054. * Sets the Color Grading 2D Lookup Texture.
  58055. */
  58056. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  58057. /**
  58058. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  58059. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  58060. * 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;
  58061. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  58062. */
  58063. get cameraColorCurves(): Nullable<ColorCurves>;
  58064. /**
  58065. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  58066. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  58067. * 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;
  58068. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  58069. */
  58070. set cameraColorCurves(value: Nullable<ColorCurves>);
  58071. /**
  58072. * Instantiates a new PBRMaterial instance.
  58073. *
  58074. * @param name The material name
  58075. * @param scene The scene the material will be use in.
  58076. */
  58077. constructor(name: string, scene: Scene);
  58078. /**
  58079. * Returns the name of this material class.
  58080. */
  58081. getClassName(): string;
  58082. /**
  58083. * Makes a duplicate of the current material.
  58084. * @param name - name to use for the new material.
  58085. */
  58086. clone(name: string): PBRMaterial;
  58087. /**
  58088. * Serializes this PBR Material.
  58089. * @returns - An object with the serialized material.
  58090. */
  58091. serialize(): any;
  58092. /**
  58093. * Parses a PBR Material from a serialized object.
  58094. * @param source - Serialized object.
  58095. * @param scene - BJS scene instance.
  58096. * @param rootUrl - url for the scene object
  58097. * @returns - PBRMaterial
  58098. */
  58099. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  58100. }
  58101. }
  58102. declare module "babylonjs/Misc/dds" {
  58103. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  58104. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58105. import { Nullable } from "babylonjs/types";
  58106. import { Scene } from "babylonjs/scene";
  58107. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  58108. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  58109. /**
  58110. * Direct draw surface info
  58111. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  58112. */
  58113. export interface DDSInfo {
  58114. /**
  58115. * Width of the texture
  58116. */
  58117. width: number;
  58118. /**
  58119. * Width of the texture
  58120. */
  58121. height: number;
  58122. /**
  58123. * Number of Mipmaps for the texture
  58124. * @see https://en.wikipedia.org/wiki/Mipmap
  58125. */
  58126. mipmapCount: number;
  58127. /**
  58128. * If the textures format is a known fourCC format
  58129. * @see https://www.fourcc.org/
  58130. */
  58131. isFourCC: boolean;
  58132. /**
  58133. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  58134. */
  58135. isRGB: boolean;
  58136. /**
  58137. * If the texture is a lumincance format
  58138. */
  58139. isLuminance: boolean;
  58140. /**
  58141. * If this is a cube texture
  58142. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  58143. */
  58144. isCube: boolean;
  58145. /**
  58146. * If the texture is a compressed format eg. FOURCC_DXT1
  58147. */
  58148. isCompressed: boolean;
  58149. /**
  58150. * The dxgiFormat of the texture
  58151. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  58152. */
  58153. dxgiFormat: number;
  58154. /**
  58155. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  58156. */
  58157. textureType: number;
  58158. /**
  58159. * Sphericle polynomial created for the dds texture
  58160. */
  58161. sphericalPolynomial?: SphericalPolynomial;
  58162. }
  58163. /**
  58164. * Class used to provide DDS decompression tools
  58165. */
  58166. export class DDSTools {
  58167. /**
  58168. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  58169. */
  58170. static StoreLODInAlphaChannel: boolean;
  58171. /**
  58172. * Gets DDS information from an array buffer
  58173. * @param data defines the array buffer view to read data from
  58174. * @returns the DDS information
  58175. */
  58176. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  58177. private static _FloatView;
  58178. private static _Int32View;
  58179. private static _ToHalfFloat;
  58180. private static _FromHalfFloat;
  58181. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  58182. private static _GetHalfFloatRGBAArrayBuffer;
  58183. private static _GetFloatRGBAArrayBuffer;
  58184. private static _GetFloatAsUIntRGBAArrayBuffer;
  58185. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  58186. private static _GetRGBAArrayBuffer;
  58187. private static _ExtractLongWordOrder;
  58188. private static _GetRGBArrayBuffer;
  58189. private static _GetLuminanceArrayBuffer;
  58190. /**
  58191. * Uploads DDS Levels to a Babylon Texture
  58192. * @hidden
  58193. */
  58194. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  58195. }
  58196. module "babylonjs/Engines/thinEngine" {
  58197. interface ThinEngine {
  58198. /**
  58199. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  58200. * @param rootUrl defines the url where the file to load is located
  58201. * @param scene defines the current scene
  58202. * @param lodScale defines scale to apply to the mip map selection
  58203. * @param lodOffset defines offset to apply to the mip map selection
  58204. * @param onLoad defines an optional callback raised when the texture is loaded
  58205. * @param onError defines an optional callback raised if there is an issue to load the texture
  58206. * @param format defines the format of the data
  58207. * @param forcedExtension defines the extension to use to pick the right loader
  58208. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  58209. * @returns the cube texture as an InternalTexture
  58210. */
  58211. 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;
  58212. }
  58213. }
  58214. }
  58215. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  58216. import { Nullable } from "babylonjs/types";
  58217. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58218. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58219. /**
  58220. * Implementation of the DDS Texture Loader.
  58221. * @hidden
  58222. */
  58223. export class _DDSTextureLoader implements IInternalTextureLoader {
  58224. /**
  58225. * Defines wether the loader supports cascade loading the different faces.
  58226. */
  58227. readonly supportCascades: boolean;
  58228. /**
  58229. * This returns if the loader support the current file information.
  58230. * @param extension defines the file extension of the file being loaded
  58231. * @returns true if the loader can load the specified file
  58232. */
  58233. canLoad(extension: string): boolean;
  58234. /**
  58235. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58236. * @param data contains the texture data
  58237. * @param texture defines the BabylonJS internal texture
  58238. * @param createPolynomials will be true if polynomials have been requested
  58239. * @param onLoad defines the callback to trigger once the texture is ready
  58240. * @param onError defines the callback to trigger in case of error
  58241. */
  58242. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58243. /**
  58244. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58245. * @param data contains the texture data
  58246. * @param texture defines the BabylonJS internal texture
  58247. * @param callback defines the method to call once ready to upload
  58248. */
  58249. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58250. }
  58251. }
  58252. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  58253. import { Nullable } from "babylonjs/types";
  58254. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58255. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58256. /**
  58257. * Implementation of the ENV Texture Loader.
  58258. * @hidden
  58259. */
  58260. export class _ENVTextureLoader implements IInternalTextureLoader {
  58261. /**
  58262. * Defines wether the loader supports cascade loading the different faces.
  58263. */
  58264. readonly supportCascades: boolean;
  58265. /**
  58266. * This returns if the loader support the current file information.
  58267. * @param extension defines the file extension of the file being loaded
  58268. * @returns true if the loader can load the specified file
  58269. */
  58270. canLoad(extension: string): boolean;
  58271. /**
  58272. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58273. * @param data contains the texture data
  58274. * @param texture defines the BabylonJS internal texture
  58275. * @param createPolynomials will be true if polynomials have been requested
  58276. * @param onLoad defines the callback to trigger once the texture is ready
  58277. * @param onError defines the callback to trigger in case of error
  58278. */
  58279. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58280. /**
  58281. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58282. * @param data contains the texture data
  58283. * @param texture defines the BabylonJS internal texture
  58284. * @param callback defines the method to call once ready to upload
  58285. */
  58286. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58287. }
  58288. }
  58289. declare module "babylonjs/Misc/khronosTextureContainer" {
  58290. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58291. /**
  58292. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  58293. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  58294. */
  58295. export class KhronosTextureContainer {
  58296. /** contents of the KTX container file */
  58297. data: ArrayBufferView;
  58298. private static HEADER_LEN;
  58299. private static COMPRESSED_2D;
  58300. private static COMPRESSED_3D;
  58301. private static TEX_2D;
  58302. private static TEX_3D;
  58303. /**
  58304. * Gets the openGL type
  58305. */
  58306. glType: number;
  58307. /**
  58308. * Gets the openGL type size
  58309. */
  58310. glTypeSize: number;
  58311. /**
  58312. * Gets the openGL format
  58313. */
  58314. glFormat: number;
  58315. /**
  58316. * Gets the openGL internal format
  58317. */
  58318. glInternalFormat: number;
  58319. /**
  58320. * Gets the base internal format
  58321. */
  58322. glBaseInternalFormat: number;
  58323. /**
  58324. * Gets image width in pixel
  58325. */
  58326. pixelWidth: number;
  58327. /**
  58328. * Gets image height in pixel
  58329. */
  58330. pixelHeight: number;
  58331. /**
  58332. * Gets image depth in pixels
  58333. */
  58334. pixelDepth: number;
  58335. /**
  58336. * Gets the number of array elements
  58337. */
  58338. numberOfArrayElements: number;
  58339. /**
  58340. * Gets the number of faces
  58341. */
  58342. numberOfFaces: number;
  58343. /**
  58344. * Gets the number of mipmap levels
  58345. */
  58346. numberOfMipmapLevels: number;
  58347. /**
  58348. * Gets the bytes of key value data
  58349. */
  58350. bytesOfKeyValueData: number;
  58351. /**
  58352. * Gets the load type
  58353. */
  58354. loadType: number;
  58355. /**
  58356. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  58357. */
  58358. isInvalid: boolean;
  58359. /**
  58360. * Creates a new KhronosTextureContainer
  58361. * @param data contents of the KTX container file
  58362. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  58363. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  58364. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  58365. */
  58366. constructor(
  58367. /** contents of the KTX container file */
  58368. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  58369. /**
  58370. * Uploads KTX content to a Babylon Texture.
  58371. * It is assumed that the texture has already been created & is currently bound
  58372. * @hidden
  58373. */
  58374. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  58375. private _upload2DCompressedLevels;
  58376. /**
  58377. * Checks if the given data starts with a KTX file identifier.
  58378. * @param data the data to check
  58379. * @returns true if the data is a KTX file or false otherwise
  58380. */
  58381. static IsValid(data: ArrayBufferView): boolean;
  58382. }
  58383. }
  58384. declare module "babylonjs/Misc/khronosTextureContainer2" {
  58385. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58386. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  58387. /**
  58388. * Class for loading KTX2 files
  58389. * !!! Experimental Extension Subject to Changes !!!
  58390. * @hidden
  58391. */
  58392. export class KhronosTextureContainer2 {
  58393. private static _ModulePromise;
  58394. private static _TranscodeFormat;
  58395. constructor(engine: ThinEngine);
  58396. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  58397. private _determineTranscodeFormat;
  58398. /**
  58399. * Checks if the given data starts with a KTX2 file identifier.
  58400. * @param data the data to check
  58401. * @returns true if the data is a KTX2 file or false otherwise
  58402. */
  58403. static IsValid(data: ArrayBufferView): boolean;
  58404. }
  58405. }
  58406. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  58407. import { Nullable } from "babylonjs/types";
  58408. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58409. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58410. /**
  58411. * Implementation of the KTX Texture Loader.
  58412. * @hidden
  58413. */
  58414. export class _KTXTextureLoader implements IInternalTextureLoader {
  58415. /**
  58416. * Defines wether the loader supports cascade loading the different faces.
  58417. */
  58418. readonly supportCascades: boolean;
  58419. /**
  58420. * This returns if the loader support the current file information.
  58421. * @param extension defines the file extension of the file being loaded
  58422. * @returns true if the loader can load the specified file
  58423. */
  58424. canLoad(extension: string): boolean;
  58425. /**
  58426. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58427. * @param data contains the texture data
  58428. * @param texture defines the BabylonJS internal texture
  58429. * @param createPolynomials will be true if polynomials have been requested
  58430. * @param onLoad defines the callback to trigger once the texture is ready
  58431. * @param onError defines the callback to trigger in case of error
  58432. */
  58433. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58434. /**
  58435. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58436. * @param data contains the texture data
  58437. * @param texture defines the BabylonJS internal texture
  58438. * @param callback defines the method to call once ready to upload
  58439. */
  58440. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  58441. }
  58442. }
  58443. declare module "babylonjs/Helpers/sceneHelpers" {
  58444. import { Nullable } from "babylonjs/types";
  58445. import { Mesh } from "babylonjs/Meshes/mesh";
  58446. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58447. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  58448. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  58449. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  58450. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  58451. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  58452. import "babylonjs/Meshes/Builders/boxBuilder";
  58453. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  58454. /** @hidden */
  58455. export var _forceSceneHelpersToBundle: boolean;
  58456. module "babylonjs/scene" {
  58457. interface Scene {
  58458. /**
  58459. * Creates a default light for the scene.
  58460. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  58461. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  58462. */
  58463. createDefaultLight(replace?: boolean): void;
  58464. /**
  58465. * Creates a default camera for the scene.
  58466. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  58467. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  58468. * @param replace has default false, when true replaces the active camera in the scene
  58469. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  58470. */
  58471. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  58472. /**
  58473. * Creates a default camera and a default light.
  58474. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  58475. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  58476. * @param replace has the default false, when true replaces the active camera/light in the scene
  58477. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  58478. */
  58479. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  58480. /**
  58481. * Creates a new sky box
  58482. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  58483. * @param environmentTexture defines the texture to use as environment texture
  58484. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  58485. * @param scale defines the overall scale of the skybox
  58486. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  58487. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  58488. * @returns a new mesh holding the sky box
  58489. */
  58490. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  58491. /**
  58492. * Creates a new environment
  58493. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  58494. * @param options defines the options you can use to configure the environment
  58495. * @returns the new EnvironmentHelper
  58496. */
  58497. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  58498. /**
  58499. * Creates a new VREXperienceHelper
  58500. * @see http://doc.babylonjs.com/how_to/webvr_helper
  58501. * @param webVROptions defines the options used to create the new VREXperienceHelper
  58502. * @returns a new VREXperienceHelper
  58503. */
  58504. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  58505. /**
  58506. * Creates a new WebXRDefaultExperience
  58507. * @see http://doc.babylonjs.com/how_to/webxr
  58508. * @param options experience options
  58509. * @returns a promise for a new WebXRDefaultExperience
  58510. */
  58511. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  58512. }
  58513. }
  58514. }
  58515. declare module "babylonjs/Helpers/videoDome" {
  58516. import { Scene } from "babylonjs/scene";
  58517. import { TransformNode } from "babylonjs/Meshes/transformNode";
  58518. import { Mesh } from "babylonjs/Meshes/mesh";
  58519. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  58520. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  58521. import "babylonjs/Meshes/Builders/sphereBuilder";
  58522. /**
  58523. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  58524. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  58525. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  58526. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  58527. */
  58528. export class VideoDome extends TransformNode {
  58529. /**
  58530. * Define the video source as a Monoscopic panoramic 360 video.
  58531. */
  58532. static readonly MODE_MONOSCOPIC: number;
  58533. /**
  58534. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  58535. */
  58536. static readonly MODE_TOPBOTTOM: number;
  58537. /**
  58538. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  58539. */
  58540. static readonly MODE_SIDEBYSIDE: number;
  58541. private _halfDome;
  58542. private _useDirectMapping;
  58543. /**
  58544. * The video texture being displayed on the sphere
  58545. */
  58546. protected _videoTexture: VideoTexture;
  58547. /**
  58548. * Gets the video texture being displayed on the sphere
  58549. */
  58550. get videoTexture(): VideoTexture;
  58551. /**
  58552. * The skybox material
  58553. */
  58554. protected _material: BackgroundMaterial;
  58555. /**
  58556. * The surface used for the skybox
  58557. */
  58558. protected _mesh: Mesh;
  58559. /**
  58560. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  58561. */
  58562. private _halfDomeMask;
  58563. /**
  58564. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  58565. * Also see the options.resolution property.
  58566. */
  58567. get fovMultiplier(): number;
  58568. set fovMultiplier(value: number);
  58569. private _videoMode;
  58570. /**
  58571. * Gets or set the current video mode for the video. It can be:
  58572. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  58573. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  58574. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  58575. */
  58576. get videoMode(): number;
  58577. set videoMode(value: number);
  58578. /**
  58579. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  58580. *
  58581. */
  58582. get halfDome(): boolean;
  58583. /**
  58584. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  58585. */
  58586. set halfDome(enabled: boolean);
  58587. /**
  58588. * Oberserver used in Stereoscopic VR Mode.
  58589. */
  58590. private _onBeforeCameraRenderObserver;
  58591. /**
  58592. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  58593. * @param name Element's name, child elements will append suffixes for their own names.
  58594. * @param urlsOrVideo defines the url(s) or the video element to use
  58595. * @param options An object containing optional or exposed sub element properties
  58596. */
  58597. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  58598. resolution?: number;
  58599. clickToPlay?: boolean;
  58600. autoPlay?: boolean;
  58601. loop?: boolean;
  58602. size?: number;
  58603. poster?: string;
  58604. faceForward?: boolean;
  58605. useDirectMapping?: boolean;
  58606. halfDomeMode?: boolean;
  58607. }, scene: Scene);
  58608. private _changeVideoMode;
  58609. /**
  58610. * Releases resources associated with this node.
  58611. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  58612. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  58613. */
  58614. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  58615. }
  58616. }
  58617. declare module "babylonjs/Helpers/index" {
  58618. export * from "babylonjs/Helpers/environmentHelper";
  58619. export * from "babylonjs/Helpers/photoDome";
  58620. export * from "babylonjs/Helpers/sceneHelpers";
  58621. export * from "babylonjs/Helpers/videoDome";
  58622. }
  58623. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  58624. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  58625. import { IDisposable } from "babylonjs/scene";
  58626. import { Engine } from "babylonjs/Engines/engine";
  58627. /**
  58628. * This class can be used to get instrumentation data from a Babylon engine
  58629. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  58630. */
  58631. export class EngineInstrumentation implements IDisposable {
  58632. /**
  58633. * Define the instrumented engine.
  58634. */
  58635. engine: Engine;
  58636. private _captureGPUFrameTime;
  58637. private _gpuFrameTimeToken;
  58638. private _gpuFrameTime;
  58639. private _captureShaderCompilationTime;
  58640. private _shaderCompilationTime;
  58641. private _onBeginFrameObserver;
  58642. private _onEndFrameObserver;
  58643. private _onBeforeShaderCompilationObserver;
  58644. private _onAfterShaderCompilationObserver;
  58645. /**
  58646. * Gets the perf counter used for GPU frame time
  58647. */
  58648. get gpuFrameTimeCounter(): PerfCounter;
  58649. /**
  58650. * Gets the GPU frame time capture status
  58651. */
  58652. get captureGPUFrameTime(): boolean;
  58653. /**
  58654. * Enable or disable the GPU frame time capture
  58655. */
  58656. set captureGPUFrameTime(value: boolean);
  58657. /**
  58658. * Gets the perf counter used for shader compilation time
  58659. */
  58660. get shaderCompilationTimeCounter(): PerfCounter;
  58661. /**
  58662. * Gets the shader compilation time capture status
  58663. */
  58664. get captureShaderCompilationTime(): boolean;
  58665. /**
  58666. * Enable or disable the shader compilation time capture
  58667. */
  58668. set captureShaderCompilationTime(value: boolean);
  58669. /**
  58670. * Instantiates a new engine instrumentation.
  58671. * This class can be used to get instrumentation data from a Babylon engine
  58672. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  58673. * @param engine Defines the engine to instrument
  58674. */
  58675. constructor(
  58676. /**
  58677. * Define the instrumented engine.
  58678. */
  58679. engine: Engine);
  58680. /**
  58681. * Dispose and release associated resources.
  58682. */
  58683. dispose(): void;
  58684. }
  58685. }
  58686. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  58687. import { Scene, IDisposable } from "babylonjs/scene";
  58688. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  58689. /**
  58690. * This class can be used to get instrumentation data from a Babylon engine
  58691. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  58692. */
  58693. export class SceneInstrumentation implements IDisposable {
  58694. /**
  58695. * Defines the scene to instrument
  58696. */
  58697. scene: Scene;
  58698. private _captureActiveMeshesEvaluationTime;
  58699. private _activeMeshesEvaluationTime;
  58700. private _captureRenderTargetsRenderTime;
  58701. private _renderTargetsRenderTime;
  58702. private _captureFrameTime;
  58703. private _frameTime;
  58704. private _captureRenderTime;
  58705. private _renderTime;
  58706. private _captureInterFrameTime;
  58707. private _interFrameTime;
  58708. private _captureParticlesRenderTime;
  58709. private _particlesRenderTime;
  58710. private _captureSpritesRenderTime;
  58711. private _spritesRenderTime;
  58712. private _capturePhysicsTime;
  58713. private _physicsTime;
  58714. private _captureAnimationsTime;
  58715. private _animationsTime;
  58716. private _captureCameraRenderTime;
  58717. private _cameraRenderTime;
  58718. private _onBeforeActiveMeshesEvaluationObserver;
  58719. private _onAfterActiveMeshesEvaluationObserver;
  58720. private _onBeforeRenderTargetsRenderObserver;
  58721. private _onAfterRenderTargetsRenderObserver;
  58722. private _onAfterRenderObserver;
  58723. private _onBeforeDrawPhaseObserver;
  58724. private _onAfterDrawPhaseObserver;
  58725. private _onBeforeAnimationsObserver;
  58726. private _onBeforeParticlesRenderingObserver;
  58727. private _onAfterParticlesRenderingObserver;
  58728. private _onBeforeSpritesRenderingObserver;
  58729. private _onAfterSpritesRenderingObserver;
  58730. private _onBeforePhysicsObserver;
  58731. private _onAfterPhysicsObserver;
  58732. private _onAfterAnimationsObserver;
  58733. private _onBeforeCameraRenderObserver;
  58734. private _onAfterCameraRenderObserver;
  58735. /**
  58736. * Gets the perf counter used for active meshes evaluation time
  58737. */
  58738. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  58739. /**
  58740. * Gets the active meshes evaluation time capture status
  58741. */
  58742. get captureActiveMeshesEvaluationTime(): boolean;
  58743. /**
  58744. * Enable or disable the active meshes evaluation time capture
  58745. */
  58746. set captureActiveMeshesEvaluationTime(value: boolean);
  58747. /**
  58748. * Gets the perf counter used for render targets render time
  58749. */
  58750. get renderTargetsRenderTimeCounter(): PerfCounter;
  58751. /**
  58752. * Gets the render targets render time capture status
  58753. */
  58754. get captureRenderTargetsRenderTime(): boolean;
  58755. /**
  58756. * Enable or disable the render targets render time capture
  58757. */
  58758. set captureRenderTargetsRenderTime(value: boolean);
  58759. /**
  58760. * Gets the perf counter used for particles render time
  58761. */
  58762. get particlesRenderTimeCounter(): PerfCounter;
  58763. /**
  58764. * Gets the particles render time capture status
  58765. */
  58766. get captureParticlesRenderTime(): boolean;
  58767. /**
  58768. * Enable or disable the particles render time capture
  58769. */
  58770. set captureParticlesRenderTime(value: boolean);
  58771. /**
  58772. * Gets the perf counter used for sprites render time
  58773. */
  58774. get spritesRenderTimeCounter(): PerfCounter;
  58775. /**
  58776. * Gets the sprites render time capture status
  58777. */
  58778. get captureSpritesRenderTime(): boolean;
  58779. /**
  58780. * Enable or disable the sprites render time capture
  58781. */
  58782. set captureSpritesRenderTime(value: boolean);
  58783. /**
  58784. * Gets the perf counter used for physics time
  58785. */
  58786. get physicsTimeCounter(): PerfCounter;
  58787. /**
  58788. * Gets the physics time capture status
  58789. */
  58790. get capturePhysicsTime(): boolean;
  58791. /**
  58792. * Enable or disable the physics time capture
  58793. */
  58794. set capturePhysicsTime(value: boolean);
  58795. /**
  58796. * Gets the perf counter used for animations time
  58797. */
  58798. get animationsTimeCounter(): PerfCounter;
  58799. /**
  58800. * Gets the animations time capture status
  58801. */
  58802. get captureAnimationsTime(): boolean;
  58803. /**
  58804. * Enable or disable the animations time capture
  58805. */
  58806. set captureAnimationsTime(value: boolean);
  58807. /**
  58808. * Gets the perf counter used for frame time capture
  58809. */
  58810. get frameTimeCounter(): PerfCounter;
  58811. /**
  58812. * Gets the frame time capture status
  58813. */
  58814. get captureFrameTime(): boolean;
  58815. /**
  58816. * Enable or disable the frame time capture
  58817. */
  58818. set captureFrameTime(value: boolean);
  58819. /**
  58820. * Gets the perf counter used for inter-frames time capture
  58821. */
  58822. get interFrameTimeCounter(): PerfCounter;
  58823. /**
  58824. * Gets the inter-frames time capture status
  58825. */
  58826. get captureInterFrameTime(): boolean;
  58827. /**
  58828. * Enable or disable the inter-frames time capture
  58829. */
  58830. set captureInterFrameTime(value: boolean);
  58831. /**
  58832. * Gets the perf counter used for render time capture
  58833. */
  58834. get renderTimeCounter(): PerfCounter;
  58835. /**
  58836. * Gets the render time capture status
  58837. */
  58838. get captureRenderTime(): boolean;
  58839. /**
  58840. * Enable or disable the render time capture
  58841. */
  58842. set captureRenderTime(value: boolean);
  58843. /**
  58844. * Gets the perf counter used for camera render time capture
  58845. */
  58846. get cameraRenderTimeCounter(): PerfCounter;
  58847. /**
  58848. * Gets the camera render time capture status
  58849. */
  58850. get captureCameraRenderTime(): boolean;
  58851. /**
  58852. * Enable or disable the camera render time capture
  58853. */
  58854. set captureCameraRenderTime(value: boolean);
  58855. /**
  58856. * Gets the perf counter used for draw calls
  58857. */
  58858. get drawCallsCounter(): PerfCounter;
  58859. /**
  58860. * Instantiates a new scene instrumentation.
  58861. * This class can be used to get instrumentation data from a Babylon engine
  58862. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  58863. * @param scene Defines the scene to instrument
  58864. */
  58865. constructor(
  58866. /**
  58867. * Defines the scene to instrument
  58868. */
  58869. scene: Scene);
  58870. /**
  58871. * Dispose and release associated resources.
  58872. */
  58873. dispose(): void;
  58874. }
  58875. }
  58876. declare module "babylonjs/Instrumentation/index" {
  58877. export * from "babylonjs/Instrumentation/engineInstrumentation";
  58878. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  58879. export * from "babylonjs/Instrumentation/timeToken";
  58880. }
  58881. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  58882. /** @hidden */
  58883. export var glowMapGenerationPixelShader: {
  58884. name: string;
  58885. shader: string;
  58886. };
  58887. }
  58888. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  58889. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  58890. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  58891. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  58892. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  58893. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  58894. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  58895. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  58896. /** @hidden */
  58897. export var glowMapGenerationVertexShader: {
  58898. name: string;
  58899. shader: string;
  58900. };
  58901. }
  58902. declare module "babylonjs/Layers/effectLayer" {
  58903. import { Observable } from "babylonjs/Misc/observable";
  58904. import { Nullable } from "babylonjs/types";
  58905. import { Camera } from "babylonjs/Cameras/camera";
  58906. import { Scene } from "babylonjs/scene";
  58907. import { ISize } from "babylonjs/Maths/math.size";
  58908. import { Color4 } from "babylonjs/Maths/math.color";
  58909. import { Engine } from "babylonjs/Engines/engine";
  58910. import { SubMesh } from "babylonjs/Meshes/subMesh";
  58911. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58912. import { Mesh } from "babylonjs/Meshes/mesh";
  58913. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  58914. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58915. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  58916. import { Effect } from "babylonjs/Materials/effect";
  58917. import { Material } from "babylonjs/Materials/material";
  58918. import "babylonjs/Shaders/glowMapGeneration.fragment";
  58919. import "babylonjs/Shaders/glowMapGeneration.vertex";
  58920. /**
  58921. * Effect layer options. This helps customizing the behaviour
  58922. * of the effect layer.
  58923. */
  58924. export interface IEffectLayerOptions {
  58925. /**
  58926. * Multiplication factor apply to the canvas size to compute the render target size
  58927. * used to generated the objects (the smaller the faster).
  58928. */
  58929. mainTextureRatio: number;
  58930. /**
  58931. * Enforces a fixed size texture to ensure effect stability across devices.
  58932. */
  58933. mainTextureFixedSize?: number;
  58934. /**
  58935. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  58936. */
  58937. alphaBlendingMode: number;
  58938. /**
  58939. * The camera attached to the layer.
  58940. */
  58941. camera: Nullable<Camera>;
  58942. /**
  58943. * The rendering group to draw the layer in.
  58944. */
  58945. renderingGroupId: number;
  58946. }
  58947. /**
  58948. * The effect layer Helps adding post process effect blended with the main pass.
  58949. *
  58950. * This can be for instance use to generate glow or higlight effects on the scene.
  58951. *
  58952. * The effect layer class can not be used directly and is intented to inherited from to be
  58953. * customized per effects.
  58954. */
  58955. export abstract class EffectLayer {
  58956. private _vertexBuffers;
  58957. private _indexBuffer;
  58958. private _cachedDefines;
  58959. private _effectLayerMapGenerationEffect;
  58960. private _effectLayerOptions;
  58961. private _mergeEffect;
  58962. protected _scene: Scene;
  58963. protected _engine: Engine;
  58964. protected _maxSize: number;
  58965. protected _mainTextureDesiredSize: ISize;
  58966. protected _mainTexture: RenderTargetTexture;
  58967. protected _shouldRender: boolean;
  58968. protected _postProcesses: PostProcess[];
  58969. protected _textures: BaseTexture[];
  58970. protected _emissiveTextureAndColor: {
  58971. texture: Nullable<BaseTexture>;
  58972. color: Color4;
  58973. };
  58974. /**
  58975. * The name of the layer
  58976. */
  58977. name: string;
  58978. /**
  58979. * The clear color of the texture used to generate the glow map.
  58980. */
  58981. neutralColor: Color4;
  58982. /**
  58983. * Specifies whether the highlight layer is enabled or not.
  58984. */
  58985. isEnabled: boolean;
  58986. /**
  58987. * Gets the camera attached to the layer.
  58988. */
  58989. get camera(): Nullable<Camera>;
  58990. /**
  58991. * Gets the rendering group id the layer should render in.
  58992. */
  58993. get renderingGroupId(): number;
  58994. set renderingGroupId(renderingGroupId: number);
  58995. /**
  58996. * An event triggered when the effect layer has been disposed.
  58997. */
  58998. onDisposeObservable: Observable<EffectLayer>;
  58999. /**
  59000. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  59001. */
  59002. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  59003. /**
  59004. * An event triggered when the generated texture is being merged in the scene.
  59005. */
  59006. onBeforeComposeObservable: Observable<EffectLayer>;
  59007. /**
  59008. * An event triggered when the mesh is rendered into the effect render target.
  59009. */
  59010. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  59011. /**
  59012. * An event triggered after the mesh has been rendered into the effect render target.
  59013. */
  59014. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  59015. /**
  59016. * An event triggered when the generated texture has been merged in the scene.
  59017. */
  59018. onAfterComposeObservable: Observable<EffectLayer>;
  59019. /**
  59020. * An event triggered when the efffect layer changes its size.
  59021. */
  59022. onSizeChangedObservable: Observable<EffectLayer>;
  59023. /** @hidden */
  59024. static _SceneComponentInitialization: (scene: Scene) => void;
  59025. /**
  59026. * Instantiates a new effect Layer and references it in the scene.
  59027. * @param name The name of the layer
  59028. * @param scene The scene to use the layer in
  59029. */
  59030. constructor(
  59031. /** The Friendly of the effect in the scene */
  59032. name: string, scene: Scene);
  59033. /**
  59034. * Get the effect name of the layer.
  59035. * @return The effect name
  59036. */
  59037. abstract getEffectName(): string;
  59038. /**
  59039. * Checks for the readiness of the element composing the layer.
  59040. * @param subMesh the mesh to check for
  59041. * @param useInstances specify whether or not to use instances to render the mesh
  59042. * @return true if ready otherwise, false
  59043. */
  59044. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59045. /**
  59046. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  59047. * @returns true if the effect requires stencil during the main canvas render pass.
  59048. */
  59049. abstract needStencil(): boolean;
  59050. /**
  59051. * Create the merge effect. This is the shader use to blit the information back
  59052. * to the main canvas at the end of the scene rendering.
  59053. * @returns The effect containing the shader used to merge the effect on the main canvas
  59054. */
  59055. protected abstract _createMergeEffect(): Effect;
  59056. /**
  59057. * Creates the render target textures and post processes used in the effect layer.
  59058. */
  59059. protected abstract _createTextureAndPostProcesses(): void;
  59060. /**
  59061. * Implementation specific of rendering the generating effect on the main canvas.
  59062. * @param effect The effect used to render through
  59063. */
  59064. protected abstract _internalRender(effect: Effect): void;
  59065. /**
  59066. * Sets the required values for both the emissive texture and and the main color.
  59067. */
  59068. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59069. /**
  59070. * Free any resources and references associated to a mesh.
  59071. * Internal use
  59072. * @param mesh The mesh to free.
  59073. */
  59074. abstract _disposeMesh(mesh: Mesh): void;
  59075. /**
  59076. * Serializes this layer (Glow or Highlight for example)
  59077. * @returns a serialized layer object
  59078. */
  59079. abstract serialize?(): any;
  59080. /**
  59081. * Initializes the effect layer with the required options.
  59082. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  59083. */
  59084. protected _init(options: Partial<IEffectLayerOptions>): void;
  59085. /**
  59086. * Generates the index buffer of the full screen quad blending to the main canvas.
  59087. */
  59088. private _generateIndexBuffer;
  59089. /**
  59090. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  59091. */
  59092. private _generateVertexBuffer;
  59093. /**
  59094. * Sets the main texture desired size which is the closest power of two
  59095. * of the engine canvas size.
  59096. */
  59097. private _setMainTextureSize;
  59098. /**
  59099. * Creates the main texture for the effect layer.
  59100. */
  59101. protected _createMainTexture(): void;
  59102. /**
  59103. * Adds specific effects defines.
  59104. * @param defines The defines to add specifics to.
  59105. */
  59106. protected _addCustomEffectDefines(defines: string[]): void;
  59107. /**
  59108. * Checks for the readiness of the element composing the layer.
  59109. * @param subMesh the mesh to check for
  59110. * @param useInstances specify whether or not to use instances to render the mesh
  59111. * @param emissiveTexture the associated emissive texture used to generate the glow
  59112. * @return true if ready otherwise, false
  59113. */
  59114. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  59115. /**
  59116. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  59117. */
  59118. render(): void;
  59119. /**
  59120. * Determine if a given mesh will be used in the current effect.
  59121. * @param mesh mesh to test
  59122. * @returns true if the mesh will be used
  59123. */
  59124. hasMesh(mesh: AbstractMesh): boolean;
  59125. /**
  59126. * Returns true if the layer contains information to display, otherwise false.
  59127. * @returns true if the glow layer should be rendered
  59128. */
  59129. shouldRender(): boolean;
  59130. /**
  59131. * Returns true if the mesh should render, otherwise false.
  59132. * @param mesh The mesh to render
  59133. * @returns true if it should render otherwise false
  59134. */
  59135. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  59136. /**
  59137. * Returns true if the mesh can be rendered, otherwise false.
  59138. * @param mesh The mesh to render
  59139. * @param material The material used on the mesh
  59140. * @returns true if it can be rendered otherwise false
  59141. */
  59142. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  59143. /**
  59144. * Returns true if the mesh should render, otherwise false.
  59145. * @param mesh The mesh to render
  59146. * @returns true if it should render otherwise false
  59147. */
  59148. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  59149. /**
  59150. * Renders the submesh passed in parameter to the generation map.
  59151. */
  59152. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  59153. /**
  59154. * Defines whether the current material of the mesh should be use to render the effect.
  59155. * @param mesh defines the current mesh to render
  59156. */
  59157. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  59158. /**
  59159. * Rebuild the required buffers.
  59160. * @hidden Internal use only.
  59161. */
  59162. _rebuild(): void;
  59163. /**
  59164. * Dispose only the render target textures and post process.
  59165. */
  59166. private _disposeTextureAndPostProcesses;
  59167. /**
  59168. * Dispose the highlight layer and free resources.
  59169. */
  59170. dispose(): void;
  59171. /**
  59172. * Gets the class name of the effect layer
  59173. * @returns the string with the class name of the effect layer
  59174. */
  59175. getClassName(): string;
  59176. /**
  59177. * Creates an effect layer from parsed effect layer data
  59178. * @param parsedEffectLayer defines effect layer data
  59179. * @param scene defines the current scene
  59180. * @param rootUrl defines the root URL containing the effect layer information
  59181. * @returns a parsed effect Layer
  59182. */
  59183. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  59184. }
  59185. }
  59186. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  59187. import { Scene } from "babylonjs/scene";
  59188. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  59189. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  59190. import { AbstractScene } from "babylonjs/abstractScene";
  59191. module "babylonjs/abstractScene" {
  59192. interface AbstractScene {
  59193. /**
  59194. * The list of effect layers (highlights/glow) added to the scene
  59195. * @see http://doc.babylonjs.com/how_to/highlight_layer
  59196. * @see http://doc.babylonjs.com/how_to/glow_layer
  59197. */
  59198. effectLayers: Array<EffectLayer>;
  59199. /**
  59200. * Removes the given effect layer from this scene.
  59201. * @param toRemove defines the effect layer to remove
  59202. * @returns the index of the removed effect layer
  59203. */
  59204. removeEffectLayer(toRemove: EffectLayer): number;
  59205. /**
  59206. * Adds the given effect layer to this scene
  59207. * @param newEffectLayer defines the effect layer to add
  59208. */
  59209. addEffectLayer(newEffectLayer: EffectLayer): void;
  59210. }
  59211. }
  59212. /**
  59213. * Defines the layer scene component responsible to manage any effect layers
  59214. * in a given scene.
  59215. */
  59216. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  59217. /**
  59218. * The component name helpfull to identify the component in the list of scene components.
  59219. */
  59220. readonly name: string;
  59221. /**
  59222. * The scene the component belongs to.
  59223. */
  59224. scene: Scene;
  59225. private _engine;
  59226. private _renderEffects;
  59227. private _needStencil;
  59228. private _previousStencilState;
  59229. /**
  59230. * Creates a new instance of the component for the given scene
  59231. * @param scene Defines the scene to register the component in
  59232. */
  59233. constructor(scene: Scene);
  59234. /**
  59235. * Registers the component in a given scene
  59236. */
  59237. register(): void;
  59238. /**
  59239. * Rebuilds the elements related to this component in case of
  59240. * context lost for instance.
  59241. */
  59242. rebuild(): void;
  59243. /**
  59244. * Serializes the component data to the specified json object
  59245. * @param serializationObject The object to serialize to
  59246. */
  59247. serialize(serializationObject: any): void;
  59248. /**
  59249. * Adds all the elements from the container to the scene
  59250. * @param container the container holding the elements
  59251. */
  59252. addFromContainer(container: AbstractScene): void;
  59253. /**
  59254. * Removes all the elements in the container from the scene
  59255. * @param container contains the elements to remove
  59256. * @param dispose if the removed element should be disposed (default: false)
  59257. */
  59258. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59259. /**
  59260. * Disposes the component and the associated ressources.
  59261. */
  59262. dispose(): void;
  59263. private _isReadyForMesh;
  59264. private _renderMainTexture;
  59265. private _setStencil;
  59266. private _setStencilBack;
  59267. private _draw;
  59268. private _drawCamera;
  59269. private _drawRenderingGroup;
  59270. }
  59271. }
  59272. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  59273. /** @hidden */
  59274. export var glowMapMergePixelShader: {
  59275. name: string;
  59276. shader: string;
  59277. };
  59278. }
  59279. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  59280. /** @hidden */
  59281. export var glowMapMergeVertexShader: {
  59282. name: string;
  59283. shader: string;
  59284. };
  59285. }
  59286. declare module "babylonjs/Layers/glowLayer" {
  59287. import { Nullable } from "babylonjs/types";
  59288. import { Camera } from "babylonjs/Cameras/camera";
  59289. import { Scene } from "babylonjs/scene";
  59290. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59291. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59292. import { Mesh } from "babylonjs/Meshes/mesh";
  59293. import { Texture } from "babylonjs/Materials/Textures/texture";
  59294. import { Effect } from "babylonjs/Materials/effect";
  59295. import { Material } from "babylonjs/Materials/material";
  59296. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  59297. import { Color4 } from "babylonjs/Maths/math.color";
  59298. import "babylonjs/Shaders/glowMapMerge.fragment";
  59299. import "babylonjs/Shaders/glowMapMerge.vertex";
  59300. import "babylonjs/Layers/effectLayerSceneComponent";
  59301. module "babylonjs/abstractScene" {
  59302. interface AbstractScene {
  59303. /**
  59304. * Return a the first highlight layer of the scene with a given name.
  59305. * @param name The name of the highlight layer to look for.
  59306. * @return The highlight layer if found otherwise null.
  59307. */
  59308. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  59309. }
  59310. }
  59311. /**
  59312. * Glow layer options. This helps customizing the behaviour
  59313. * of the glow layer.
  59314. */
  59315. export interface IGlowLayerOptions {
  59316. /**
  59317. * Multiplication factor apply to the canvas size to compute the render target size
  59318. * used to generated the glowing objects (the smaller the faster).
  59319. */
  59320. mainTextureRatio: number;
  59321. /**
  59322. * Enforces a fixed size texture to ensure resize independant blur.
  59323. */
  59324. mainTextureFixedSize?: number;
  59325. /**
  59326. * How big is the kernel of the blur texture.
  59327. */
  59328. blurKernelSize: number;
  59329. /**
  59330. * The camera attached to the layer.
  59331. */
  59332. camera: Nullable<Camera>;
  59333. /**
  59334. * Enable MSAA by chosing the number of samples.
  59335. */
  59336. mainTextureSamples?: number;
  59337. /**
  59338. * The rendering group to draw the layer in.
  59339. */
  59340. renderingGroupId: number;
  59341. }
  59342. /**
  59343. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  59344. *
  59345. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  59346. *
  59347. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  59348. */
  59349. export class GlowLayer extends EffectLayer {
  59350. /**
  59351. * Effect Name of the layer.
  59352. */
  59353. static readonly EffectName: string;
  59354. /**
  59355. * The default blur kernel size used for the glow.
  59356. */
  59357. static DefaultBlurKernelSize: number;
  59358. /**
  59359. * The default texture size ratio used for the glow.
  59360. */
  59361. static DefaultTextureRatio: number;
  59362. /**
  59363. * Sets the kernel size of the blur.
  59364. */
  59365. set blurKernelSize(value: number);
  59366. /**
  59367. * Gets the kernel size of the blur.
  59368. */
  59369. get blurKernelSize(): number;
  59370. /**
  59371. * Sets the glow intensity.
  59372. */
  59373. set intensity(value: number);
  59374. /**
  59375. * Gets the glow intensity.
  59376. */
  59377. get intensity(): number;
  59378. private _options;
  59379. private _intensity;
  59380. private _horizontalBlurPostprocess1;
  59381. private _verticalBlurPostprocess1;
  59382. private _horizontalBlurPostprocess2;
  59383. private _verticalBlurPostprocess2;
  59384. private _blurTexture1;
  59385. private _blurTexture2;
  59386. private _postProcesses1;
  59387. private _postProcesses2;
  59388. private _includedOnlyMeshes;
  59389. private _excludedMeshes;
  59390. private _meshesUsingTheirOwnMaterials;
  59391. /**
  59392. * Callback used to let the user override the color selection on a per mesh basis
  59393. */
  59394. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  59395. /**
  59396. * Callback used to let the user override the texture selection on a per mesh basis
  59397. */
  59398. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  59399. /**
  59400. * Instantiates a new glow Layer and references it to the scene.
  59401. * @param name The name of the layer
  59402. * @param scene The scene to use the layer in
  59403. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  59404. */
  59405. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  59406. /**
  59407. * Get the effect name of the layer.
  59408. * @return The effect name
  59409. */
  59410. getEffectName(): string;
  59411. /**
  59412. * Create the merge effect. This is the shader use to blit the information back
  59413. * to the main canvas at the end of the scene rendering.
  59414. */
  59415. protected _createMergeEffect(): Effect;
  59416. /**
  59417. * Creates the render target textures and post processes used in the glow layer.
  59418. */
  59419. protected _createTextureAndPostProcesses(): void;
  59420. /**
  59421. * Checks for the readiness of the element composing the layer.
  59422. * @param subMesh the mesh to check for
  59423. * @param useInstances specify wether or not to use instances to render the mesh
  59424. * @param emissiveTexture the associated emissive texture used to generate the glow
  59425. * @return true if ready otherwise, false
  59426. */
  59427. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59428. /**
  59429. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  59430. */
  59431. needStencil(): boolean;
  59432. /**
  59433. * Returns true if the mesh can be rendered, otherwise false.
  59434. * @param mesh The mesh to render
  59435. * @param material The material used on the mesh
  59436. * @returns true if it can be rendered otherwise false
  59437. */
  59438. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  59439. /**
  59440. * Implementation specific of rendering the generating effect on the main canvas.
  59441. * @param effect The effect used to render through
  59442. */
  59443. protected _internalRender(effect: Effect): void;
  59444. /**
  59445. * Sets the required values for both the emissive texture and and the main color.
  59446. */
  59447. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59448. /**
  59449. * Returns true if the mesh should render, otherwise false.
  59450. * @param mesh The mesh to render
  59451. * @returns true if it should render otherwise false
  59452. */
  59453. protected _shouldRenderMesh(mesh: Mesh): boolean;
  59454. /**
  59455. * Adds specific effects defines.
  59456. * @param defines The defines to add specifics to.
  59457. */
  59458. protected _addCustomEffectDefines(defines: string[]): void;
  59459. /**
  59460. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  59461. * @param mesh The mesh to exclude from the glow layer
  59462. */
  59463. addExcludedMesh(mesh: Mesh): void;
  59464. /**
  59465. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  59466. * @param mesh The mesh to remove
  59467. */
  59468. removeExcludedMesh(mesh: Mesh): void;
  59469. /**
  59470. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  59471. * @param mesh The mesh to include in the glow layer
  59472. */
  59473. addIncludedOnlyMesh(mesh: Mesh): void;
  59474. /**
  59475. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  59476. * @param mesh The mesh to remove
  59477. */
  59478. removeIncludedOnlyMesh(mesh: Mesh): void;
  59479. /**
  59480. * Determine if a given mesh will be used in the glow layer
  59481. * @param mesh The mesh to test
  59482. * @returns true if the mesh will be highlighted by the current glow layer
  59483. */
  59484. hasMesh(mesh: AbstractMesh): boolean;
  59485. /**
  59486. * Defines whether the current material of the mesh should be use to render the effect.
  59487. * @param mesh defines the current mesh to render
  59488. */
  59489. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  59490. /**
  59491. * Add a mesh to be rendered through its own material and not with emissive only.
  59492. * @param mesh The mesh for which we need to use its material
  59493. */
  59494. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  59495. /**
  59496. * Remove a mesh from being rendered through its own material and not with emissive only.
  59497. * @param mesh The mesh for which we need to not use its material
  59498. */
  59499. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  59500. /**
  59501. * Free any resources and references associated to a mesh.
  59502. * Internal use
  59503. * @param mesh The mesh to free.
  59504. * @hidden
  59505. */
  59506. _disposeMesh(mesh: Mesh): void;
  59507. /**
  59508. * Gets the class name of the effect layer
  59509. * @returns the string with the class name of the effect layer
  59510. */
  59511. getClassName(): string;
  59512. /**
  59513. * Serializes this glow layer
  59514. * @returns a serialized glow layer object
  59515. */
  59516. serialize(): any;
  59517. /**
  59518. * Creates a Glow Layer from parsed glow layer data
  59519. * @param parsedGlowLayer defines glow layer data
  59520. * @param scene defines the current scene
  59521. * @param rootUrl defines the root URL containing the glow layer information
  59522. * @returns a parsed Glow Layer
  59523. */
  59524. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  59525. }
  59526. }
  59527. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  59528. /** @hidden */
  59529. export var glowBlurPostProcessPixelShader: {
  59530. name: string;
  59531. shader: string;
  59532. };
  59533. }
  59534. declare module "babylonjs/Layers/highlightLayer" {
  59535. import { Observable } from "babylonjs/Misc/observable";
  59536. import { Nullable } from "babylonjs/types";
  59537. import { Camera } from "babylonjs/Cameras/camera";
  59538. import { Scene } from "babylonjs/scene";
  59539. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59540. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59541. import { Mesh } from "babylonjs/Meshes/mesh";
  59542. import { Effect } from "babylonjs/Materials/effect";
  59543. import { Material } from "babylonjs/Materials/material";
  59544. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  59545. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  59546. import "babylonjs/Shaders/glowMapMerge.fragment";
  59547. import "babylonjs/Shaders/glowMapMerge.vertex";
  59548. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  59549. module "babylonjs/abstractScene" {
  59550. interface AbstractScene {
  59551. /**
  59552. * Return a the first highlight layer of the scene with a given name.
  59553. * @param name The name of the highlight layer to look for.
  59554. * @return The highlight layer if found otherwise null.
  59555. */
  59556. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  59557. }
  59558. }
  59559. /**
  59560. * Highlight layer options. This helps customizing the behaviour
  59561. * of the highlight layer.
  59562. */
  59563. export interface IHighlightLayerOptions {
  59564. /**
  59565. * Multiplication factor apply to the canvas size to compute the render target size
  59566. * used to generated the glowing objects (the smaller the faster).
  59567. */
  59568. mainTextureRatio: number;
  59569. /**
  59570. * Enforces a fixed size texture to ensure resize independant blur.
  59571. */
  59572. mainTextureFixedSize?: number;
  59573. /**
  59574. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  59575. * of the picture to blur (the smaller the faster).
  59576. */
  59577. blurTextureSizeRatio: number;
  59578. /**
  59579. * How big in texel of the blur texture is the vertical blur.
  59580. */
  59581. blurVerticalSize: number;
  59582. /**
  59583. * How big in texel of the blur texture is the horizontal blur.
  59584. */
  59585. blurHorizontalSize: number;
  59586. /**
  59587. * Alpha blending mode used to apply the blur. Default is combine.
  59588. */
  59589. alphaBlendingMode: number;
  59590. /**
  59591. * The camera attached to the layer.
  59592. */
  59593. camera: Nullable<Camera>;
  59594. /**
  59595. * Should we display highlight as a solid stroke?
  59596. */
  59597. isStroke?: boolean;
  59598. /**
  59599. * The rendering group to draw the layer in.
  59600. */
  59601. renderingGroupId: number;
  59602. }
  59603. /**
  59604. * The highlight layer Helps adding a glow effect around a mesh.
  59605. *
  59606. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  59607. * glowy meshes to your scene.
  59608. *
  59609. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  59610. */
  59611. export class HighlightLayer extends EffectLayer {
  59612. name: string;
  59613. /**
  59614. * Effect Name of the highlight layer.
  59615. */
  59616. static readonly EffectName: string;
  59617. /**
  59618. * The neutral color used during the preparation of the glow effect.
  59619. * This is black by default as the blend operation is a blend operation.
  59620. */
  59621. static NeutralColor: Color4;
  59622. /**
  59623. * Stencil value used for glowing meshes.
  59624. */
  59625. static GlowingMeshStencilReference: number;
  59626. /**
  59627. * Stencil value used for the other meshes in the scene.
  59628. */
  59629. static NormalMeshStencilReference: number;
  59630. /**
  59631. * Specifies whether or not the inner glow is ACTIVE in the layer.
  59632. */
  59633. innerGlow: boolean;
  59634. /**
  59635. * Specifies whether or not the outer glow is ACTIVE in the layer.
  59636. */
  59637. outerGlow: boolean;
  59638. /**
  59639. * Specifies the horizontal size of the blur.
  59640. */
  59641. set blurHorizontalSize(value: number);
  59642. /**
  59643. * Specifies the vertical size of the blur.
  59644. */
  59645. set blurVerticalSize(value: number);
  59646. /**
  59647. * Gets the horizontal size of the blur.
  59648. */
  59649. get blurHorizontalSize(): number;
  59650. /**
  59651. * Gets the vertical size of the blur.
  59652. */
  59653. get blurVerticalSize(): number;
  59654. /**
  59655. * An event triggered when the highlight layer is being blurred.
  59656. */
  59657. onBeforeBlurObservable: Observable<HighlightLayer>;
  59658. /**
  59659. * An event triggered when the highlight layer has been blurred.
  59660. */
  59661. onAfterBlurObservable: Observable<HighlightLayer>;
  59662. private _instanceGlowingMeshStencilReference;
  59663. private _options;
  59664. private _downSamplePostprocess;
  59665. private _horizontalBlurPostprocess;
  59666. private _verticalBlurPostprocess;
  59667. private _blurTexture;
  59668. private _meshes;
  59669. private _excludedMeshes;
  59670. /**
  59671. * Instantiates a new highlight Layer and references it to the scene..
  59672. * @param name The name of the layer
  59673. * @param scene The scene to use the layer in
  59674. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  59675. */
  59676. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  59677. /**
  59678. * Get the effect name of the layer.
  59679. * @return The effect name
  59680. */
  59681. getEffectName(): string;
  59682. /**
  59683. * Create the merge effect. This is the shader use to blit the information back
  59684. * to the main canvas at the end of the scene rendering.
  59685. */
  59686. protected _createMergeEffect(): Effect;
  59687. /**
  59688. * Creates the render target textures and post processes used in the highlight layer.
  59689. */
  59690. protected _createTextureAndPostProcesses(): void;
  59691. /**
  59692. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  59693. */
  59694. needStencil(): boolean;
  59695. /**
  59696. * Checks for the readiness of the element composing the layer.
  59697. * @param subMesh the mesh to check for
  59698. * @param useInstances specify wether or not to use instances to render the mesh
  59699. * @param emissiveTexture the associated emissive texture used to generate the glow
  59700. * @return true if ready otherwise, false
  59701. */
  59702. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59703. /**
  59704. * Implementation specific of rendering the generating effect on the main canvas.
  59705. * @param effect The effect used to render through
  59706. */
  59707. protected _internalRender(effect: Effect): void;
  59708. /**
  59709. * Returns true if the layer contains information to display, otherwise false.
  59710. */
  59711. shouldRender(): boolean;
  59712. /**
  59713. * Returns true if the mesh should render, otherwise false.
  59714. * @param mesh The mesh to render
  59715. * @returns true if it should render otherwise false
  59716. */
  59717. protected _shouldRenderMesh(mesh: Mesh): boolean;
  59718. /**
  59719. * Adds specific effects defines.
  59720. * @param defines The defines to add specifics to.
  59721. */
  59722. protected _addCustomEffectDefines(defines: string[]): void;
  59723. /**
  59724. * Sets the required values for both the emissive texture and and the main color.
  59725. */
  59726. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59727. /**
  59728. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  59729. * @param mesh The mesh to exclude from the highlight layer
  59730. */
  59731. addExcludedMesh(mesh: Mesh): void;
  59732. /**
  59733. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  59734. * @param mesh The mesh to highlight
  59735. */
  59736. removeExcludedMesh(mesh: Mesh): void;
  59737. /**
  59738. * Determine if a given mesh will be highlighted by the current HighlightLayer
  59739. * @param mesh mesh to test
  59740. * @returns true if the mesh will be highlighted by the current HighlightLayer
  59741. */
  59742. hasMesh(mesh: AbstractMesh): boolean;
  59743. /**
  59744. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  59745. * @param mesh The mesh to highlight
  59746. * @param color The color of the highlight
  59747. * @param glowEmissiveOnly Extract the glow from the emissive texture
  59748. */
  59749. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  59750. /**
  59751. * Remove a mesh from the highlight layer in order to make it stop glowing.
  59752. * @param mesh The mesh to highlight
  59753. */
  59754. removeMesh(mesh: Mesh): void;
  59755. /**
  59756. * Remove all the meshes currently referenced in the highlight layer
  59757. */
  59758. removeAllMeshes(): void;
  59759. /**
  59760. * Force the stencil to the normal expected value for none glowing parts
  59761. */
  59762. private _defaultStencilReference;
  59763. /**
  59764. * Free any resources and references associated to a mesh.
  59765. * Internal use
  59766. * @param mesh The mesh to free.
  59767. * @hidden
  59768. */
  59769. _disposeMesh(mesh: Mesh): void;
  59770. /**
  59771. * Dispose the highlight layer and free resources.
  59772. */
  59773. dispose(): void;
  59774. /**
  59775. * Gets the class name of the effect layer
  59776. * @returns the string with the class name of the effect layer
  59777. */
  59778. getClassName(): string;
  59779. /**
  59780. * Serializes this Highlight layer
  59781. * @returns a serialized Highlight layer object
  59782. */
  59783. serialize(): any;
  59784. /**
  59785. * Creates a Highlight layer from parsed Highlight layer data
  59786. * @param parsedHightlightLayer defines the Highlight layer data
  59787. * @param scene defines the current scene
  59788. * @param rootUrl defines the root URL containing the Highlight layer information
  59789. * @returns a parsed Highlight layer
  59790. */
  59791. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  59792. }
  59793. }
  59794. declare module "babylonjs/Layers/layerSceneComponent" {
  59795. import { Scene } from "babylonjs/scene";
  59796. import { ISceneComponent } from "babylonjs/sceneComponent";
  59797. import { Layer } from "babylonjs/Layers/layer";
  59798. import { AbstractScene } from "babylonjs/abstractScene";
  59799. module "babylonjs/abstractScene" {
  59800. interface AbstractScene {
  59801. /**
  59802. * The list of layers (background and foreground) of the scene
  59803. */
  59804. layers: Array<Layer>;
  59805. }
  59806. }
  59807. /**
  59808. * Defines the layer scene component responsible to manage any layers
  59809. * in a given scene.
  59810. */
  59811. export class LayerSceneComponent implements ISceneComponent {
  59812. /**
  59813. * The component name helpfull to identify the component in the list of scene components.
  59814. */
  59815. readonly name: string;
  59816. /**
  59817. * The scene the component belongs to.
  59818. */
  59819. scene: Scene;
  59820. private _engine;
  59821. /**
  59822. * Creates a new instance of the component for the given scene
  59823. * @param scene Defines the scene to register the component in
  59824. */
  59825. constructor(scene: Scene);
  59826. /**
  59827. * Registers the component in a given scene
  59828. */
  59829. register(): void;
  59830. /**
  59831. * Rebuilds the elements related to this component in case of
  59832. * context lost for instance.
  59833. */
  59834. rebuild(): void;
  59835. /**
  59836. * Disposes the component and the associated ressources.
  59837. */
  59838. dispose(): void;
  59839. private _draw;
  59840. private _drawCameraPredicate;
  59841. private _drawCameraBackground;
  59842. private _drawCameraForeground;
  59843. private _drawRenderTargetPredicate;
  59844. private _drawRenderTargetBackground;
  59845. private _drawRenderTargetForeground;
  59846. /**
  59847. * Adds all the elements from the container to the scene
  59848. * @param container the container holding the elements
  59849. */
  59850. addFromContainer(container: AbstractScene): void;
  59851. /**
  59852. * Removes all the elements in the container from the scene
  59853. * @param container contains the elements to remove
  59854. * @param dispose if the removed element should be disposed (default: false)
  59855. */
  59856. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59857. }
  59858. }
  59859. declare module "babylonjs/Shaders/layer.fragment" {
  59860. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59861. /** @hidden */
  59862. export var layerPixelShader: {
  59863. name: string;
  59864. shader: string;
  59865. };
  59866. }
  59867. declare module "babylonjs/Shaders/layer.vertex" {
  59868. /** @hidden */
  59869. export var layerVertexShader: {
  59870. name: string;
  59871. shader: string;
  59872. };
  59873. }
  59874. declare module "babylonjs/Layers/layer" {
  59875. import { Observable } from "babylonjs/Misc/observable";
  59876. import { Nullable } from "babylonjs/types";
  59877. import { Scene } from "babylonjs/scene";
  59878. import { Vector2 } from "babylonjs/Maths/math.vector";
  59879. import { Color4 } from "babylonjs/Maths/math.color";
  59880. import { Texture } from "babylonjs/Materials/Textures/texture";
  59881. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  59882. import "babylonjs/Shaders/layer.fragment";
  59883. import "babylonjs/Shaders/layer.vertex";
  59884. /**
  59885. * This represents a full screen 2d layer.
  59886. * This can be useful to display a picture in the background of your scene for instance.
  59887. * @see https://www.babylonjs-playground.com/#08A2BS#1
  59888. */
  59889. export class Layer {
  59890. /**
  59891. * Define the name of the layer.
  59892. */
  59893. name: string;
  59894. /**
  59895. * Define the texture the layer should display.
  59896. */
  59897. texture: Nullable<Texture>;
  59898. /**
  59899. * Is the layer in background or foreground.
  59900. */
  59901. isBackground: boolean;
  59902. /**
  59903. * Define the color of the layer (instead of texture).
  59904. */
  59905. color: Color4;
  59906. /**
  59907. * Define the scale of the layer in order to zoom in out of the texture.
  59908. */
  59909. scale: Vector2;
  59910. /**
  59911. * Define an offset for the layer in order to shift the texture.
  59912. */
  59913. offset: Vector2;
  59914. /**
  59915. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  59916. */
  59917. alphaBlendingMode: number;
  59918. /**
  59919. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  59920. * Alpha test will not mix with the background color in case of transparency.
  59921. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  59922. */
  59923. alphaTest: boolean;
  59924. /**
  59925. * Define a mask to restrict the layer to only some of the scene cameras.
  59926. */
  59927. layerMask: number;
  59928. /**
  59929. * Define the list of render target the layer is visible into.
  59930. */
  59931. renderTargetTextures: RenderTargetTexture[];
  59932. /**
  59933. * Define if the layer is only used in renderTarget or if it also
  59934. * renders in the main frame buffer of the canvas.
  59935. */
  59936. renderOnlyInRenderTargetTextures: boolean;
  59937. private _scene;
  59938. private _vertexBuffers;
  59939. private _indexBuffer;
  59940. private _effect;
  59941. private _previousDefines;
  59942. /**
  59943. * An event triggered when the layer is disposed.
  59944. */
  59945. onDisposeObservable: Observable<Layer>;
  59946. private _onDisposeObserver;
  59947. /**
  59948. * Back compatibility with callback before the onDisposeObservable existed.
  59949. * The set callback will be triggered when the layer has been disposed.
  59950. */
  59951. set onDispose(callback: () => void);
  59952. /**
  59953. * An event triggered before rendering the scene
  59954. */
  59955. onBeforeRenderObservable: Observable<Layer>;
  59956. private _onBeforeRenderObserver;
  59957. /**
  59958. * Back compatibility with callback before the onBeforeRenderObservable existed.
  59959. * The set callback will be triggered just before rendering the layer.
  59960. */
  59961. set onBeforeRender(callback: () => void);
  59962. /**
  59963. * An event triggered after rendering the scene
  59964. */
  59965. onAfterRenderObservable: Observable<Layer>;
  59966. private _onAfterRenderObserver;
  59967. /**
  59968. * Back compatibility with callback before the onAfterRenderObservable existed.
  59969. * The set callback will be triggered just after rendering the layer.
  59970. */
  59971. set onAfterRender(callback: () => void);
  59972. /**
  59973. * Instantiates a new layer.
  59974. * This represents a full screen 2d layer.
  59975. * This can be useful to display a picture in the background of your scene for instance.
  59976. * @see https://www.babylonjs-playground.com/#08A2BS#1
  59977. * @param name Define the name of the layer in the scene
  59978. * @param imgUrl Define the url of the texture to display in the layer
  59979. * @param scene Define the scene the layer belongs to
  59980. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  59981. * @param color Defines a color for the layer
  59982. */
  59983. constructor(
  59984. /**
  59985. * Define the name of the layer.
  59986. */
  59987. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  59988. private _createIndexBuffer;
  59989. /** @hidden */
  59990. _rebuild(): void;
  59991. /**
  59992. * Renders the layer in the scene.
  59993. */
  59994. render(): void;
  59995. /**
  59996. * Disposes and releases the associated ressources.
  59997. */
  59998. dispose(): void;
  59999. }
  60000. }
  60001. declare module "babylonjs/Layers/index" {
  60002. export * from "babylonjs/Layers/effectLayer";
  60003. export * from "babylonjs/Layers/effectLayerSceneComponent";
  60004. export * from "babylonjs/Layers/glowLayer";
  60005. export * from "babylonjs/Layers/highlightLayer";
  60006. export * from "babylonjs/Layers/layer";
  60007. export * from "babylonjs/Layers/layerSceneComponent";
  60008. }
  60009. declare module "babylonjs/Shaders/lensFlare.fragment" {
  60010. /** @hidden */
  60011. export var lensFlarePixelShader: {
  60012. name: string;
  60013. shader: string;
  60014. };
  60015. }
  60016. declare module "babylonjs/Shaders/lensFlare.vertex" {
  60017. /** @hidden */
  60018. export var lensFlareVertexShader: {
  60019. name: string;
  60020. shader: string;
  60021. };
  60022. }
  60023. declare module "babylonjs/LensFlares/lensFlareSystem" {
  60024. import { Scene } from "babylonjs/scene";
  60025. import { Vector3 } from "babylonjs/Maths/math.vector";
  60026. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60027. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  60028. import "babylonjs/Shaders/lensFlare.fragment";
  60029. import "babylonjs/Shaders/lensFlare.vertex";
  60030. import { Viewport } from "babylonjs/Maths/math.viewport";
  60031. /**
  60032. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  60033. * It is usually composed of several `lensFlare`.
  60034. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60035. */
  60036. export class LensFlareSystem {
  60037. /**
  60038. * Define the name of the lens flare system
  60039. */
  60040. name: string;
  60041. /**
  60042. * List of lens flares used in this system.
  60043. */
  60044. lensFlares: LensFlare[];
  60045. /**
  60046. * Define a limit from the border the lens flare can be visible.
  60047. */
  60048. borderLimit: number;
  60049. /**
  60050. * Define a viewport border we do not want to see the lens flare in.
  60051. */
  60052. viewportBorder: number;
  60053. /**
  60054. * Define a predicate which could limit the list of meshes able to occlude the effect.
  60055. */
  60056. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  60057. /**
  60058. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  60059. */
  60060. layerMask: number;
  60061. /**
  60062. * Define the id of the lens flare system in the scene.
  60063. * (equal to name by default)
  60064. */
  60065. id: string;
  60066. private _scene;
  60067. private _emitter;
  60068. private _vertexBuffers;
  60069. private _indexBuffer;
  60070. private _effect;
  60071. private _positionX;
  60072. private _positionY;
  60073. private _isEnabled;
  60074. /** @hidden */
  60075. static _SceneComponentInitialization: (scene: Scene) => void;
  60076. /**
  60077. * Instantiates a lens flare system.
  60078. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  60079. * It is usually composed of several `lensFlare`.
  60080. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60081. * @param name Define the name of the lens flare system in the scene
  60082. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  60083. * @param scene Define the scene the lens flare system belongs to
  60084. */
  60085. constructor(
  60086. /**
  60087. * Define the name of the lens flare system
  60088. */
  60089. name: string, emitter: any, scene: Scene);
  60090. /**
  60091. * Define if the lens flare system is enabled.
  60092. */
  60093. get isEnabled(): boolean;
  60094. set isEnabled(value: boolean);
  60095. /**
  60096. * Get the scene the effects belongs to.
  60097. * @returns the scene holding the lens flare system
  60098. */
  60099. getScene(): Scene;
  60100. /**
  60101. * Get the emitter of the lens flare system.
  60102. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  60103. * @returns the emitter of the lens flare system
  60104. */
  60105. getEmitter(): any;
  60106. /**
  60107. * Set the emitter of the lens flare system.
  60108. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  60109. * @param newEmitter Define the new emitter of the system
  60110. */
  60111. setEmitter(newEmitter: any): void;
  60112. /**
  60113. * Get the lens flare system emitter position.
  60114. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  60115. * @returns the position
  60116. */
  60117. getEmitterPosition(): Vector3;
  60118. /**
  60119. * @hidden
  60120. */
  60121. computeEffectivePosition(globalViewport: Viewport): boolean;
  60122. /** @hidden */
  60123. _isVisible(): boolean;
  60124. /**
  60125. * @hidden
  60126. */
  60127. render(): boolean;
  60128. /**
  60129. * Dispose and release the lens flare with its associated resources.
  60130. */
  60131. dispose(): void;
  60132. /**
  60133. * Parse a lens flare system from a JSON repressentation
  60134. * @param parsedLensFlareSystem Define the JSON to parse
  60135. * @param scene Define the scene the parsed system should be instantiated in
  60136. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  60137. * @returns the parsed system
  60138. */
  60139. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  60140. /**
  60141. * Serialize the current Lens Flare System into a JSON representation.
  60142. * @returns the serialized JSON
  60143. */
  60144. serialize(): any;
  60145. }
  60146. }
  60147. declare module "babylonjs/LensFlares/lensFlare" {
  60148. import { Nullable } from "babylonjs/types";
  60149. import { Color3 } from "babylonjs/Maths/math.color";
  60150. import { Texture } from "babylonjs/Materials/Textures/texture";
  60151. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  60152. /**
  60153. * This represents one of the lens effect in a `lensFlareSystem`.
  60154. * It controls one of the indiviual texture used in the effect.
  60155. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60156. */
  60157. export class LensFlare {
  60158. /**
  60159. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  60160. */
  60161. size: number;
  60162. /**
  60163. * 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.
  60164. */
  60165. position: number;
  60166. /**
  60167. * Define the lens color.
  60168. */
  60169. color: Color3;
  60170. /**
  60171. * Define the lens texture.
  60172. */
  60173. texture: Nullable<Texture>;
  60174. /**
  60175. * Define the alpha mode to render this particular lens.
  60176. */
  60177. alphaMode: number;
  60178. private _system;
  60179. /**
  60180. * Creates a new Lens Flare.
  60181. * This represents one of the lens effect in a `lensFlareSystem`.
  60182. * It controls one of the indiviual texture used in the effect.
  60183. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60184. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  60185. * @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.
  60186. * @param color Define the lens color
  60187. * @param imgUrl Define the lens texture url
  60188. * @param system Define the `lensFlareSystem` this flare is part of
  60189. * @returns The newly created Lens Flare
  60190. */
  60191. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  60192. /**
  60193. * Instantiates a new Lens Flare.
  60194. * This represents one of the lens effect in a `lensFlareSystem`.
  60195. * It controls one of the indiviual texture used in the effect.
  60196. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60197. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  60198. * @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.
  60199. * @param color Define the lens color
  60200. * @param imgUrl Define the lens texture url
  60201. * @param system Define the `lensFlareSystem` this flare is part of
  60202. */
  60203. constructor(
  60204. /**
  60205. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  60206. */
  60207. size: number,
  60208. /**
  60209. * 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.
  60210. */
  60211. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  60212. /**
  60213. * Dispose and release the lens flare with its associated resources.
  60214. */
  60215. dispose(): void;
  60216. }
  60217. }
  60218. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  60219. import { Nullable } from "babylonjs/types";
  60220. import { Scene } from "babylonjs/scene";
  60221. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  60222. import { AbstractScene } from "babylonjs/abstractScene";
  60223. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  60224. module "babylonjs/abstractScene" {
  60225. interface AbstractScene {
  60226. /**
  60227. * The list of lens flare system added to the scene
  60228. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60229. */
  60230. lensFlareSystems: Array<LensFlareSystem>;
  60231. /**
  60232. * Removes the given lens flare system from this scene.
  60233. * @param toRemove The lens flare system to remove
  60234. * @returns The index of the removed lens flare system
  60235. */
  60236. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  60237. /**
  60238. * Adds the given lens flare system to this scene
  60239. * @param newLensFlareSystem The lens flare system to add
  60240. */
  60241. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  60242. /**
  60243. * Gets a lens flare system using its name
  60244. * @param name defines the name to look for
  60245. * @returns the lens flare system or null if not found
  60246. */
  60247. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  60248. /**
  60249. * Gets a lens flare system using its id
  60250. * @param id defines the id to look for
  60251. * @returns the lens flare system or null if not found
  60252. */
  60253. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  60254. }
  60255. }
  60256. /**
  60257. * Defines the lens flare scene component responsible to manage any lens flares
  60258. * in a given scene.
  60259. */
  60260. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  60261. /**
  60262. * The component name helpfull to identify the component in the list of scene components.
  60263. */
  60264. readonly name: string;
  60265. /**
  60266. * The scene the component belongs to.
  60267. */
  60268. scene: Scene;
  60269. /**
  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. * Adds all the elements from the container to the scene
  60285. * @param container the container holding the elements
  60286. */
  60287. addFromContainer(container: AbstractScene): void;
  60288. /**
  60289. * Removes all the elements in the container from the scene
  60290. * @param container contains the elements to remove
  60291. * @param dispose if the removed element should be disposed (default: false)
  60292. */
  60293. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60294. /**
  60295. * Serializes the component data to the specified json object
  60296. * @param serializationObject The object to serialize to
  60297. */
  60298. serialize(serializationObject: any): void;
  60299. /**
  60300. * Disposes the component and the associated ressources.
  60301. */
  60302. dispose(): void;
  60303. private _draw;
  60304. }
  60305. }
  60306. declare module "babylonjs/LensFlares/index" {
  60307. export * from "babylonjs/LensFlares/lensFlare";
  60308. export * from "babylonjs/LensFlares/lensFlareSystem";
  60309. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  60310. }
  60311. declare module "babylonjs/Shaders/depth.fragment" {
  60312. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  60313. /** @hidden */
  60314. export var depthPixelShader: {
  60315. name: string;
  60316. shader: string;
  60317. };
  60318. }
  60319. declare module "babylonjs/Shaders/depth.vertex" {
  60320. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60321. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  60322. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  60323. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  60324. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  60325. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  60326. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60327. /** @hidden */
  60328. export var depthVertexShader: {
  60329. name: string;
  60330. shader: string;
  60331. };
  60332. }
  60333. declare module "babylonjs/Rendering/depthRenderer" {
  60334. import { Nullable } from "babylonjs/types";
  60335. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60336. import { Scene } from "babylonjs/scene";
  60337. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60338. import { Camera } from "babylonjs/Cameras/camera";
  60339. import "babylonjs/Shaders/depth.fragment";
  60340. import "babylonjs/Shaders/depth.vertex";
  60341. /**
  60342. * This represents a depth renderer in Babylon.
  60343. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  60344. */
  60345. export class DepthRenderer {
  60346. private _scene;
  60347. private _depthMap;
  60348. private _effect;
  60349. private readonly _storeNonLinearDepth;
  60350. private readonly _clearColor;
  60351. /** Get if the depth renderer is using packed depth or not */
  60352. readonly isPacked: boolean;
  60353. private _cachedDefines;
  60354. private _camera;
  60355. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  60356. enabled: boolean;
  60357. /**
  60358. * Specifiess that the depth renderer will only be used within
  60359. * the camera it is created for.
  60360. * This can help forcing its rendering during the camera processing.
  60361. */
  60362. useOnlyInActiveCamera: boolean;
  60363. /** @hidden */
  60364. static _SceneComponentInitialization: (scene: Scene) => void;
  60365. /**
  60366. * Instantiates a depth renderer
  60367. * @param scene The scene the renderer belongs to
  60368. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  60369. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  60370. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  60371. */
  60372. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  60373. /**
  60374. * Creates the depth rendering effect and checks if the effect is ready.
  60375. * @param subMesh The submesh to be used to render the depth map of
  60376. * @param useInstances If multiple world instances should be used
  60377. * @returns if the depth renderer is ready to render the depth map
  60378. */
  60379. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60380. /**
  60381. * Gets the texture which the depth map will be written to.
  60382. * @returns The depth map texture
  60383. */
  60384. getDepthMap(): RenderTargetTexture;
  60385. /**
  60386. * Disposes of the depth renderer.
  60387. */
  60388. dispose(): void;
  60389. }
  60390. }
  60391. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  60392. /** @hidden */
  60393. export var minmaxReduxPixelShader: {
  60394. name: string;
  60395. shader: string;
  60396. };
  60397. }
  60398. declare module "babylonjs/Misc/minMaxReducer" {
  60399. import { Nullable } from "babylonjs/types";
  60400. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60401. import { Camera } from "babylonjs/Cameras/camera";
  60402. import { Observer } from "babylonjs/Misc/observable";
  60403. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  60404. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  60405. import { Observable } from "babylonjs/Misc/observable";
  60406. import "babylonjs/Shaders/minmaxRedux.fragment";
  60407. /**
  60408. * This class computes a min/max reduction from a texture: it means it computes the minimum
  60409. * and maximum values from all values of the texture.
  60410. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  60411. * The source values are read from the red channel of the texture.
  60412. */
  60413. export class MinMaxReducer {
  60414. /**
  60415. * Observable triggered when the computation has been performed
  60416. */
  60417. onAfterReductionPerformed: Observable<{
  60418. min: number;
  60419. max: number;
  60420. }>;
  60421. protected _camera: Camera;
  60422. protected _sourceTexture: Nullable<RenderTargetTexture>;
  60423. protected _reductionSteps: Nullable<Array<PostProcess>>;
  60424. protected _postProcessManager: PostProcessManager;
  60425. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  60426. protected _forceFullscreenViewport: boolean;
  60427. /**
  60428. * Creates a min/max reducer
  60429. * @param camera The camera to use for the post processes
  60430. */
  60431. constructor(camera: Camera);
  60432. /**
  60433. * Gets the texture used to read the values from.
  60434. */
  60435. get sourceTexture(): Nullable<RenderTargetTexture>;
  60436. /**
  60437. * Sets the source texture to read the values from.
  60438. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  60439. * because in such textures '1' value must not be taken into account to compute the maximum
  60440. * as this value is used to clear the texture.
  60441. * Note that the computation is not activated by calling this function, you must call activate() for that!
  60442. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  60443. * @param depthRedux Indicates if the texture is a depth texture or not
  60444. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  60445. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  60446. */
  60447. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  60448. /**
  60449. * Defines the refresh rate of the computation.
  60450. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  60451. */
  60452. get refreshRate(): number;
  60453. set refreshRate(value: number);
  60454. protected _activated: boolean;
  60455. /**
  60456. * Gets the activation status of the reducer
  60457. */
  60458. get activated(): boolean;
  60459. /**
  60460. * Activates the reduction computation.
  60461. * When activated, the observers registered in onAfterReductionPerformed are
  60462. * called after the compuation is performed
  60463. */
  60464. activate(): void;
  60465. /**
  60466. * Deactivates the reduction computation.
  60467. */
  60468. deactivate(): void;
  60469. /**
  60470. * Disposes the min/max reducer
  60471. * @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.
  60472. */
  60473. dispose(disposeAll?: boolean): void;
  60474. }
  60475. }
  60476. declare module "babylonjs/Misc/depthReducer" {
  60477. import { Nullable } from "babylonjs/types";
  60478. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60479. import { Camera } from "babylonjs/Cameras/camera";
  60480. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  60481. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  60482. /**
  60483. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  60484. */
  60485. export class DepthReducer extends MinMaxReducer {
  60486. private _depthRenderer;
  60487. private _depthRendererId;
  60488. /**
  60489. * Gets the depth renderer used for the computation.
  60490. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  60491. */
  60492. get depthRenderer(): Nullable<DepthRenderer>;
  60493. /**
  60494. * Creates a depth reducer
  60495. * @param camera The camera used to render the depth texture
  60496. */
  60497. constructor(camera: Camera);
  60498. /**
  60499. * Sets the depth renderer to use to generate the depth map
  60500. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  60501. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  60502. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  60503. */
  60504. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  60505. /** @hidden */
  60506. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  60507. /**
  60508. * Activates the reduction computation.
  60509. * When activated, the observers registered in onAfterReductionPerformed are
  60510. * called after the compuation is performed
  60511. */
  60512. activate(): void;
  60513. /**
  60514. * Deactivates the reduction computation.
  60515. */
  60516. deactivate(): void;
  60517. /**
  60518. * Disposes the depth reducer
  60519. * @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.
  60520. */
  60521. dispose(disposeAll?: boolean): void;
  60522. }
  60523. }
  60524. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  60525. import { Nullable } from "babylonjs/types";
  60526. import { Scene } from "babylonjs/scene";
  60527. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  60528. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60529. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60530. import { Effect } from "babylonjs/Materials/effect";
  60531. import "babylonjs/Shaders/shadowMap.fragment";
  60532. import "babylonjs/Shaders/shadowMap.vertex";
  60533. import "babylonjs/Shaders/depthBoxBlur.fragment";
  60534. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  60535. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  60536. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  60537. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  60538. /**
  60539. * A CSM implementation allowing casting shadows on large scenes.
  60540. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  60541. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  60542. */
  60543. export class CascadedShadowGenerator extends ShadowGenerator {
  60544. private static readonly frustumCornersNDCSpace;
  60545. /**
  60546. * Name of the CSM class
  60547. */
  60548. static CLASSNAME: string;
  60549. /**
  60550. * Defines the default number of cascades used by the CSM.
  60551. */
  60552. static readonly DEFAULT_CASCADES_COUNT: number;
  60553. /**
  60554. * Defines the minimum number of cascades used by the CSM.
  60555. */
  60556. static readonly MIN_CASCADES_COUNT: number;
  60557. /**
  60558. * Defines the maximum number of cascades used by the CSM.
  60559. */
  60560. static readonly MAX_CASCADES_COUNT: number;
  60561. protected _validateFilter(filter: number): number;
  60562. /**
  60563. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  60564. */
  60565. penumbraDarkness: number;
  60566. private _numCascades;
  60567. /**
  60568. * Gets or set the number of cascades used by the CSM.
  60569. */
  60570. get numCascades(): number;
  60571. set numCascades(value: number);
  60572. /**
  60573. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  60574. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  60575. */
  60576. stabilizeCascades: boolean;
  60577. private _freezeShadowCastersBoundingInfo;
  60578. private _freezeShadowCastersBoundingInfoObservable;
  60579. /**
  60580. * Enables or disables the shadow casters bounding info computation.
  60581. * If your shadow casters don't move, you can disable this feature.
  60582. * If it is enabled, the bounding box computation is done every frame.
  60583. */
  60584. get freezeShadowCastersBoundingInfo(): boolean;
  60585. set freezeShadowCastersBoundingInfo(freeze: boolean);
  60586. private _scbiMin;
  60587. private _scbiMax;
  60588. protected _computeShadowCastersBoundingInfo(): void;
  60589. protected _shadowCastersBoundingInfo: BoundingInfo;
  60590. /**
  60591. * Gets or sets the shadow casters bounding info.
  60592. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  60593. * so that the system won't overwrite the bounds you provide
  60594. */
  60595. get shadowCastersBoundingInfo(): BoundingInfo;
  60596. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  60597. protected _breaksAreDirty: boolean;
  60598. protected _minDistance: number;
  60599. protected _maxDistance: number;
  60600. /**
  60601. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  60602. *
  60603. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  60604. * If you don't know these values, simply leave them to their defaults and don't call this function.
  60605. * @param min minimal distance for the breaks (default to 0.)
  60606. * @param max maximal distance for the breaks (default to 1.)
  60607. */
  60608. setMinMaxDistance(min: number, max: number): void;
  60609. /** Gets the minimal distance used in the cascade break computation */
  60610. get minDistance(): number;
  60611. /** Gets the maximal distance used in the cascade break computation */
  60612. get maxDistance(): number;
  60613. /**
  60614. * Gets the class name of that object
  60615. * @returns "CascadedShadowGenerator"
  60616. */
  60617. getClassName(): string;
  60618. private _cascadeMinExtents;
  60619. private _cascadeMaxExtents;
  60620. /**
  60621. * Gets a cascade minimum extents
  60622. * @param cascadeIndex index of the cascade
  60623. * @returns the minimum cascade extents
  60624. */
  60625. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  60626. /**
  60627. * Gets a cascade maximum extents
  60628. * @param cascadeIndex index of the cascade
  60629. * @returns the maximum cascade extents
  60630. */
  60631. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  60632. private _cascades;
  60633. private _currentLayer;
  60634. private _viewSpaceFrustumsZ;
  60635. private _viewMatrices;
  60636. private _projectionMatrices;
  60637. private _transformMatrices;
  60638. private _transformMatricesAsArray;
  60639. private _frustumLengths;
  60640. private _lightSizeUVCorrection;
  60641. private _depthCorrection;
  60642. private _frustumCornersWorldSpace;
  60643. private _frustumCenter;
  60644. private _shadowCameraPos;
  60645. private _shadowMaxZ;
  60646. /**
  60647. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  60648. * It defaults to camera.maxZ
  60649. */
  60650. get shadowMaxZ(): number;
  60651. /**
  60652. * Sets the shadow max z distance.
  60653. */
  60654. set shadowMaxZ(value: number);
  60655. protected _debug: boolean;
  60656. /**
  60657. * Gets or sets the debug flag.
  60658. * When enabled, the cascades are materialized by different colors on the screen.
  60659. */
  60660. get debug(): boolean;
  60661. set debug(dbg: boolean);
  60662. private _depthClamp;
  60663. /**
  60664. * Gets or sets the depth clamping value.
  60665. *
  60666. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  60667. * to account for the shadow casters far away.
  60668. *
  60669. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  60670. */
  60671. get depthClamp(): boolean;
  60672. set depthClamp(value: boolean);
  60673. private _cascadeBlendPercentage;
  60674. /**
  60675. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  60676. * It defaults to 0.1 (10% blending).
  60677. */
  60678. get cascadeBlendPercentage(): number;
  60679. set cascadeBlendPercentage(value: number);
  60680. private _lambda;
  60681. /**
  60682. * Gets or set the lambda parameter.
  60683. * This parameter is used to split the camera frustum and create the cascades.
  60684. * 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.
  60685. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  60686. */
  60687. get lambda(): number;
  60688. set lambda(value: number);
  60689. /**
  60690. * Gets the view matrix corresponding to a given cascade
  60691. * @param cascadeNum cascade to retrieve the view matrix from
  60692. * @returns the cascade view matrix
  60693. */
  60694. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  60695. /**
  60696. * Gets the projection matrix corresponding to a given cascade
  60697. * @param cascadeNum cascade to retrieve the projection matrix from
  60698. * @returns the cascade projection matrix
  60699. */
  60700. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  60701. /**
  60702. * Gets the transformation matrix corresponding to a given cascade
  60703. * @param cascadeNum cascade to retrieve the transformation matrix from
  60704. * @returns the cascade transformation matrix
  60705. */
  60706. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  60707. private _depthRenderer;
  60708. /**
  60709. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  60710. *
  60711. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  60712. *
  60713. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  60714. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  60715. * @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
  60716. */
  60717. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  60718. private _depthReducer;
  60719. private _autoCalcDepthBounds;
  60720. /**
  60721. * Gets or sets the autoCalcDepthBounds property.
  60722. *
  60723. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  60724. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  60725. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  60726. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  60727. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  60728. */
  60729. get autoCalcDepthBounds(): boolean;
  60730. set autoCalcDepthBounds(value: boolean);
  60731. /**
  60732. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  60733. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  60734. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  60735. * for setting the refresh rate on the renderer yourself!
  60736. */
  60737. get autoCalcDepthBoundsRefreshRate(): number;
  60738. set autoCalcDepthBoundsRefreshRate(value: number);
  60739. /**
  60740. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  60741. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  60742. * you change the camera near/far planes!
  60743. */
  60744. splitFrustum(): void;
  60745. private _splitFrustum;
  60746. private _computeMatrices;
  60747. private _computeFrustumInWorldSpace;
  60748. private _computeCascadeFrustum;
  60749. /**
  60750. * Support test.
  60751. */
  60752. static get IsSupported(): boolean;
  60753. /** @hidden */
  60754. static _SceneComponentInitialization: (scene: Scene) => void;
  60755. /**
  60756. * Creates a Cascaded Shadow Generator object.
  60757. * A ShadowGenerator is the required tool to use the shadows.
  60758. * Each directional light casting shadows needs to use its own ShadowGenerator.
  60759. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  60760. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  60761. * @param light The directional light object generating the shadows.
  60762. * @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.
  60763. */
  60764. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  60765. protected _initializeGenerator(): void;
  60766. protected _createTargetRenderTexture(): void;
  60767. protected _initializeShadowMap(): void;
  60768. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  60769. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  60770. /**
  60771. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  60772. * @param defines Defines of the material we want to update
  60773. * @param lightIndex Index of the light in the enabled light list of the material
  60774. */
  60775. prepareDefines(defines: any, lightIndex: number): void;
  60776. /**
  60777. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  60778. * defined in the generator but impacting the effect).
  60779. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  60780. * @param effect The effect we are binfing the information for
  60781. */
  60782. bindShadowLight(lightIndex: string, effect: Effect): void;
  60783. /**
  60784. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  60785. * (eq to view projection * shadow projection matrices)
  60786. * @returns The transform matrix used to create the shadow map
  60787. */
  60788. getTransformMatrix(): Matrix;
  60789. /**
  60790. * Disposes the ShadowGenerator.
  60791. * Returns nothing.
  60792. */
  60793. dispose(): void;
  60794. /**
  60795. * Serializes the shadow generator setup to a json object.
  60796. * @returns The serialized JSON object
  60797. */
  60798. serialize(): any;
  60799. /**
  60800. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  60801. * @param parsedShadowGenerator The JSON object to parse
  60802. * @param scene The scene to create the shadow map for
  60803. * @returns The parsed shadow generator
  60804. */
  60805. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  60806. }
  60807. }
  60808. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  60809. import { Scene } from "babylonjs/scene";
  60810. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  60811. import { AbstractScene } from "babylonjs/abstractScene";
  60812. /**
  60813. * Defines the shadow generator component responsible to manage any shadow generators
  60814. * in a given scene.
  60815. */
  60816. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  60817. /**
  60818. * The component name helpfull to identify the component in the list of scene components.
  60819. */
  60820. readonly name: string;
  60821. /**
  60822. * The scene the component belongs to.
  60823. */
  60824. scene: Scene;
  60825. /**
  60826. * Creates a new instance of the component for the given scene
  60827. * @param scene Defines the scene to register the component in
  60828. */
  60829. constructor(scene: Scene);
  60830. /**
  60831. * Registers the component in a given scene
  60832. */
  60833. register(): void;
  60834. /**
  60835. * Rebuilds the elements related to this component in case of
  60836. * context lost for instance.
  60837. */
  60838. rebuild(): void;
  60839. /**
  60840. * Serializes the component data to the specified json object
  60841. * @param serializationObject The object to serialize to
  60842. */
  60843. serialize(serializationObject: any): void;
  60844. /**
  60845. * Adds all the elements from the container to the scene
  60846. * @param container the container holding the elements
  60847. */
  60848. addFromContainer(container: AbstractScene): void;
  60849. /**
  60850. * Removes all the elements in the container from the scene
  60851. * @param container contains the elements to remove
  60852. * @param dispose if the removed element should be disposed (default: false)
  60853. */
  60854. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60855. /**
  60856. * Rebuilds the elements related to this component in case of
  60857. * context lost for instance.
  60858. */
  60859. dispose(): void;
  60860. private _gatherRenderTargets;
  60861. }
  60862. }
  60863. declare module "babylonjs/Lights/Shadows/index" {
  60864. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  60865. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  60866. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  60867. }
  60868. declare module "babylonjs/Lights/pointLight" {
  60869. import { Scene } from "babylonjs/scene";
  60870. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  60871. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60872. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  60873. import { Effect } from "babylonjs/Materials/effect";
  60874. /**
  60875. * A point light is a light defined by an unique point in world space.
  60876. * The light is emitted in every direction from this point.
  60877. * A good example of a point light is a standard light bulb.
  60878. * Documentation: https://doc.babylonjs.com/babylon101/lights
  60879. */
  60880. export class PointLight extends ShadowLight {
  60881. private _shadowAngle;
  60882. /**
  60883. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60884. * This specifies what angle the shadow will use to be created.
  60885. *
  60886. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  60887. */
  60888. get shadowAngle(): number;
  60889. /**
  60890. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60891. * This specifies what angle the shadow will use to be created.
  60892. *
  60893. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  60894. */
  60895. set shadowAngle(value: number);
  60896. /**
  60897. * Gets the direction if it has been set.
  60898. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60899. */
  60900. get direction(): Vector3;
  60901. /**
  60902. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60903. */
  60904. set direction(value: Vector3);
  60905. /**
  60906. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  60907. * A PointLight emits the light in every direction.
  60908. * It can cast shadows.
  60909. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  60910. * ```javascript
  60911. * var pointLight = new PointLight("pl", camera.position, scene);
  60912. * ```
  60913. * Documentation : https://doc.babylonjs.com/babylon101/lights
  60914. * @param name The light friendly name
  60915. * @param position The position of the point light in the scene
  60916. * @param scene The scene the lights belongs to
  60917. */
  60918. constructor(name: string, position: Vector3, scene: Scene);
  60919. /**
  60920. * Returns the string "PointLight"
  60921. * @returns the class name
  60922. */
  60923. getClassName(): string;
  60924. /**
  60925. * Returns the integer 0.
  60926. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  60927. */
  60928. getTypeID(): number;
  60929. /**
  60930. * Specifies wether or not the shadowmap should be a cube texture.
  60931. * @returns true if the shadowmap needs to be a cube texture.
  60932. */
  60933. needCube(): boolean;
  60934. /**
  60935. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  60936. * @param faceIndex The index of the face we are computed the direction to generate shadow
  60937. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  60938. */
  60939. getShadowDirection(faceIndex?: number): Vector3;
  60940. /**
  60941. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  60942. * - fov = PI / 2
  60943. * - aspect ratio : 1.0
  60944. * - z-near and far equal to the active camera minZ and maxZ.
  60945. * Returns the PointLight.
  60946. */
  60947. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  60948. protected _buildUniformLayout(): void;
  60949. /**
  60950. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  60951. * @param effect The effect to update
  60952. * @param lightIndex The index of the light in the effect to update
  60953. * @returns The point light
  60954. */
  60955. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  60956. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  60957. /**
  60958. * Prepares the list of defines specific to the light type.
  60959. * @param defines the list of defines
  60960. * @param lightIndex defines the index of the light for the effect
  60961. */
  60962. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  60963. }
  60964. }
  60965. declare module "babylonjs/Lights/index" {
  60966. export * from "babylonjs/Lights/light";
  60967. export * from "babylonjs/Lights/shadowLight";
  60968. export * from "babylonjs/Lights/Shadows/index";
  60969. export * from "babylonjs/Lights/directionalLight";
  60970. export * from "babylonjs/Lights/hemisphericLight";
  60971. export * from "babylonjs/Lights/pointLight";
  60972. export * from "babylonjs/Lights/spotLight";
  60973. }
  60974. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  60975. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  60976. /**
  60977. * Header information of HDR texture files.
  60978. */
  60979. export interface HDRInfo {
  60980. /**
  60981. * The height of the texture in pixels.
  60982. */
  60983. height: number;
  60984. /**
  60985. * The width of the texture in pixels.
  60986. */
  60987. width: number;
  60988. /**
  60989. * The index of the beginning of the data in the binary file.
  60990. */
  60991. dataPosition: number;
  60992. }
  60993. /**
  60994. * This groups tools to convert HDR texture to native colors array.
  60995. */
  60996. export class HDRTools {
  60997. private static Ldexp;
  60998. private static Rgbe2float;
  60999. private static readStringLine;
  61000. /**
  61001. * Reads header information from an RGBE texture stored in a native array.
  61002. * More information on this format are available here:
  61003. * https://en.wikipedia.org/wiki/RGBE_image_format
  61004. *
  61005. * @param uint8array The binary file stored in native array.
  61006. * @return The header information.
  61007. */
  61008. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  61009. /**
  61010. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  61011. * This RGBE texture needs to store the information as a panorama.
  61012. *
  61013. * More information on this format are available here:
  61014. * https://en.wikipedia.org/wiki/RGBE_image_format
  61015. *
  61016. * @param buffer The binary file stored in an array buffer.
  61017. * @param size The expected size of the extracted cubemap.
  61018. * @return The Cube Map information.
  61019. */
  61020. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  61021. /**
  61022. * Returns the pixels data extracted from an RGBE texture.
  61023. * This pixels will be stored left to right up to down in the R G B order in one array.
  61024. *
  61025. * More information on this format are available here:
  61026. * https://en.wikipedia.org/wiki/RGBE_image_format
  61027. *
  61028. * @param uint8array The binary file stored in an array buffer.
  61029. * @param hdrInfo The header information of the file.
  61030. * @return The pixels data in RGB right to left up to down order.
  61031. */
  61032. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  61033. private static RGBE_ReadPixels_RLE;
  61034. }
  61035. }
  61036. declare module "babylonjs/Materials/effectRenderer" {
  61037. import { Nullable } from "babylonjs/types";
  61038. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61039. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61040. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  61041. import { Viewport } from "babylonjs/Maths/math.viewport";
  61042. import { Observable } from "babylonjs/Misc/observable";
  61043. import { Effect } from "babylonjs/Materials/effect";
  61044. import "babylonjs/Shaders/postprocess.vertex";
  61045. /**
  61046. * Effect Render Options
  61047. */
  61048. export interface IEffectRendererOptions {
  61049. /**
  61050. * Defines the vertices positions.
  61051. */
  61052. positions?: number[];
  61053. /**
  61054. * Defines the indices.
  61055. */
  61056. indices?: number[];
  61057. }
  61058. /**
  61059. * Helper class to render one or more effects.
  61060. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  61061. */
  61062. export class EffectRenderer {
  61063. private engine;
  61064. private static _DefaultOptions;
  61065. private _vertexBuffers;
  61066. private _indexBuffer;
  61067. private _fullscreenViewport;
  61068. /**
  61069. * Creates an effect renderer
  61070. * @param engine the engine to use for rendering
  61071. * @param options defines the options of the effect renderer
  61072. */
  61073. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  61074. /**
  61075. * Sets the current viewport in normalized coordinates 0-1
  61076. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  61077. */
  61078. setViewport(viewport?: Viewport): void;
  61079. /**
  61080. * Binds the embedded attributes buffer to the effect.
  61081. * @param effect Defines the effect to bind the attributes for
  61082. */
  61083. bindBuffers(effect: Effect): void;
  61084. /**
  61085. * Sets the current effect wrapper to use during draw.
  61086. * The effect needs to be ready before calling this api.
  61087. * This also sets the default full screen position attribute.
  61088. * @param effectWrapper Defines the effect to draw with
  61089. */
  61090. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  61091. /**
  61092. * Restores engine states
  61093. */
  61094. restoreStates(): void;
  61095. /**
  61096. * Draws a full screen quad.
  61097. */
  61098. draw(): void;
  61099. private isRenderTargetTexture;
  61100. /**
  61101. * renders one or more effects to a specified texture
  61102. * @param effectWrapper the effect to renderer
  61103. * @param outputTexture texture to draw to, if null it will render to the screen.
  61104. */
  61105. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  61106. /**
  61107. * Disposes of the effect renderer
  61108. */
  61109. dispose(): void;
  61110. }
  61111. /**
  61112. * Options to create an EffectWrapper
  61113. */
  61114. interface EffectWrapperCreationOptions {
  61115. /**
  61116. * Engine to use to create the effect
  61117. */
  61118. engine: ThinEngine;
  61119. /**
  61120. * Fragment shader for the effect
  61121. */
  61122. fragmentShader: string;
  61123. /**
  61124. * Use the shader store instead of direct source code
  61125. */
  61126. useShaderStore?: boolean;
  61127. /**
  61128. * Vertex shader for the effect
  61129. */
  61130. vertexShader?: string;
  61131. /**
  61132. * Attributes to use in the shader
  61133. */
  61134. attributeNames?: Array<string>;
  61135. /**
  61136. * Uniforms to use in the shader
  61137. */
  61138. uniformNames?: Array<string>;
  61139. /**
  61140. * Texture sampler names to use in the shader
  61141. */
  61142. samplerNames?: Array<string>;
  61143. /**
  61144. * Defines to use in the shader
  61145. */
  61146. defines?: Array<string>;
  61147. /**
  61148. * Callback when effect is compiled
  61149. */
  61150. onCompiled?: Nullable<(effect: Effect) => void>;
  61151. /**
  61152. * The friendly name of the effect displayed in Spector.
  61153. */
  61154. name?: string;
  61155. }
  61156. /**
  61157. * Wraps an effect to be used for rendering
  61158. */
  61159. export class EffectWrapper {
  61160. /**
  61161. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  61162. */
  61163. onApplyObservable: Observable<{}>;
  61164. /**
  61165. * The underlying effect
  61166. */
  61167. effect: Effect;
  61168. /**
  61169. * Creates an effect to be renderer
  61170. * @param creationOptions options to create the effect
  61171. */
  61172. constructor(creationOptions: EffectWrapperCreationOptions);
  61173. /**
  61174. * Disposes of the effect wrapper
  61175. */
  61176. dispose(): void;
  61177. }
  61178. }
  61179. declare module "babylonjs/Shaders/hdrFiltering.vertex" {
  61180. /** @hidden */
  61181. export var hdrFilteringVertexShader: {
  61182. name: string;
  61183. shader: string;
  61184. };
  61185. }
  61186. declare module "babylonjs/Shaders/hdrFiltering.fragment" {
  61187. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61188. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  61189. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  61190. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  61191. /** @hidden */
  61192. export var hdrFilteringPixelShader: {
  61193. name: string;
  61194. shader: string;
  61195. };
  61196. }
  61197. declare module "babylonjs/Materials/Textures/Filtering/hdrFiltering" {
  61198. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  61199. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  61200. import { Nullable } from "babylonjs/types";
  61201. import "babylonjs/Shaders/hdrFiltering.vertex";
  61202. import "babylonjs/Shaders/hdrFiltering.fragment";
  61203. /**
  61204. * Options for texture filtering
  61205. */
  61206. interface IHDRFilteringOptions {
  61207. /**
  61208. * Scales pixel intensity for the input HDR map.
  61209. */
  61210. hdrScale?: number;
  61211. /**
  61212. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  61213. */
  61214. quality?: number;
  61215. }
  61216. /**
  61217. * Filters HDR maps to get correct renderings of PBR reflections
  61218. */
  61219. export class HDRFiltering {
  61220. private _engine;
  61221. private _effectRenderer;
  61222. private _effectWrapper;
  61223. private _lodGenerationOffset;
  61224. private _lodGenerationScale;
  61225. /**
  61226. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  61227. * you care about baking speed.
  61228. */
  61229. quality: number;
  61230. /**
  61231. * Scales pixel intensity for the input HDR map.
  61232. */
  61233. hdrScale: number;
  61234. /**
  61235. * Instantiates HDR filter for reflection maps
  61236. *
  61237. * @param engine Thin engine
  61238. * @param options Options
  61239. */
  61240. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  61241. private _createRenderTarget;
  61242. private _prefilterInternal;
  61243. private _createEffect;
  61244. /**
  61245. * Get a value indicating if the filter is ready to be used
  61246. * @param texture Texture to filter
  61247. * @returns true if the filter is ready
  61248. */
  61249. isReady(texture: BaseTexture): boolean;
  61250. /**
  61251. * Prefilters a cube texture to have mipmap levels representing roughness values.
  61252. * Prefiltering will be invoked at the end of next rendering pass.
  61253. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  61254. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  61255. * @param texture Texture to filter
  61256. * @param onFinished Callback when filtering is done
  61257. * @return Promise called when prefiltering is done
  61258. */
  61259. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  61260. }
  61261. }
  61262. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  61263. import { Nullable } from "babylonjs/types";
  61264. import { Scene } from "babylonjs/scene";
  61265. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  61266. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  61267. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  61268. import "babylonjs/Engines/Extensions/engine.rawTexture";
  61269. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  61270. /**
  61271. * This represents a texture coming from an HDR input.
  61272. *
  61273. * The only supported format is currently panorama picture stored in RGBE format.
  61274. * Example of such files can be found on HDRLib: http://hdrlib.com/
  61275. */
  61276. export class HDRCubeTexture extends BaseTexture {
  61277. private static _facesMapping;
  61278. private _generateHarmonics;
  61279. private _noMipmap;
  61280. private _prefilterOnLoad;
  61281. private _textureMatrix;
  61282. private _size;
  61283. private _onLoad;
  61284. private _onError;
  61285. /**
  61286. * The texture URL.
  61287. */
  61288. url: string;
  61289. /**
  61290. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  61291. */
  61292. coordinatesMode: number;
  61293. protected _isBlocking: boolean;
  61294. /**
  61295. * Sets wether or not the texture is blocking during loading.
  61296. */
  61297. set isBlocking(value: boolean);
  61298. /**
  61299. * Gets wether or not the texture is blocking during loading.
  61300. */
  61301. get isBlocking(): boolean;
  61302. protected _rotationY: number;
  61303. /**
  61304. * Sets texture matrix rotation angle around Y axis in radians.
  61305. */
  61306. set rotationY(value: number);
  61307. /**
  61308. * Gets texture matrix rotation angle around Y axis radians.
  61309. */
  61310. get rotationY(): number;
  61311. /**
  61312. * Gets or sets the center of the bounding box associated with the cube texture
  61313. * It must define where the camera used to render the texture was set
  61314. */
  61315. boundingBoxPosition: Vector3;
  61316. private _boundingBoxSize;
  61317. /**
  61318. * Gets or sets the size of the bounding box associated with the cube texture
  61319. * When defined, the cubemap will switch to local mode
  61320. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  61321. * @example https://www.babylonjs-playground.com/#RNASML
  61322. */
  61323. set boundingBoxSize(value: Vector3);
  61324. get boundingBoxSize(): Vector3;
  61325. /**
  61326. * Instantiates an HDRTexture from the following parameters.
  61327. *
  61328. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  61329. * @param sceneOrEngine The scene or engine the texture will be used in
  61330. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  61331. * @param noMipmap Forces to not generate the mipmap if true
  61332. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  61333. * @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)
  61334. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  61335. */
  61336. 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>);
  61337. /**
  61338. * Get the current class name of the texture useful for serialization or dynamic coding.
  61339. * @returns "HDRCubeTexture"
  61340. */
  61341. getClassName(): string;
  61342. /**
  61343. * Occurs when the file is raw .hdr file.
  61344. */
  61345. private loadTexture;
  61346. clone(): HDRCubeTexture;
  61347. delayLoad(): void;
  61348. /**
  61349. * Get the texture reflection matrix used to rotate/transform the reflection.
  61350. * @returns the reflection matrix
  61351. */
  61352. getReflectionTextureMatrix(): Matrix;
  61353. /**
  61354. * Set the texture reflection matrix used to rotate/transform the reflection.
  61355. * @param value Define the reflection matrix to set
  61356. */
  61357. setReflectionTextureMatrix(value: Matrix): void;
  61358. /**
  61359. * Parses a JSON representation of an HDR Texture in order to create the texture
  61360. * @param parsedTexture Define the JSON representation
  61361. * @param scene Define the scene the texture should be created in
  61362. * @param rootUrl Define the root url in case we need to load relative dependencies
  61363. * @returns the newly created texture after parsing
  61364. */
  61365. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  61366. serialize(): any;
  61367. }
  61368. }
  61369. declare module "babylonjs/Physics/physicsEngine" {
  61370. import { Nullable } from "babylonjs/types";
  61371. import { Vector3 } from "babylonjs/Maths/math.vector";
  61372. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  61373. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  61374. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  61375. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  61376. /**
  61377. * Class used to control physics engine
  61378. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  61379. */
  61380. export class PhysicsEngine implements IPhysicsEngine {
  61381. private _physicsPlugin;
  61382. /**
  61383. * Global value used to control the smallest number supported by the simulation
  61384. */
  61385. static Epsilon: number;
  61386. private _impostors;
  61387. private _joints;
  61388. private _subTimeStep;
  61389. /**
  61390. * Gets the gravity vector used by the simulation
  61391. */
  61392. gravity: Vector3;
  61393. /**
  61394. * Factory used to create the default physics plugin.
  61395. * @returns The default physics plugin
  61396. */
  61397. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  61398. /**
  61399. * Creates a new Physics Engine
  61400. * @param gravity defines the gravity vector used by the simulation
  61401. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  61402. */
  61403. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  61404. /**
  61405. * Sets the gravity vector used by the simulation
  61406. * @param gravity defines the gravity vector to use
  61407. */
  61408. setGravity(gravity: Vector3): void;
  61409. /**
  61410. * Set the time step of the physics engine.
  61411. * Default is 1/60.
  61412. * To slow it down, enter 1/600 for example.
  61413. * To speed it up, 1/30
  61414. * @param newTimeStep defines the new timestep to apply to this world.
  61415. */
  61416. setTimeStep(newTimeStep?: number): void;
  61417. /**
  61418. * Get the time step of the physics engine.
  61419. * @returns the current time step
  61420. */
  61421. getTimeStep(): number;
  61422. /**
  61423. * Set the sub time step of the physics engine.
  61424. * Default is 0 meaning there is no sub steps
  61425. * To increase physics resolution precision, set a small value (like 1 ms)
  61426. * @param subTimeStep defines the new sub timestep used for physics resolution.
  61427. */
  61428. setSubTimeStep(subTimeStep?: number): void;
  61429. /**
  61430. * Get the sub time step of the physics engine.
  61431. * @returns the current sub time step
  61432. */
  61433. getSubTimeStep(): number;
  61434. /**
  61435. * Release all resources
  61436. */
  61437. dispose(): void;
  61438. /**
  61439. * Gets the name of the current physics plugin
  61440. * @returns the name of the plugin
  61441. */
  61442. getPhysicsPluginName(): string;
  61443. /**
  61444. * Adding a new impostor for the impostor tracking.
  61445. * This will be done by the impostor itself.
  61446. * @param impostor the impostor to add
  61447. */
  61448. addImpostor(impostor: PhysicsImpostor): void;
  61449. /**
  61450. * Remove an impostor from the engine.
  61451. * This impostor and its mesh will not longer be updated by the physics engine.
  61452. * @param impostor the impostor to remove
  61453. */
  61454. removeImpostor(impostor: PhysicsImpostor): void;
  61455. /**
  61456. * Add a joint to the physics engine
  61457. * @param mainImpostor defines the main impostor to which the joint is added.
  61458. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  61459. * @param joint defines the joint that will connect both impostors.
  61460. */
  61461. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  61462. /**
  61463. * Removes a joint from the simulation
  61464. * @param mainImpostor defines the impostor used with the joint
  61465. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  61466. * @param joint defines the joint to remove
  61467. */
  61468. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  61469. /**
  61470. * Called by the scene. No need to call it.
  61471. * @param delta defines the timespam between frames
  61472. */
  61473. _step(delta: number): void;
  61474. /**
  61475. * Gets the current plugin used to run the simulation
  61476. * @returns current plugin
  61477. */
  61478. getPhysicsPlugin(): IPhysicsEnginePlugin;
  61479. /**
  61480. * Gets the list of physic impostors
  61481. * @returns an array of PhysicsImpostor
  61482. */
  61483. getImpostors(): Array<PhysicsImpostor>;
  61484. /**
  61485. * Gets the impostor for a physics enabled object
  61486. * @param object defines the object impersonated by the impostor
  61487. * @returns the PhysicsImpostor or null if not found
  61488. */
  61489. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  61490. /**
  61491. * Gets the impostor for a physics body object
  61492. * @param body defines physics body used by the impostor
  61493. * @returns the PhysicsImpostor or null if not found
  61494. */
  61495. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  61496. /**
  61497. * Does a raycast in the physics world
  61498. * @param from when should the ray start?
  61499. * @param to when should the ray end?
  61500. * @returns PhysicsRaycastResult
  61501. */
  61502. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  61503. }
  61504. }
  61505. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  61506. import { Nullable } from "babylonjs/types";
  61507. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  61508. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61509. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  61510. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  61511. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  61512. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  61513. /** @hidden */
  61514. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  61515. private _useDeltaForWorldStep;
  61516. world: any;
  61517. name: string;
  61518. private _physicsMaterials;
  61519. private _fixedTimeStep;
  61520. private _cannonRaycastResult;
  61521. private _raycastResult;
  61522. private _physicsBodysToRemoveAfterStep;
  61523. private _firstFrame;
  61524. BJSCANNON: any;
  61525. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  61526. setGravity(gravity: Vector3): void;
  61527. setTimeStep(timeStep: number): void;
  61528. getTimeStep(): number;
  61529. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  61530. private _removeMarkedPhysicsBodiesFromWorld;
  61531. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61532. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61533. generatePhysicsBody(impostor: PhysicsImpostor): void;
  61534. private _processChildMeshes;
  61535. removePhysicsBody(impostor: PhysicsImpostor): void;
  61536. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  61537. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  61538. private _addMaterial;
  61539. private _checkWithEpsilon;
  61540. private _createShape;
  61541. private _createHeightmap;
  61542. private _minus90X;
  61543. private _plus90X;
  61544. private _tmpPosition;
  61545. private _tmpDeltaPosition;
  61546. private _tmpUnityRotation;
  61547. private _updatePhysicsBodyTransformation;
  61548. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  61549. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  61550. isSupported(): boolean;
  61551. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61552. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61553. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61554. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61555. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  61556. getBodyMass(impostor: PhysicsImpostor): number;
  61557. getBodyFriction(impostor: PhysicsImpostor): number;
  61558. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  61559. getBodyRestitution(impostor: PhysicsImpostor): number;
  61560. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  61561. sleepBody(impostor: PhysicsImpostor): void;
  61562. wakeUpBody(impostor: PhysicsImpostor): void;
  61563. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  61564. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  61565. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  61566. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  61567. getRadius(impostor: PhysicsImpostor): number;
  61568. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  61569. dispose(): void;
  61570. private _extendNamespace;
  61571. /**
  61572. * Does a raycast in the physics world
  61573. * @param from when should the ray start?
  61574. * @param to when should the ray end?
  61575. * @returns PhysicsRaycastResult
  61576. */
  61577. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  61578. }
  61579. }
  61580. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  61581. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  61582. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  61583. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  61584. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61585. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  61586. import { Nullable } from "babylonjs/types";
  61587. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  61588. /** @hidden */
  61589. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  61590. private _useDeltaForWorldStep;
  61591. world: any;
  61592. name: string;
  61593. BJSOIMO: any;
  61594. private _raycastResult;
  61595. private _fixedTimeStep;
  61596. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  61597. setGravity(gravity: Vector3): void;
  61598. setTimeStep(timeStep: number): void;
  61599. getTimeStep(): number;
  61600. private _tmpImpostorsArray;
  61601. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  61602. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61603. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61604. generatePhysicsBody(impostor: PhysicsImpostor): void;
  61605. private _tmpPositionVector;
  61606. removePhysicsBody(impostor: PhysicsImpostor): void;
  61607. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  61608. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  61609. isSupported(): boolean;
  61610. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  61611. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  61612. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61613. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61614. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61615. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61616. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  61617. getBodyMass(impostor: PhysicsImpostor): number;
  61618. getBodyFriction(impostor: PhysicsImpostor): number;
  61619. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  61620. getBodyRestitution(impostor: PhysicsImpostor): number;
  61621. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  61622. sleepBody(impostor: PhysicsImpostor): void;
  61623. wakeUpBody(impostor: PhysicsImpostor): void;
  61624. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  61625. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  61626. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  61627. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  61628. getRadius(impostor: PhysicsImpostor): number;
  61629. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  61630. dispose(): void;
  61631. /**
  61632. * Does a raycast in the physics world
  61633. * @param from when should the ray start?
  61634. * @param to when should the ray end?
  61635. * @returns PhysicsRaycastResult
  61636. */
  61637. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  61638. }
  61639. }
  61640. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  61641. import { Nullable } from "babylonjs/types";
  61642. import { Scene } from "babylonjs/scene";
  61643. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  61644. import { Color4 } from "babylonjs/Maths/math.color";
  61645. import { Mesh } from "babylonjs/Meshes/mesh";
  61646. /**
  61647. * Class containing static functions to help procedurally build meshes
  61648. */
  61649. export class RibbonBuilder {
  61650. /**
  61651. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61652. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  61653. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  61654. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  61655. * * 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
  61656. * * 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
  61657. * * 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
  61658. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61659. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61660. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61661. * * 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
  61662. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  61663. * * 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
  61664. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  61665. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61666. * @param name defines the name of the mesh
  61667. * @param options defines the options used to create the mesh
  61668. * @param scene defines the hosting scene
  61669. * @returns the ribbon mesh
  61670. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  61671. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61672. */
  61673. static CreateRibbon(name: string, options: {
  61674. pathArray: Vector3[][];
  61675. closeArray?: boolean;
  61676. closePath?: boolean;
  61677. offset?: number;
  61678. updatable?: boolean;
  61679. sideOrientation?: number;
  61680. frontUVs?: Vector4;
  61681. backUVs?: Vector4;
  61682. instance?: Mesh;
  61683. invertUV?: boolean;
  61684. uvs?: Vector2[];
  61685. colors?: Color4[];
  61686. }, scene?: Nullable<Scene>): Mesh;
  61687. }
  61688. }
  61689. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  61690. import { Nullable } from "babylonjs/types";
  61691. import { Scene } from "babylonjs/scene";
  61692. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  61693. import { Mesh } from "babylonjs/Meshes/mesh";
  61694. /**
  61695. * Class containing static functions to help procedurally build meshes
  61696. */
  61697. export class ShapeBuilder {
  61698. /**
  61699. * 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.
  61700. * * 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.
  61701. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61702. * * 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.
  61703. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  61704. * * 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
  61705. * * 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
  61706. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  61707. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61708. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61709. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  61710. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61711. * @param name defines the name of the mesh
  61712. * @param options defines the options used to create the mesh
  61713. * @param scene defines the hosting scene
  61714. * @returns the extruded shape mesh
  61715. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61716. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61717. */
  61718. static ExtrudeShape(name: string, options: {
  61719. shape: Vector3[];
  61720. path: Vector3[];
  61721. scale?: number;
  61722. rotation?: number;
  61723. cap?: number;
  61724. updatable?: boolean;
  61725. sideOrientation?: number;
  61726. frontUVs?: Vector4;
  61727. backUVs?: Vector4;
  61728. instance?: Mesh;
  61729. invertUV?: boolean;
  61730. }, scene?: Nullable<Scene>): Mesh;
  61731. /**
  61732. * Creates an custom extruded shape mesh.
  61733. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  61734. * * 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.
  61735. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61736. * * 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
  61737. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  61738. * * 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
  61739. * * It must returns a float value that will be the scale value applied to the shape on each path point
  61740. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  61741. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  61742. * * 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
  61743. * * 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
  61744. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  61745. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61746. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61747. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61748. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61749. * @param name defines the name of the mesh
  61750. * @param options defines the options used to create the mesh
  61751. * @param scene defines the hosting scene
  61752. * @returns the custom extruded shape mesh
  61753. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  61754. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61755. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61756. */
  61757. static ExtrudeShapeCustom(name: string, options: {
  61758. shape: Vector3[];
  61759. path: Vector3[];
  61760. scaleFunction?: any;
  61761. rotationFunction?: any;
  61762. ribbonCloseArray?: boolean;
  61763. ribbonClosePath?: boolean;
  61764. cap?: number;
  61765. updatable?: boolean;
  61766. sideOrientation?: number;
  61767. frontUVs?: Vector4;
  61768. backUVs?: Vector4;
  61769. instance?: Mesh;
  61770. invertUV?: boolean;
  61771. }, scene?: Nullable<Scene>): Mesh;
  61772. private static _ExtrudeShapeGeneric;
  61773. }
  61774. }
  61775. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  61776. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  61777. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  61778. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  61779. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  61780. import { Nullable } from "babylonjs/types";
  61781. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61782. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  61783. /**
  61784. * AmmoJS Physics plugin
  61785. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  61786. * @see https://github.com/kripken/ammo.js/
  61787. */
  61788. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  61789. private _useDeltaForWorldStep;
  61790. /**
  61791. * Reference to the Ammo library
  61792. */
  61793. bjsAMMO: any;
  61794. /**
  61795. * Created ammoJS world which physics bodies are added to
  61796. */
  61797. world: any;
  61798. /**
  61799. * Name of the plugin
  61800. */
  61801. name: string;
  61802. private _timeStep;
  61803. private _fixedTimeStep;
  61804. private _maxSteps;
  61805. private _tmpQuaternion;
  61806. private _tmpAmmoTransform;
  61807. private _tmpAmmoQuaternion;
  61808. private _tmpAmmoConcreteContactResultCallback;
  61809. private _collisionConfiguration;
  61810. private _dispatcher;
  61811. private _overlappingPairCache;
  61812. private _solver;
  61813. private _softBodySolver;
  61814. private _tmpAmmoVectorA;
  61815. private _tmpAmmoVectorB;
  61816. private _tmpAmmoVectorC;
  61817. private _tmpAmmoVectorD;
  61818. private _tmpContactCallbackResult;
  61819. private _tmpAmmoVectorRCA;
  61820. private _tmpAmmoVectorRCB;
  61821. private _raycastResult;
  61822. private static readonly DISABLE_COLLISION_FLAG;
  61823. private static readonly KINEMATIC_FLAG;
  61824. private static readonly DISABLE_DEACTIVATION_FLAG;
  61825. /**
  61826. * Initializes the ammoJS plugin
  61827. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  61828. * @param ammoInjection can be used to inject your own ammo reference
  61829. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  61830. */
  61831. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  61832. /**
  61833. * Sets the gravity of the physics world (m/(s^2))
  61834. * @param gravity Gravity to set
  61835. */
  61836. setGravity(gravity: Vector3): void;
  61837. /**
  61838. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  61839. * @param timeStep timestep to use in seconds
  61840. */
  61841. setTimeStep(timeStep: number): void;
  61842. /**
  61843. * 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)
  61844. * @param fixedTimeStep fixedTimeStep to use in seconds
  61845. */
  61846. setFixedTimeStep(fixedTimeStep: number): void;
  61847. /**
  61848. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  61849. * @param maxSteps the maximum number of steps by the physics engine per frame
  61850. */
  61851. setMaxSteps(maxSteps: number): void;
  61852. /**
  61853. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  61854. * @returns the current timestep in seconds
  61855. */
  61856. getTimeStep(): number;
  61857. /**
  61858. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  61859. */
  61860. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  61861. private _isImpostorInContact;
  61862. private _isImpostorPairInContact;
  61863. private _stepSimulation;
  61864. /**
  61865. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  61866. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  61867. * After the step the babylon meshes are set to the position of the physics imposters
  61868. * @param delta amount of time to step forward
  61869. * @param impostors array of imposters to update before/after the step
  61870. */
  61871. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  61872. /**
  61873. * Update babylon mesh to match physics world object
  61874. * @param impostor imposter to match
  61875. */
  61876. private _afterSoftStep;
  61877. /**
  61878. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  61879. * @param impostor imposter to match
  61880. */
  61881. private _ropeStep;
  61882. /**
  61883. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  61884. * @param impostor imposter to match
  61885. */
  61886. private _softbodyOrClothStep;
  61887. private _tmpMatrix;
  61888. /**
  61889. * Applies an impulse on the imposter
  61890. * @param impostor imposter to apply impulse to
  61891. * @param force amount of force to be applied to the imposter
  61892. * @param contactPoint the location to apply the impulse on the imposter
  61893. */
  61894. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61895. /**
  61896. * Applies a force on the imposter
  61897. * @param impostor imposter to apply force
  61898. * @param force amount of force to be applied to the imposter
  61899. * @param contactPoint the location to apply the force on the imposter
  61900. */
  61901. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61902. /**
  61903. * Creates a physics body using the plugin
  61904. * @param impostor the imposter to create the physics body on
  61905. */
  61906. generatePhysicsBody(impostor: PhysicsImpostor): void;
  61907. /**
  61908. * Removes the physics body from the imposter and disposes of the body's memory
  61909. * @param impostor imposter to remove the physics body from
  61910. */
  61911. removePhysicsBody(impostor: PhysicsImpostor): void;
  61912. /**
  61913. * Generates a joint
  61914. * @param impostorJoint the imposter joint to create the joint with
  61915. */
  61916. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  61917. /**
  61918. * Removes a joint
  61919. * @param impostorJoint the imposter joint to remove the joint from
  61920. */
  61921. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  61922. private _addMeshVerts;
  61923. /**
  61924. * Initialise the soft body vertices to match its object's (mesh) vertices
  61925. * Softbody vertices (nodes) are in world space and to match this
  61926. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  61927. * @param impostor to create the softbody for
  61928. */
  61929. private _softVertexData;
  61930. /**
  61931. * Create an impostor's soft body
  61932. * @param impostor to create the softbody for
  61933. */
  61934. private _createSoftbody;
  61935. /**
  61936. * Create cloth for an impostor
  61937. * @param impostor to create the softbody for
  61938. */
  61939. private _createCloth;
  61940. /**
  61941. * Create rope for an impostor
  61942. * @param impostor to create the softbody for
  61943. */
  61944. private _createRope;
  61945. /**
  61946. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  61947. * @param impostor to create the custom physics shape for
  61948. */
  61949. private _createCustom;
  61950. private _addHullVerts;
  61951. private _createShape;
  61952. /**
  61953. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  61954. * @param impostor imposter containing the physics body and babylon object
  61955. */
  61956. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  61957. /**
  61958. * Sets the babylon object's position/rotation from the physics body's position/rotation
  61959. * @param impostor imposter containing the physics body and babylon object
  61960. * @param newPosition new position
  61961. * @param newRotation new rotation
  61962. */
  61963. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  61964. /**
  61965. * If this plugin is supported
  61966. * @returns true if its supported
  61967. */
  61968. isSupported(): boolean;
  61969. /**
  61970. * Sets the linear velocity of the physics body
  61971. * @param impostor imposter to set the velocity on
  61972. * @param velocity velocity to set
  61973. */
  61974. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61975. /**
  61976. * Sets the angular velocity of the physics body
  61977. * @param impostor imposter to set the velocity on
  61978. * @param velocity velocity to set
  61979. */
  61980. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61981. /**
  61982. * gets the linear velocity
  61983. * @param impostor imposter to get linear velocity from
  61984. * @returns linear velocity
  61985. */
  61986. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61987. /**
  61988. * gets the angular velocity
  61989. * @param impostor imposter to get angular velocity from
  61990. * @returns angular velocity
  61991. */
  61992. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61993. /**
  61994. * Sets the mass of physics body
  61995. * @param impostor imposter to set the mass on
  61996. * @param mass mass to set
  61997. */
  61998. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  61999. /**
  62000. * Gets the mass of the physics body
  62001. * @param impostor imposter to get the mass from
  62002. * @returns mass
  62003. */
  62004. getBodyMass(impostor: PhysicsImpostor): number;
  62005. /**
  62006. * Gets friction of the impostor
  62007. * @param impostor impostor to get friction from
  62008. * @returns friction value
  62009. */
  62010. getBodyFriction(impostor: PhysicsImpostor): number;
  62011. /**
  62012. * Sets friction of the impostor
  62013. * @param impostor impostor to set friction on
  62014. * @param friction friction value
  62015. */
  62016. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  62017. /**
  62018. * Gets restitution of the impostor
  62019. * @param impostor impostor to get restitution from
  62020. * @returns restitution value
  62021. */
  62022. getBodyRestitution(impostor: PhysicsImpostor): number;
  62023. /**
  62024. * Sets resitution of the impostor
  62025. * @param impostor impostor to set resitution on
  62026. * @param restitution resitution value
  62027. */
  62028. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  62029. /**
  62030. * Gets pressure inside the impostor
  62031. * @param impostor impostor to get pressure from
  62032. * @returns pressure value
  62033. */
  62034. getBodyPressure(impostor: PhysicsImpostor): number;
  62035. /**
  62036. * Sets pressure inside a soft body impostor
  62037. * Cloth and rope must remain 0 pressure
  62038. * @param impostor impostor to set pressure on
  62039. * @param pressure pressure value
  62040. */
  62041. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  62042. /**
  62043. * Gets stiffness of the impostor
  62044. * @param impostor impostor to get stiffness from
  62045. * @returns pressure value
  62046. */
  62047. getBodyStiffness(impostor: PhysicsImpostor): number;
  62048. /**
  62049. * Sets stiffness of the impostor
  62050. * @param impostor impostor to set stiffness on
  62051. * @param stiffness stiffness value from 0 to 1
  62052. */
  62053. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  62054. /**
  62055. * Gets velocityIterations of the impostor
  62056. * @param impostor impostor to get velocity iterations from
  62057. * @returns velocityIterations value
  62058. */
  62059. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  62060. /**
  62061. * Sets velocityIterations of the impostor
  62062. * @param impostor impostor to set velocity iterations on
  62063. * @param velocityIterations velocityIterations value
  62064. */
  62065. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  62066. /**
  62067. * Gets positionIterations of the impostor
  62068. * @param impostor impostor to get position iterations from
  62069. * @returns positionIterations value
  62070. */
  62071. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  62072. /**
  62073. * Sets positionIterations of the impostor
  62074. * @param impostor impostor to set position on
  62075. * @param positionIterations positionIterations value
  62076. */
  62077. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  62078. /**
  62079. * Append an anchor to a cloth object
  62080. * @param impostor is the cloth impostor to add anchor to
  62081. * @param otherImpostor is the rigid impostor to anchor to
  62082. * @param width ratio across width from 0 to 1
  62083. * @param height ratio up height from 0 to 1
  62084. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  62085. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  62086. */
  62087. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  62088. /**
  62089. * Append an hook to a rope object
  62090. * @param impostor is the rope impostor to add hook to
  62091. * @param otherImpostor is the rigid impostor to hook to
  62092. * @param length ratio along the rope from 0 to 1
  62093. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  62094. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  62095. */
  62096. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  62097. /**
  62098. * Sleeps the physics body and stops it from being active
  62099. * @param impostor impostor to sleep
  62100. */
  62101. sleepBody(impostor: PhysicsImpostor): void;
  62102. /**
  62103. * Activates the physics body
  62104. * @param impostor impostor to activate
  62105. */
  62106. wakeUpBody(impostor: PhysicsImpostor): void;
  62107. /**
  62108. * Updates the distance parameters of the joint
  62109. * @param joint joint to update
  62110. * @param maxDistance maximum distance of the joint
  62111. * @param minDistance minimum distance of the joint
  62112. */
  62113. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  62114. /**
  62115. * Sets a motor on the joint
  62116. * @param joint joint to set motor on
  62117. * @param speed speed of the motor
  62118. * @param maxForce maximum force of the motor
  62119. * @param motorIndex index of the motor
  62120. */
  62121. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  62122. /**
  62123. * Sets the motors limit
  62124. * @param joint joint to set limit on
  62125. * @param upperLimit upper limit
  62126. * @param lowerLimit lower limit
  62127. */
  62128. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  62129. /**
  62130. * Syncs the position and rotation of a mesh with the impostor
  62131. * @param mesh mesh to sync
  62132. * @param impostor impostor to update the mesh with
  62133. */
  62134. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  62135. /**
  62136. * Gets the radius of the impostor
  62137. * @param impostor impostor to get radius from
  62138. * @returns the radius
  62139. */
  62140. getRadius(impostor: PhysicsImpostor): number;
  62141. /**
  62142. * Gets the box size of the impostor
  62143. * @param impostor impostor to get box size from
  62144. * @param result the resulting box size
  62145. */
  62146. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  62147. /**
  62148. * Disposes of the impostor
  62149. */
  62150. dispose(): void;
  62151. /**
  62152. * Does a raycast in the physics world
  62153. * @param from when should the ray start?
  62154. * @param to when should the ray end?
  62155. * @returns PhysicsRaycastResult
  62156. */
  62157. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62158. }
  62159. }
  62160. declare module "babylonjs/Probes/reflectionProbe" {
  62161. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62162. import { Vector3 } from "babylonjs/Maths/math.vector";
  62163. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62164. import { Nullable } from "babylonjs/types";
  62165. import { Scene } from "babylonjs/scene";
  62166. module "babylonjs/abstractScene" {
  62167. interface AbstractScene {
  62168. /**
  62169. * The list of reflection probes added to the scene
  62170. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  62171. */
  62172. reflectionProbes: Array<ReflectionProbe>;
  62173. /**
  62174. * Removes the given reflection probe from this scene.
  62175. * @param toRemove The reflection probe to remove
  62176. * @returns The index of the removed reflection probe
  62177. */
  62178. removeReflectionProbe(toRemove: ReflectionProbe): number;
  62179. /**
  62180. * Adds the given reflection probe to this scene.
  62181. * @param newReflectionProbe The reflection probe to add
  62182. */
  62183. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  62184. }
  62185. }
  62186. /**
  62187. * Class used to generate realtime reflection / refraction cube textures
  62188. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  62189. */
  62190. export class ReflectionProbe {
  62191. /** defines the name of the probe */
  62192. name: string;
  62193. private _scene;
  62194. private _renderTargetTexture;
  62195. private _projectionMatrix;
  62196. private _viewMatrix;
  62197. private _target;
  62198. private _add;
  62199. private _attachedMesh;
  62200. private _invertYAxis;
  62201. /** Gets or sets probe position (center of the cube map) */
  62202. position: Vector3;
  62203. /**
  62204. * Creates a new reflection probe
  62205. * @param name defines the name of the probe
  62206. * @param size defines the texture resolution (for each face)
  62207. * @param scene defines the hosting scene
  62208. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  62209. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  62210. */
  62211. constructor(
  62212. /** defines the name of the probe */
  62213. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  62214. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  62215. get samples(): number;
  62216. set samples(value: number);
  62217. /** Gets or sets the refresh rate to use (on every frame by default) */
  62218. get refreshRate(): number;
  62219. set refreshRate(value: number);
  62220. /**
  62221. * Gets the hosting scene
  62222. * @returns a Scene
  62223. */
  62224. getScene(): Scene;
  62225. /** Gets the internal CubeTexture used to render to */
  62226. get cubeTexture(): RenderTargetTexture;
  62227. /** Gets the list of meshes to render */
  62228. get renderList(): Nullable<AbstractMesh[]>;
  62229. /**
  62230. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  62231. * @param mesh defines the mesh to attach to
  62232. */
  62233. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  62234. /**
  62235. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  62236. * @param renderingGroupId The rendering group id corresponding to its index
  62237. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  62238. */
  62239. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  62240. /**
  62241. * Clean all associated resources
  62242. */
  62243. dispose(): void;
  62244. /**
  62245. * Converts the reflection probe information to a readable string for debug purpose.
  62246. * @param fullDetails Supports for multiple levels of logging within scene loading
  62247. * @returns the human readable reflection probe info
  62248. */
  62249. toString(fullDetails?: boolean): string;
  62250. /**
  62251. * Get the class name of the relfection probe.
  62252. * @returns "ReflectionProbe"
  62253. */
  62254. getClassName(): string;
  62255. /**
  62256. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  62257. * @returns The JSON representation of the texture
  62258. */
  62259. serialize(): any;
  62260. /**
  62261. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  62262. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  62263. * @param scene Define the scene the parsed reflection probe should be instantiated in
  62264. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  62265. * @returns The parsed reflection probe if successful
  62266. */
  62267. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  62268. }
  62269. }
  62270. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  62271. /** @hidden */
  62272. export var _BabylonLoaderRegistered: boolean;
  62273. /**
  62274. * Helps setting up some configuration for the babylon file loader.
  62275. */
  62276. export class BabylonFileLoaderConfiguration {
  62277. /**
  62278. * The loader does not allow injecting custom physix engine into the plugins.
  62279. * Unfortunately in ES6, we need to manually inject them into the plugin.
  62280. * So you could set this variable to your engine import to make it work.
  62281. */
  62282. static LoaderInjectedPhysicsEngine: any;
  62283. }
  62284. }
  62285. declare module "babylonjs/Loading/Plugins/index" {
  62286. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  62287. }
  62288. declare module "babylonjs/Loading/index" {
  62289. export * from "babylonjs/Loading/loadingScreen";
  62290. export * from "babylonjs/Loading/Plugins/index";
  62291. export * from "babylonjs/Loading/sceneLoader";
  62292. export * from "babylonjs/Loading/sceneLoaderFlags";
  62293. }
  62294. declare module "babylonjs/Materials/Background/index" {
  62295. export * from "babylonjs/Materials/Background/backgroundMaterial";
  62296. }
  62297. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  62298. import { Scene } from "babylonjs/scene";
  62299. import { Color3 } from "babylonjs/Maths/math.color";
  62300. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  62301. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62302. /**
  62303. * The Physically based simple base material of BJS.
  62304. *
  62305. * This enables better naming and convention enforcements on top of the pbrMaterial.
  62306. * It is used as the base class for both the specGloss and metalRough conventions.
  62307. */
  62308. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  62309. /**
  62310. * Number of Simultaneous lights allowed on the material.
  62311. */
  62312. maxSimultaneousLights: number;
  62313. /**
  62314. * If sets to true, disables all the lights affecting the material.
  62315. */
  62316. disableLighting: boolean;
  62317. /**
  62318. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  62319. */
  62320. environmentTexture: BaseTexture;
  62321. /**
  62322. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  62323. */
  62324. invertNormalMapX: boolean;
  62325. /**
  62326. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  62327. */
  62328. invertNormalMapY: boolean;
  62329. /**
  62330. * Normal map used in the model.
  62331. */
  62332. normalTexture: BaseTexture;
  62333. /**
  62334. * Emissivie color used to self-illuminate the model.
  62335. */
  62336. emissiveColor: Color3;
  62337. /**
  62338. * Emissivie texture used to self-illuminate the model.
  62339. */
  62340. emissiveTexture: BaseTexture;
  62341. /**
  62342. * Occlusion Channel Strenght.
  62343. */
  62344. occlusionStrength: number;
  62345. /**
  62346. * Occlusion Texture of the material (adding extra occlusion effects).
  62347. */
  62348. occlusionTexture: BaseTexture;
  62349. /**
  62350. * Defines the alpha limits in alpha test mode.
  62351. */
  62352. alphaCutOff: number;
  62353. /**
  62354. * Gets the current double sided mode.
  62355. */
  62356. get doubleSided(): boolean;
  62357. /**
  62358. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  62359. */
  62360. set doubleSided(value: boolean);
  62361. /**
  62362. * Stores the pre-calculated light information of a mesh in a texture.
  62363. */
  62364. lightmapTexture: BaseTexture;
  62365. /**
  62366. * If true, the light map contains occlusion information instead of lighting info.
  62367. */
  62368. useLightmapAsShadowmap: boolean;
  62369. /**
  62370. * Instantiates a new PBRMaterial instance.
  62371. *
  62372. * @param name The material name
  62373. * @param scene The scene the material will be use in.
  62374. */
  62375. constructor(name: string, scene: Scene);
  62376. getClassName(): string;
  62377. }
  62378. }
  62379. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  62380. import { Scene } from "babylonjs/scene";
  62381. import { Color3 } from "babylonjs/Maths/math.color";
  62382. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62383. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  62384. /**
  62385. * The PBR material of BJS following the metal roughness convention.
  62386. *
  62387. * This fits to the PBR convention in the GLTF definition:
  62388. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  62389. */
  62390. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  62391. /**
  62392. * The base color has two different interpretations depending on the value of metalness.
  62393. * When the material is a metal, the base color is the specific measured reflectance value
  62394. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  62395. * of the material.
  62396. */
  62397. baseColor: Color3;
  62398. /**
  62399. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  62400. * well as opacity information in the alpha channel.
  62401. */
  62402. baseTexture: BaseTexture;
  62403. /**
  62404. * Specifies the metallic scalar value of the material.
  62405. * Can also be used to scale the metalness values of the metallic texture.
  62406. */
  62407. metallic: number;
  62408. /**
  62409. * Specifies the roughness scalar value of the material.
  62410. * Can also be used to scale the roughness values of the metallic texture.
  62411. */
  62412. roughness: number;
  62413. /**
  62414. * Texture containing both the metallic value in the B channel and the
  62415. * roughness value in the G channel to keep better precision.
  62416. */
  62417. metallicRoughnessTexture: BaseTexture;
  62418. /**
  62419. * Instantiates a new PBRMetalRoughnessMaterial instance.
  62420. *
  62421. * @param name The material name
  62422. * @param scene The scene the material will be use in.
  62423. */
  62424. constructor(name: string, scene: Scene);
  62425. /**
  62426. * Return the currrent class name of the material.
  62427. */
  62428. getClassName(): string;
  62429. /**
  62430. * Makes a duplicate of the current material.
  62431. * @param name - name to use for the new material.
  62432. */
  62433. clone(name: string): PBRMetallicRoughnessMaterial;
  62434. /**
  62435. * Serialize the material to a parsable JSON object.
  62436. */
  62437. serialize(): any;
  62438. /**
  62439. * Parses a JSON object correponding to the serialize function.
  62440. */
  62441. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  62442. }
  62443. }
  62444. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  62445. import { Scene } from "babylonjs/scene";
  62446. import { Color3 } from "babylonjs/Maths/math.color";
  62447. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62448. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  62449. /**
  62450. * The PBR material of BJS following the specular glossiness convention.
  62451. *
  62452. * This fits to the PBR convention in the GLTF definition:
  62453. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  62454. */
  62455. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  62456. /**
  62457. * Specifies the diffuse color of the material.
  62458. */
  62459. diffuseColor: Color3;
  62460. /**
  62461. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  62462. * channel.
  62463. */
  62464. diffuseTexture: BaseTexture;
  62465. /**
  62466. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  62467. */
  62468. specularColor: Color3;
  62469. /**
  62470. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  62471. */
  62472. glossiness: number;
  62473. /**
  62474. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  62475. */
  62476. specularGlossinessTexture: BaseTexture;
  62477. /**
  62478. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  62479. *
  62480. * @param name The material name
  62481. * @param scene The scene the material will be use in.
  62482. */
  62483. constructor(name: string, scene: Scene);
  62484. /**
  62485. * Return the currrent class name of the material.
  62486. */
  62487. getClassName(): string;
  62488. /**
  62489. * Makes a duplicate of the current material.
  62490. * @param name - name to use for the new material.
  62491. */
  62492. clone(name: string): PBRSpecularGlossinessMaterial;
  62493. /**
  62494. * Serialize the material to a parsable JSON object.
  62495. */
  62496. serialize(): any;
  62497. /**
  62498. * Parses a JSON object correponding to the serialize function.
  62499. */
  62500. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  62501. }
  62502. }
  62503. declare module "babylonjs/Materials/PBR/index" {
  62504. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  62505. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  62506. export * from "babylonjs/Materials/PBR/pbrMaterial";
  62507. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  62508. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  62509. }
  62510. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  62511. import { Nullable } from "babylonjs/types";
  62512. import { Scene } from "babylonjs/scene";
  62513. import { Matrix } from "babylonjs/Maths/math.vector";
  62514. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62515. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  62516. import "babylonjs/Engines/Extensions/engine.rawTexture";
  62517. /**
  62518. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  62519. * It can help converting any input color in a desired output one. This can then be used to create effects
  62520. * from sepia, black and white to sixties or futuristic rendering...
  62521. *
  62522. * The only supported format is currently 3dl.
  62523. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  62524. */
  62525. export class ColorGradingTexture extends BaseTexture {
  62526. /**
  62527. * The texture URL.
  62528. */
  62529. url: string;
  62530. /**
  62531. * Empty line regex stored for GC.
  62532. */
  62533. private static _noneEmptyLineRegex;
  62534. private _textureMatrix;
  62535. private _onLoad;
  62536. /**
  62537. * Instantiates a ColorGradingTexture from the following parameters.
  62538. *
  62539. * @param url The location of the color gradind data (currently only supporting 3dl)
  62540. * @param sceneOrEngine The scene or engine the texture will be used in
  62541. * @param onLoad defines a callback triggered when the texture has been loaded
  62542. */
  62543. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  62544. /**
  62545. * Fires the onload event from the constructor if requested.
  62546. */
  62547. private _triggerOnLoad;
  62548. /**
  62549. * Returns the texture matrix used in most of the material.
  62550. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  62551. */
  62552. getTextureMatrix(): Matrix;
  62553. /**
  62554. * Occurs when the file being loaded is a .3dl LUT file.
  62555. */
  62556. private load3dlTexture;
  62557. /**
  62558. * Starts the loading process of the texture.
  62559. */
  62560. private loadTexture;
  62561. /**
  62562. * Clones the color gradind texture.
  62563. */
  62564. clone(): ColorGradingTexture;
  62565. /**
  62566. * Called during delayed load for textures.
  62567. */
  62568. delayLoad(): void;
  62569. /**
  62570. * Parses a color grading texture serialized by Babylon.
  62571. * @param parsedTexture The texture information being parsedTexture
  62572. * @param scene The scene to load the texture in
  62573. * @param rootUrl The root url of the data assets to load
  62574. * @return A color gradind texture
  62575. */
  62576. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  62577. /**
  62578. * Serializes the LUT texture to json format.
  62579. */
  62580. serialize(): any;
  62581. }
  62582. }
  62583. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  62584. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62585. import { Scene } from "babylonjs/scene";
  62586. import { Nullable } from "babylonjs/types";
  62587. import "babylonjs/Engines/Extensions/engine.rawTexture";
  62588. /**
  62589. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  62590. */
  62591. export class EquiRectangularCubeTexture extends BaseTexture {
  62592. /** The six faces of the cube. */
  62593. private static _FacesMapping;
  62594. private _noMipmap;
  62595. private _onLoad;
  62596. private _onError;
  62597. /** The size of the cubemap. */
  62598. private _size;
  62599. /** The buffer of the image. */
  62600. private _buffer;
  62601. /** The width of the input image. */
  62602. private _width;
  62603. /** The height of the input image. */
  62604. private _height;
  62605. /** The URL to the image. */
  62606. url: string;
  62607. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  62608. coordinatesMode: number;
  62609. /**
  62610. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  62611. * @param url The location of the image
  62612. * @param scene The scene the texture will be used in
  62613. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  62614. * @param noMipmap Forces to not generate the mipmap if true
  62615. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  62616. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  62617. * @param onLoad — defines a callback called when texture is loaded
  62618. * @param onError — defines a callback called if there is an error
  62619. */
  62620. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  62621. /**
  62622. * Load the image data, by putting the image on a canvas and extracting its buffer.
  62623. */
  62624. private loadImage;
  62625. /**
  62626. * Convert the image buffer into a cubemap and create a CubeTexture.
  62627. */
  62628. private loadTexture;
  62629. /**
  62630. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  62631. * @param buffer The ArrayBuffer that should be converted.
  62632. * @returns The buffer as Float32Array.
  62633. */
  62634. private getFloat32ArrayFromArrayBuffer;
  62635. /**
  62636. * Get the current class name of the texture useful for serialization or dynamic coding.
  62637. * @returns "EquiRectangularCubeTexture"
  62638. */
  62639. getClassName(): string;
  62640. /**
  62641. * Create a clone of the current EquiRectangularCubeTexture and return it.
  62642. * @returns A clone of the current EquiRectangularCubeTexture.
  62643. */
  62644. clone(): EquiRectangularCubeTexture;
  62645. }
  62646. }
  62647. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  62648. import { Nullable } from "babylonjs/types";
  62649. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62650. import { Matrix } from "babylonjs/Maths/math.vector";
  62651. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  62652. import "babylonjs/Engines/Extensions/engine.videoTexture";
  62653. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  62654. import { Scene } from "babylonjs/scene";
  62655. /**
  62656. * Defines the options related to the creation of an HtmlElementTexture
  62657. */
  62658. export interface IHtmlElementTextureOptions {
  62659. /**
  62660. * Defines wether mip maps should be created or not.
  62661. */
  62662. generateMipMaps?: boolean;
  62663. /**
  62664. * Defines the sampling mode of the texture.
  62665. */
  62666. samplingMode?: number;
  62667. /**
  62668. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  62669. */
  62670. engine: Nullable<ThinEngine>;
  62671. /**
  62672. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  62673. */
  62674. scene: Nullable<Scene>;
  62675. }
  62676. /**
  62677. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  62678. * To be as efficient as possible depending on your constraints nothing aside the first upload
  62679. * is automatically managed.
  62680. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  62681. * in your application.
  62682. *
  62683. * As the update is not automatic, you need to call them manually.
  62684. */
  62685. export class HtmlElementTexture extends BaseTexture {
  62686. /**
  62687. * The texture URL.
  62688. */
  62689. element: HTMLVideoElement | HTMLCanvasElement;
  62690. private static readonly DefaultOptions;
  62691. private _textureMatrix;
  62692. private _isVideo;
  62693. private _generateMipMaps;
  62694. private _samplingMode;
  62695. /**
  62696. * Instantiates a HtmlElementTexture from the following parameters.
  62697. *
  62698. * @param name Defines the name of the texture
  62699. * @param element Defines the video or canvas the texture is filled with
  62700. * @param options Defines the other none mandatory texture creation options
  62701. */
  62702. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  62703. private _createInternalTexture;
  62704. /**
  62705. * Returns the texture matrix used in most of the material.
  62706. */
  62707. getTextureMatrix(): Matrix;
  62708. /**
  62709. * Updates the content of the texture.
  62710. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  62711. */
  62712. update(invertY?: Nullable<boolean>): void;
  62713. }
  62714. }
  62715. declare module "babylonjs/Misc/tga" {
  62716. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  62717. /**
  62718. * Based on jsTGALoader - Javascript loader for TGA file
  62719. * By Vincent Thibault
  62720. * @see http://blog.robrowser.com/javascript-tga-loader.html
  62721. */
  62722. export class TGATools {
  62723. private static _TYPE_INDEXED;
  62724. private static _TYPE_RGB;
  62725. private static _TYPE_GREY;
  62726. private static _TYPE_RLE_INDEXED;
  62727. private static _TYPE_RLE_RGB;
  62728. private static _TYPE_RLE_GREY;
  62729. private static _ORIGIN_MASK;
  62730. private static _ORIGIN_SHIFT;
  62731. private static _ORIGIN_BL;
  62732. private static _ORIGIN_BR;
  62733. private static _ORIGIN_UL;
  62734. private static _ORIGIN_UR;
  62735. /**
  62736. * Gets the header of a TGA file
  62737. * @param data defines the TGA data
  62738. * @returns the header
  62739. */
  62740. static GetTGAHeader(data: Uint8Array): any;
  62741. /**
  62742. * Uploads TGA content to a Babylon Texture
  62743. * @hidden
  62744. */
  62745. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  62746. /** @hidden */
  62747. 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;
  62748. /** @hidden */
  62749. 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;
  62750. /** @hidden */
  62751. 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;
  62752. /** @hidden */
  62753. 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;
  62754. /** @hidden */
  62755. 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;
  62756. /** @hidden */
  62757. 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;
  62758. }
  62759. }
  62760. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  62761. import { Nullable } from "babylonjs/types";
  62762. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  62763. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  62764. /**
  62765. * Implementation of the TGA Texture Loader.
  62766. * @hidden
  62767. */
  62768. export class _TGATextureLoader implements IInternalTextureLoader {
  62769. /**
  62770. * Defines wether the loader supports cascade loading the different faces.
  62771. */
  62772. readonly supportCascades: boolean;
  62773. /**
  62774. * This returns if the loader support the current file information.
  62775. * @param extension defines the file extension of the file being loaded
  62776. * @returns true if the loader can load the specified file
  62777. */
  62778. canLoad(extension: string): boolean;
  62779. /**
  62780. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62781. * @param data contains the texture data
  62782. * @param texture defines the BabylonJS internal texture
  62783. * @param createPolynomials will be true if polynomials have been requested
  62784. * @param onLoad defines the callback to trigger once the texture is ready
  62785. * @param onError defines the callback to trigger in case of error
  62786. */
  62787. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62788. /**
  62789. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62790. * @param data contains the texture data
  62791. * @param texture defines the BabylonJS internal texture
  62792. * @param callback defines the method to call once ready to upload
  62793. */
  62794. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  62795. }
  62796. }
  62797. declare module "babylonjs/Misc/basis" {
  62798. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  62799. /**
  62800. * Info about the .basis files
  62801. */
  62802. class BasisFileInfo {
  62803. /**
  62804. * If the file has alpha
  62805. */
  62806. hasAlpha: boolean;
  62807. /**
  62808. * Info about each image of the basis file
  62809. */
  62810. images: Array<{
  62811. levels: Array<{
  62812. width: number;
  62813. height: number;
  62814. transcodedPixels: ArrayBufferView;
  62815. }>;
  62816. }>;
  62817. }
  62818. /**
  62819. * Result of transcoding a basis file
  62820. */
  62821. class TranscodeResult {
  62822. /**
  62823. * Info about the .basis file
  62824. */
  62825. fileInfo: BasisFileInfo;
  62826. /**
  62827. * Format to use when loading the file
  62828. */
  62829. format: number;
  62830. }
  62831. /**
  62832. * Configuration options for the Basis transcoder
  62833. */
  62834. export class BasisTranscodeConfiguration {
  62835. /**
  62836. * Supported compression formats used to determine the supported output format of the transcoder
  62837. */
  62838. supportedCompressionFormats?: {
  62839. /**
  62840. * etc1 compression format
  62841. */
  62842. etc1?: boolean;
  62843. /**
  62844. * s3tc compression format
  62845. */
  62846. s3tc?: boolean;
  62847. /**
  62848. * pvrtc compression format
  62849. */
  62850. pvrtc?: boolean;
  62851. /**
  62852. * etc2 compression format
  62853. */
  62854. etc2?: boolean;
  62855. };
  62856. /**
  62857. * If mipmap levels should be loaded for transcoded images (Default: true)
  62858. */
  62859. loadMipmapLevels?: boolean;
  62860. /**
  62861. * Index of a single image to load (Default: all images)
  62862. */
  62863. loadSingleImage?: number;
  62864. }
  62865. /**
  62866. * Used to load .Basis files
  62867. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  62868. */
  62869. export class BasisTools {
  62870. private static _IgnoreSupportedFormats;
  62871. /**
  62872. * URL to use when loading the basis transcoder
  62873. */
  62874. static JSModuleURL: string;
  62875. /**
  62876. * URL to use when loading the wasm module for the transcoder
  62877. */
  62878. static WasmModuleURL: string;
  62879. /**
  62880. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  62881. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  62882. * @returns internal format corresponding to the Basis format
  62883. */
  62884. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  62885. private static _WorkerPromise;
  62886. private static _Worker;
  62887. private static _actionId;
  62888. private static _CreateWorkerAsync;
  62889. /**
  62890. * Transcodes a loaded image file to compressed pixel data
  62891. * @param data image data to transcode
  62892. * @param config configuration options for the transcoding
  62893. * @returns a promise resulting in the transcoded image
  62894. */
  62895. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  62896. /**
  62897. * Loads a texture from the transcode result
  62898. * @param texture texture load to
  62899. * @param transcodeResult the result of transcoding the basis file to load from
  62900. */
  62901. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  62902. }
  62903. }
  62904. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  62905. import { Nullable } from "babylonjs/types";
  62906. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  62907. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  62908. /**
  62909. * Loader for .basis file format
  62910. */
  62911. export class _BasisTextureLoader implements IInternalTextureLoader {
  62912. /**
  62913. * Defines whether the loader supports cascade loading the different faces.
  62914. */
  62915. readonly supportCascades: boolean;
  62916. /**
  62917. * This returns if the loader support the current file information.
  62918. * @param extension defines the file extension of the file being loaded
  62919. * @returns true if the loader can load the specified file
  62920. */
  62921. canLoad(extension: string): boolean;
  62922. /**
  62923. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62924. * @param data contains the texture data
  62925. * @param texture defines the BabylonJS internal texture
  62926. * @param createPolynomials will be true if polynomials have been requested
  62927. * @param onLoad defines the callback to trigger once the texture is ready
  62928. * @param onError defines the callback to trigger in case of error
  62929. */
  62930. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62931. /**
  62932. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62933. * @param data contains the texture data
  62934. * @param texture defines the BabylonJS internal texture
  62935. * @param callback defines the method to call once ready to upload
  62936. */
  62937. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  62938. }
  62939. }
  62940. declare module "babylonjs/Materials/Textures/Loaders/index" {
  62941. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  62942. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  62943. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  62944. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  62945. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  62946. }
  62947. declare module "babylonjs/Materials/Textures/Packer/frame" {
  62948. import { Vector2 } from "babylonjs/Maths/math.vector";
  62949. /**
  62950. * Defines the basic options interface of a TexturePacker Frame
  62951. */
  62952. export interface ITexturePackerFrame {
  62953. /**
  62954. * The frame ID
  62955. */
  62956. id: number;
  62957. /**
  62958. * The frames Scale
  62959. */
  62960. scale: Vector2;
  62961. /**
  62962. * The Frames offset
  62963. */
  62964. offset: Vector2;
  62965. }
  62966. /**
  62967. * This is a support class for frame Data on texture packer sets.
  62968. */
  62969. export class TexturePackerFrame implements ITexturePackerFrame {
  62970. /**
  62971. * The frame ID
  62972. */
  62973. id: number;
  62974. /**
  62975. * The frames Scale
  62976. */
  62977. scale: Vector2;
  62978. /**
  62979. * The Frames offset
  62980. */
  62981. offset: Vector2;
  62982. /**
  62983. * Initializes a texture package frame.
  62984. * @param id The numerical frame identifier
  62985. * @param scale Scalar Vector2 for UV frame
  62986. * @param offset Vector2 for the frame position in UV units.
  62987. * @returns TexturePackerFrame
  62988. */
  62989. constructor(id: number, scale: Vector2, offset: Vector2);
  62990. }
  62991. }
  62992. declare module "babylonjs/Materials/Textures/Packer/packer" {
  62993. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62994. import { Scene } from "babylonjs/scene";
  62995. import { Nullable } from "babylonjs/types";
  62996. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  62997. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  62998. /**
  62999. * Defines the basic options interface of a TexturePacker
  63000. */
  63001. export interface ITexturePackerOptions {
  63002. /**
  63003. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  63004. */
  63005. map?: string[];
  63006. /**
  63007. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  63008. */
  63009. uvsIn?: string;
  63010. /**
  63011. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  63012. */
  63013. uvsOut?: string;
  63014. /**
  63015. * number representing the layout style. Defaults to LAYOUT_STRIP
  63016. */
  63017. layout?: number;
  63018. /**
  63019. * number of columns if using custom column count layout(2). This defaults to 4.
  63020. */
  63021. colnum?: number;
  63022. /**
  63023. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  63024. */
  63025. updateInputMeshes?: boolean;
  63026. /**
  63027. * boolean flag to dispose all the source textures. Defaults to true.
  63028. */
  63029. disposeSources?: boolean;
  63030. /**
  63031. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  63032. */
  63033. fillBlanks?: boolean;
  63034. /**
  63035. * string value representing the context fill style color. Defaults to 'black'.
  63036. */
  63037. customFillColor?: string;
  63038. /**
  63039. * Width and Height Value of each Frame in the TexturePacker Sets
  63040. */
  63041. frameSize?: number;
  63042. /**
  63043. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  63044. */
  63045. paddingRatio?: number;
  63046. /**
  63047. * Number that declares the fill method for the padding gutter.
  63048. */
  63049. paddingMode?: number;
  63050. /**
  63051. * If in SUBUV_COLOR padding mode what color to use.
  63052. */
  63053. paddingColor?: Color3 | Color4;
  63054. }
  63055. /**
  63056. * Defines the basic interface of a TexturePacker JSON File
  63057. */
  63058. export interface ITexturePackerJSON {
  63059. /**
  63060. * The frame ID
  63061. */
  63062. name: string;
  63063. /**
  63064. * The base64 channel data
  63065. */
  63066. sets: any;
  63067. /**
  63068. * The options of the Packer
  63069. */
  63070. options: ITexturePackerOptions;
  63071. /**
  63072. * The frame data of the Packer
  63073. */
  63074. frames: Array<number>;
  63075. }
  63076. /**
  63077. * This is a support class that generates a series of packed texture sets.
  63078. * @see https://doc.babylonjs.com/babylon101/materials
  63079. */
  63080. export class TexturePacker {
  63081. /** Packer Layout Constant 0 */
  63082. static readonly LAYOUT_STRIP: number;
  63083. /** Packer Layout Constant 1 */
  63084. static readonly LAYOUT_POWER2: number;
  63085. /** Packer Layout Constant 2 */
  63086. static readonly LAYOUT_COLNUM: number;
  63087. /** Packer Layout Constant 0 */
  63088. static readonly SUBUV_WRAP: number;
  63089. /** Packer Layout Constant 1 */
  63090. static readonly SUBUV_EXTEND: number;
  63091. /** Packer Layout Constant 2 */
  63092. static readonly SUBUV_COLOR: number;
  63093. /** The Name of the Texture Package */
  63094. name: string;
  63095. /** The scene scope of the TexturePacker */
  63096. scene: Scene;
  63097. /** The Meshes to target */
  63098. meshes: AbstractMesh[];
  63099. /** Arguments passed with the Constructor */
  63100. options: ITexturePackerOptions;
  63101. /** The promise that is started upon initialization */
  63102. promise: Nullable<Promise<TexturePacker | string>>;
  63103. /** The Container object for the channel sets that are generated */
  63104. sets: object;
  63105. /** The Container array for the frames that are generated */
  63106. frames: TexturePackerFrame[];
  63107. /** The expected number of textures the system is parsing. */
  63108. private _expecting;
  63109. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  63110. private _paddingValue;
  63111. /**
  63112. * Initializes a texture package series from an array of meshes or a single mesh.
  63113. * @param name The name of the package
  63114. * @param meshes The target meshes to compose the package from
  63115. * @param options The arguments that texture packer should follow while building.
  63116. * @param scene The scene which the textures are scoped to.
  63117. * @returns TexturePacker
  63118. */
  63119. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  63120. /**
  63121. * Starts the package process
  63122. * @param resolve The promises resolution function
  63123. * @returns TexturePacker
  63124. */
  63125. private _createFrames;
  63126. /**
  63127. * Calculates the Size of the Channel Sets
  63128. * @returns Vector2
  63129. */
  63130. private _calculateSize;
  63131. /**
  63132. * Calculates the UV data for the frames.
  63133. * @param baseSize the base frameSize
  63134. * @param padding the base frame padding
  63135. * @param dtSize size of the Dynamic Texture for that channel
  63136. * @param dtUnits is 1/dtSize
  63137. * @param update flag to update the input meshes
  63138. */
  63139. private _calculateMeshUVFrames;
  63140. /**
  63141. * Calculates the frames Offset.
  63142. * @param index of the frame
  63143. * @returns Vector2
  63144. */
  63145. private _getFrameOffset;
  63146. /**
  63147. * Updates a Mesh to the frame data
  63148. * @param mesh that is the target
  63149. * @param frameID or the frame index
  63150. */
  63151. private _updateMeshUV;
  63152. /**
  63153. * Updates a Meshes materials to use the texture packer channels
  63154. * @param m is the mesh to target
  63155. * @param force all channels on the packer to be set.
  63156. */
  63157. private _updateTextureReferences;
  63158. /**
  63159. * Public method to set a Mesh to a frame
  63160. * @param m that is the target
  63161. * @param frameID or the frame index
  63162. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  63163. */
  63164. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  63165. /**
  63166. * Starts the async promise to compile the texture packer.
  63167. * @returns Promise<void>
  63168. */
  63169. processAsync(): Promise<void>;
  63170. /**
  63171. * Disposes all textures associated with this packer
  63172. */
  63173. dispose(): void;
  63174. /**
  63175. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  63176. * @param imageType is the image type to use.
  63177. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  63178. */
  63179. download(imageType?: string, quality?: number): void;
  63180. /**
  63181. * Public method to load a texturePacker JSON file.
  63182. * @param data of the JSON file in string format.
  63183. */
  63184. updateFromJSON(data: string): void;
  63185. }
  63186. }
  63187. declare module "babylonjs/Materials/Textures/Packer/index" {
  63188. export * from "babylonjs/Materials/Textures/Packer/packer";
  63189. export * from "babylonjs/Materials/Textures/Packer/frame";
  63190. }
  63191. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  63192. import { Scene } from "babylonjs/scene";
  63193. import { Texture } from "babylonjs/Materials/Textures/texture";
  63194. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  63195. /**
  63196. * 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.
  63197. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  63198. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  63199. */
  63200. export class CustomProceduralTexture extends ProceduralTexture {
  63201. private _animate;
  63202. private _time;
  63203. private _config;
  63204. private _texturePath;
  63205. /**
  63206. * Instantiates a new Custom Procedural Texture.
  63207. * 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.
  63208. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  63209. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  63210. * @param name Define the name of the texture
  63211. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  63212. * @param size Define the size of the texture to create
  63213. * @param scene Define the scene the texture belongs to
  63214. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  63215. * @param generateMipMaps Define if the texture should creates mip maps or not
  63216. */
  63217. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  63218. private _loadJson;
  63219. /**
  63220. * Is the texture ready to be used ? (rendered at least once)
  63221. * @returns true if ready, otherwise, false.
  63222. */
  63223. isReady(): boolean;
  63224. /**
  63225. * Render the texture to its associated render target.
  63226. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  63227. */
  63228. render(useCameraPostProcess?: boolean): void;
  63229. /**
  63230. * Update the list of dependant textures samplers in the shader.
  63231. */
  63232. updateTextures(): void;
  63233. /**
  63234. * Update the uniform values of the procedural texture in the shader.
  63235. */
  63236. updateShaderUniforms(): void;
  63237. /**
  63238. * Define if the texture animates or not.
  63239. */
  63240. get animate(): boolean;
  63241. set animate(value: boolean);
  63242. }
  63243. }
  63244. declare module "babylonjs/Shaders/noise.fragment" {
  63245. /** @hidden */
  63246. export var noisePixelShader: {
  63247. name: string;
  63248. shader: string;
  63249. };
  63250. }
  63251. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  63252. import { Nullable } from "babylonjs/types";
  63253. import { Scene } from "babylonjs/scene";
  63254. import { Texture } from "babylonjs/Materials/Textures/texture";
  63255. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  63256. import "babylonjs/Shaders/noise.fragment";
  63257. /**
  63258. * Class used to generate noise procedural textures
  63259. */
  63260. export class NoiseProceduralTexture extends ProceduralTexture {
  63261. private _time;
  63262. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  63263. brightness: number;
  63264. /** Defines the number of octaves to process */
  63265. octaves: number;
  63266. /** Defines the level of persistence (0.8 by default) */
  63267. persistence: number;
  63268. /** Gets or sets animation speed factor (default is 1) */
  63269. animationSpeedFactor: number;
  63270. /**
  63271. * Creates a new NoiseProceduralTexture
  63272. * @param name defines the name fo the texture
  63273. * @param size defines the size of the texture (default is 256)
  63274. * @param scene defines the hosting scene
  63275. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  63276. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  63277. */
  63278. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  63279. private _updateShaderUniforms;
  63280. protected _getDefines(): string;
  63281. /** Generate the current state of the procedural texture */
  63282. render(useCameraPostProcess?: boolean): void;
  63283. /**
  63284. * Serializes this noise procedural texture
  63285. * @returns a serialized noise procedural texture object
  63286. */
  63287. serialize(): any;
  63288. /**
  63289. * Clone the texture.
  63290. * @returns the cloned texture
  63291. */
  63292. clone(): NoiseProceduralTexture;
  63293. /**
  63294. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  63295. * @param parsedTexture defines parsed texture data
  63296. * @param scene defines the current scene
  63297. * @param rootUrl defines the root URL containing noise procedural texture information
  63298. * @returns a parsed NoiseProceduralTexture
  63299. */
  63300. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  63301. }
  63302. }
  63303. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  63304. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  63305. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  63306. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  63307. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  63308. }
  63309. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  63310. import { Nullable } from "babylonjs/types";
  63311. import { Scene } from "babylonjs/scene";
  63312. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  63313. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63314. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  63315. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63316. /**
  63317. * Raw cube texture where the raw buffers are passed in
  63318. */
  63319. export class RawCubeTexture extends CubeTexture {
  63320. /**
  63321. * Creates a cube texture where the raw buffers are passed in.
  63322. * @param scene defines the scene the texture is attached to
  63323. * @param data defines the array of data to use to create each face
  63324. * @param size defines the size of the textures
  63325. * @param format defines the format of the data
  63326. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  63327. * @param generateMipMaps defines if the engine should generate the mip levels
  63328. * @param invertY defines if data must be stored with Y axis inverted
  63329. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  63330. * @param compression defines the compression used (null by default)
  63331. */
  63332. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  63333. /**
  63334. * Updates the raw cube texture.
  63335. * @param data defines the data to store
  63336. * @param format defines the data format
  63337. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  63338. * @param invertY defines if data must be stored with Y axis inverted
  63339. * @param compression defines the compression used (null by default)
  63340. * @param level defines which level of the texture to update
  63341. */
  63342. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  63343. /**
  63344. * Updates a raw cube texture with RGBD encoded data.
  63345. * @param data defines the array of data [mipmap][face] to use to create each face
  63346. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  63347. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  63348. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  63349. * @returns a promsie that resolves when the operation is complete
  63350. */
  63351. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  63352. /**
  63353. * Clones the raw cube texture.
  63354. * @return a new cube texture
  63355. */
  63356. clone(): CubeTexture;
  63357. /** @hidden */
  63358. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  63359. }
  63360. }
  63361. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  63362. import { Scene } from "babylonjs/scene";
  63363. import { Texture } from "babylonjs/Materials/Textures/texture";
  63364. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63365. /**
  63366. * Class used to store 2D array textures containing user data
  63367. */
  63368. export class RawTexture2DArray extends Texture {
  63369. /** Gets or sets the texture format to use */
  63370. format: number;
  63371. /**
  63372. * Create a new RawTexture2DArray
  63373. * @param data defines the data of the texture
  63374. * @param width defines the width of the texture
  63375. * @param height defines the height of the texture
  63376. * @param depth defines the number of layers of the texture
  63377. * @param format defines the texture format to use
  63378. * @param scene defines the hosting scene
  63379. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  63380. * @param invertY defines if texture must be stored with Y axis inverted
  63381. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  63382. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  63383. */
  63384. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  63385. /** Gets or sets the texture format to use */
  63386. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  63387. /**
  63388. * Update the texture with new data
  63389. * @param data defines the data to store in the texture
  63390. */
  63391. update(data: ArrayBufferView): void;
  63392. }
  63393. }
  63394. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  63395. import { Scene } from "babylonjs/scene";
  63396. import { Texture } from "babylonjs/Materials/Textures/texture";
  63397. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63398. /**
  63399. * Class used to store 3D textures containing user data
  63400. */
  63401. export class RawTexture3D extends Texture {
  63402. /** Gets or sets the texture format to use */
  63403. format: number;
  63404. /**
  63405. * Create a new RawTexture3D
  63406. * @param data defines the data of the texture
  63407. * @param width defines the width of the texture
  63408. * @param height defines the height of the texture
  63409. * @param depth defines the depth of the texture
  63410. * @param format defines the texture format to use
  63411. * @param scene defines the hosting scene
  63412. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  63413. * @param invertY defines if texture must be stored with Y axis inverted
  63414. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  63415. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  63416. */
  63417. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  63418. /** Gets or sets the texture format to use */
  63419. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  63420. /**
  63421. * Update the texture with new data
  63422. * @param data defines the data to store in the texture
  63423. */
  63424. update(data: ArrayBufferView): void;
  63425. }
  63426. }
  63427. declare module "babylonjs/Materials/Textures/refractionTexture" {
  63428. import { Scene } from "babylonjs/scene";
  63429. import { Plane } from "babylonjs/Maths/math.plane";
  63430. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63431. /**
  63432. * Creates a refraction texture used by refraction channel of the standard material.
  63433. * It is like a mirror but to see through a material.
  63434. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63435. */
  63436. export class RefractionTexture extends RenderTargetTexture {
  63437. /**
  63438. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  63439. * 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.
  63440. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63441. */
  63442. refractionPlane: Plane;
  63443. /**
  63444. * Define how deep under the surface we should see.
  63445. */
  63446. depth: number;
  63447. /**
  63448. * Creates a refraction texture used by refraction channel of the standard material.
  63449. * It is like a mirror but to see through a material.
  63450. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63451. * @param name Define the texture name
  63452. * @param size Define the size of the underlying texture
  63453. * @param scene Define the scene the refraction belongs to
  63454. * @param generateMipMaps Define if we need to generate mips level for the refraction
  63455. */
  63456. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  63457. /**
  63458. * Clone the refraction texture.
  63459. * @returns the cloned texture
  63460. */
  63461. clone(): RefractionTexture;
  63462. /**
  63463. * Serialize the texture to a JSON representation you could use in Parse later on
  63464. * @returns the serialized JSON representation
  63465. */
  63466. serialize(): any;
  63467. }
  63468. }
  63469. declare module "babylonjs/Materials/Textures/index" {
  63470. export * from "babylonjs/Materials/Textures/baseTexture";
  63471. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  63472. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  63473. export * from "babylonjs/Materials/Textures/cubeTexture";
  63474. export * from "babylonjs/Materials/Textures/dynamicTexture";
  63475. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  63476. export * from "babylonjs/Materials/Textures/Filtering/hdrFiltering";
  63477. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  63478. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  63479. export * from "babylonjs/Materials/Textures/internalTexture";
  63480. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  63481. export * from "babylonjs/Materials/Textures/Loaders/index";
  63482. export * from "babylonjs/Materials/Textures/mirrorTexture";
  63483. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  63484. export * from "babylonjs/Materials/Textures/Packer/index";
  63485. export * from "babylonjs/Materials/Textures/Procedurals/index";
  63486. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  63487. export * from "babylonjs/Materials/Textures/rawTexture";
  63488. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  63489. export * from "babylonjs/Materials/Textures/rawTexture3D";
  63490. export * from "babylonjs/Materials/Textures/refractionTexture";
  63491. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  63492. export * from "babylonjs/Materials/Textures/texture";
  63493. export * from "babylonjs/Materials/Textures/videoTexture";
  63494. }
  63495. declare module "babylonjs/Materials/Node/Enums/index" {
  63496. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  63497. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  63498. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  63499. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  63500. export * from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  63501. }
  63502. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  63503. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63504. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63505. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63506. import { Mesh } from "babylonjs/Meshes/mesh";
  63507. import { Effect } from "babylonjs/Materials/effect";
  63508. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63509. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  63510. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63511. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63512. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  63513. /**
  63514. * Block used to add support for vertex skinning (bones)
  63515. */
  63516. export class BonesBlock extends NodeMaterialBlock {
  63517. /**
  63518. * Creates a new BonesBlock
  63519. * @param name defines the block name
  63520. */
  63521. constructor(name: string);
  63522. /**
  63523. * Initialize the block and prepare the context for build
  63524. * @param state defines the state that will be used for the build
  63525. */
  63526. initialize(state: NodeMaterialBuildState): void;
  63527. /**
  63528. * Gets the current class name
  63529. * @returns the class name
  63530. */
  63531. getClassName(): string;
  63532. /**
  63533. * Gets the matrix indices input component
  63534. */
  63535. get matricesIndices(): NodeMaterialConnectionPoint;
  63536. /**
  63537. * Gets the matrix weights input component
  63538. */
  63539. get matricesWeights(): NodeMaterialConnectionPoint;
  63540. /**
  63541. * Gets the extra matrix indices input component
  63542. */
  63543. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  63544. /**
  63545. * Gets the extra matrix weights input component
  63546. */
  63547. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  63548. /**
  63549. * Gets the world input component
  63550. */
  63551. get world(): NodeMaterialConnectionPoint;
  63552. /**
  63553. * Gets the output component
  63554. */
  63555. get output(): NodeMaterialConnectionPoint;
  63556. autoConfigure(material: NodeMaterial): void;
  63557. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  63558. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63559. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63560. protected _buildBlock(state: NodeMaterialBuildState): this;
  63561. }
  63562. }
  63563. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  63564. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63565. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63566. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63567. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63568. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  63569. import { SubMesh } from "babylonjs/Meshes/subMesh";
  63570. /**
  63571. * Block used to add support for instances
  63572. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  63573. */
  63574. export class InstancesBlock extends NodeMaterialBlock {
  63575. /**
  63576. * Creates a new InstancesBlock
  63577. * @param name defines the block name
  63578. */
  63579. constructor(name: string);
  63580. /**
  63581. * Gets the current class name
  63582. * @returns the class name
  63583. */
  63584. getClassName(): string;
  63585. /**
  63586. * Gets the first world row input component
  63587. */
  63588. get world0(): NodeMaterialConnectionPoint;
  63589. /**
  63590. * Gets the second world row input component
  63591. */
  63592. get world1(): NodeMaterialConnectionPoint;
  63593. /**
  63594. * Gets the third world row input component
  63595. */
  63596. get world2(): NodeMaterialConnectionPoint;
  63597. /**
  63598. * Gets the forth world row input component
  63599. */
  63600. get world3(): NodeMaterialConnectionPoint;
  63601. /**
  63602. * Gets the world input component
  63603. */
  63604. get world(): NodeMaterialConnectionPoint;
  63605. /**
  63606. * Gets the output component
  63607. */
  63608. get output(): NodeMaterialConnectionPoint;
  63609. /**
  63610. * Gets the isntanceID component
  63611. */
  63612. get instanceID(): NodeMaterialConnectionPoint;
  63613. autoConfigure(material: NodeMaterial): void;
  63614. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  63615. protected _buildBlock(state: NodeMaterialBuildState): this;
  63616. }
  63617. }
  63618. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  63619. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63620. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63621. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63622. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63623. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  63624. import { Effect } from "babylonjs/Materials/effect";
  63625. import { Mesh } from "babylonjs/Meshes/mesh";
  63626. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  63627. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  63628. /**
  63629. * Block used to add morph targets support to vertex shader
  63630. */
  63631. export class MorphTargetsBlock extends NodeMaterialBlock {
  63632. private _repeatableContentAnchor;
  63633. /**
  63634. * Create a new MorphTargetsBlock
  63635. * @param name defines the block name
  63636. */
  63637. constructor(name: string);
  63638. /**
  63639. * Gets the current class name
  63640. * @returns the class name
  63641. */
  63642. getClassName(): string;
  63643. /**
  63644. * Gets the position input component
  63645. */
  63646. get position(): NodeMaterialConnectionPoint;
  63647. /**
  63648. * Gets the normal input component
  63649. */
  63650. get normal(): NodeMaterialConnectionPoint;
  63651. /**
  63652. * Gets the tangent input component
  63653. */
  63654. get tangent(): NodeMaterialConnectionPoint;
  63655. /**
  63656. * Gets the tangent input component
  63657. */
  63658. get uv(): NodeMaterialConnectionPoint;
  63659. /**
  63660. * Gets the position output component
  63661. */
  63662. get positionOutput(): NodeMaterialConnectionPoint;
  63663. /**
  63664. * Gets the normal output component
  63665. */
  63666. get normalOutput(): NodeMaterialConnectionPoint;
  63667. /**
  63668. * Gets the tangent output component
  63669. */
  63670. get tangentOutput(): NodeMaterialConnectionPoint;
  63671. /**
  63672. * Gets the tangent output component
  63673. */
  63674. get uvOutput(): NodeMaterialConnectionPoint;
  63675. initialize(state: NodeMaterialBuildState): void;
  63676. autoConfigure(material: NodeMaterial): void;
  63677. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63678. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63679. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  63680. protected _buildBlock(state: NodeMaterialBuildState): this;
  63681. }
  63682. }
  63683. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  63684. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63685. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63686. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63687. import { Nullable } from "babylonjs/types";
  63688. import { Scene } from "babylonjs/scene";
  63689. import { Effect } from "babylonjs/Materials/effect";
  63690. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  63691. import { Mesh } from "babylonjs/Meshes/mesh";
  63692. import { Light } from "babylonjs/Lights/light";
  63693. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63694. /**
  63695. * Block used to get data information from a light
  63696. */
  63697. export class LightInformationBlock extends NodeMaterialBlock {
  63698. private _lightDataUniformName;
  63699. private _lightColorUniformName;
  63700. private _lightTypeDefineName;
  63701. /**
  63702. * Gets or sets the light associated with this block
  63703. */
  63704. light: Nullable<Light>;
  63705. /**
  63706. * Creates a new LightInformationBlock
  63707. * @param name defines the block name
  63708. */
  63709. constructor(name: string);
  63710. /**
  63711. * Gets the current class name
  63712. * @returns the class name
  63713. */
  63714. getClassName(): string;
  63715. /**
  63716. * Gets the world position input component
  63717. */
  63718. get worldPosition(): NodeMaterialConnectionPoint;
  63719. /**
  63720. * Gets the direction output component
  63721. */
  63722. get direction(): NodeMaterialConnectionPoint;
  63723. /**
  63724. * Gets the direction output component
  63725. */
  63726. get color(): NodeMaterialConnectionPoint;
  63727. /**
  63728. * Gets the direction output component
  63729. */
  63730. get intensity(): NodeMaterialConnectionPoint;
  63731. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63732. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63733. protected _buildBlock(state: NodeMaterialBuildState): this;
  63734. serialize(): any;
  63735. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63736. }
  63737. }
  63738. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  63739. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  63740. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  63741. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  63742. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  63743. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  63744. }
  63745. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  63746. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63747. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63748. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63749. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63750. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  63751. import { Effect } from "babylonjs/Materials/effect";
  63752. import { Mesh } from "babylonjs/Meshes/mesh";
  63753. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63754. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  63755. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  63756. /**
  63757. * Block used to add image processing support to fragment shader
  63758. */
  63759. export class ImageProcessingBlock extends NodeMaterialBlock {
  63760. /**
  63761. * Create a new ImageProcessingBlock
  63762. * @param name defines the block name
  63763. */
  63764. constructor(name: string);
  63765. /**
  63766. * Gets the current class name
  63767. * @returns the class name
  63768. */
  63769. getClassName(): string;
  63770. /**
  63771. * Gets the color input component
  63772. */
  63773. get color(): NodeMaterialConnectionPoint;
  63774. /**
  63775. * Gets the output component
  63776. */
  63777. get output(): NodeMaterialConnectionPoint;
  63778. /**
  63779. * Initialize the block and prepare the context for build
  63780. * @param state defines the state that will be used for the build
  63781. */
  63782. initialize(state: NodeMaterialBuildState): void;
  63783. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  63784. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63785. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63786. protected _buildBlock(state: NodeMaterialBuildState): this;
  63787. }
  63788. }
  63789. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  63790. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63791. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63792. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63793. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  63794. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63795. import { Effect } from "babylonjs/Materials/effect";
  63796. import { Mesh } from "babylonjs/Meshes/mesh";
  63797. import { Scene } from "babylonjs/scene";
  63798. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  63799. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  63800. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  63801. /**
  63802. * Block used to pertub normals based on a normal map
  63803. */
  63804. export class PerturbNormalBlock extends NodeMaterialBlock {
  63805. private _tangentSpaceParameterName;
  63806. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  63807. invertX: boolean;
  63808. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  63809. invertY: boolean;
  63810. /**
  63811. * Create a new PerturbNormalBlock
  63812. * @param name defines the block name
  63813. */
  63814. constructor(name: string);
  63815. /**
  63816. * Gets the current class name
  63817. * @returns the class name
  63818. */
  63819. getClassName(): string;
  63820. /**
  63821. * Gets the world position input component
  63822. */
  63823. get worldPosition(): NodeMaterialConnectionPoint;
  63824. /**
  63825. * Gets the world normal input component
  63826. */
  63827. get worldNormal(): NodeMaterialConnectionPoint;
  63828. /**
  63829. * Gets the world tangent input component
  63830. */
  63831. get worldTangent(): NodeMaterialConnectionPoint;
  63832. /**
  63833. * Gets the uv input component
  63834. */
  63835. get uv(): NodeMaterialConnectionPoint;
  63836. /**
  63837. * Gets the normal map color input component
  63838. */
  63839. get normalMapColor(): NodeMaterialConnectionPoint;
  63840. /**
  63841. * Gets the strength input component
  63842. */
  63843. get strength(): NodeMaterialConnectionPoint;
  63844. /**
  63845. * Gets the output component
  63846. */
  63847. get output(): NodeMaterialConnectionPoint;
  63848. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63849. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63850. autoConfigure(material: NodeMaterial): void;
  63851. protected _buildBlock(state: NodeMaterialBuildState): this;
  63852. protected _dumpPropertiesCode(): string;
  63853. serialize(): any;
  63854. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63855. }
  63856. }
  63857. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  63858. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63859. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63860. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63861. /**
  63862. * Block used to discard a pixel if a value is smaller than a cutoff
  63863. */
  63864. export class DiscardBlock extends NodeMaterialBlock {
  63865. /**
  63866. * Create a new DiscardBlock
  63867. * @param name defines the block name
  63868. */
  63869. constructor(name: string);
  63870. /**
  63871. * Gets the current class name
  63872. * @returns the class name
  63873. */
  63874. getClassName(): string;
  63875. /**
  63876. * Gets the color input component
  63877. */
  63878. get value(): NodeMaterialConnectionPoint;
  63879. /**
  63880. * Gets the cutoff input component
  63881. */
  63882. get cutoff(): NodeMaterialConnectionPoint;
  63883. protected _buildBlock(state: NodeMaterialBuildState): this;
  63884. }
  63885. }
  63886. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  63887. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63888. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63889. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63890. /**
  63891. * Block used to test if the fragment shader is front facing
  63892. */
  63893. export class FrontFacingBlock extends NodeMaterialBlock {
  63894. /**
  63895. * Creates a new FrontFacingBlock
  63896. * @param name defines the block name
  63897. */
  63898. constructor(name: string);
  63899. /**
  63900. * Gets the current class name
  63901. * @returns the class name
  63902. */
  63903. getClassName(): string;
  63904. /**
  63905. * Gets the output component
  63906. */
  63907. get output(): NodeMaterialConnectionPoint;
  63908. protected _buildBlock(state: NodeMaterialBuildState): this;
  63909. }
  63910. }
  63911. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  63912. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63913. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63914. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63915. /**
  63916. * Block used to get the derivative value on x and y of a given input
  63917. */
  63918. export class DerivativeBlock extends NodeMaterialBlock {
  63919. /**
  63920. * Create a new DerivativeBlock
  63921. * @param name defines the block name
  63922. */
  63923. constructor(name: string);
  63924. /**
  63925. * Gets the current class name
  63926. * @returns the class name
  63927. */
  63928. getClassName(): string;
  63929. /**
  63930. * Gets the input component
  63931. */
  63932. get input(): NodeMaterialConnectionPoint;
  63933. /**
  63934. * Gets the derivative output on x
  63935. */
  63936. get dx(): NodeMaterialConnectionPoint;
  63937. /**
  63938. * Gets the derivative output on y
  63939. */
  63940. get dy(): NodeMaterialConnectionPoint;
  63941. protected _buildBlock(state: NodeMaterialBuildState): this;
  63942. }
  63943. }
  63944. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  63945. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  63946. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  63947. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  63948. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  63949. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  63950. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  63951. }
  63952. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  63953. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63954. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63955. import { Mesh } from "babylonjs/Meshes/mesh";
  63956. import { Effect } from "babylonjs/Materials/effect";
  63957. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63958. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63959. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  63960. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  63961. /**
  63962. * Block used to add support for scene fog
  63963. */
  63964. export class FogBlock extends NodeMaterialBlock {
  63965. private _fogDistanceName;
  63966. private _fogParameters;
  63967. /**
  63968. * Create a new FogBlock
  63969. * @param name defines the block name
  63970. */
  63971. constructor(name: string);
  63972. /**
  63973. * Gets the current class name
  63974. * @returns the class name
  63975. */
  63976. getClassName(): string;
  63977. /**
  63978. * Gets the world position input component
  63979. */
  63980. get worldPosition(): NodeMaterialConnectionPoint;
  63981. /**
  63982. * Gets the view input component
  63983. */
  63984. get view(): NodeMaterialConnectionPoint;
  63985. /**
  63986. * Gets the color input component
  63987. */
  63988. get input(): NodeMaterialConnectionPoint;
  63989. /**
  63990. * Gets the fog color input component
  63991. */
  63992. get fogColor(): NodeMaterialConnectionPoint;
  63993. /**
  63994. * Gets the output component
  63995. */
  63996. get output(): NodeMaterialConnectionPoint;
  63997. autoConfigure(material: NodeMaterial): void;
  63998. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63999. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64000. protected _buildBlock(state: NodeMaterialBuildState): this;
  64001. }
  64002. }
  64003. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  64004. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64005. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64006. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64007. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64008. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64009. import { Effect } from "babylonjs/Materials/effect";
  64010. import { Mesh } from "babylonjs/Meshes/mesh";
  64011. import { Light } from "babylonjs/Lights/light";
  64012. import { Nullable } from "babylonjs/types";
  64013. import { Scene } from "babylonjs/scene";
  64014. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  64015. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  64016. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  64017. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  64018. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  64019. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  64020. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  64021. /**
  64022. * Block used to add light in the fragment shader
  64023. */
  64024. export class LightBlock extends NodeMaterialBlock {
  64025. private _lightId;
  64026. /**
  64027. * Gets or sets the light associated with this block
  64028. */
  64029. light: Nullable<Light>;
  64030. /**
  64031. * Create a new LightBlock
  64032. * @param name defines the block name
  64033. */
  64034. constructor(name: string);
  64035. /**
  64036. * Gets the current class name
  64037. * @returns the class name
  64038. */
  64039. getClassName(): string;
  64040. /**
  64041. * Gets the world position input component
  64042. */
  64043. get worldPosition(): NodeMaterialConnectionPoint;
  64044. /**
  64045. * Gets the world normal input component
  64046. */
  64047. get worldNormal(): NodeMaterialConnectionPoint;
  64048. /**
  64049. * Gets the camera (or eye) position component
  64050. */
  64051. get cameraPosition(): NodeMaterialConnectionPoint;
  64052. /**
  64053. * Gets the glossiness component
  64054. */
  64055. get glossiness(): NodeMaterialConnectionPoint;
  64056. /**
  64057. * Gets the glossinness power component
  64058. */
  64059. get glossPower(): NodeMaterialConnectionPoint;
  64060. /**
  64061. * Gets the diffuse color component
  64062. */
  64063. get diffuseColor(): NodeMaterialConnectionPoint;
  64064. /**
  64065. * Gets the specular color component
  64066. */
  64067. get specularColor(): NodeMaterialConnectionPoint;
  64068. /**
  64069. * Gets the diffuse output component
  64070. */
  64071. get diffuseOutput(): NodeMaterialConnectionPoint;
  64072. /**
  64073. * Gets the specular output component
  64074. */
  64075. get specularOutput(): NodeMaterialConnectionPoint;
  64076. /**
  64077. * Gets the shadow output component
  64078. */
  64079. get shadow(): NodeMaterialConnectionPoint;
  64080. autoConfigure(material: NodeMaterial): void;
  64081. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64082. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  64083. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64084. private _injectVertexCode;
  64085. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64086. serialize(): any;
  64087. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64088. }
  64089. }
  64090. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  64091. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64092. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64093. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  64094. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  64095. /**
  64096. * Block used to read a reflection texture from a sampler
  64097. */
  64098. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  64099. /**
  64100. * Create a new ReflectionTextureBlock
  64101. * @param name defines the block name
  64102. */
  64103. constructor(name: string);
  64104. /**
  64105. * Gets the current class name
  64106. * @returns the class name
  64107. */
  64108. getClassName(): string;
  64109. /**
  64110. * Gets the world position input component
  64111. */
  64112. get position(): NodeMaterialConnectionPoint;
  64113. /**
  64114. * Gets the world position input component
  64115. */
  64116. get worldPosition(): NodeMaterialConnectionPoint;
  64117. /**
  64118. * Gets the world normal input component
  64119. */
  64120. get worldNormal(): NodeMaterialConnectionPoint;
  64121. /**
  64122. * Gets the world input component
  64123. */
  64124. get world(): NodeMaterialConnectionPoint;
  64125. /**
  64126. * Gets the camera (or eye) position component
  64127. */
  64128. get cameraPosition(): NodeMaterialConnectionPoint;
  64129. /**
  64130. * Gets the view input component
  64131. */
  64132. get view(): NodeMaterialConnectionPoint;
  64133. /**
  64134. * Gets the rgb output component
  64135. */
  64136. get rgb(): NodeMaterialConnectionPoint;
  64137. /**
  64138. * Gets the r output component
  64139. */
  64140. get r(): NodeMaterialConnectionPoint;
  64141. /**
  64142. * Gets the g output component
  64143. */
  64144. get g(): NodeMaterialConnectionPoint;
  64145. /**
  64146. * Gets the b output component
  64147. */
  64148. get b(): NodeMaterialConnectionPoint;
  64149. autoConfigure(material: NodeMaterial): void;
  64150. protected _buildBlock(state: NodeMaterialBuildState): this;
  64151. }
  64152. }
  64153. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  64154. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  64155. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  64156. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  64157. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  64158. export * from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  64159. }
  64160. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  64161. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  64162. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  64163. }
  64164. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  64165. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64166. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64167. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64168. /**
  64169. * Block used to add 2 vectors
  64170. */
  64171. export class AddBlock extends NodeMaterialBlock {
  64172. /**
  64173. * Creates a new AddBlock
  64174. * @param name defines the block name
  64175. */
  64176. constructor(name: string);
  64177. /**
  64178. * Gets the current class name
  64179. * @returns the class name
  64180. */
  64181. getClassName(): string;
  64182. /**
  64183. * Gets the left operand input component
  64184. */
  64185. get left(): NodeMaterialConnectionPoint;
  64186. /**
  64187. * Gets the right operand input component
  64188. */
  64189. get right(): NodeMaterialConnectionPoint;
  64190. /**
  64191. * Gets the output component
  64192. */
  64193. get output(): NodeMaterialConnectionPoint;
  64194. protected _buildBlock(state: NodeMaterialBuildState): this;
  64195. }
  64196. }
  64197. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  64198. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64199. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64200. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64201. /**
  64202. * Block used to scale a vector by a float
  64203. */
  64204. export class ScaleBlock extends NodeMaterialBlock {
  64205. /**
  64206. * Creates a new ScaleBlock
  64207. * @param name defines the block name
  64208. */
  64209. constructor(name: string);
  64210. /**
  64211. * Gets the current class name
  64212. * @returns the class name
  64213. */
  64214. getClassName(): string;
  64215. /**
  64216. * Gets the input component
  64217. */
  64218. get input(): NodeMaterialConnectionPoint;
  64219. /**
  64220. * Gets the factor input component
  64221. */
  64222. get factor(): NodeMaterialConnectionPoint;
  64223. /**
  64224. * Gets the output component
  64225. */
  64226. get output(): NodeMaterialConnectionPoint;
  64227. protected _buildBlock(state: NodeMaterialBuildState): this;
  64228. }
  64229. }
  64230. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  64231. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64232. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64233. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64234. import { Scene } from "babylonjs/scene";
  64235. /**
  64236. * Block used to clamp a float
  64237. */
  64238. export class ClampBlock extends NodeMaterialBlock {
  64239. /** Gets or sets the minimum range */
  64240. minimum: number;
  64241. /** Gets or sets the maximum range */
  64242. maximum: number;
  64243. /**
  64244. * Creates a new ClampBlock
  64245. * @param name defines the block name
  64246. */
  64247. constructor(name: string);
  64248. /**
  64249. * Gets the current class name
  64250. * @returns the class name
  64251. */
  64252. getClassName(): string;
  64253. /**
  64254. * Gets the value input component
  64255. */
  64256. get value(): NodeMaterialConnectionPoint;
  64257. /**
  64258. * Gets the output component
  64259. */
  64260. get output(): NodeMaterialConnectionPoint;
  64261. protected _buildBlock(state: NodeMaterialBuildState): this;
  64262. protected _dumpPropertiesCode(): string;
  64263. serialize(): any;
  64264. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64265. }
  64266. }
  64267. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  64268. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64269. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64270. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64271. /**
  64272. * Block used to apply a cross product between 2 vectors
  64273. */
  64274. export class CrossBlock extends NodeMaterialBlock {
  64275. /**
  64276. * Creates a new CrossBlock
  64277. * @param name defines the block name
  64278. */
  64279. constructor(name: string);
  64280. /**
  64281. * Gets the current class name
  64282. * @returns the class name
  64283. */
  64284. getClassName(): string;
  64285. /**
  64286. * Gets the left operand input component
  64287. */
  64288. get left(): NodeMaterialConnectionPoint;
  64289. /**
  64290. * Gets the right operand input component
  64291. */
  64292. get right(): NodeMaterialConnectionPoint;
  64293. /**
  64294. * Gets the output component
  64295. */
  64296. get output(): NodeMaterialConnectionPoint;
  64297. protected _buildBlock(state: NodeMaterialBuildState): this;
  64298. }
  64299. }
  64300. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  64301. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64302. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64303. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64304. /**
  64305. * Block used to apply a dot product between 2 vectors
  64306. */
  64307. export class DotBlock extends NodeMaterialBlock {
  64308. /**
  64309. * Creates a new DotBlock
  64310. * @param name defines the block name
  64311. */
  64312. constructor(name: string);
  64313. /**
  64314. * Gets the current class name
  64315. * @returns the class name
  64316. */
  64317. getClassName(): string;
  64318. /**
  64319. * Gets the left operand input component
  64320. */
  64321. get left(): NodeMaterialConnectionPoint;
  64322. /**
  64323. * Gets the right operand input component
  64324. */
  64325. get right(): NodeMaterialConnectionPoint;
  64326. /**
  64327. * Gets the output component
  64328. */
  64329. get output(): NodeMaterialConnectionPoint;
  64330. protected _buildBlock(state: NodeMaterialBuildState): this;
  64331. }
  64332. }
  64333. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  64334. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64335. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64336. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64337. /**
  64338. * Block used to normalize a vector
  64339. */
  64340. export class NormalizeBlock extends NodeMaterialBlock {
  64341. /**
  64342. * Creates a new NormalizeBlock
  64343. * @param name defines the block name
  64344. */
  64345. constructor(name: string);
  64346. /**
  64347. * Gets the current class name
  64348. * @returns the class name
  64349. */
  64350. getClassName(): string;
  64351. /**
  64352. * Gets the input component
  64353. */
  64354. get input(): NodeMaterialConnectionPoint;
  64355. /**
  64356. * Gets the output component
  64357. */
  64358. get output(): NodeMaterialConnectionPoint;
  64359. protected _buildBlock(state: NodeMaterialBuildState): this;
  64360. }
  64361. }
  64362. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  64363. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64364. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64365. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64366. import { Scene } from "babylonjs/scene";
  64367. /**
  64368. * Operations supported by the Trigonometry block
  64369. */
  64370. export enum TrigonometryBlockOperations {
  64371. /** Cos */
  64372. Cos = 0,
  64373. /** Sin */
  64374. Sin = 1,
  64375. /** Abs */
  64376. Abs = 2,
  64377. /** Exp */
  64378. Exp = 3,
  64379. /** Exp2 */
  64380. Exp2 = 4,
  64381. /** Round */
  64382. Round = 5,
  64383. /** Floor */
  64384. Floor = 6,
  64385. /** Ceiling */
  64386. Ceiling = 7,
  64387. /** Square root */
  64388. Sqrt = 8,
  64389. /** Log */
  64390. Log = 9,
  64391. /** Tangent */
  64392. Tan = 10,
  64393. /** Arc tangent */
  64394. ArcTan = 11,
  64395. /** Arc cosinus */
  64396. ArcCos = 12,
  64397. /** Arc sinus */
  64398. ArcSin = 13,
  64399. /** Fraction */
  64400. Fract = 14,
  64401. /** Sign */
  64402. Sign = 15,
  64403. /** To radians (from degrees) */
  64404. Radians = 16,
  64405. /** To degrees (from radians) */
  64406. Degrees = 17
  64407. }
  64408. /**
  64409. * Block used to apply trigonometry operation to floats
  64410. */
  64411. export class TrigonometryBlock extends NodeMaterialBlock {
  64412. /**
  64413. * Gets or sets the operation applied by the block
  64414. */
  64415. operation: TrigonometryBlockOperations;
  64416. /**
  64417. * Creates a new TrigonometryBlock
  64418. * @param name defines the block name
  64419. */
  64420. constructor(name: string);
  64421. /**
  64422. * Gets the current class name
  64423. * @returns the class name
  64424. */
  64425. getClassName(): string;
  64426. /**
  64427. * Gets the input component
  64428. */
  64429. get input(): NodeMaterialConnectionPoint;
  64430. /**
  64431. * Gets the output component
  64432. */
  64433. get output(): NodeMaterialConnectionPoint;
  64434. protected _buildBlock(state: NodeMaterialBuildState): this;
  64435. serialize(): any;
  64436. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64437. protected _dumpPropertiesCode(): string;
  64438. }
  64439. }
  64440. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  64441. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64442. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64443. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64444. /**
  64445. * Block used to create a Color3/4 out of individual inputs (one for each component)
  64446. */
  64447. export class ColorMergerBlock extends NodeMaterialBlock {
  64448. /**
  64449. * Create a new ColorMergerBlock
  64450. * @param name defines the block name
  64451. */
  64452. constructor(name: string);
  64453. /**
  64454. * Gets the current class name
  64455. * @returns the class name
  64456. */
  64457. getClassName(): string;
  64458. /**
  64459. * Gets the rgb component (input)
  64460. */
  64461. get rgbIn(): NodeMaterialConnectionPoint;
  64462. /**
  64463. * Gets the r component (input)
  64464. */
  64465. get r(): NodeMaterialConnectionPoint;
  64466. /**
  64467. * Gets the g component (input)
  64468. */
  64469. get g(): NodeMaterialConnectionPoint;
  64470. /**
  64471. * Gets the b component (input)
  64472. */
  64473. get b(): NodeMaterialConnectionPoint;
  64474. /**
  64475. * Gets the a component (input)
  64476. */
  64477. get a(): NodeMaterialConnectionPoint;
  64478. /**
  64479. * Gets the rgba component (output)
  64480. */
  64481. get rgba(): NodeMaterialConnectionPoint;
  64482. /**
  64483. * Gets the rgb component (output)
  64484. */
  64485. get rgbOut(): NodeMaterialConnectionPoint;
  64486. /**
  64487. * Gets the rgb component (output)
  64488. * @deprecated Please use rgbOut instead.
  64489. */
  64490. get rgb(): NodeMaterialConnectionPoint;
  64491. protected _buildBlock(state: NodeMaterialBuildState): this;
  64492. }
  64493. }
  64494. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  64495. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64496. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64497. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64498. /**
  64499. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  64500. */
  64501. export class VectorSplitterBlock extends NodeMaterialBlock {
  64502. /**
  64503. * Create a new VectorSplitterBlock
  64504. * @param name defines the block name
  64505. */
  64506. constructor(name: string);
  64507. /**
  64508. * Gets the current class name
  64509. * @returns the class name
  64510. */
  64511. getClassName(): string;
  64512. /**
  64513. * Gets the xyzw component (input)
  64514. */
  64515. get xyzw(): NodeMaterialConnectionPoint;
  64516. /**
  64517. * Gets the xyz component (input)
  64518. */
  64519. get xyzIn(): NodeMaterialConnectionPoint;
  64520. /**
  64521. * Gets the xy component (input)
  64522. */
  64523. get xyIn(): NodeMaterialConnectionPoint;
  64524. /**
  64525. * Gets the xyz component (output)
  64526. */
  64527. get xyzOut(): NodeMaterialConnectionPoint;
  64528. /**
  64529. * Gets the xy component (output)
  64530. */
  64531. get xyOut(): NodeMaterialConnectionPoint;
  64532. /**
  64533. * Gets the x component (output)
  64534. */
  64535. get x(): NodeMaterialConnectionPoint;
  64536. /**
  64537. * Gets the y component (output)
  64538. */
  64539. get y(): NodeMaterialConnectionPoint;
  64540. /**
  64541. * Gets the z component (output)
  64542. */
  64543. get z(): NodeMaterialConnectionPoint;
  64544. /**
  64545. * Gets the w component (output)
  64546. */
  64547. get w(): NodeMaterialConnectionPoint;
  64548. protected _inputRename(name: string): string;
  64549. protected _outputRename(name: string): string;
  64550. protected _buildBlock(state: NodeMaterialBuildState): this;
  64551. }
  64552. }
  64553. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  64554. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64555. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64556. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64557. /**
  64558. * Block used to lerp between 2 values
  64559. */
  64560. export class LerpBlock extends NodeMaterialBlock {
  64561. /**
  64562. * Creates a new LerpBlock
  64563. * @param name defines the block name
  64564. */
  64565. constructor(name: string);
  64566. /**
  64567. * Gets the current class name
  64568. * @returns the class name
  64569. */
  64570. getClassName(): string;
  64571. /**
  64572. * Gets the left operand input component
  64573. */
  64574. get left(): NodeMaterialConnectionPoint;
  64575. /**
  64576. * Gets the right operand input component
  64577. */
  64578. get right(): NodeMaterialConnectionPoint;
  64579. /**
  64580. * Gets the gradient operand input component
  64581. */
  64582. get gradient(): NodeMaterialConnectionPoint;
  64583. /**
  64584. * Gets the output component
  64585. */
  64586. get output(): NodeMaterialConnectionPoint;
  64587. protected _buildBlock(state: NodeMaterialBuildState): this;
  64588. }
  64589. }
  64590. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  64591. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64592. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64593. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64594. /**
  64595. * Block used to divide 2 vectors
  64596. */
  64597. export class DivideBlock extends NodeMaterialBlock {
  64598. /**
  64599. * Creates a new DivideBlock
  64600. * @param name defines the block name
  64601. */
  64602. constructor(name: string);
  64603. /**
  64604. * Gets the current class name
  64605. * @returns the class name
  64606. */
  64607. getClassName(): string;
  64608. /**
  64609. * Gets the left operand input component
  64610. */
  64611. get left(): NodeMaterialConnectionPoint;
  64612. /**
  64613. * Gets the right operand input component
  64614. */
  64615. get right(): NodeMaterialConnectionPoint;
  64616. /**
  64617. * Gets the output component
  64618. */
  64619. get output(): NodeMaterialConnectionPoint;
  64620. protected _buildBlock(state: NodeMaterialBuildState): this;
  64621. }
  64622. }
  64623. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  64624. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64625. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64626. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64627. /**
  64628. * Block used to subtract 2 vectors
  64629. */
  64630. export class SubtractBlock extends NodeMaterialBlock {
  64631. /**
  64632. * Creates a new SubtractBlock
  64633. * @param name defines the block name
  64634. */
  64635. constructor(name: string);
  64636. /**
  64637. * Gets the current class name
  64638. * @returns the class name
  64639. */
  64640. getClassName(): string;
  64641. /**
  64642. * Gets the left operand input component
  64643. */
  64644. get left(): NodeMaterialConnectionPoint;
  64645. /**
  64646. * Gets the right operand input component
  64647. */
  64648. get right(): NodeMaterialConnectionPoint;
  64649. /**
  64650. * Gets the output component
  64651. */
  64652. get output(): NodeMaterialConnectionPoint;
  64653. protected _buildBlock(state: NodeMaterialBuildState): this;
  64654. }
  64655. }
  64656. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  64657. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64658. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64659. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64660. /**
  64661. * Block used to step a value
  64662. */
  64663. export class StepBlock extends NodeMaterialBlock {
  64664. /**
  64665. * Creates a new StepBlock
  64666. * @param name defines the block name
  64667. */
  64668. constructor(name: string);
  64669. /**
  64670. * Gets the current class name
  64671. * @returns the class name
  64672. */
  64673. getClassName(): string;
  64674. /**
  64675. * Gets the value operand input component
  64676. */
  64677. get value(): NodeMaterialConnectionPoint;
  64678. /**
  64679. * Gets the edge operand input component
  64680. */
  64681. get edge(): NodeMaterialConnectionPoint;
  64682. /**
  64683. * Gets the output component
  64684. */
  64685. get output(): NodeMaterialConnectionPoint;
  64686. protected _buildBlock(state: NodeMaterialBuildState): this;
  64687. }
  64688. }
  64689. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  64690. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64691. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64692. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64693. /**
  64694. * Block used to get the opposite (1 - x) of a value
  64695. */
  64696. export class OneMinusBlock extends NodeMaterialBlock {
  64697. /**
  64698. * Creates a new OneMinusBlock
  64699. * @param name defines the block name
  64700. */
  64701. constructor(name: string);
  64702. /**
  64703. * Gets the current class name
  64704. * @returns the class name
  64705. */
  64706. getClassName(): string;
  64707. /**
  64708. * Gets the input component
  64709. */
  64710. get input(): NodeMaterialConnectionPoint;
  64711. /**
  64712. * Gets the output component
  64713. */
  64714. get output(): NodeMaterialConnectionPoint;
  64715. protected _buildBlock(state: NodeMaterialBuildState): this;
  64716. }
  64717. }
  64718. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  64719. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64720. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64721. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64722. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  64723. /**
  64724. * Block used to get the view direction
  64725. */
  64726. export class ViewDirectionBlock extends NodeMaterialBlock {
  64727. /**
  64728. * Creates a new ViewDirectionBlock
  64729. * @param name defines the block name
  64730. */
  64731. constructor(name: string);
  64732. /**
  64733. * Gets the current class name
  64734. * @returns the class name
  64735. */
  64736. getClassName(): string;
  64737. /**
  64738. * Gets the world position component
  64739. */
  64740. get worldPosition(): NodeMaterialConnectionPoint;
  64741. /**
  64742. * Gets the camera position component
  64743. */
  64744. get cameraPosition(): NodeMaterialConnectionPoint;
  64745. /**
  64746. * Gets the output component
  64747. */
  64748. get output(): NodeMaterialConnectionPoint;
  64749. autoConfigure(material: NodeMaterial): void;
  64750. protected _buildBlock(state: NodeMaterialBuildState): this;
  64751. }
  64752. }
  64753. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  64754. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64755. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64756. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64757. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  64758. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  64759. /**
  64760. * Block used to compute fresnel value
  64761. */
  64762. export class FresnelBlock extends NodeMaterialBlock {
  64763. /**
  64764. * Create a new FresnelBlock
  64765. * @param name defines the block name
  64766. */
  64767. constructor(name: string);
  64768. /**
  64769. * Gets the current class name
  64770. * @returns the class name
  64771. */
  64772. getClassName(): string;
  64773. /**
  64774. * Gets the world normal input component
  64775. */
  64776. get worldNormal(): NodeMaterialConnectionPoint;
  64777. /**
  64778. * Gets the view direction input component
  64779. */
  64780. get viewDirection(): NodeMaterialConnectionPoint;
  64781. /**
  64782. * Gets the bias input component
  64783. */
  64784. get bias(): NodeMaterialConnectionPoint;
  64785. /**
  64786. * Gets the camera (or eye) position component
  64787. */
  64788. get power(): NodeMaterialConnectionPoint;
  64789. /**
  64790. * Gets the fresnel output component
  64791. */
  64792. get fresnel(): NodeMaterialConnectionPoint;
  64793. autoConfigure(material: NodeMaterial): void;
  64794. protected _buildBlock(state: NodeMaterialBuildState): this;
  64795. }
  64796. }
  64797. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  64798. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64799. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64800. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64801. /**
  64802. * Block used to get the max of 2 values
  64803. */
  64804. export class MaxBlock extends NodeMaterialBlock {
  64805. /**
  64806. * Creates a new MaxBlock
  64807. * @param name defines the block name
  64808. */
  64809. constructor(name: string);
  64810. /**
  64811. * Gets the current class name
  64812. * @returns the class name
  64813. */
  64814. getClassName(): string;
  64815. /**
  64816. * Gets the left operand input component
  64817. */
  64818. get left(): NodeMaterialConnectionPoint;
  64819. /**
  64820. * Gets the right operand input component
  64821. */
  64822. get right(): NodeMaterialConnectionPoint;
  64823. /**
  64824. * Gets the output component
  64825. */
  64826. get output(): NodeMaterialConnectionPoint;
  64827. protected _buildBlock(state: NodeMaterialBuildState): this;
  64828. }
  64829. }
  64830. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  64831. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64832. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64833. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64834. /**
  64835. * Block used to get the min of 2 values
  64836. */
  64837. export class MinBlock extends NodeMaterialBlock {
  64838. /**
  64839. * Creates a new MinBlock
  64840. * @param name defines the block name
  64841. */
  64842. constructor(name: string);
  64843. /**
  64844. * Gets the current class name
  64845. * @returns the class name
  64846. */
  64847. getClassName(): string;
  64848. /**
  64849. * Gets the left operand input component
  64850. */
  64851. get left(): NodeMaterialConnectionPoint;
  64852. /**
  64853. * Gets the right operand input component
  64854. */
  64855. get right(): NodeMaterialConnectionPoint;
  64856. /**
  64857. * Gets the output component
  64858. */
  64859. get output(): NodeMaterialConnectionPoint;
  64860. protected _buildBlock(state: NodeMaterialBuildState): this;
  64861. }
  64862. }
  64863. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  64864. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64865. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64866. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64867. /**
  64868. * Block used to get the distance between 2 values
  64869. */
  64870. export class DistanceBlock extends NodeMaterialBlock {
  64871. /**
  64872. * Creates a new DistanceBlock
  64873. * @param name defines the block name
  64874. */
  64875. constructor(name: string);
  64876. /**
  64877. * Gets the current class name
  64878. * @returns the class name
  64879. */
  64880. getClassName(): string;
  64881. /**
  64882. * Gets the left operand input component
  64883. */
  64884. get left(): NodeMaterialConnectionPoint;
  64885. /**
  64886. * Gets the right operand input component
  64887. */
  64888. get right(): NodeMaterialConnectionPoint;
  64889. /**
  64890. * Gets the output component
  64891. */
  64892. get output(): NodeMaterialConnectionPoint;
  64893. protected _buildBlock(state: NodeMaterialBuildState): this;
  64894. }
  64895. }
  64896. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  64897. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64898. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64899. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64900. /**
  64901. * Block used to get the length of a vector
  64902. */
  64903. export class LengthBlock extends NodeMaterialBlock {
  64904. /**
  64905. * Creates a new LengthBlock
  64906. * @param name defines the block name
  64907. */
  64908. constructor(name: string);
  64909. /**
  64910. * Gets the current class name
  64911. * @returns the class name
  64912. */
  64913. getClassName(): string;
  64914. /**
  64915. * Gets the value input component
  64916. */
  64917. get value(): NodeMaterialConnectionPoint;
  64918. /**
  64919. * Gets the output component
  64920. */
  64921. get output(): NodeMaterialConnectionPoint;
  64922. protected _buildBlock(state: NodeMaterialBuildState): this;
  64923. }
  64924. }
  64925. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  64926. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64927. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64928. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64929. /**
  64930. * Block used to get negative version of a value (i.e. x * -1)
  64931. */
  64932. export class NegateBlock extends NodeMaterialBlock {
  64933. /**
  64934. * Creates a new NegateBlock
  64935. * @param name defines the block name
  64936. */
  64937. constructor(name: string);
  64938. /**
  64939. * Gets the current class name
  64940. * @returns the class name
  64941. */
  64942. getClassName(): string;
  64943. /**
  64944. * Gets the value input component
  64945. */
  64946. get value(): NodeMaterialConnectionPoint;
  64947. /**
  64948. * Gets the output component
  64949. */
  64950. get output(): NodeMaterialConnectionPoint;
  64951. protected _buildBlock(state: NodeMaterialBuildState): this;
  64952. }
  64953. }
  64954. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  64955. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64956. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64957. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64958. /**
  64959. * Block used to get the value of the first parameter raised to the power of the second
  64960. */
  64961. export class PowBlock extends NodeMaterialBlock {
  64962. /**
  64963. * Creates a new PowBlock
  64964. * @param name defines the block name
  64965. */
  64966. constructor(name: string);
  64967. /**
  64968. * Gets the current class name
  64969. * @returns the class name
  64970. */
  64971. getClassName(): string;
  64972. /**
  64973. * Gets the value operand input component
  64974. */
  64975. get value(): NodeMaterialConnectionPoint;
  64976. /**
  64977. * Gets the power operand input component
  64978. */
  64979. get power(): NodeMaterialConnectionPoint;
  64980. /**
  64981. * Gets the output component
  64982. */
  64983. get output(): NodeMaterialConnectionPoint;
  64984. protected _buildBlock(state: NodeMaterialBuildState): this;
  64985. }
  64986. }
  64987. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  64988. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64989. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64990. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64991. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  64992. /**
  64993. * Block used to get a random number
  64994. */
  64995. export class RandomNumberBlock extends NodeMaterialBlock {
  64996. /**
  64997. * Creates a new RandomNumberBlock
  64998. * @param name defines the block name
  64999. */
  65000. constructor(name: string);
  65001. /**
  65002. * Gets the current class name
  65003. * @returns the class name
  65004. */
  65005. getClassName(): string;
  65006. /**
  65007. * Gets the seed input component
  65008. */
  65009. get seed(): NodeMaterialConnectionPoint;
  65010. /**
  65011. * Gets the output component
  65012. */
  65013. get output(): NodeMaterialConnectionPoint;
  65014. protected _buildBlock(state: NodeMaterialBuildState): this;
  65015. }
  65016. }
  65017. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  65018. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65019. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65020. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65021. /**
  65022. * Block used to compute arc tangent of 2 values
  65023. */
  65024. export class ArcTan2Block extends NodeMaterialBlock {
  65025. /**
  65026. * Creates a new ArcTan2Block
  65027. * @param name defines the block name
  65028. */
  65029. constructor(name: string);
  65030. /**
  65031. * Gets the current class name
  65032. * @returns the class name
  65033. */
  65034. getClassName(): string;
  65035. /**
  65036. * Gets the x operand input component
  65037. */
  65038. get x(): NodeMaterialConnectionPoint;
  65039. /**
  65040. * Gets the y operand input component
  65041. */
  65042. get y(): NodeMaterialConnectionPoint;
  65043. /**
  65044. * Gets the output component
  65045. */
  65046. get output(): NodeMaterialConnectionPoint;
  65047. protected _buildBlock(state: NodeMaterialBuildState): this;
  65048. }
  65049. }
  65050. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  65051. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65052. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65053. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65054. /**
  65055. * Block used to smooth step a value
  65056. */
  65057. export class SmoothStepBlock extends NodeMaterialBlock {
  65058. /**
  65059. * Creates a new SmoothStepBlock
  65060. * @param name defines the block name
  65061. */
  65062. constructor(name: string);
  65063. /**
  65064. * Gets the current class name
  65065. * @returns the class name
  65066. */
  65067. getClassName(): string;
  65068. /**
  65069. * Gets the value operand input component
  65070. */
  65071. get value(): NodeMaterialConnectionPoint;
  65072. /**
  65073. * Gets the first edge operand input component
  65074. */
  65075. get edge0(): NodeMaterialConnectionPoint;
  65076. /**
  65077. * Gets the second edge operand input component
  65078. */
  65079. get edge1(): NodeMaterialConnectionPoint;
  65080. /**
  65081. * Gets the output component
  65082. */
  65083. get output(): NodeMaterialConnectionPoint;
  65084. protected _buildBlock(state: NodeMaterialBuildState): this;
  65085. }
  65086. }
  65087. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  65088. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65089. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65090. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65091. /**
  65092. * Block used to get the reciprocal (1 / x) of a value
  65093. */
  65094. export class ReciprocalBlock extends NodeMaterialBlock {
  65095. /**
  65096. * Creates a new ReciprocalBlock
  65097. * @param name defines the block name
  65098. */
  65099. constructor(name: string);
  65100. /**
  65101. * Gets the current class name
  65102. * @returns the class name
  65103. */
  65104. getClassName(): string;
  65105. /**
  65106. * Gets the input component
  65107. */
  65108. get input(): NodeMaterialConnectionPoint;
  65109. /**
  65110. * Gets the output component
  65111. */
  65112. get output(): NodeMaterialConnectionPoint;
  65113. protected _buildBlock(state: NodeMaterialBuildState): this;
  65114. }
  65115. }
  65116. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  65117. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65118. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65119. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65120. /**
  65121. * Block used to replace a color by another one
  65122. */
  65123. export class ReplaceColorBlock extends NodeMaterialBlock {
  65124. /**
  65125. * Creates a new ReplaceColorBlock
  65126. * @param name defines the block name
  65127. */
  65128. constructor(name: string);
  65129. /**
  65130. * Gets the current class name
  65131. * @returns the class name
  65132. */
  65133. getClassName(): string;
  65134. /**
  65135. * Gets the value input component
  65136. */
  65137. get value(): NodeMaterialConnectionPoint;
  65138. /**
  65139. * Gets the reference input component
  65140. */
  65141. get reference(): NodeMaterialConnectionPoint;
  65142. /**
  65143. * Gets the distance input component
  65144. */
  65145. get distance(): NodeMaterialConnectionPoint;
  65146. /**
  65147. * Gets the replacement input component
  65148. */
  65149. get replacement(): NodeMaterialConnectionPoint;
  65150. /**
  65151. * Gets the output component
  65152. */
  65153. get output(): NodeMaterialConnectionPoint;
  65154. protected _buildBlock(state: NodeMaterialBuildState): this;
  65155. }
  65156. }
  65157. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  65158. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65159. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65160. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65161. /**
  65162. * Block used to posterize a value
  65163. * @see https://en.wikipedia.org/wiki/Posterization
  65164. */
  65165. export class PosterizeBlock extends NodeMaterialBlock {
  65166. /**
  65167. * Creates a new PosterizeBlock
  65168. * @param name defines the block name
  65169. */
  65170. constructor(name: string);
  65171. /**
  65172. * Gets the current class name
  65173. * @returns the class name
  65174. */
  65175. getClassName(): string;
  65176. /**
  65177. * Gets the value input component
  65178. */
  65179. get value(): NodeMaterialConnectionPoint;
  65180. /**
  65181. * Gets the steps input component
  65182. */
  65183. get steps(): NodeMaterialConnectionPoint;
  65184. /**
  65185. * Gets the output component
  65186. */
  65187. get output(): NodeMaterialConnectionPoint;
  65188. protected _buildBlock(state: NodeMaterialBuildState): this;
  65189. }
  65190. }
  65191. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  65192. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65193. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65194. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65195. import { Scene } from "babylonjs/scene";
  65196. /**
  65197. * Operations supported by the Wave block
  65198. */
  65199. export enum WaveBlockKind {
  65200. /** SawTooth */
  65201. SawTooth = 0,
  65202. /** Square */
  65203. Square = 1,
  65204. /** Triangle */
  65205. Triangle = 2
  65206. }
  65207. /**
  65208. * Block used to apply wave operation to floats
  65209. */
  65210. export class WaveBlock extends NodeMaterialBlock {
  65211. /**
  65212. * Gets or sets the kibnd of wave to be applied by the block
  65213. */
  65214. kind: WaveBlockKind;
  65215. /**
  65216. * Creates a new WaveBlock
  65217. * @param name defines the block name
  65218. */
  65219. constructor(name: string);
  65220. /**
  65221. * Gets the current class name
  65222. * @returns the class name
  65223. */
  65224. getClassName(): string;
  65225. /**
  65226. * Gets the input component
  65227. */
  65228. get input(): NodeMaterialConnectionPoint;
  65229. /**
  65230. * Gets the output component
  65231. */
  65232. get output(): NodeMaterialConnectionPoint;
  65233. protected _buildBlock(state: NodeMaterialBuildState): this;
  65234. serialize(): any;
  65235. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65236. }
  65237. }
  65238. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  65239. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65240. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65241. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65242. import { Color3 } from "babylonjs/Maths/math.color";
  65243. import { Scene } from "babylonjs/scene";
  65244. /**
  65245. * Class used to store a color step for the GradientBlock
  65246. */
  65247. export class GradientBlockColorStep {
  65248. /**
  65249. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  65250. */
  65251. step: number;
  65252. /**
  65253. * Gets or sets the color associated with this step
  65254. */
  65255. color: Color3;
  65256. /**
  65257. * Creates a new GradientBlockColorStep
  65258. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  65259. * @param color defines the color associated with this step
  65260. */
  65261. constructor(
  65262. /**
  65263. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  65264. */
  65265. step: number,
  65266. /**
  65267. * Gets or sets the color associated with this step
  65268. */
  65269. color: Color3);
  65270. }
  65271. /**
  65272. * Block used to return a color from a gradient based on an input value between 0 and 1
  65273. */
  65274. export class GradientBlock extends NodeMaterialBlock {
  65275. /**
  65276. * Gets or sets the list of color steps
  65277. */
  65278. colorSteps: GradientBlockColorStep[];
  65279. /**
  65280. * Creates a new GradientBlock
  65281. * @param name defines the block name
  65282. */
  65283. constructor(name: string);
  65284. /**
  65285. * Gets the current class name
  65286. * @returns the class name
  65287. */
  65288. getClassName(): string;
  65289. /**
  65290. * Gets the gradient input component
  65291. */
  65292. get gradient(): NodeMaterialConnectionPoint;
  65293. /**
  65294. * Gets the output component
  65295. */
  65296. get output(): NodeMaterialConnectionPoint;
  65297. private _writeColorConstant;
  65298. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65299. serialize(): any;
  65300. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65301. protected _dumpPropertiesCode(): string;
  65302. }
  65303. }
  65304. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  65305. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65306. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65307. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65308. /**
  65309. * Block used to normalize lerp between 2 values
  65310. */
  65311. export class NLerpBlock extends NodeMaterialBlock {
  65312. /**
  65313. * Creates a new NLerpBlock
  65314. * @param name defines the block name
  65315. */
  65316. constructor(name: string);
  65317. /**
  65318. * Gets the current class name
  65319. * @returns the class name
  65320. */
  65321. getClassName(): string;
  65322. /**
  65323. * Gets the left operand input component
  65324. */
  65325. get left(): NodeMaterialConnectionPoint;
  65326. /**
  65327. * Gets the right operand input component
  65328. */
  65329. get right(): NodeMaterialConnectionPoint;
  65330. /**
  65331. * Gets the gradient operand input component
  65332. */
  65333. get gradient(): NodeMaterialConnectionPoint;
  65334. /**
  65335. * Gets the output component
  65336. */
  65337. get output(): NodeMaterialConnectionPoint;
  65338. protected _buildBlock(state: NodeMaterialBuildState): this;
  65339. }
  65340. }
  65341. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  65342. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65343. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65344. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65345. import { Scene } from "babylonjs/scene";
  65346. /**
  65347. * block used to Generate a Worley Noise 3D Noise Pattern
  65348. */
  65349. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  65350. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  65351. manhattanDistance: boolean;
  65352. /**
  65353. * Creates a new WorleyNoise3DBlock
  65354. * @param name defines the block name
  65355. */
  65356. constructor(name: string);
  65357. /**
  65358. * Gets the current class name
  65359. * @returns the class name
  65360. */
  65361. getClassName(): string;
  65362. /**
  65363. * Gets the seed input component
  65364. */
  65365. get seed(): NodeMaterialConnectionPoint;
  65366. /**
  65367. * Gets the jitter input component
  65368. */
  65369. get jitter(): NodeMaterialConnectionPoint;
  65370. /**
  65371. * Gets the output component
  65372. */
  65373. get output(): NodeMaterialConnectionPoint;
  65374. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65375. /**
  65376. * Exposes the properties to the UI?
  65377. */
  65378. protected _dumpPropertiesCode(): string;
  65379. /**
  65380. * Exposes the properties to the Seralize?
  65381. */
  65382. serialize(): any;
  65383. /**
  65384. * Exposes the properties to the deseralize?
  65385. */
  65386. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65387. }
  65388. }
  65389. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  65390. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65391. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65392. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65393. /**
  65394. * block used to Generate a Simplex Perlin 3d Noise Pattern
  65395. */
  65396. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  65397. /**
  65398. * Creates a new SimplexPerlin3DBlock
  65399. * @param name defines the block name
  65400. */
  65401. constructor(name: string);
  65402. /**
  65403. * Gets the current class name
  65404. * @returns the class name
  65405. */
  65406. getClassName(): string;
  65407. /**
  65408. * Gets the seed operand input component
  65409. */
  65410. get seed(): NodeMaterialConnectionPoint;
  65411. /**
  65412. * Gets the output component
  65413. */
  65414. get output(): NodeMaterialConnectionPoint;
  65415. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65416. }
  65417. }
  65418. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  65419. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65420. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65421. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65422. /**
  65423. * Block used to blend normals
  65424. */
  65425. export class NormalBlendBlock extends NodeMaterialBlock {
  65426. /**
  65427. * Creates a new NormalBlendBlock
  65428. * @param name defines the block name
  65429. */
  65430. constructor(name: string);
  65431. /**
  65432. * Gets the current class name
  65433. * @returns the class name
  65434. */
  65435. getClassName(): string;
  65436. /**
  65437. * Gets the first input component
  65438. */
  65439. get normalMap0(): NodeMaterialConnectionPoint;
  65440. /**
  65441. * Gets the second input component
  65442. */
  65443. get normalMap1(): NodeMaterialConnectionPoint;
  65444. /**
  65445. * Gets the output component
  65446. */
  65447. get output(): NodeMaterialConnectionPoint;
  65448. protected _buildBlock(state: NodeMaterialBuildState): this;
  65449. }
  65450. }
  65451. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  65452. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65453. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65454. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65455. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  65456. /**
  65457. * Block used to rotate a 2d vector by a given angle
  65458. */
  65459. export class Rotate2dBlock extends NodeMaterialBlock {
  65460. /**
  65461. * Creates a new Rotate2dBlock
  65462. * @param name defines the block name
  65463. */
  65464. constructor(name: string);
  65465. /**
  65466. * Gets the current class name
  65467. * @returns the class name
  65468. */
  65469. getClassName(): string;
  65470. /**
  65471. * Gets the input vector
  65472. */
  65473. get input(): NodeMaterialConnectionPoint;
  65474. /**
  65475. * Gets the input angle
  65476. */
  65477. get angle(): NodeMaterialConnectionPoint;
  65478. /**
  65479. * Gets the output component
  65480. */
  65481. get output(): NodeMaterialConnectionPoint;
  65482. autoConfigure(material: NodeMaterial): void;
  65483. protected _buildBlock(state: NodeMaterialBuildState): this;
  65484. }
  65485. }
  65486. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  65487. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65488. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65489. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65490. /**
  65491. * Block used to get the reflected vector from a direction and a normal
  65492. */
  65493. export class ReflectBlock extends NodeMaterialBlock {
  65494. /**
  65495. * Creates a new ReflectBlock
  65496. * @param name defines the block name
  65497. */
  65498. constructor(name: string);
  65499. /**
  65500. * Gets the current class name
  65501. * @returns the class name
  65502. */
  65503. getClassName(): string;
  65504. /**
  65505. * Gets the incident component
  65506. */
  65507. get incident(): NodeMaterialConnectionPoint;
  65508. /**
  65509. * Gets the normal component
  65510. */
  65511. get normal(): NodeMaterialConnectionPoint;
  65512. /**
  65513. * Gets the output component
  65514. */
  65515. get output(): NodeMaterialConnectionPoint;
  65516. protected _buildBlock(state: NodeMaterialBuildState): this;
  65517. }
  65518. }
  65519. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  65520. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65521. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65522. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65523. /**
  65524. * Block used to get the refracted vector from a direction and a normal
  65525. */
  65526. export class RefractBlock extends NodeMaterialBlock {
  65527. /**
  65528. * Creates a new RefractBlock
  65529. * @param name defines the block name
  65530. */
  65531. constructor(name: string);
  65532. /**
  65533. * Gets the current class name
  65534. * @returns the class name
  65535. */
  65536. getClassName(): string;
  65537. /**
  65538. * Gets the incident component
  65539. */
  65540. get incident(): NodeMaterialConnectionPoint;
  65541. /**
  65542. * Gets the normal component
  65543. */
  65544. get normal(): NodeMaterialConnectionPoint;
  65545. /**
  65546. * Gets the index of refraction component
  65547. */
  65548. get ior(): NodeMaterialConnectionPoint;
  65549. /**
  65550. * Gets the output component
  65551. */
  65552. get output(): NodeMaterialConnectionPoint;
  65553. protected _buildBlock(state: NodeMaterialBuildState): this;
  65554. }
  65555. }
  65556. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  65557. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65558. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65559. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65560. /**
  65561. * Block used to desaturate a color
  65562. */
  65563. export class DesaturateBlock extends NodeMaterialBlock {
  65564. /**
  65565. * Creates a new DesaturateBlock
  65566. * @param name defines the block name
  65567. */
  65568. constructor(name: string);
  65569. /**
  65570. * Gets the current class name
  65571. * @returns the class name
  65572. */
  65573. getClassName(): string;
  65574. /**
  65575. * Gets the color operand input component
  65576. */
  65577. get color(): NodeMaterialConnectionPoint;
  65578. /**
  65579. * Gets the level operand input component
  65580. */
  65581. get level(): NodeMaterialConnectionPoint;
  65582. /**
  65583. * Gets the output component
  65584. */
  65585. get output(): NodeMaterialConnectionPoint;
  65586. protected _buildBlock(state: NodeMaterialBuildState): this;
  65587. }
  65588. }
  65589. declare module "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock" {
  65590. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65591. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65592. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65593. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65594. import { Nullable } from "babylonjs/types";
  65595. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65596. import { Scene } from "babylonjs/scene";
  65597. /**
  65598. * Block used to implement the ambient occlusion module of the PBR material
  65599. */
  65600. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  65601. /**
  65602. * Create a new AmbientOcclusionBlock
  65603. * @param name defines the block name
  65604. */
  65605. constructor(name: string);
  65606. /**
  65607. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  65608. */
  65609. useAmbientInGrayScale: boolean;
  65610. /**
  65611. * Initialize the block and prepare the context for build
  65612. * @param state defines the state that will be used for the build
  65613. */
  65614. initialize(state: NodeMaterialBuildState): void;
  65615. /**
  65616. * Gets the current class name
  65617. * @returns the class name
  65618. */
  65619. getClassName(): string;
  65620. /**
  65621. * Gets the texture input component
  65622. */
  65623. get texture(): NodeMaterialConnectionPoint;
  65624. /**
  65625. * Gets the texture intensity component
  65626. */
  65627. get intensity(): NodeMaterialConnectionPoint;
  65628. /**
  65629. * Gets the direct light intensity input component
  65630. */
  65631. get directLightIntensity(): NodeMaterialConnectionPoint;
  65632. /**
  65633. * Gets the ambient occlusion object output component
  65634. */
  65635. get ambientOcclusion(): NodeMaterialConnectionPoint;
  65636. /**
  65637. * Gets the main code of the block (fragment side)
  65638. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  65639. * @returns the shader code
  65640. */
  65641. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  65642. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65643. protected _buildBlock(state: NodeMaterialBuildState): this;
  65644. protected _dumpPropertiesCode(): string;
  65645. serialize(): any;
  65646. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65647. }
  65648. }
  65649. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock" {
  65650. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65651. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65652. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65653. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  65654. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65655. import { Nullable } from "babylonjs/types";
  65656. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65657. import { Mesh } from "babylonjs/Meshes/mesh";
  65658. import { SubMesh } from "babylonjs/Meshes/subMesh";
  65659. import { Effect } from "babylonjs/Materials/effect";
  65660. import { Scene } from "babylonjs/scene";
  65661. /**
  65662. * Block used to implement the reflection module of the PBR material
  65663. */
  65664. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  65665. /** @hidden */
  65666. _defineLODReflectionAlpha: string;
  65667. /** @hidden */
  65668. _defineLinearSpecularReflection: string;
  65669. private _vEnvironmentIrradianceName;
  65670. /** @hidden */
  65671. _vReflectionMicrosurfaceInfosName: string;
  65672. /** @hidden */
  65673. _vReflectionInfosName: string;
  65674. private _scene;
  65675. /**
  65676. * The three properties below are set by the main PBR block prior to calling methods of this class.
  65677. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  65678. * It's less burden on the user side in the editor part.
  65679. */
  65680. /** @hidden */
  65681. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  65682. /** @hidden */
  65683. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  65684. /** @hidden */
  65685. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  65686. /**
  65687. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  65688. * diffuse part of the IBL.
  65689. */
  65690. useSphericalHarmonics: boolean;
  65691. /**
  65692. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  65693. */
  65694. forceIrradianceInFragment: boolean;
  65695. /**
  65696. * Create a new ReflectionBlock
  65697. * @param name defines the block name
  65698. */
  65699. constructor(name: string);
  65700. /**
  65701. * Gets the current class name
  65702. * @returns the class name
  65703. */
  65704. getClassName(): string;
  65705. /**
  65706. * Gets the position input component
  65707. */
  65708. get position(): NodeMaterialConnectionPoint;
  65709. /**
  65710. * Gets the world position input component
  65711. */
  65712. get worldPosition(): NodeMaterialConnectionPoint;
  65713. /**
  65714. * Gets the world normal input component
  65715. */
  65716. get worldNormal(): NodeMaterialConnectionPoint;
  65717. /**
  65718. * Gets the world input component
  65719. */
  65720. get world(): NodeMaterialConnectionPoint;
  65721. /**
  65722. * Gets the camera (or eye) position component
  65723. */
  65724. get cameraPosition(): NodeMaterialConnectionPoint;
  65725. /**
  65726. * Gets the view input component
  65727. */
  65728. get view(): NodeMaterialConnectionPoint;
  65729. /**
  65730. * Gets the color input component
  65731. */
  65732. get color(): NodeMaterialConnectionPoint;
  65733. /**
  65734. * Gets the reflection object output component
  65735. */
  65736. get reflection(): NodeMaterialConnectionPoint;
  65737. /**
  65738. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  65739. */
  65740. get hasTexture(): boolean;
  65741. /**
  65742. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  65743. */
  65744. get reflectionColor(): string;
  65745. protected _getTexture(): Nullable<BaseTexture>;
  65746. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65747. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  65748. /**
  65749. * Gets the code to inject in the vertex shader
  65750. * @param state current state of the node material building
  65751. * @returns the shader code
  65752. */
  65753. handleVertexSide(state: NodeMaterialBuildState): string;
  65754. /**
  65755. * Gets the main code of the block (fragment side)
  65756. * @param state current state of the node material building
  65757. * @param normalVarName name of the existing variable corresponding to the normal
  65758. * @returns the shader code
  65759. */
  65760. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  65761. protected _buildBlock(state: NodeMaterialBuildState): this;
  65762. protected _dumpPropertiesCode(): string;
  65763. serialize(): any;
  65764. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65765. }
  65766. }
  65767. declare module "babylonjs/Materials/Node/Blocks/PBR/sheenBlock" {
  65768. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65769. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65770. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65771. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65772. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65773. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  65774. import { Scene } from "babylonjs/scene";
  65775. import { Nullable } from "babylonjs/types";
  65776. /**
  65777. * Block used to implement the sheen module of the PBR material
  65778. */
  65779. export class SheenBlock extends NodeMaterialBlock {
  65780. /**
  65781. * Create a new SheenBlock
  65782. * @param name defines the block name
  65783. */
  65784. constructor(name: string);
  65785. /**
  65786. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  65787. * It allows the strength of the sheen effect to not depend on the base color of the material,
  65788. * making it easier to setup and tweak the effect
  65789. */
  65790. albedoScaling: boolean;
  65791. /**
  65792. * Defines if the sheen is linked to the sheen color.
  65793. */
  65794. linkSheenWithAlbedo: boolean;
  65795. /**
  65796. * Initialize the block and prepare the context for build
  65797. * @param state defines the state that will be used for the build
  65798. */
  65799. initialize(state: NodeMaterialBuildState): void;
  65800. /**
  65801. * Gets the current class name
  65802. * @returns the class name
  65803. */
  65804. getClassName(): string;
  65805. /**
  65806. * Gets the intensity input component
  65807. */
  65808. get intensity(): NodeMaterialConnectionPoint;
  65809. /**
  65810. * Gets the color input component
  65811. */
  65812. get color(): NodeMaterialConnectionPoint;
  65813. /**
  65814. * Gets the roughness input component
  65815. */
  65816. get roughness(): NodeMaterialConnectionPoint;
  65817. /**
  65818. * Gets the texture input component
  65819. */
  65820. get texture(): NodeMaterialConnectionPoint;
  65821. /**
  65822. * Gets the sheen object output component
  65823. */
  65824. get sheen(): NodeMaterialConnectionPoint;
  65825. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65826. /**
  65827. * Gets the main code of the block (fragment side)
  65828. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  65829. * @returns the shader code
  65830. */
  65831. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  65832. protected _buildBlock(state: NodeMaterialBuildState): this;
  65833. protected _dumpPropertiesCode(): string;
  65834. serialize(): any;
  65835. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65836. }
  65837. }
  65838. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock" {
  65839. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65840. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65841. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65842. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65843. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65844. import { Scene } from "babylonjs/scene";
  65845. /**
  65846. * Block used to implement the reflectivity module of the PBR material
  65847. */
  65848. export class ReflectivityBlock extends NodeMaterialBlock {
  65849. /**
  65850. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  65851. */
  65852. useAmbientOcclusionFromMetallicTextureRed: boolean;
  65853. /**
  65854. * Specifies if the metallic texture contains the metallness information in its blue channel.
  65855. */
  65856. useMetallnessFromMetallicTextureBlue: boolean;
  65857. /**
  65858. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  65859. */
  65860. useRoughnessFromMetallicTextureAlpha: boolean;
  65861. /**
  65862. * Specifies if the metallic texture contains the roughness information in its green channel.
  65863. */
  65864. useRoughnessFromMetallicTextureGreen: boolean;
  65865. /**
  65866. * Create a new ReflectivityBlock
  65867. * @param name defines the block name
  65868. */
  65869. constructor(name: string);
  65870. /**
  65871. * Initialize the block and prepare the context for build
  65872. * @param state defines the state that will be used for the build
  65873. */
  65874. initialize(state: NodeMaterialBuildState): void;
  65875. /**
  65876. * Gets the current class name
  65877. * @returns the class name
  65878. */
  65879. getClassName(): string;
  65880. /**
  65881. * Gets the metallic input component
  65882. */
  65883. get metallic(): NodeMaterialConnectionPoint;
  65884. /**
  65885. * Gets the roughness input component
  65886. */
  65887. get roughness(): NodeMaterialConnectionPoint;
  65888. /**
  65889. * Gets the texture input component
  65890. */
  65891. get texture(): NodeMaterialConnectionPoint;
  65892. /**
  65893. * Gets the reflectivity object output component
  65894. */
  65895. get reflectivity(): NodeMaterialConnectionPoint;
  65896. /**
  65897. * Gets the main code of the block (fragment side)
  65898. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  65899. * @returns the shader code
  65900. */
  65901. getCode(aoIntensityVarName: string): string;
  65902. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65903. protected _buildBlock(state: NodeMaterialBuildState): this;
  65904. protected _dumpPropertiesCode(): string;
  65905. serialize(): any;
  65906. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65907. }
  65908. }
  65909. declare module "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock" {
  65910. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65911. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65912. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65913. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65914. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65915. /**
  65916. * Block used to implement the anisotropy module of the PBR material
  65917. */
  65918. export class AnisotropyBlock extends NodeMaterialBlock {
  65919. /**
  65920. * The two properties below are set by the main PBR block prior to calling methods of this class.
  65921. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  65922. * It's less burden on the user side in the editor part.
  65923. */
  65924. /** @hidden */
  65925. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  65926. /** @hidden */
  65927. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  65928. /**
  65929. * Create a new AnisotropyBlock
  65930. * @param name defines the block name
  65931. */
  65932. constructor(name: string);
  65933. /**
  65934. * Initialize the block and prepare the context for build
  65935. * @param state defines the state that will be used for the build
  65936. */
  65937. initialize(state: NodeMaterialBuildState): void;
  65938. /**
  65939. * Gets the current class name
  65940. * @returns the class name
  65941. */
  65942. getClassName(): string;
  65943. /**
  65944. * Gets the intensity input component
  65945. */
  65946. get intensity(): NodeMaterialConnectionPoint;
  65947. /**
  65948. * Gets the direction input component
  65949. */
  65950. get direction(): NodeMaterialConnectionPoint;
  65951. /**
  65952. * Gets the texture input component
  65953. */
  65954. get texture(): NodeMaterialConnectionPoint;
  65955. /**
  65956. * Gets the uv input component
  65957. */
  65958. get uv(): NodeMaterialConnectionPoint;
  65959. /**
  65960. * Gets the worldTangent input component
  65961. */
  65962. get worldTangent(): NodeMaterialConnectionPoint;
  65963. /**
  65964. * Gets the anisotropy object output component
  65965. */
  65966. get anisotropy(): NodeMaterialConnectionPoint;
  65967. private _generateTBNSpace;
  65968. /**
  65969. * Gets the main code of the block (fragment side)
  65970. * @param state current state of the node material building
  65971. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  65972. * @returns the shader code
  65973. */
  65974. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  65975. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65976. protected _buildBlock(state: NodeMaterialBuildState): this;
  65977. }
  65978. }
  65979. declare module "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock" {
  65980. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65981. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65982. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65983. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65984. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65985. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  65986. import { Nullable } from "babylonjs/types";
  65987. import { Mesh } from "babylonjs/Meshes/mesh";
  65988. import { SubMesh } from "babylonjs/Meshes/subMesh";
  65989. import { Effect } from "babylonjs/Materials/effect";
  65990. /**
  65991. * Block used to implement the clear coat module of the PBR material
  65992. */
  65993. export class ClearCoatBlock extends NodeMaterialBlock {
  65994. private _scene;
  65995. /**
  65996. * Create a new ClearCoatBlock
  65997. * @param name defines the block name
  65998. */
  65999. constructor(name: string);
  66000. /**
  66001. * Initialize the block and prepare the context for build
  66002. * @param state defines the state that will be used for the build
  66003. */
  66004. initialize(state: NodeMaterialBuildState): void;
  66005. /**
  66006. * Gets the current class name
  66007. * @returns the class name
  66008. */
  66009. getClassName(): string;
  66010. /**
  66011. * Gets the intensity input component
  66012. */
  66013. get intensity(): NodeMaterialConnectionPoint;
  66014. /**
  66015. * Gets the roughness input component
  66016. */
  66017. get roughness(): NodeMaterialConnectionPoint;
  66018. /**
  66019. * Gets the ior input component
  66020. */
  66021. get ior(): NodeMaterialConnectionPoint;
  66022. /**
  66023. * Gets the texture input component
  66024. */
  66025. get texture(): NodeMaterialConnectionPoint;
  66026. /**
  66027. * Gets the bump texture input component
  66028. */
  66029. get bumpTexture(): NodeMaterialConnectionPoint;
  66030. /**
  66031. * Gets the uv input component
  66032. */
  66033. get uv(): NodeMaterialConnectionPoint;
  66034. /**
  66035. * Gets the tint color input component
  66036. */
  66037. get tintColor(): NodeMaterialConnectionPoint;
  66038. /**
  66039. * Gets the tint "at distance" input component
  66040. */
  66041. get tintAtDistance(): NodeMaterialConnectionPoint;
  66042. /**
  66043. * Gets the tint thickness input component
  66044. */
  66045. get tintThickness(): NodeMaterialConnectionPoint;
  66046. /**
  66047. * Gets the tint texture input component
  66048. */
  66049. get tintTexture(): NodeMaterialConnectionPoint;
  66050. /**
  66051. * Gets the world tangent input component
  66052. */
  66053. get worldTangent(): NodeMaterialConnectionPoint;
  66054. /**
  66055. * Gets the clear coat object output component
  66056. */
  66057. get clearcoat(): NodeMaterialConnectionPoint;
  66058. autoConfigure(material: NodeMaterial): void;
  66059. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66060. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  66061. private _generateTBNSpace;
  66062. /**
  66063. * Gets the main code of the block (fragment side)
  66064. * @param state current state of the node material building
  66065. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  66066. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  66067. * @param worldPosVarName name of the variable holding the world position
  66068. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  66069. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  66070. * @param worldNormalVarName name of the variable holding the world normal
  66071. * @returns the shader code
  66072. */
  66073. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  66074. protected _buildBlock(state: NodeMaterialBuildState): this;
  66075. }
  66076. }
  66077. declare module "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock" {
  66078. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66079. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66080. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66081. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66082. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66083. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  66084. import { Nullable } from "babylonjs/types";
  66085. /**
  66086. * Block used to implement the sub surface module of the PBR material
  66087. */
  66088. export class SubSurfaceBlock extends NodeMaterialBlock {
  66089. /**
  66090. * Create a new SubSurfaceBlock
  66091. * @param name defines the block name
  66092. */
  66093. constructor(name: string);
  66094. /**
  66095. * Stores the intensity of the different subsurface effects in the thickness texture.
  66096. * * the green channel is the translucency intensity.
  66097. * * the blue channel is the scattering intensity.
  66098. * * the alpha channel is the refraction intensity.
  66099. */
  66100. useMaskFromThicknessTexture: boolean;
  66101. /**
  66102. * Initialize the block and prepare the context for build
  66103. * @param state defines the state that will be used for the build
  66104. */
  66105. initialize(state: NodeMaterialBuildState): void;
  66106. /**
  66107. * Gets the current class name
  66108. * @returns the class name
  66109. */
  66110. getClassName(): string;
  66111. /**
  66112. * Gets the min thickness input component
  66113. */
  66114. get minThickness(): NodeMaterialConnectionPoint;
  66115. /**
  66116. * Gets the max thickness input component
  66117. */
  66118. get maxThickness(): NodeMaterialConnectionPoint;
  66119. /**
  66120. * Gets the thickness texture component
  66121. */
  66122. get thicknessTexture(): NodeMaterialConnectionPoint;
  66123. /**
  66124. * Gets the tint color input component
  66125. */
  66126. get tintColor(): NodeMaterialConnectionPoint;
  66127. /**
  66128. * Gets the translucency intensity input component
  66129. */
  66130. get translucencyIntensity(): NodeMaterialConnectionPoint;
  66131. /**
  66132. * Gets the translucency diffusion distance input component
  66133. */
  66134. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  66135. /**
  66136. * Gets the refraction object parameters
  66137. */
  66138. get refraction(): NodeMaterialConnectionPoint;
  66139. /**
  66140. * Gets the sub surface object output component
  66141. */
  66142. get subsurface(): NodeMaterialConnectionPoint;
  66143. autoConfigure(material: NodeMaterial): void;
  66144. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66145. /**
  66146. * Gets the main code of the block (fragment side)
  66147. * @param state current state of the node material building
  66148. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  66149. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  66150. * @param worldPosVarName name of the variable holding the world position
  66151. * @returns the shader code
  66152. */
  66153. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  66154. protected _buildBlock(state: NodeMaterialBuildState): this;
  66155. }
  66156. }
  66157. declare module "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock" {
  66158. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66159. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66160. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66161. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66162. import { Light } from "babylonjs/Lights/light";
  66163. import { Nullable } from "babylonjs/types";
  66164. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66165. import { Effect } from "babylonjs/Materials/effect";
  66166. import { Mesh } from "babylonjs/Meshes/mesh";
  66167. import { Scene } from "babylonjs/scene";
  66168. /**
  66169. * Block used to implement the PBR metallic/roughness model
  66170. */
  66171. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  66172. /**
  66173. * Gets or sets the light associated with this block
  66174. */
  66175. light: Nullable<Light>;
  66176. private _lightId;
  66177. private _scene;
  66178. private _environmentBRDFTexture;
  66179. private _environmentBrdfSamplerName;
  66180. private _vNormalWName;
  66181. private _invertNormalName;
  66182. /**
  66183. * Create a new ReflectionBlock
  66184. * @param name defines the block name
  66185. */
  66186. constructor(name: string);
  66187. /**
  66188. * Intensity of the direct lights e.g. the four lights available in your scene.
  66189. * This impacts both the direct diffuse and specular highlights.
  66190. */
  66191. directIntensity: number;
  66192. /**
  66193. * Intensity of the environment e.g. how much the environment will light the object
  66194. * either through harmonics for rough material or through the refelction for shiny ones.
  66195. */
  66196. environmentIntensity: number;
  66197. /**
  66198. * This is a special control allowing the reduction of the specular highlights coming from the
  66199. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  66200. */
  66201. specularIntensity: number;
  66202. /**
  66203. * Defines the falloff type used in this material.
  66204. * It by default is Physical.
  66205. */
  66206. lightFalloff: number;
  66207. /**
  66208. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  66209. */
  66210. useAlphaFromAlbedoTexture: boolean;
  66211. /**
  66212. * Specifies that alpha test should be used
  66213. */
  66214. useAlphaTest: boolean;
  66215. /**
  66216. * Defines the alpha limits in alpha test mode.
  66217. */
  66218. alphaTestCutoff: number;
  66219. /**
  66220. * Specifies that alpha blending should be used
  66221. */
  66222. useAlphaBlending: boolean;
  66223. /**
  66224. * Defines if the alpha value should be determined via the rgb values.
  66225. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  66226. */
  66227. opacityRGB: boolean;
  66228. /**
  66229. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  66230. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  66231. */
  66232. useRadianceOverAlpha: boolean;
  66233. /**
  66234. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  66235. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  66236. */
  66237. useSpecularOverAlpha: boolean;
  66238. /**
  66239. * Enables specular anti aliasing in the PBR shader.
  66240. * It will both interacts on the Geometry for analytical and IBL lighting.
  66241. * It also prefilter the roughness map based on the bump values.
  66242. */
  66243. enableSpecularAntiAliasing: boolean;
  66244. /**
  66245. * Defines if the material uses energy conservation.
  66246. */
  66247. useEnergyConservation: boolean;
  66248. /**
  66249. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  66250. * too much the area relying on ambient texture to define their ambient occlusion.
  66251. */
  66252. useRadianceOcclusion: boolean;
  66253. /**
  66254. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  66255. * makes the reflect vector face the model (under horizon).
  66256. */
  66257. useHorizonOcclusion: boolean;
  66258. /**
  66259. * If set to true, no lighting calculations will be applied.
  66260. */
  66261. unlit: boolean;
  66262. /**
  66263. * Force normal to face away from face.
  66264. */
  66265. forceNormalForward: boolean;
  66266. /**
  66267. * Defines the material debug mode.
  66268. * It helps seeing only some components of the material while troubleshooting.
  66269. */
  66270. debugMode: number;
  66271. /**
  66272. * Specify from where on screen the debug mode should start.
  66273. * The value goes from -1 (full screen) to 1 (not visible)
  66274. * It helps with side by side comparison against the final render
  66275. * This defaults to 0
  66276. */
  66277. debugLimit: number;
  66278. /**
  66279. * As the default viewing range might not be enough (if the ambient is really small for instance)
  66280. * You can use the factor to better multiply the final value.
  66281. */
  66282. debugFactor: number;
  66283. /**
  66284. * Initialize the block and prepare the context for build
  66285. * @param state defines the state that will be used for the build
  66286. */
  66287. initialize(state: NodeMaterialBuildState): void;
  66288. /**
  66289. * Gets the current class name
  66290. * @returns the class name
  66291. */
  66292. getClassName(): string;
  66293. /**
  66294. * Gets the world position input component
  66295. */
  66296. get worldPosition(): NodeMaterialConnectionPoint;
  66297. /**
  66298. * Gets the world normal input component
  66299. */
  66300. get worldNormal(): NodeMaterialConnectionPoint;
  66301. /**
  66302. * Gets the perturbed normal input component
  66303. */
  66304. get perturbedNormal(): NodeMaterialConnectionPoint;
  66305. /**
  66306. * Gets the camera position input component
  66307. */
  66308. get cameraPosition(): NodeMaterialConnectionPoint;
  66309. /**
  66310. * Gets the base color input component
  66311. */
  66312. get baseColor(): NodeMaterialConnectionPoint;
  66313. /**
  66314. * Gets the base texture input component
  66315. */
  66316. get baseTexture(): NodeMaterialConnectionPoint;
  66317. /**
  66318. * Gets the opacity texture input component
  66319. */
  66320. get opacityTexture(): NodeMaterialConnectionPoint;
  66321. /**
  66322. * Gets the ambient color input component
  66323. */
  66324. get ambientColor(): NodeMaterialConnectionPoint;
  66325. /**
  66326. * Gets the reflectivity object parameters
  66327. */
  66328. get reflectivity(): NodeMaterialConnectionPoint;
  66329. /**
  66330. * Gets the ambient occlusion object parameters
  66331. */
  66332. get ambientOcclusion(): NodeMaterialConnectionPoint;
  66333. /**
  66334. * Gets the reflection object parameters
  66335. */
  66336. get reflection(): NodeMaterialConnectionPoint;
  66337. /**
  66338. * Gets the sheen object parameters
  66339. */
  66340. get sheen(): NodeMaterialConnectionPoint;
  66341. /**
  66342. * Gets the clear coat object parameters
  66343. */
  66344. get clearcoat(): NodeMaterialConnectionPoint;
  66345. /**
  66346. * Gets the sub surface object parameters
  66347. */
  66348. get subsurface(): NodeMaterialConnectionPoint;
  66349. /**
  66350. * Gets the anisotropy object parameters
  66351. */
  66352. get anisotropy(): NodeMaterialConnectionPoint;
  66353. /**
  66354. * Gets the ambient output component
  66355. */
  66356. get ambient(): NodeMaterialConnectionPoint;
  66357. /**
  66358. * Gets the diffuse output component
  66359. */
  66360. get diffuse(): NodeMaterialConnectionPoint;
  66361. /**
  66362. * Gets the specular output component
  66363. */
  66364. get specular(): NodeMaterialConnectionPoint;
  66365. /**
  66366. * Gets the sheen output component
  66367. */
  66368. get sheenDir(): NodeMaterialConnectionPoint;
  66369. /**
  66370. * Gets the clear coat output component
  66371. */
  66372. get clearcoatDir(): NodeMaterialConnectionPoint;
  66373. /**
  66374. * Gets the indirect diffuse output component
  66375. */
  66376. get diffuseIndirect(): NodeMaterialConnectionPoint;
  66377. /**
  66378. * Gets the indirect specular output component
  66379. */
  66380. get specularIndirect(): NodeMaterialConnectionPoint;
  66381. /**
  66382. * Gets the indirect sheen output component
  66383. */
  66384. get sheenIndirect(): NodeMaterialConnectionPoint;
  66385. /**
  66386. * Gets the indirect clear coat output component
  66387. */
  66388. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  66389. /**
  66390. * Gets the refraction output component
  66391. */
  66392. get refraction(): NodeMaterialConnectionPoint;
  66393. /**
  66394. * Gets the global lighting output component
  66395. */
  66396. get lighting(): NodeMaterialConnectionPoint;
  66397. /**
  66398. * Gets the shadow output component
  66399. */
  66400. get shadow(): NodeMaterialConnectionPoint;
  66401. /**
  66402. * Gets the alpha output component
  66403. */
  66404. get alpha(): NodeMaterialConnectionPoint;
  66405. autoConfigure(material: NodeMaterial): void;
  66406. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66407. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  66408. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66409. private _injectVertexCode;
  66410. /**
  66411. * Gets the code corresponding to the albedo/opacity module
  66412. * @returns the shader code
  66413. */
  66414. getAlbedoOpacityCode(): string;
  66415. protected _buildBlock(state: NodeMaterialBuildState): this;
  66416. protected _dumpPropertiesCode(): string;
  66417. serialize(): any;
  66418. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66419. }
  66420. }
  66421. declare module "babylonjs/Materials/Node/Blocks/PBR/index" {
  66422. export * from "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock";
  66423. export * from "babylonjs/Materials/Node/Blocks/PBR/sheenBlock";
  66424. export * from "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock";
  66425. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock";
  66426. export * from "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock";
  66427. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  66428. export * from "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock";
  66429. export * from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  66430. export * from "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock";
  66431. }
  66432. declare module "babylonjs/Materials/Node/Blocks/Particle/index" {
  66433. export * from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  66434. export * from "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock";
  66435. export * from "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock";
  66436. }
  66437. declare module "babylonjs/Materials/Node/Blocks/modBlock" {
  66438. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66439. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66440. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66441. /**
  66442. * Block used to compute value of one parameter modulo another
  66443. */
  66444. export class ModBlock extends NodeMaterialBlock {
  66445. /**
  66446. * Creates a new ModBlock
  66447. * @param name defines the block name
  66448. */
  66449. constructor(name: string);
  66450. /**
  66451. * Gets the current class name
  66452. * @returns the class name
  66453. */
  66454. getClassName(): string;
  66455. /**
  66456. * Gets the left operand input component
  66457. */
  66458. get left(): NodeMaterialConnectionPoint;
  66459. /**
  66460. * Gets the right operand input component
  66461. */
  66462. get right(): NodeMaterialConnectionPoint;
  66463. /**
  66464. * Gets the output component
  66465. */
  66466. get output(): NodeMaterialConnectionPoint;
  66467. protected _buildBlock(state: NodeMaterialBuildState): this;
  66468. }
  66469. }
  66470. declare module "babylonjs/Materials/Node/Blocks/index" {
  66471. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  66472. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  66473. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  66474. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  66475. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  66476. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  66477. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  66478. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  66479. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  66480. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  66481. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  66482. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  66483. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  66484. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  66485. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  66486. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  66487. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  66488. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  66489. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  66490. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  66491. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  66492. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  66493. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  66494. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  66495. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  66496. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  66497. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  66498. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  66499. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  66500. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  66501. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  66502. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  66503. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  66504. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  66505. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  66506. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  66507. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  66508. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  66509. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  66510. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  66511. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  66512. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  66513. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  66514. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  66515. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  66516. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  66517. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  66518. export * from "babylonjs/Materials/Node/Blocks/PBR/index";
  66519. export * from "babylonjs/Materials/Node/Blocks/Particle/index";
  66520. export * from "babylonjs/Materials/Node/Blocks/modBlock";
  66521. }
  66522. declare module "babylonjs/Materials/Node/Optimizers/index" {
  66523. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  66524. }
  66525. declare module "babylonjs/Materials/Node/index" {
  66526. export * from "babylonjs/Materials/Node/Enums/index";
  66527. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66528. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  66529. export * from "babylonjs/Materials/Node/nodeMaterial";
  66530. export * from "babylonjs/Materials/Node/Blocks/index";
  66531. export * from "babylonjs/Materials/Node/Optimizers/index";
  66532. export * from "babylonjs/Materials/Node/nodeMaterialDecorator";
  66533. }
  66534. declare module "babylonjs/Materials/index" {
  66535. export * from "babylonjs/Materials/Background/index";
  66536. export * from "babylonjs/Materials/colorCurves";
  66537. export * from "babylonjs/Materials/iEffectFallbacks";
  66538. export * from "babylonjs/Materials/effectFallbacks";
  66539. export * from "babylonjs/Materials/effect";
  66540. export * from "babylonjs/Materials/fresnelParameters";
  66541. export * from "babylonjs/Materials/imageProcessingConfiguration";
  66542. export * from "babylonjs/Materials/material";
  66543. export * from "babylonjs/Materials/materialDefines";
  66544. export * from "babylonjs/Materials/materialHelper";
  66545. export * from "babylonjs/Materials/multiMaterial";
  66546. export * from "babylonjs/Materials/PBR/index";
  66547. export * from "babylonjs/Materials/pushMaterial";
  66548. export * from "babylonjs/Materials/shaderMaterial";
  66549. export * from "babylonjs/Materials/standardMaterial";
  66550. export * from "babylonjs/Materials/Textures/index";
  66551. export * from "babylonjs/Materials/uniformBuffer";
  66552. export * from "babylonjs/Materials/materialFlags";
  66553. export * from "babylonjs/Materials/Node/index";
  66554. export * from "babylonjs/Materials/effectRenderer";
  66555. export * from "babylonjs/Materials/shadowDepthWrapper";
  66556. }
  66557. declare module "babylonjs/Maths/index" {
  66558. export * from "babylonjs/Maths/math.scalar";
  66559. export * from "babylonjs/Maths/math";
  66560. export * from "babylonjs/Maths/sphericalPolynomial";
  66561. }
  66562. declare module "babylonjs/Misc/workerPool" {
  66563. import { IDisposable } from "babylonjs/scene";
  66564. /**
  66565. * Helper class to push actions to a pool of workers.
  66566. */
  66567. export class WorkerPool implements IDisposable {
  66568. private _workerInfos;
  66569. private _pendingActions;
  66570. /**
  66571. * Constructor
  66572. * @param workers Array of workers to use for actions
  66573. */
  66574. constructor(workers: Array<Worker>);
  66575. /**
  66576. * Terminates all workers and clears any pending actions.
  66577. */
  66578. dispose(): void;
  66579. /**
  66580. * Pushes an action to the worker pool. If all the workers are active, the action will be
  66581. * pended until a worker has completed its action.
  66582. * @param action The action to perform. Call onComplete when the action is complete.
  66583. */
  66584. push(action: (worker: Worker, onComplete: () => void) => void): void;
  66585. private _execute;
  66586. }
  66587. }
  66588. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  66589. import { IDisposable } from "babylonjs/scene";
  66590. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  66591. /**
  66592. * Configuration for Draco compression
  66593. */
  66594. export interface IDracoCompressionConfiguration {
  66595. /**
  66596. * Configuration for the decoder.
  66597. */
  66598. decoder: {
  66599. /**
  66600. * The url to the WebAssembly module.
  66601. */
  66602. wasmUrl?: string;
  66603. /**
  66604. * The url to the WebAssembly binary.
  66605. */
  66606. wasmBinaryUrl?: string;
  66607. /**
  66608. * The url to the fallback JavaScript module.
  66609. */
  66610. fallbackUrl?: string;
  66611. };
  66612. }
  66613. /**
  66614. * Draco compression (https://google.github.io/draco/)
  66615. *
  66616. * This class wraps the Draco module.
  66617. *
  66618. * **Encoder**
  66619. *
  66620. * The encoder is not currently implemented.
  66621. *
  66622. * **Decoder**
  66623. *
  66624. * 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.
  66625. *
  66626. * To update the configuration, use the following code:
  66627. * ```javascript
  66628. * DracoCompression.Configuration = {
  66629. * decoder: {
  66630. * wasmUrl: "<url to the WebAssembly library>",
  66631. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  66632. * fallbackUrl: "<url to the fallback JavaScript library>",
  66633. * }
  66634. * };
  66635. * ```
  66636. *
  66637. * 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.
  66638. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  66639. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  66640. *
  66641. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  66642. * ```javascript
  66643. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  66644. * ```
  66645. *
  66646. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  66647. */
  66648. export class DracoCompression implements IDisposable {
  66649. private _workerPoolPromise?;
  66650. private _decoderModulePromise?;
  66651. /**
  66652. * The configuration. Defaults to the following urls:
  66653. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  66654. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  66655. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  66656. */
  66657. static Configuration: IDracoCompressionConfiguration;
  66658. /**
  66659. * Returns true if the decoder configuration is available.
  66660. */
  66661. static get DecoderAvailable(): boolean;
  66662. /**
  66663. * Default number of workers to create when creating the draco compression object.
  66664. */
  66665. static DefaultNumWorkers: number;
  66666. private static GetDefaultNumWorkers;
  66667. private static _Default;
  66668. /**
  66669. * Default instance for the draco compression object.
  66670. */
  66671. static get Default(): DracoCompression;
  66672. /**
  66673. * Constructor
  66674. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  66675. */
  66676. constructor(numWorkers?: number);
  66677. /**
  66678. * Stop all async operations and release resources.
  66679. */
  66680. dispose(): void;
  66681. /**
  66682. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  66683. * @returns a promise that resolves when ready
  66684. */
  66685. whenReadyAsync(): Promise<void>;
  66686. /**
  66687. * Decode Draco compressed mesh data to vertex data.
  66688. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  66689. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  66690. * @returns A promise that resolves with the decoded vertex data
  66691. */
  66692. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  66693. [kind: string]: number;
  66694. }): Promise<VertexData>;
  66695. }
  66696. }
  66697. declare module "babylonjs/Meshes/Compression/index" {
  66698. export * from "babylonjs/Meshes/Compression/dracoCompression";
  66699. }
  66700. declare module "babylonjs/Meshes/csg" {
  66701. import { Nullable } from "babylonjs/types";
  66702. import { Scene } from "babylonjs/scene";
  66703. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  66704. import { Mesh } from "babylonjs/Meshes/mesh";
  66705. import { Material } from "babylonjs/Materials/material";
  66706. /**
  66707. * Class for building Constructive Solid Geometry
  66708. */
  66709. export class CSG {
  66710. private polygons;
  66711. /**
  66712. * The world matrix
  66713. */
  66714. matrix: Matrix;
  66715. /**
  66716. * Stores the position
  66717. */
  66718. position: Vector3;
  66719. /**
  66720. * Stores the rotation
  66721. */
  66722. rotation: Vector3;
  66723. /**
  66724. * Stores the rotation quaternion
  66725. */
  66726. rotationQuaternion: Nullable<Quaternion>;
  66727. /**
  66728. * Stores the scaling vector
  66729. */
  66730. scaling: Vector3;
  66731. /**
  66732. * Convert the Mesh to CSG
  66733. * @param mesh The Mesh to convert to CSG
  66734. * @returns A new CSG from the Mesh
  66735. */
  66736. static FromMesh(mesh: Mesh): CSG;
  66737. /**
  66738. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  66739. * @param polygons Polygons used to construct a CSG solid
  66740. */
  66741. private static FromPolygons;
  66742. /**
  66743. * Clones, or makes a deep copy, of the CSG
  66744. * @returns A new CSG
  66745. */
  66746. clone(): CSG;
  66747. /**
  66748. * Unions this CSG with another CSG
  66749. * @param csg The CSG to union against this CSG
  66750. * @returns The unioned CSG
  66751. */
  66752. union(csg: CSG): CSG;
  66753. /**
  66754. * Unions this CSG with another CSG in place
  66755. * @param csg The CSG to union against this CSG
  66756. */
  66757. unionInPlace(csg: CSG): void;
  66758. /**
  66759. * Subtracts this CSG with another CSG
  66760. * @param csg The CSG to subtract against this CSG
  66761. * @returns A new CSG
  66762. */
  66763. subtract(csg: CSG): CSG;
  66764. /**
  66765. * Subtracts this CSG with another CSG in place
  66766. * @param csg The CSG to subtact against this CSG
  66767. */
  66768. subtractInPlace(csg: CSG): void;
  66769. /**
  66770. * Intersect this CSG with another CSG
  66771. * @param csg The CSG to intersect against this CSG
  66772. * @returns A new CSG
  66773. */
  66774. intersect(csg: CSG): CSG;
  66775. /**
  66776. * Intersects this CSG with another CSG in place
  66777. * @param csg The CSG to intersect against this CSG
  66778. */
  66779. intersectInPlace(csg: CSG): void;
  66780. /**
  66781. * Return a new CSG solid with solid and empty space switched. This solid is
  66782. * not modified.
  66783. * @returns A new CSG solid with solid and empty space switched
  66784. */
  66785. inverse(): CSG;
  66786. /**
  66787. * Inverses the CSG in place
  66788. */
  66789. inverseInPlace(): void;
  66790. /**
  66791. * This is used to keep meshes transformations so they can be restored
  66792. * when we build back a Babylon Mesh
  66793. * NB : All CSG operations are performed in world coordinates
  66794. * @param csg The CSG to copy the transform attributes from
  66795. * @returns This CSG
  66796. */
  66797. copyTransformAttributes(csg: CSG): CSG;
  66798. /**
  66799. * Build Raw mesh from CSG
  66800. * Coordinates here are in world space
  66801. * @param name The name of the mesh geometry
  66802. * @param scene The Scene
  66803. * @param keepSubMeshes Specifies if the submeshes should be kept
  66804. * @returns A new Mesh
  66805. */
  66806. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  66807. /**
  66808. * Build Mesh from CSG taking material and transforms into account
  66809. * @param name The name of the Mesh
  66810. * @param material The material of the Mesh
  66811. * @param scene The Scene
  66812. * @param keepSubMeshes Specifies if submeshes should be kept
  66813. * @returns The new Mesh
  66814. */
  66815. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  66816. }
  66817. }
  66818. declare module "babylonjs/Meshes/trailMesh" {
  66819. import { Mesh } from "babylonjs/Meshes/mesh";
  66820. import { Scene } from "babylonjs/scene";
  66821. import { TransformNode } from "babylonjs/Meshes/transformNode";
  66822. /**
  66823. * Class used to create a trail following a mesh
  66824. */
  66825. export class TrailMesh extends Mesh {
  66826. private _generator;
  66827. private _autoStart;
  66828. private _running;
  66829. private _diameter;
  66830. private _length;
  66831. private _sectionPolygonPointsCount;
  66832. private _sectionVectors;
  66833. private _sectionNormalVectors;
  66834. private _beforeRenderObserver;
  66835. /**
  66836. * @constructor
  66837. * @param name The value used by scene.getMeshByName() to do a lookup.
  66838. * @param generator The mesh or transform node to generate a trail.
  66839. * @param scene The scene to add this mesh to.
  66840. * @param diameter Diameter of trailing mesh. Default is 1.
  66841. * @param length Length of trailing mesh. Default is 60.
  66842. * @param autoStart Automatically start trailing mesh. Default true.
  66843. */
  66844. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  66845. /**
  66846. * "TrailMesh"
  66847. * @returns "TrailMesh"
  66848. */
  66849. getClassName(): string;
  66850. private _createMesh;
  66851. /**
  66852. * Start trailing mesh.
  66853. */
  66854. start(): void;
  66855. /**
  66856. * Stop trailing mesh.
  66857. */
  66858. stop(): void;
  66859. /**
  66860. * Update trailing mesh geometry.
  66861. */
  66862. update(): void;
  66863. /**
  66864. * Returns a new TrailMesh object.
  66865. * @param name is a string, the name given to the new mesh
  66866. * @param newGenerator use new generator object for cloned trail mesh
  66867. * @returns a new mesh
  66868. */
  66869. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  66870. /**
  66871. * Serializes this trail mesh
  66872. * @param serializationObject object to write serialization to
  66873. */
  66874. serialize(serializationObject: any): void;
  66875. /**
  66876. * Parses a serialized trail mesh
  66877. * @param parsedMesh the serialized mesh
  66878. * @param scene the scene to create the trail mesh in
  66879. * @returns the created trail mesh
  66880. */
  66881. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  66882. }
  66883. }
  66884. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  66885. import { Nullable } from "babylonjs/types";
  66886. import { Scene } from "babylonjs/scene";
  66887. import { Vector4 } from "babylonjs/Maths/math.vector";
  66888. import { Color4 } from "babylonjs/Maths/math.color";
  66889. import { Mesh } from "babylonjs/Meshes/mesh";
  66890. /**
  66891. * Class containing static functions to help procedurally build meshes
  66892. */
  66893. export class TiledBoxBuilder {
  66894. /**
  66895. * Creates a box mesh
  66896. * 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)
  66897. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66898. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66899. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66900. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66901. * @param name defines the name of the mesh
  66902. * @param options defines the options used to create the mesh
  66903. * @param scene defines the hosting scene
  66904. * @returns the box mesh
  66905. */
  66906. static CreateTiledBox(name: string, options: {
  66907. pattern?: number;
  66908. width?: number;
  66909. height?: number;
  66910. depth?: number;
  66911. tileSize?: number;
  66912. tileWidth?: number;
  66913. tileHeight?: number;
  66914. alignHorizontal?: number;
  66915. alignVertical?: number;
  66916. faceUV?: Vector4[];
  66917. faceColors?: Color4[];
  66918. sideOrientation?: number;
  66919. updatable?: boolean;
  66920. }, scene?: Nullable<Scene>): Mesh;
  66921. }
  66922. }
  66923. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  66924. import { Vector4 } from "babylonjs/Maths/math.vector";
  66925. import { Mesh } from "babylonjs/Meshes/mesh";
  66926. /**
  66927. * Class containing static functions to help procedurally build meshes
  66928. */
  66929. export class TorusKnotBuilder {
  66930. /**
  66931. * Creates a torus knot mesh
  66932. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  66933. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  66934. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  66935. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  66936. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66937. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66938. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66939. * @param name defines the name of the mesh
  66940. * @param options defines the options used to create the mesh
  66941. * @param scene defines the hosting scene
  66942. * @returns the torus knot mesh
  66943. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  66944. */
  66945. static CreateTorusKnot(name: string, options: {
  66946. radius?: number;
  66947. tube?: number;
  66948. radialSegments?: number;
  66949. tubularSegments?: number;
  66950. p?: number;
  66951. q?: number;
  66952. updatable?: boolean;
  66953. sideOrientation?: number;
  66954. frontUVs?: Vector4;
  66955. backUVs?: Vector4;
  66956. }, scene: any): Mesh;
  66957. }
  66958. }
  66959. declare module "babylonjs/Meshes/polygonMesh" {
  66960. import { Scene } from "babylonjs/scene";
  66961. import { Vector2 } from "babylonjs/Maths/math.vector";
  66962. import { Mesh } from "babylonjs/Meshes/mesh";
  66963. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  66964. import { Path2 } from "babylonjs/Maths/math.path";
  66965. /**
  66966. * Polygon
  66967. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  66968. */
  66969. export class Polygon {
  66970. /**
  66971. * Creates a rectangle
  66972. * @param xmin bottom X coord
  66973. * @param ymin bottom Y coord
  66974. * @param xmax top X coord
  66975. * @param ymax top Y coord
  66976. * @returns points that make the resulting rectation
  66977. */
  66978. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  66979. /**
  66980. * Creates a circle
  66981. * @param radius radius of circle
  66982. * @param cx scale in x
  66983. * @param cy scale in y
  66984. * @param numberOfSides number of sides that make up the circle
  66985. * @returns points that make the resulting circle
  66986. */
  66987. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  66988. /**
  66989. * Creates a polygon from input string
  66990. * @param input Input polygon data
  66991. * @returns the parsed points
  66992. */
  66993. static Parse(input: string): Vector2[];
  66994. /**
  66995. * Starts building a polygon from x and y coordinates
  66996. * @param x x coordinate
  66997. * @param y y coordinate
  66998. * @returns the started path2
  66999. */
  67000. static StartingAt(x: number, y: number): Path2;
  67001. }
  67002. /**
  67003. * Builds a polygon
  67004. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  67005. */
  67006. export class PolygonMeshBuilder {
  67007. private _points;
  67008. private _outlinepoints;
  67009. private _holes;
  67010. private _name;
  67011. private _scene;
  67012. private _epoints;
  67013. private _eholes;
  67014. private _addToepoint;
  67015. /**
  67016. * Babylon reference to the earcut plugin.
  67017. */
  67018. bjsEarcut: any;
  67019. /**
  67020. * Creates a PolygonMeshBuilder
  67021. * @param name name of the builder
  67022. * @param contours Path of the polygon
  67023. * @param scene scene to add to when creating the mesh
  67024. * @param earcutInjection can be used to inject your own earcut reference
  67025. */
  67026. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  67027. /**
  67028. * Adds a whole within the polygon
  67029. * @param hole Array of points defining the hole
  67030. * @returns this
  67031. */
  67032. addHole(hole: Vector2[]): PolygonMeshBuilder;
  67033. /**
  67034. * Creates the polygon
  67035. * @param updatable If the mesh should be updatable
  67036. * @param depth The depth of the mesh created
  67037. * @returns the created mesh
  67038. */
  67039. build(updatable?: boolean, depth?: number): Mesh;
  67040. /**
  67041. * Creates the polygon
  67042. * @param depth The depth of the mesh created
  67043. * @returns the created VertexData
  67044. */
  67045. buildVertexData(depth?: number): VertexData;
  67046. /**
  67047. * Adds a side to the polygon
  67048. * @param positions points that make the polygon
  67049. * @param normals normals of the polygon
  67050. * @param uvs uvs of the polygon
  67051. * @param indices indices of the polygon
  67052. * @param bounds bounds of the polygon
  67053. * @param points points of the polygon
  67054. * @param depth depth of the polygon
  67055. * @param flip flip of the polygon
  67056. */
  67057. private addSide;
  67058. }
  67059. }
  67060. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  67061. import { Scene } from "babylonjs/scene";
  67062. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  67063. import { Color4 } from "babylonjs/Maths/math.color";
  67064. import { Mesh } from "babylonjs/Meshes/mesh";
  67065. import { Nullable } from "babylonjs/types";
  67066. /**
  67067. * Class containing static functions to help procedurally build meshes
  67068. */
  67069. export class PolygonBuilder {
  67070. /**
  67071. * Creates a polygon mesh
  67072. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  67073. * * 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
  67074. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  67075. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67076. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  67077. * * Remember you can only change the shape positions, not their number when updating a polygon
  67078. * @param name defines the name of the mesh
  67079. * @param options defines the options used to create the mesh
  67080. * @param scene defines the hosting scene
  67081. * @param earcutInjection can be used to inject your own earcut reference
  67082. * @returns the polygon mesh
  67083. */
  67084. static CreatePolygon(name: string, options: {
  67085. shape: Vector3[];
  67086. holes?: Vector3[][];
  67087. depth?: number;
  67088. faceUV?: Vector4[];
  67089. faceColors?: Color4[];
  67090. updatable?: boolean;
  67091. sideOrientation?: number;
  67092. frontUVs?: Vector4;
  67093. backUVs?: Vector4;
  67094. wrap?: boolean;
  67095. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  67096. /**
  67097. * Creates an extruded polygon mesh, with depth in the Y direction.
  67098. * * 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)
  67099. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  67100. * @param name defines the name of the mesh
  67101. * @param options defines the options used to create the mesh
  67102. * @param scene defines the hosting scene
  67103. * @param earcutInjection can be used to inject your own earcut reference
  67104. * @returns the polygon mesh
  67105. */
  67106. static ExtrudePolygon(name: string, options: {
  67107. shape: Vector3[];
  67108. holes?: Vector3[][];
  67109. depth?: number;
  67110. faceUV?: Vector4[];
  67111. faceColors?: Color4[];
  67112. updatable?: boolean;
  67113. sideOrientation?: number;
  67114. frontUVs?: Vector4;
  67115. backUVs?: Vector4;
  67116. wrap?: boolean;
  67117. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  67118. }
  67119. }
  67120. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  67121. import { Scene } from "babylonjs/scene";
  67122. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  67123. import { Mesh } from "babylonjs/Meshes/mesh";
  67124. import { Nullable } from "babylonjs/types";
  67125. /**
  67126. * Class containing static functions to help procedurally build meshes
  67127. */
  67128. export class LatheBuilder {
  67129. /**
  67130. * Creates lathe mesh.
  67131. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  67132. * * 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
  67133. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  67134. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  67135. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  67136. * * 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
  67137. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  67138. * * 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
  67139. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67140. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67141. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67142. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67143. * @param name defines the name of the mesh
  67144. * @param options defines the options used to create the mesh
  67145. * @param scene defines the hosting scene
  67146. * @returns the lathe mesh
  67147. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  67148. */
  67149. static CreateLathe(name: string, options: {
  67150. shape: Vector3[];
  67151. radius?: number;
  67152. tessellation?: number;
  67153. clip?: number;
  67154. arc?: number;
  67155. closed?: boolean;
  67156. updatable?: boolean;
  67157. sideOrientation?: number;
  67158. frontUVs?: Vector4;
  67159. backUVs?: Vector4;
  67160. cap?: number;
  67161. invertUV?: boolean;
  67162. }, scene?: Nullable<Scene>): Mesh;
  67163. }
  67164. }
  67165. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  67166. import { Nullable } from "babylonjs/types";
  67167. import { Scene } from "babylonjs/scene";
  67168. import { Vector4 } from "babylonjs/Maths/math.vector";
  67169. import { Mesh } from "babylonjs/Meshes/mesh";
  67170. /**
  67171. * Class containing static functions to help procedurally build meshes
  67172. */
  67173. export class TiledPlaneBuilder {
  67174. /**
  67175. * Creates a tiled plane mesh
  67176. * * The parameter `pattern` will, depending on value, do nothing or
  67177. * * * flip (reflect about central vertical) alternate tiles across and up
  67178. * * * flip every tile on alternate rows
  67179. * * * rotate (180 degs) alternate tiles across and up
  67180. * * * rotate every tile on alternate rows
  67181. * * * flip and rotate alternate tiles across and up
  67182. * * * flip and rotate every tile on alternate rows
  67183. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  67184. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  67185. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67186. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  67187. * * 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)
  67188. * * 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)
  67189. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  67190. * @param name defines the name of the mesh
  67191. * @param options defines the options used to create the mesh
  67192. * @param scene defines the hosting scene
  67193. * @returns the box mesh
  67194. */
  67195. static CreateTiledPlane(name: string, options: {
  67196. pattern?: number;
  67197. tileSize?: number;
  67198. tileWidth?: number;
  67199. tileHeight?: number;
  67200. size?: number;
  67201. width?: number;
  67202. height?: number;
  67203. alignHorizontal?: number;
  67204. alignVertical?: number;
  67205. sideOrientation?: number;
  67206. frontUVs?: Vector4;
  67207. backUVs?: Vector4;
  67208. updatable?: boolean;
  67209. }, scene?: Nullable<Scene>): Mesh;
  67210. }
  67211. }
  67212. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  67213. import { Nullable } from "babylonjs/types";
  67214. import { Scene } from "babylonjs/scene";
  67215. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  67216. import { Mesh } from "babylonjs/Meshes/mesh";
  67217. /**
  67218. * Class containing static functions to help procedurally build meshes
  67219. */
  67220. export class TubeBuilder {
  67221. /**
  67222. * Creates a tube mesh.
  67223. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  67224. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  67225. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  67226. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  67227. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  67228. * * 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)
  67229. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  67230. * * 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
  67231. * * 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
  67232. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67233. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67234. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67235. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67236. * @param name defines the name of the mesh
  67237. * @param options defines the options used to create the mesh
  67238. * @param scene defines the hosting scene
  67239. * @returns the tube mesh
  67240. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67241. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  67242. */
  67243. static CreateTube(name: string, options: {
  67244. path: Vector3[];
  67245. radius?: number;
  67246. tessellation?: number;
  67247. radiusFunction?: {
  67248. (i: number, distance: number): number;
  67249. };
  67250. cap?: number;
  67251. arc?: number;
  67252. updatable?: boolean;
  67253. sideOrientation?: number;
  67254. frontUVs?: Vector4;
  67255. backUVs?: Vector4;
  67256. instance?: Mesh;
  67257. invertUV?: boolean;
  67258. }, scene?: Nullable<Scene>): Mesh;
  67259. }
  67260. }
  67261. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  67262. import { Scene } from "babylonjs/scene";
  67263. import { Vector4 } from "babylonjs/Maths/math.vector";
  67264. import { Mesh } from "babylonjs/Meshes/mesh";
  67265. import { Nullable } from "babylonjs/types";
  67266. /**
  67267. * Class containing static functions to help procedurally build meshes
  67268. */
  67269. export class IcoSphereBuilder {
  67270. /**
  67271. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  67272. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  67273. * * 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`)
  67274. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  67275. * * 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
  67276. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67277. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67278. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67279. * @param name defines the name of the mesh
  67280. * @param options defines the options used to create the mesh
  67281. * @param scene defines the hosting scene
  67282. * @returns the icosahedron mesh
  67283. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  67284. */
  67285. static CreateIcoSphere(name: string, options: {
  67286. radius?: number;
  67287. radiusX?: number;
  67288. radiusY?: number;
  67289. radiusZ?: number;
  67290. flat?: boolean;
  67291. subdivisions?: number;
  67292. sideOrientation?: number;
  67293. frontUVs?: Vector4;
  67294. backUVs?: Vector4;
  67295. updatable?: boolean;
  67296. }, scene?: Nullable<Scene>): Mesh;
  67297. }
  67298. }
  67299. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  67300. import { Vector3 } from "babylonjs/Maths/math.vector";
  67301. import { Mesh } from "babylonjs/Meshes/mesh";
  67302. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67303. /**
  67304. * Class containing static functions to help procedurally build meshes
  67305. */
  67306. export class DecalBuilder {
  67307. /**
  67308. * Creates a decal mesh.
  67309. * 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
  67310. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  67311. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  67312. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  67313. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  67314. * @param name defines the name of the mesh
  67315. * @param sourceMesh defines the mesh where the decal must be applied
  67316. * @param options defines the options used to create the mesh
  67317. * @param scene defines the hosting scene
  67318. * @returns the decal mesh
  67319. * @see https://doc.babylonjs.com/how_to/decals
  67320. */
  67321. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  67322. position?: Vector3;
  67323. normal?: Vector3;
  67324. size?: Vector3;
  67325. angle?: number;
  67326. }): Mesh;
  67327. }
  67328. }
  67329. declare module "babylonjs/Meshes/meshBuilder" {
  67330. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  67331. import { Nullable } from "babylonjs/types";
  67332. import { Scene } from "babylonjs/scene";
  67333. import { Mesh } from "babylonjs/Meshes/mesh";
  67334. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  67335. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  67336. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67337. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  67338. import { Plane } from "babylonjs/Maths/math.plane";
  67339. /**
  67340. * Class containing static functions to help procedurally build meshes
  67341. */
  67342. export class MeshBuilder {
  67343. /**
  67344. * Creates a box mesh
  67345. * * The parameter `size` sets the size (float) of each box side (default 1)
  67346. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  67347. * * 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)
  67348. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  67349. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67350. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67351. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67352. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  67353. * @param name defines the name of the mesh
  67354. * @param options defines the options used to create the mesh
  67355. * @param scene defines the hosting scene
  67356. * @returns the box mesh
  67357. */
  67358. static CreateBox(name: string, options: {
  67359. size?: number;
  67360. width?: number;
  67361. height?: number;
  67362. depth?: number;
  67363. faceUV?: Vector4[];
  67364. faceColors?: Color4[];
  67365. sideOrientation?: number;
  67366. frontUVs?: Vector4;
  67367. backUVs?: Vector4;
  67368. wrap?: boolean;
  67369. topBaseAt?: number;
  67370. bottomBaseAt?: number;
  67371. updatable?: boolean;
  67372. }, scene?: Nullable<Scene>): Mesh;
  67373. /**
  67374. * Creates a tiled box mesh
  67375. * * faceTiles sets the pattern, tile size and number of tiles for a face
  67376. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67377. * @param name defines the name of the mesh
  67378. * @param options defines the options used to create the mesh
  67379. * @param scene defines the hosting scene
  67380. * @returns the tiled box mesh
  67381. */
  67382. static CreateTiledBox(name: string, options: {
  67383. pattern?: number;
  67384. size?: number;
  67385. width?: number;
  67386. height?: number;
  67387. depth: number;
  67388. tileSize?: number;
  67389. tileWidth?: number;
  67390. tileHeight?: number;
  67391. faceUV?: Vector4[];
  67392. faceColors?: Color4[];
  67393. alignHorizontal?: number;
  67394. alignVertical?: number;
  67395. sideOrientation?: number;
  67396. updatable?: boolean;
  67397. }, scene?: Nullable<Scene>): Mesh;
  67398. /**
  67399. * Creates a sphere mesh
  67400. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  67401. * * 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`)
  67402. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  67403. * * 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
  67404. * * 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)
  67405. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67406. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67407. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67408. * @param name defines the name of the mesh
  67409. * @param options defines the options used to create the mesh
  67410. * @param scene defines the hosting scene
  67411. * @returns the sphere mesh
  67412. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  67413. */
  67414. static CreateSphere(name: string, options: {
  67415. segments?: number;
  67416. diameter?: number;
  67417. diameterX?: number;
  67418. diameterY?: number;
  67419. diameterZ?: number;
  67420. arc?: number;
  67421. slice?: number;
  67422. sideOrientation?: number;
  67423. frontUVs?: Vector4;
  67424. backUVs?: Vector4;
  67425. updatable?: boolean;
  67426. }, scene?: Nullable<Scene>): Mesh;
  67427. /**
  67428. * Creates a plane polygonal mesh. By default, this is a disc
  67429. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  67430. * * 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
  67431. * * 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
  67432. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67433. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67434. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67435. * @param name defines the name of the mesh
  67436. * @param options defines the options used to create the mesh
  67437. * @param scene defines the hosting scene
  67438. * @returns the plane polygonal mesh
  67439. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  67440. */
  67441. static CreateDisc(name: string, options: {
  67442. radius?: number;
  67443. tessellation?: number;
  67444. arc?: number;
  67445. updatable?: boolean;
  67446. sideOrientation?: number;
  67447. frontUVs?: Vector4;
  67448. backUVs?: Vector4;
  67449. }, scene?: Nullable<Scene>): Mesh;
  67450. /**
  67451. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  67452. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  67453. * * 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`)
  67454. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  67455. * * 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
  67456. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67457. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67458. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67459. * @param name defines the name of the mesh
  67460. * @param options defines the options used to create the mesh
  67461. * @param scene defines the hosting scene
  67462. * @returns the icosahedron mesh
  67463. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  67464. */
  67465. static CreateIcoSphere(name: string, options: {
  67466. radius?: number;
  67467. radiusX?: number;
  67468. radiusY?: number;
  67469. radiusZ?: number;
  67470. flat?: boolean;
  67471. subdivisions?: number;
  67472. sideOrientation?: number;
  67473. frontUVs?: Vector4;
  67474. backUVs?: Vector4;
  67475. updatable?: boolean;
  67476. }, scene?: Nullable<Scene>): Mesh;
  67477. /**
  67478. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  67479. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  67480. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  67481. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  67482. * * 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
  67483. * * 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
  67484. * * 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
  67485. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67486. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67487. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67488. * * 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
  67489. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  67490. * * 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
  67491. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  67492. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67493. * @param name defines the name of the mesh
  67494. * @param options defines the options used to create the mesh
  67495. * @param scene defines the hosting scene
  67496. * @returns the ribbon mesh
  67497. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  67498. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67499. */
  67500. static CreateRibbon(name: string, options: {
  67501. pathArray: Vector3[][];
  67502. closeArray?: boolean;
  67503. closePath?: boolean;
  67504. offset?: number;
  67505. updatable?: boolean;
  67506. sideOrientation?: number;
  67507. frontUVs?: Vector4;
  67508. backUVs?: Vector4;
  67509. instance?: Mesh;
  67510. invertUV?: boolean;
  67511. uvs?: Vector2[];
  67512. colors?: Color4[];
  67513. }, scene?: Nullable<Scene>): Mesh;
  67514. /**
  67515. * Creates a cylinder or a cone mesh
  67516. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  67517. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  67518. * * 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.
  67519. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  67520. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  67521. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  67522. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  67523. * * 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).
  67524. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  67525. * * 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).
  67526. * * 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
  67527. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  67528. * * 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
  67529. * * 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.
  67530. * * If `enclose` is false, a ring surface is one element.
  67531. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  67532. * * 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
  67533. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67534. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67535. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67536. * @param name defines the name of the mesh
  67537. * @param options defines the options used to create the mesh
  67538. * @param scene defines the hosting scene
  67539. * @returns the cylinder mesh
  67540. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  67541. */
  67542. static CreateCylinder(name: string, options: {
  67543. height?: number;
  67544. diameterTop?: number;
  67545. diameterBottom?: number;
  67546. diameter?: number;
  67547. tessellation?: number;
  67548. subdivisions?: number;
  67549. arc?: number;
  67550. faceColors?: Color4[];
  67551. faceUV?: Vector4[];
  67552. updatable?: boolean;
  67553. hasRings?: boolean;
  67554. enclose?: boolean;
  67555. cap?: number;
  67556. sideOrientation?: number;
  67557. frontUVs?: Vector4;
  67558. backUVs?: Vector4;
  67559. }, scene?: Nullable<Scene>): Mesh;
  67560. /**
  67561. * Creates a torus mesh
  67562. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  67563. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  67564. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  67565. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67566. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67567. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67568. * @param name defines the name of the mesh
  67569. * @param options defines the options used to create the mesh
  67570. * @param scene defines the hosting scene
  67571. * @returns the torus mesh
  67572. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  67573. */
  67574. static CreateTorus(name: string, options: {
  67575. diameter?: number;
  67576. thickness?: number;
  67577. tessellation?: number;
  67578. updatable?: boolean;
  67579. sideOrientation?: number;
  67580. frontUVs?: Vector4;
  67581. backUVs?: Vector4;
  67582. }, scene?: Nullable<Scene>): Mesh;
  67583. /**
  67584. * Creates a torus knot mesh
  67585. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  67586. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  67587. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  67588. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  67589. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67590. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67591. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67592. * @param name defines the name of the mesh
  67593. * @param options defines the options used to create the mesh
  67594. * @param scene defines the hosting scene
  67595. * @returns the torus knot mesh
  67596. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  67597. */
  67598. static CreateTorusKnot(name: string, options: {
  67599. radius?: number;
  67600. tube?: number;
  67601. radialSegments?: number;
  67602. tubularSegments?: number;
  67603. p?: number;
  67604. q?: number;
  67605. updatable?: boolean;
  67606. sideOrientation?: number;
  67607. frontUVs?: Vector4;
  67608. backUVs?: Vector4;
  67609. }, scene?: Nullable<Scene>): Mesh;
  67610. /**
  67611. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  67612. * * 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
  67613. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  67614. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  67615. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  67616. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  67617. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  67618. * * 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
  67619. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  67620. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67621. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  67622. * @param name defines the name of the new line system
  67623. * @param options defines the options used to create the line system
  67624. * @param scene defines the hosting scene
  67625. * @returns a new line system mesh
  67626. */
  67627. static CreateLineSystem(name: string, options: {
  67628. lines: Vector3[][];
  67629. updatable?: boolean;
  67630. instance?: Nullable<LinesMesh>;
  67631. colors?: Nullable<Color4[][]>;
  67632. useVertexAlpha?: boolean;
  67633. }, scene: Nullable<Scene>): LinesMesh;
  67634. /**
  67635. * Creates a line mesh
  67636. * 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
  67637. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  67638. * * The parameter `points` is an array successive Vector3
  67639. * * 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
  67640. * * The optional parameter `colors` is an array of successive Color4, one per line point
  67641. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  67642. * * When updating an instance, remember that only point positions can change, not the number of points
  67643. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67644. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  67645. * @param name defines the name of the new line system
  67646. * @param options defines the options used to create the line system
  67647. * @param scene defines the hosting scene
  67648. * @returns a new line mesh
  67649. */
  67650. static CreateLines(name: string, options: {
  67651. points: Vector3[];
  67652. updatable?: boolean;
  67653. instance?: Nullable<LinesMesh>;
  67654. colors?: Color4[];
  67655. useVertexAlpha?: boolean;
  67656. }, scene?: Nullable<Scene>): LinesMesh;
  67657. /**
  67658. * Creates a dashed line mesh
  67659. * * 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
  67660. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  67661. * * The parameter `points` is an array successive Vector3
  67662. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  67663. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  67664. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  67665. * * 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
  67666. * * When updating an instance, remember that only point positions can change, not the number of points
  67667. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67668. * @param name defines the name of the mesh
  67669. * @param options defines the options used to create the mesh
  67670. * @param scene defines the hosting scene
  67671. * @returns the dashed line mesh
  67672. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  67673. */
  67674. static CreateDashedLines(name: string, options: {
  67675. points: Vector3[];
  67676. dashSize?: number;
  67677. gapSize?: number;
  67678. dashNb?: number;
  67679. updatable?: boolean;
  67680. instance?: LinesMesh;
  67681. }, scene?: Nullable<Scene>): LinesMesh;
  67682. /**
  67683. * 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.
  67684. * * 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.
  67685. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  67686. * * 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.
  67687. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  67688. * * 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
  67689. * * 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
  67690. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  67691. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67692. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67693. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  67694. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67695. * @param name defines the name of the mesh
  67696. * @param options defines the options used to create the mesh
  67697. * @param scene defines the hosting scene
  67698. * @returns the extruded shape mesh
  67699. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67700. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  67701. */
  67702. static ExtrudeShape(name: string, options: {
  67703. shape: Vector3[];
  67704. path: Vector3[];
  67705. scale?: number;
  67706. rotation?: number;
  67707. cap?: number;
  67708. updatable?: boolean;
  67709. sideOrientation?: number;
  67710. frontUVs?: Vector4;
  67711. backUVs?: Vector4;
  67712. instance?: Mesh;
  67713. invertUV?: boolean;
  67714. }, scene?: Nullable<Scene>): Mesh;
  67715. /**
  67716. * Creates an custom extruded shape mesh.
  67717. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  67718. * * 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.
  67719. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  67720. * * 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
  67721. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  67722. * * 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
  67723. * * It must returns a float value that will be the scale value applied to the shape on each path point
  67724. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  67725. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  67726. * * 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
  67727. * * 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
  67728. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  67729. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67730. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67731. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67732. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67733. * @param name defines the name of the mesh
  67734. * @param options defines the options used to create the mesh
  67735. * @param scene defines the hosting scene
  67736. * @returns the custom extruded shape mesh
  67737. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  67738. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67739. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  67740. */
  67741. static ExtrudeShapeCustom(name: string, options: {
  67742. shape: Vector3[];
  67743. path: Vector3[];
  67744. scaleFunction?: any;
  67745. rotationFunction?: any;
  67746. ribbonCloseArray?: boolean;
  67747. ribbonClosePath?: boolean;
  67748. cap?: number;
  67749. updatable?: boolean;
  67750. sideOrientation?: number;
  67751. frontUVs?: Vector4;
  67752. backUVs?: Vector4;
  67753. instance?: Mesh;
  67754. invertUV?: boolean;
  67755. }, scene?: Nullable<Scene>): Mesh;
  67756. /**
  67757. * Creates lathe mesh.
  67758. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  67759. * * 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
  67760. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  67761. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  67762. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  67763. * * 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
  67764. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  67765. * * 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
  67766. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67767. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67768. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67769. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67770. * @param name defines the name of the mesh
  67771. * @param options defines the options used to create the mesh
  67772. * @param scene defines the hosting scene
  67773. * @returns the lathe mesh
  67774. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  67775. */
  67776. static CreateLathe(name: string, options: {
  67777. shape: Vector3[];
  67778. radius?: number;
  67779. tessellation?: number;
  67780. clip?: number;
  67781. arc?: number;
  67782. closed?: boolean;
  67783. updatable?: boolean;
  67784. sideOrientation?: number;
  67785. frontUVs?: Vector4;
  67786. backUVs?: Vector4;
  67787. cap?: number;
  67788. invertUV?: boolean;
  67789. }, scene?: Nullable<Scene>): Mesh;
  67790. /**
  67791. * Creates a tiled plane mesh
  67792. * * You can set a limited pattern arrangement with the tiles
  67793. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67794. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67795. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67796. * @param name defines the name of the mesh
  67797. * @param options defines the options used to create the mesh
  67798. * @param scene defines the hosting scene
  67799. * @returns the plane mesh
  67800. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  67801. */
  67802. static CreateTiledPlane(name: string, options: {
  67803. pattern?: number;
  67804. tileSize?: number;
  67805. tileWidth?: number;
  67806. tileHeight?: number;
  67807. size?: number;
  67808. width?: number;
  67809. height?: number;
  67810. alignHorizontal?: number;
  67811. alignVertical?: number;
  67812. sideOrientation?: number;
  67813. frontUVs?: Vector4;
  67814. backUVs?: Vector4;
  67815. updatable?: boolean;
  67816. }, scene?: Nullable<Scene>): Mesh;
  67817. /**
  67818. * Creates a plane mesh
  67819. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  67820. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  67821. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  67822. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67823. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67824. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67825. * @param name defines the name of the mesh
  67826. * @param options defines the options used to create the mesh
  67827. * @param scene defines the hosting scene
  67828. * @returns the plane mesh
  67829. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  67830. */
  67831. static CreatePlane(name: string, options: {
  67832. size?: number;
  67833. width?: number;
  67834. height?: number;
  67835. sideOrientation?: number;
  67836. frontUVs?: Vector4;
  67837. backUVs?: Vector4;
  67838. updatable?: boolean;
  67839. sourcePlane?: Plane;
  67840. }, scene?: Nullable<Scene>): Mesh;
  67841. /**
  67842. * Creates a ground mesh
  67843. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  67844. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  67845. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67846. * @param name defines the name of the mesh
  67847. * @param options defines the options used to create the mesh
  67848. * @param scene defines the hosting scene
  67849. * @returns the ground mesh
  67850. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  67851. */
  67852. static CreateGround(name: string, options: {
  67853. width?: number;
  67854. height?: number;
  67855. subdivisions?: number;
  67856. subdivisionsX?: number;
  67857. subdivisionsY?: number;
  67858. updatable?: boolean;
  67859. }, scene?: Nullable<Scene>): Mesh;
  67860. /**
  67861. * Creates a tiled ground mesh
  67862. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  67863. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  67864. * * 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
  67865. * * 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
  67866. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67867. * @param name defines the name of the mesh
  67868. * @param options defines the options used to create the mesh
  67869. * @param scene defines the hosting scene
  67870. * @returns the tiled ground mesh
  67871. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  67872. */
  67873. static CreateTiledGround(name: string, options: {
  67874. xmin: number;
  67875. zmin: number;
  67876. xmax: number;
  67877. zmax: number;
  67878. subdivisions?: {
  67879. w: number;
  67880. h: number;
  67881. };
  67882. precision?: {
  67883. w: number;
  67884. h: number;
  67885. };
  67886. updatable?: boolean;
  67887. }, scene?: Nullable<Scene>): Mesh;
  67888. /**
  67889. * Creates a ground mesh from a height map
  67890. * * The parameter `url` sets the URL of the height map image resource.
  67891. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  67892. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  67893. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  67894. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  67895. * * 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.
  67896. * * 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).
  67897. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  67898. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67899. * @param name defines the name of the mesh
  67900. * @param url defines the url to the height map
  67901. * @param options defines the options used to create the mesh
  67902. * @param scene defines the hosting scene
  67903. * @returns the ground mesh
  67904. * @see https://doc.babylonjs.com/babylon101/height_map
  67905. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  67906. */
  67907. static CreateGroundFromHeightMap(name: string, url: string, options: {
  67908. width?: number;
  67909. height?: number;
  67910. subdivisions?: number;
  67911. minHeight?: number;
  67912. maxHeight?: number;
  67913. colorFilter?: Color3;
  67914. alphaFilter?: number;
  67915. updatable?: boolean;
  67916. onReady?: (mesh: GroundMesh) => void;
  67917. }, scene?: Nullable<Scene>): GroundMesh;
  67918. /**
  67919. * Creates a polygon mesh
  67920. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  67921. * * 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
  67922. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  67923. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67924. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  67925. * * Remember you can only change the shape positions, not their number when updating a polygon
  67926. * @param name defines the name of the mesh
  67927. * @param options defines the options used to create the mesh
  67928. * @param scene defines the hosting scene
  67929. * @param earcutInjection can be used to inject your own earcut reference
  67930. * @returns the polygon mesh
  67931. */
  67932. static CreatePolygon(name: string, options: {
  67933. shape: Vector3[];
  67934. holes?: Vector3[][];
  67935. depth?: number;
  67936. faceUV?: Vector4[];
  67937. faceColors?: Color4[];
  67938. updatable?: boolean;
  67939. sideOrientation?: number;
  67940. frontUVs?: Vector4;
  67941. backUVs?: Vector4;
  67942. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  67943. /**
  67944. * Creates an extruded polygon mesh, with depth in the Y direction.
  67945. * * 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)
  67946. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  67947. * @param name defines the name of the mesh
  67948. * @param options defines the options used to create the mesh
  67949. * @param scene defines the hosting scene
  67950. * @param earcutInjection can be used to inject your own earcut reference
  67951. * @returns the polygon mesh
  67952. */
  67953. static ExtrudePolygon(name: string, options: {
  67954. shape: Vector3[];
  67955. holes?: Vector3[][];
  67956. depth?: number;
  67957. faceUV?: Vector4[];
  67958. faceColors?: Color4[];
  67959. updatable?: boolean;
  67960. sideOrientation?: number;
  67961. frontUVs?: Vector4;
  67962. backUVs?: Vector4;
  67963. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  67964. /**
  67965. * Creates a tube mesh.
  67966. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  67967. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  67968. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  67969. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  67970. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  67971. * * 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)
  67972. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  67973. * * 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
  67974. * * 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
  67975. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67976. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67977. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67978. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67979. * @param name defines the name of the mesh
  67980. * @param options defines the options used to create the mesh
  67981. * @param scene defines the hosting scene
  67982. * @returns the tube mesh
  67983. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67984. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  67985. */
  67986. static CreateTube(name: string, options: {
  67987. path: Vector3[];
  67988. radius?: number;
  67989. tessellation?: number;
  67990. radiusFunction?: {
  67991. (i: number, distance: number): number;
  67992. };
  67993. cap?: number;
  67994. arc?: number;
  67995. updatable?: boolean;
  67996. sideOrientation?: number;
  67997. frontUVs?: Vector4;
  67998. backUVs?: Vector4;
  67999. instance?: Mesh;
  68000. invertUV?: boolean;
  68001. }, scene?: Nullable<Scene>): Mesh;
  68002. /**
  68003. * Creates a polyhedron mesh
  68004. * * 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
  68005. * * The parameter `size` (positive float, default 1) sets the polygon size
  68006. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  68007. * * 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`
  68008. * * 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
  68009. * * 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)`)
  68010. * * 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
  68011. * * 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
  68012. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68013. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68014. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68015. * @param name defines the name of the mesh
  68016. * @param options defines the options used to create the mesh
  68017. * @param scene defines the hosting scene
  68018. * @returns the polyhedron mesh
  68019. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  68020. */
  68021. static CreatePolyhedron(name: string, options: {
  68022. type?: number;
  68023. size?: number;
  68024. sizeX?: number;
  68025. sizeY?: number;
  68026. sizeZ?: number;
  68027. custom?: any;
  68028. faceUV?: Vector4[];
  68029. faceColors?: Color4[];
  68030. flat?: boolean;
  68031. updatable?: boolean;
  68032. sideOrientation?: number;
  68033. frontUVs?: Vector4;
  68034. backUVs?: Vector4;
  68035. }, scene?: Nullable<Scene>): Mesh;
  68036. /**
  68037. * Creates a decal mesh.
  68038. * 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
  68039. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  68040. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  68041. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  68042. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  68043. * @param name defines the name of the mesh
  68044. * @param sourceMesh defines the mesh where the decal must be applied
  68045. * @param options defines the options used to create the mesh
  68046. * @param scene defines the hosting scene
  68047. * @returns the decal mesh
  68048. * @see https://doc.babylonjs.com/how_to/decals
  68049. */
  68050. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  68051. position?: Vector3;
  68052. normal?: Vector3;
  68053. size?: Vector3;
  68054. angle?: number;
  68055. }): Mesh;
  68056. }
  68057. }
  68058. declare module "babylonjs/Meshes/meshSimplification" {
  68059. import { Mesh } from "babylonjs/Meshes/mesh";
  68060. /**
  68061. * A simplifier interface for future simplification implementations
  68062. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68063. */
  68064. export interface ISimplifier {
  68065. /**
  68066. * Simplification of a given mesh according to the given settings.
  68067. * Since this requires computation, it is assumed that the function runs async.
  68068. * @param settings The settings of the simplification, including quality and distance
  68069. * @param successCallback A callback that will be called after the mesh was simplified.
  68070. * @param errorCallback in case of an error, this callback will be called. optional.
  68071. */
  68072. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  68073. }
  68074. /**
  68075. * Expected simplification settings.
  68076. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  68077. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68078. */
  68079. export interface ISimplificationSettings {
  68080. /**
  68081. * Gets or sets the expected quality
  68082. */
  68083. quality: number;
  68084. /**
  68085. * Gets or sets the distance when this optimized version should be used
  68086. */
  68087. distance: number;
  68088. /**
  68089. * Gets an already optimized mesh
  68090. */
  68091. optimizeMesh?: boolean;
  68092. }
  68093. /**
  68094. * Class used to specify simplification options
  68095. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68096. */
  68097. export class SimplificationSettings implements ISimplificationSettings {
  68098. /** expected quality */
  68099. quality: number;
  68100. /** distance when this optimized version should be used */
  68101. distance: number;
  68102. /** already optimized mesh */
  68103. optimizeMesh?: boolean | undefined;
  68104. /**
  68105. * Creates a SimplificationSettings
  68106. * @param quality expected quality
  68107. * @param distance distance when this optimized version should be used
  68108. * @param optimizeMesh already optimized mesh
  68109. */
  68110. constructor(
  68111. /** expected quality */
  68112. quality: number,
  68113. /** distance when this optimized version should be used */
  68114. distance: number,
  68115. /** already optimized mesh */
  68116. optimizeMesh?: boolean | undefined);
  68117. }
  68118. /**
  68119. * Interface used to define a simplification task
  68120. */
  68121. export interface ISimplificationTask {
  68122. /**
  68123. * Array of settings
  68124. */
  68125. settings: Array<ISimplificationSettings>;
  68126. /**
  68127. * Simplification type
  68128. */
  68129. simplificationType: SimplificationType;
  68130. /**
  68131. * Mesh to simplify
  68132. */
  68133. mesh: Mesh;
  68134. /**
  68135. * Callback called on success
  68136. */
  68137. successCallback?: () => void;
  68138. /**
  68139. * Defines if parallel processing can be used
  68140. */
  68141. parallelProcessing: boolean;
  68142. }
  68143. /**
  68144. * Queue used to order the simplification tasks
  68145. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68146. */
  68147. export class SimplificationQueue {
  68148. private _simplificationArray;
  68149. /**
  68150. * Gets a boolean indicating that the process is still running
  68151. */
  68152. running: boolean;
  68153. /**
  68154. * Creates a new queue
  68155. */
  68156. constructor();
  68157. /**
  68158. * Adds a new simplification task
  68159. * @param task defines a task to add
  68160. */
  68161. addTask(task: ISimplificationTask): void;
  68162. /**
  68163. * Execute next task
  68164. */
  68165. executeNext(): void;
  68166. /**
  68167. * Execute a simplification task
  68168. * @param task defines the task to run
  68169. */
  68170. runSimplification(task: ISimplificationTask): void;
  68171. private getSimplifier;
  68172. }
  68173. /**
  68174. * The implemented types of simplification
  68175. * At the moment only Quadratic Error Decimation is implemented
  68176. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68177. */
  68178. export enum SimplificationType {
  68179. /** Quadratic error decimation */
  68180. QUADRATIC = 0
  68181. }
  68182. /**
  68183. * An implementation of the Quadratic Error simplification algorithm.
  68184. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  68185. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  68186. * @author RaananW
  68187. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68188. */
  68189. export class QuadraticErrorSimplification implements ISimplifier {
  68190. private _mesh;
  68191. private triangles;
  68192. private vertices;
  68193. private references;
  68194. private _reconstructedMesh;
  68195. /** Gets or sets the number pf sync interations */
  68196. syncIterations: number;
  68197. /** Gets or sets the aggressiveness of the simplifier */
  68198. aggressiveness: number;
  68199. /** Gets or sets the number of allowed iterations for decimation */
  68200. decimationIterations: number;
  68201. /** Gets or sets the espilon to use for bounding box computation */
  68202. boundingBoxEpsilon: number;
  68203. /**
  68204. * Creates a new QuadraticErrorSimplification
  68205. * @param _mesh defines the target mesh
  68206. */
  68207. constructor(_mesh: Mesh);
  68208. /**
  68209. * Simplification of a given mesh according to the given settings.
  68210. * Since this requires computation, it is assumed that the function runs async.
  68211. * @param settings The settings of the simplification, including quality and distance
  68212. * @param successCallback A callback that will be called after the mesh was simplified.
  68213. */
  68214. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  68215. private runDecimation;
  68216. private initWithMesh;
  68217. private init;
  68218. private reconstructMesh;
  68219. private initDecimatedMesh;
  68220. private isFlipped;
  68221. private updateTriangles;
  68222. private identifyBorder;
  68223. private updateMesh;
  68224. private vertexError;
  68225. private calculateError;
  68226. }
  68227. }
  68228. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  68229. import { Scene } from "babylonjs/scene";
  68230. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  68231. import { ISceneComponent } from "babylonjs/sceneComponent";
  68232. module "babylonjs/scene" {
  68233. interface Scene {
  68234. /** @hidden (Backing field) */
  68235. _simplificationQueue: SimplificationQueue;
  68236. /**
  68237. * Gets or sets the simplification queue attached to the scene
  68238. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68239. */
  68240. simplificationQueue: SimplificationQueue;
  68241. }
  68242. }
  68243. module "babylonjs/Meshes/mesh" {
  68244. interface Mesh {
  68245. /**
  68246. * Simplify the mesh according to the given array of settings.
  68247. * Function will return immediately and will simplify async
  68248. * @param settings a collection of simplification settings
  68249. * @param parallelProcessing should all levels calculate parallel or one after the other
  68250. * @param simplificationType the type of simplification to run
  68251. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  68252. * @returns the current mesh
  68253. */
  68254. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  68255. }
  68256. }
  68257. /**
  68258. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  68259. * created in a scene
  68260. */
  68261. export class SimplicationQueueSceneComponent implements ISceneComponent {
  68262. /**
  68263. * The component name helpfull to identify the component in the list of scene components.
  68264. */
  68265. readonly name: string;
  68266. /**
  68267. * The scene the component belongs to.
  68268. */
  68269. scene: Scene;
  68270. /**
  68271. * Creates a new instance of the component for the given scene
  68272. * @param scene Defines the scene to register the component in
  68273. */
  68274. constructor(scene: Scene);
  68275. /**
  68276. * Registers the component in a given scene
  68277. */
  68278. register(): void;
  68279. /**
  68280. * Rebuilds the elements related to this component in case of
  68281. * context lost for instance.
  68282. */
  68283. rebuild(): void;
  68284. /**
  68285. * Disposes the component and the associated ressources
  68286. */
  68287. dispose(): void;
  68288. private _beforeCameraUpdate;
  68289. }
  68290. }
  68291. declare module "babylonjs/Meshes/Builders/index" {
  68292. export * from "babylonjs/Meshes/Builders/boxBuilder";
  68293. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  68294. export * from "babylonjs/Meshes/Builders/discBuilder";
  68295. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  68296. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  68297. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  68298. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  68299. export * from "babylonjs/Meshes/Builders/torusBuilder";
  68300. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  68301. export * from "babylonjs/Meshes/Builders/linesBuilder";
  68302. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  68303. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  68304. export * from "babylonjs/Meshes/Builders/latheBuilder";
  68305. export * from "babylonjs/Meshes/Builders/planeBuilder";
  68306. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  68307. export * from "babylonjs/Meshes/Builders/groundBuilder";
  68308. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  68309. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  68310. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  68311. export * from "babylonjs/Meshes/Builders/decalBuilder";
  68312. }
  68313. declare module "babylonjs/Meshes/thinInstanceMesh" {
  68314. import { Nullable, DeepImmutableObject } from "babylonjs/types";
  68315. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  68316. import { Matrix } from "babylonjs/Maths/math.vector";
  68317. module "babylonjs/Meshes/mesh" {
  68318. interface Mesh {
  68319. /**
  68320. * Creates a new thin instance
  68321. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  68322. * @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
  68323. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  68324. */
  68325. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  68326. /**
  68327. * Adds the transformation (matrix) of the current mesh as a thin instance
  68328. * @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
  68329. * @returns the thin instance index number
  68330. */
  68331. thinInstanceAddSelf(refresh: boolean): number;
  68332. /**
  68333. * Registers a custom attribute to be used with thin instances
  68334. * @param kind name of the attribute
  68335. * @param stride size in floats of the attribute
  68336. */
  68337. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  68338. /**
  68339. * Sets the matrix of a thin instance
  68340. * @param index index of the thin instance
  68341. * @param matrix matrix to set
  68342. * @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
  68343. */
  68344. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  68345. /**
  68346. * Sets the value of a custom attribute for a thin instance
  68347. * @param kind name of the attribute
  68348. * @param index index of the thin instance
  68349. * @param value value to set
  68350. * @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
  68351. */
  68352. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  68353. /**
  68354. * 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.
  68355. */
  68356. thinInstanceCount: number;
  68357. /**
  68358. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  68359. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  68360. * @param buffer buffer to set
  68361. * @param stride size in floats of each value of the buffer
  68362. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  68363. */
  68364. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  68365. /**
  68366. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  68367. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  68368. */
  68369. thinInstanceBufferUpdated(kind: string): void;
  68370. /**
  68371. * Refreshes the bounding info, taking into account all the thin instances defined
  68372. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  68373. */
  68374. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  68375. /** @hidden */
  68376. _thinInstanceInitializeUserStorage(): void;
  68377. /** @hidden */
  68378. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  68379. /** @hidden */
  68380. _userThinInstanceBuffersStorage: {
  68381. data: {
  68382. [key: string]: Float32Array;
  68383. };
  68384. sizes: {
  68385. [key: string]: number;
  68386. };
  68387. vertexBuffers: {
  68388. [key: string]: Nullable<VertexBuffer>;
  68389. };
  68390. strides: {
  68391. [key: string]: number;
  68392. };
  68393. };
  68394. }
  68395. }
  68396. }
  68397. declare module "babylonjs/Meshes/index" {
  68398. export * from "babylonjs/Meshes/abstractMesh";
  68399. export * from "babylonjs/Meshes/buffer";
  68400. export * from "babylonjs/Meshes/Compression/index";
  68401. export * from "babylonjs/Meshes/csg";
  68402. export * from "babylonjs/Meshes/geometry";
  68403. export * from "babylonjs/Meshes/groundMesh";
  68404. export * from "babylonjs/Meshes/trailMesh";
  68405. export * from "babylonjs/Meshes/instancedMesh";
  68406. export * from "babylonjs/Meshes/linesMesh";
  68407. export * from "babylonjs/Meshes/mesh";
  68408. export * from "babylonjs/Meshes/mesh.vertexData";
  68409. export * from "babylonjs/Meshes/meshBuilder";
  68410. export * from "babylonjs/Meshes/meshSimplification";
  68411. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  68412. export * from "babylonjs/Meshes/polygonMesh";
  68413. export * from "babylonjs/Meshes/subMesh";
  68414. export * from "babylonjs/Meshes/meshLODLevel";
  68415. export * from "babylonjs/Meshes/transformNode";
  68416. export * from "babylonjs/Meshes/Builders/index";
  68417. export * from "babylonjs/Meshes/dataBuffer";
  68418. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  68419. import "babylonjs/Meshes/thinInstanceMesh";
  68420. export * from "babylonjs/Meshes/thinInstanceMesh";
  68421. }
  68422. declare module "babylonjs/Morph/index" {
  68423. export * from "babylonjs/Morph/morphTarget";
  68424. export * from "babylonjs/Morph/morphTargetManager";
  68425. }
  68426. declare module "babylonjs/Navigation/INavigationEngine" {
  68427. import { TransformNode } from "babylonjs/Meshes/transformNode";
  68428. import { Vector3 } from "babylonjs/Maths/math";
  68429. import { Mesh } from "babylonjs/Meshes/mesh";
  68430. import { Scene } from "babylonjs/scene";
  68431. /**
  68432. * Navigation plugin interface to add navigation constrained by a navigation mesh
  68433. */
  68434. export interface INavigationEnginePlugin {
  68435. /**
  68436. * plugin name
  68437. */
  68438. name: string;
  68439. /**
  68440. * Creates a navigation mesh
  68441. * @param meshes array of all the geometry used to compute the navigatio mesh
  68442. * @param parameters bunch of parameters used to filter geometry
  68443. */
  68444. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  68445. /**
  68446. * Create a navigation mesh debug mesh
  68447. * @param scene is where the mesh will be added
  68448. * @returns debug display mesh
  68449. */
  68450. createDebugNavMesh(scene: Scene): Mesh;
  68451. /**
  68452. * Get a navigation mesh constrained position, closest to the parameter position
  68453. * @param position world position
  68454. * @returns the closest point to position constrained by the navigation mesh
  68455. */
  68456. getClosestPoint(position: Vector3): Vector3;
  68457. /**
  68458. * Get a navigation mesh constrained position, closest to the parameter position
  68459. * @param position world position
  68460. * @param result output the closest point to position constrained by the navigation mesh
  68461. */
  68462. getClosestPointToRef(position: Vector3, result: Vector3): void;
  68463. /**
  68464. * Get a navigation mesh constrained position, within a particular radius
  68465. * @param position world position
  68466. * @param maxRadius the maximum distance to the constrained world position
  68467. * @returns the closest point to position constrained by the navigation mesh
  68468. */
  68469. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  68470. /**
  68471. * Get a navigation mesh constrained position, within a particular radius
  68472. * @param position world position
  68473. * @param maxRadius the maximum distance to the constrained world position
  68474. * @param result output the closest point to position constrained by the navigation mesh
  68475. */
  68476. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  68477. /**
  68478. * Compute the final position from a segment made of destination-position
  68479. * @param position world position
  68480. * @param destination world position
  68481. * @returns the resulting point along the navmesh
  68482. */
  68483. moveAlong(position: Vector3, destination: Vector3): Vector3;
  68484. /**
  68485. * Compute the final position from a segment made of destination-position
  68486. * @param position world position
  68487. * @param destination world position
  68488. * @param result output the resulting point along the navmesh
  68489. */
  68490. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  68491. /**
  68492. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  68493. * @param start world position
  68494. * @param end world position
  68495. * @returns array containing world position composing the path
  68496. */
  68497. computePath(start: Vector3, end: Vector3): Vector3[];
  68498. /**
  68499. * If this plugin is supported
  68500. * @returns true if plugin is supported
  68501. */
  68502. isSupported(): boolean;
  68503. /**
  68504. * Create a new Crowd so you can add agents
  68505. * @param maxAgents the maximum agent count in the crowd
  68506. * @param maxAgentRadius the maximum radius an agent can have
  68507. * @param scene to attach the crowd to
  68508. * @returns the crowd you can add agents to
  68509. */
  68510. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  68511. /**
  68512. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68513. * The queries will try to find a solution within those bounds
  68514. * default is (1,1,1)
  68515. * @param extent x,y,z value that define the extent around the queries point of reference
  68516. */
  68517. setDefaultQueryExtent(extent: Vector3): void;
  68518. /**
  68519. * Get the Bounding box extent specified by setDefaultQueryExtent
  68520. * @returns the box extent values
  68521. */
  68522. getDefaultQueryExtent(): Vector3;
  68523. /**
  68524. * build the navmesh from a previously saved state using getNavmeshData
  68525. * @param data the Uint8Array returned by getNavmeshData
  68526. */
  68527. buildFromNavmeshData(data: Uint8Array): void;
  68528. /**
  68529. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  68530. * @returns data the Uint8Array that can be saved and reused
  68531. */
  68532. getNavmeshData(): Uint8Array;
  68533. /**
  68534. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68535. * @param result output the box extent values
  68536. */
  68537. getDefaultQueryExtentToRef(result: Vector3): void;
  68538. /**
  68539. * Release all resources
  68540. */
  68541. dispose(): void;
  68542. }
  68543. /**
  68544. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  68545. */
  68546. export interface ICrowd {
  68547. /**
  68548. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  68549. * You can attach anything to that node. The node position is updated in the scene update tick.
  68550. * @param pos world position that will be constrained by the navigation mesh
  68551. * @param parameters agent parameters
  68552. * @param transform hooked to the agent that will be update by the scene
  68553. * @returns agent index
  68554. */
  68555. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  68556. /**
  68557. * Returns the agent position in world space
  68558. * @param index agent index returned by addAgent
  68559. * @returns world space position
  68560. */
  68561. getAgentPosition(index: number): Vector3;
  68562. /**
  68563. * Gets the agent position result in world space
  68564. * @param index agent index returned by addAgent
  68565. * @param result output world space position
  68566. */
  68567. getAgentPositionToRef(index: number, result: Vector3): void;
  68568. /**
  68569. * Gets the agent velocity in world space
  68570. * @param index agent index returned by addAgent
  68571. * @returns world space velocity
  68572. */
  68573. getAgentVelocity(index: number): Vector3;
  68574. /**
  68575. * Gets the agent velocity result in world space
  68576. * @param index agent index returned by addAgent
  68577. * @param result output world space velocity
  68578. */
  68579. getAgentVelocityToRef(index: number, result: Vector3): void;
  68580. /**
  68581. * remove a particular agent previously created
  68582. * @param index agent index returned by addAgent
  68583. */
  68584. removeAgent(index: number): void;
  68585. /**
  68586. * get the list of all agents attached to this crowd
  68587. * @returns list of agent indices
  68588. */
  68589. getAgents(): number[];
  68590. /**
  68591. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  68592. * @param deltaTime in seconds
  68593. */
  68594. update(deltaTime: number): void;
  68595. /**
  68596. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  68597. * @param index agent index returned by addAgent
  68598. * @param destination targeted world position
  68599. */
  68600. agentGoto(index: number, destination: Vector3): void;
  68601. /**
  68602. * Teleport the agent to a new position
  68603. * @param index agent index returned by addAgent
  68604. * @param destination targeted world position
  68605. */
  68606. agentTeleport(index: number, destination: Vector3): void;
  68607. /**
  68608. * Update agent parameters
  68609. * @param index agent index returned by addAgent
  68610. * @param parameters agent parameters
  68611. */
  68612. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  68613. /**
  68614. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68615. * The queries will try to find a solution within those bounds
  68616. * default is (1,1,1)
  68617. * @param extent x,y,z value that define the extent around the queries point of reference
  68618. */
  68619. setDefaultQueryExtent(extent: Vector3): void;
  68620. /**
  68621. * Get the Bounding box extent specified by setDefaultQueryExtent
  68622. * @returns the box extent values
  68623. */
  68624. getDefaultQueryExtent(): Vector3;
  68625. /**
  68626. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68627. * @param result output the box extent values
  68628. */
  68629. getDefaultQueryExtentToRef(result: Vector3): void;
  68630. /**
  68631. * Release all resources
  68632. */
  68633. dispose(): void;
  68634. }
  68635. /**
  68636. * Configures an agent
  68637. */
  68638. export interface IAgentParameters {
  68639. /**
  68640. * Agent radius. [Limit: >= 0]
  68641. */
  68642. radius: number;
  68643. /**
  68644. * Agent height. [Limit: > 0]
  68645. */
  68646. height: number;
  68647. /**
  68648. * Maximum allowed acceleration. [Limit: >= 0]
  68649. */
  68650. maxAcceleration: number;
  68651. /**
  68652. * Maximum allowed speed. [Limit: >= 0]
  68653. */
  68654. maxSpeed: number;
  68655. /**
  68656. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  68657. */
  68658. collisionQueryRange: number;
  68659. /**
  68660. * The path visibility optimization range. [Limit: > 0]
  68661. */
  68662. pathOptimizationRange: number;
  68663. /**
  68664. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  68665. */
  68666. separationWeight: number;
  68667. }
  68668. /**
  68669. * Configures the navigation mesh creation
  68670. */
  68671. export interface INavMeshParameters {
  68672. /**
  68673. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  68674. */
  68675. cs: number;
  68676. /**
  68677. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  68678. */
  68679. ch: number;
  68680. /**
  68681. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  68682. */
  68683. walkableSlopeAngle: number;
  68684. /**
  68685. * Minimum floor to 'ceiling' height that will still allow the floor area to
  68686. * be considered walkable. [Limit: >= 3] [Units: vx]
  68687. */
  68688. walkableHeight: number;
  68689. /**
  68690. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  68691. */
  68692. walkableClimb: number;
  68693. /**
  68694. * The distance to erode/shrink the walkable area of the heightfield away from
  68695. * obstructions. [Limit: >=0] [Units: vx]
  68696. */
  68697. walkableRadius: number;
  68698. /**
  68699. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  68700. */
  68701. maxEdgeLen: number;
  68702. /**
  68703. * The maximum distance a simplfied contour's border edges should deviate
  68704. * the original raw contour. [Limit: >=0] [Units: vx]
  68705. */
  68706. maxSimplificationError: number;
  68707. /**
  68708. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  68709. */
  68710. minRegionArea: number;
  68711. /**
  68712. * Any regions with a span count smaller than this value will, if possible,
  68713. * be merged with larger regions. [Limit: >=0] [Units: vx]
  68714. */
  68715. mergeRegionArea: number;
  68716. /**
  68717. * The maximum number of vertices allowed for polygons generated during the
  68718. * contour to polygon conversion process. [Limit: >= 3]
  68719. */
  68720. maxVertsPerPoly: number;
  68721. /**
  68722. * Sets the sampling distance to use when generating the detail mesh.
  68723. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  68724. */
  68725. detailSampleDist: number;
  68726. /**
  68727. * The maximum distance the detail mesh surface should deviate from heightfield
  68728. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  68729. */
  68730. detailSampleMaxError: number;
  68731. }
  68732. }
  68733. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  68734. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  68735. import { Mesh } from "babylonjs/Meshes/mesh";
  68736. import { Scene } from "babylonjs/scene";
  68737. import { Vector3 } from "babylonjs/Maths/math";
  68738. import { TransformNode } from "babylonjs/Meshes/transformNode";
  68739. /**
  68740. * RecastJS navigation plugin
  68741. */
  68742. export class RecastJSPlugin implements INavigationEnginePlugin {
  68743. /**
  68744. * Reference to the Recast library
  68745. */
  68746. bjsRECAST: any;
  68747. /**
  68748. * plugin name
  68749. */
  68750. name: string;
  68751. /**
  68752. * the first navmesh created. We might extend this to support multiple navmeshes
  68753. */
  68754. navMesh: any;
  68755. /**
  68756. * Initializes the recastJS plugin
  68757. * @param recastInjection can be used to inject your own recast reference
  68758. */
  68759. constructor(recastInjection?: any);
  68760. /**
  68761. * Creates a navigation mesh
  68762. * @param meshes array of all the geometry used to compute the navigatio mesh
  68763. * @param parameters bunch of parameters used to filter geometry
  68764. */
  68765. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  68766. /**
  68767. * Create a navigation mesh debug mesh
  68768. * @param scene is where the mesh will be added
  68769. * @returns debug display mesh
  68770. */
  68771. createDebugNavMesh(scene: Scene): Mesh;
  68772. /**
  68773. * Get a navigation mesh constrained position, closest to the parameter position
  68774. * @param position world position
  68775. * @returns the closest point to position constrained by the navigation mesh
  68776. */
  68777. getClosestPoint(position: Vector3): Vector3;
  68778. /**
  68779. * Get a navigation mesh constrained position, closest to the parameter position
  68780. * @param position world position
  68781. * @param result output the closest point to position constrained by the navigation mesh
  68782. */
  68783. getClosestPointToRef(position: Vector3, result: Vector3): void;
  68784. /**
  68785. * Get a navigation mesh constrained position, within a particular radius
  68786. * @param position world position
  68787. * @param maxRadius the maximum distance to the constrained world position
  68788. * @returns the closest point to position constrained by the navigation mesh
  68789. */
  68790. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  68791. /**
  68792. * Get a navigation mesh constrained position, within a particular radius
  68793. * @param position world position
  68794. * @param maxRadius the maximum distance to the constrained world position
  68795. * @param result output the closest point to position constrained by the navigation mesh
  68796. */
  68797. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  68798. /**
  68799. * Compute the final position from a segment made of destination-position
  68800. * @param position world position
  68801. * @param destination world position
  68802. * @returns the resulting point along the navmesh
  68803. */
  68804. moveAlong(position: Vector3, destination: Vector3): Vector3;
  68805. /**
  68806. * Compute the final position from a segment made of destination-position
  68807. * @param position world position
  68808. * @param destination world position
  68809. * @param result output the resulting point along the navmesh
  68810. */
  68811. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  68812. /**
  68813. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  68814. * @param start world position
  68815. * @param end world position
  68816. * @returns array containing world position composing the path
  68817. */
  68818. computePath(start: Vector3, end: Vector3): Vector3[];
  68819. /**
  68820. * Create a new Crowd so you can add agents
  68821. * @param maxAgents the maximum agent count in the crowd
  68822. * @param maxAgentRadius the maximum radius an agent can have
  68823. * @param scene to attach the crowd to
  68824. * @returns the crowd you can add agents to
  68825. */
  68826. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  68827. /**
  68828. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68829. * The queries will try to find a solution within those bounds
  68830. * default is (1,1,1)
  68831. * @param extent x,y,z value that define the extent around the queries point of reference
  68832. */
  68833. setDefaultQueryExtent(extent: Vector3): void;
  68834. /**
  68835. * Get the Bounding box extent specified by setDefaultQueryExtent
  68836. * @returns the box extent values
  68837. */
  68838. getDefaultQueryExtent(): Vector3;
  68839. /**
  68840. * build the navmesh from a previously saved state using getNavmeshData
  68841. * @param data the Uint8Array returned by getNavmeshData
  68842. */
  68843. buildFromNavmeshData(data: Uint8Array): void;
  68844. /**
  68845. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  68846. * @returns data the Uint8Array that can be saved and reused
  68847. */
  68848. getNavmeshData(): Uint8Array;
  68849. /**
  68850. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68851. * @param result output the box extent values
  68852. */
  68853. getDefaultQueryExtentToRef(result: Vector3): void;
  68854. /**
  68855. * Disposes
  68856. */
  68857. dispose(): void;
  68858. /**
  68859. * If this plugin is supported
  68860. * @returns true if plugin is supported
  68861. */
  68862. isSupported(): boolean;
  68863. }
  68864. /**
  68865. * Recast detour crowd implementation
  68866. */
  68867. export class RecastJSCrowd implements ICrowd {
  68868. /**
  68869. * Recast/detour plugin
  68870. */
  68871. bjsRECASTPlugin: RecastJSPlugin;
  68872. /**
  68873. * Link to the detour crowd
  68874. */
  68875. recastCrowd: any;
  68876. /**
  68877. * One transform per agent
  68878. */
  68879. transforms: TransformNode[];
  68880. /**
  68881. * All agents created
  68882. */
  68883. agents: number[];
  68884. /**
  68885. * Link to the scene is kept to unregister the crowd from the scene
  68886. */
  68887. private _scene;
  68888. /**
  68889. * Observer for crowd updates
  68890. */
  68891. private _onBeforeAnimationsObserver;
  68892. /**
  68893. * Constructor
  68894. * @param plugin recastJS plugin
  68895. * @param maxAgents the maximum agent count in the crowd
  68896. * @param maxAgentRadius the maximum radius an agent can have
  68897. * @param scene to attach the crowd to
  68898. * @returns the crowd you can add agents to
  68899. */
  68900. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  68901. /**
  68902. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  68903. * You can attach anything to that node. The node position is updated in the scene update tick.
  68904. * @param pos world position that will be constrained by the navigation mesh
  68905. * @param parameters agent parameters
  68906. * @param transform hooked to the agent that will be update by the scene
  68907. * @returns agent index
  68908. */
  68909. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  68910. /**
  68911. * Returns the agent position in world space
  68912. * @param index agent index returned by addAgent
  68913. * @returns world space position
  68914. */
  68915. getAgentPosition(index: number): Vector3;
  68916. /**
  68917. * Returns the agent position result in world space
  68918. * @param index agent index returned by addAgent
  68919. * @param result output world space position
  68920. */
  68921. getAgentPositionToRef(index: number, result: Vector3): void;
  68922. /**
  68923. * Returns the agent velocity in world space
  68924. * @param index agent index returned by addAgent
  68925. * @returns world space velocity
  68926. */
  68927. getAgentVelocity(index: number): Vector3;
  68928. /**
  68929. * Returns the agent velocity result in world space
  68930. * @param index agent index returned by addAgent
  68931. * @param result output world space velocity
  68932. */
  68933. getAgentVelocityToRef(index: number, result: Vector3): void;
  68934. /**
  68935. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  68936. * @param index agent index returned by addAgent
  68937. * @param destination targeted world position
  68938. */
  68939. agentGoto(index: number, destination: Vector3): void;
  68940. /**
  68941. * Teleport the agent to a new position
  68942. * @param index agent index returned by addAgent
  68943. * @param destination targeted world position
  68944. */
  68945. agentTeleport(index: number, destination: Vector3): void;
  68946. /**
  68947. * Update agent parameters
  68948. * @param index agent index returned by addAgent
  68949. * @param parameters agent parameters
  68950. */
  68951. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  68952. /**
  68953. * remove a particular agent previously created
  68954. * @param index agent index returned by addAgent
  68955. */
  68956. removeAgent(index: number): void;
  68957. /**
  68958. * get the list of all agents attached to this crowd
  68959. * @returns list of agent indices
  68960. */
  68961. getAgents(): number[];
  68962. /**
  68963. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  68964. * @param deltaTime in seconds
  68965. */
  68966. update(deltaTime: number): void;
  68967. /**
  68968. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68969. * The queries will try to find a solution within those bounds
  68970. * default is (1,1,1)
  68971. * @param extent x,y,z value that define the extent around the queries point of reference
  68972. */
  68973. setDefaultQueryExtent(extent: Vector3): void;
  68974. /**
  68975. * Get the Bounding box extent specified by setDefaultQueryExtent
  68976. * @returns the box extent values
  68977. */
  68978. getDefaultQueryExtent(): Vector3;
  68979. /**
  68980. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68981. * @param result output the box extent values
  68982. */
  68983. getDefaultQueryExtentToRef(result: Vector3): void;
  68984. /**
  68985. * Release all resources
  68986. */
  68987. dispose(): void;
  68988. }
  68989. }
  68990. declare module "babylonjs/Navigation/Plugins/index" {
  68991. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  68992. }
  68993. declare module "babylonjs/Navigation/index" {
  68994. export * from "babylonjs/Navigation/INavigationEngine";
  68995. export * from "babylonjs/Navigation/Plugins/index";
  68996. }
  68997. declare module "babylonjs/Offline/database" {
  68998. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  68999. /**
  69000. * Class used to enable access to IndexedDB
  69001. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  69002. */
  69003. export class Database implements IOfflineProvider {
  69004. private _callbackManifestChecked;
  69005. private _currentSceneUrl;
  69006. private _db;
  69007. private _enableSceneOffline;
  69008. private _enableTexturesOffline;
  69009. private _manifestVersionFound;
  69010. private _mustUpdateRessources;
  69011. private _hasReachedQuota;
  69012. private _isSupported;
  69013. private _idbFactory;
  69014. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  69015. private static IsUASupportingBlobStorage;
  69016. /**
  69017. * Gets a boolean indicating if Database storate is enabled (off by default)
  69018. */
  69019. static IDBStorageEnabled: boolean;
  69020. /**
  69021. * Gets a boolean indicating if scene must be saved in the database
  69022. */
  69023. get enableSceneOffline(): boolean;
  69024. /**
  69025. * Gets a boolean indicating if textures must be saved in the database
  69026. */
  69027. get enableTexturesOffline(): boolean;
  69028. /**
  69029. * Creates a new Database
  69030. * @param urlToScene defines the url to load the scene
  69031. * @param callbackManifestChecked defines the callback to use when manifest is checked
  69032. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  69033. */
  69034. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  69035. private static _ParseURL;
  69036. private static _ReturnFullUrlLocation;
  69037. private _checkManifestFile;
  69038. /**
  69039. * Open the database and make it available
  69040. * @param successCallback defines the callback to call on success
  69041. * @param errorCallback defines the callback to call on error
  69042. */
  69043. open(successCallback: () => void, errorCallback: () => void): void;
  69044. /**
  69045. * Loads an image from the database
  69046. * @param url defines the url to load from
  69047. * @param image defines the target DOM image
  69048. */
  69049. loadImage(url: string, image: HTMLImageElement): void;
  69050. private _loadImageFromDBAsync;
  69051. private _saveImageIntoDBAsync;
  69052. private _checkVersionFromDB;
  69053. private _loadVersionFromDBAsync;
  69054. private _saveVersionIntoDBAsync;
  69055. /**
  69056. * Loads a file from database
  69057. * @param url defines the URL to load from
  69058. * @param sceneLoaded defines a callback to call on success
  69059. * @param progressCallBack defines a callback to call when progress changed
  69060. * @param errorCallback defines a callback to call on error
  69061. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  69062. */
  69063. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  69064. private _loadFileAsync;
  69065. private _saveFileAsync;
  69066. /**
  69067. * Validates if xhr data is correct
  69068. * @param xhr defines the request to validate
  69069. * @param dataType defines the expected data type
  69070. * @returns true if data is correct
  69071. */
  69072. private static _ValidateXHRData;
  69073. }
  69074. }
  69075. declare module "babylonjs/Offline/index" {
  69076. export * from "babylonjs/Offline/database";
  69077. export * from "babylonjs/Offline/IOfflineProvider";
  69078. }
  69079. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  69080. /** @hidden */
  69081. export var gpuUpdateParticlesPixelShader: {
  69082. name: string;
  69083. shader: string;
  69084. };
  69085. }
  69086. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  69087. /** @hidden */
  69088. export var gpuUpdateParticlesVertexShader: {
  69089. name: string;
  69090. shader: string;
  69091. };
  69092. }
  69093. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  69094. /** @hidden */
  69095. export var clipPlaneFragmentDeclaration2: {
  69096. name: string;
  69097. shader: string;
  69098. };
  69099. }
  69100. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  69101. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  69102. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  69103. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  69104. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  69105. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  69106. /** @hidden */
  69107. export var gpuRenderParticlesPixelShader: {
  69108. name: string;
  69109. shader: string;
  69110. };
  69111. }
  69112. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  69113. /** @hidden */
  69114. export var clipPlaneVertexDeclaration2: {
  69115. name: string;
  69116. shader: string;
  69117. };
  69118. }
  69119. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  69120. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  69121. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  69122. /** @hidden */
  69123. export var gpuRenderParticlesVertexShader: {
  69124. name: string;
  69125. shader: string;
  69126. };
  69127. }
  69128. declare module "babylonjs/Particles/gpuParticleSystem" {
  69129. import { Nullable } from "babylonjs/types";
  69130. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  69131. import { Observable } from "babylonjs/Misc/observable";
  69132. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  69133. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  69134. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  69135. import { Scene, IDisposable } from "babylonjs/scene";
  69136. import { Effect } from "babylonjs/Materials/effect";
  69137. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  69138. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  69139. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  69140. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  69141. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  69142. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  69143. /**
  69144. * This represents a GPU particle system in Babylon
  69145. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  69146. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  69147. */
  69148. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  69149. /**
  69150. * The layer mask we are rendering the particles through.
  69151. */
  69152. layerMask: number;
  69153. private _capacity;
  69154. private _activeCount;
  69155. private _currentActiveCount;
  69156. private _accumulatedCount;
  69157. private _renderEffect;
  69158. private _updateEffect;
  69159. private _buffer0;
  69160. private _buffer1;
  69161. private _spriteBuffer;
  69162. private _updateVAO;
  69163. private _renderVAO;
  69164. private _targetIndex;
  69165. private _sourceBuffer;
  69166. private _targetBuffer;
  69167. private _engine;
  69168. private _currentRenderId;
  69169. private _started;
  69170. private _stopped;
  69171. private _timeDelta;
  69172. private _randomTexture;
  69173. private _randomTexture2;
  69174. private _attributesStrideSize;
  69175. private _updateEffectOptions;
  69176. private _randomTextureSize;
  69177. private _actualFrame;
  69178. private _customEffect;
  69179. private readonly _rawTextureWidth;
  69180. /**
  69181. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  69182. */
  69183. static get IsSupported(): boolean;
  69184. /**
  69185. * An event triggered when the system is disposed.
  69186. */
  69187. onDisposeObservable: Observable<IParticleSystem>;
  69188. /**
  69189. * Gets the maximum number of particles active at the same time.
  69190. * @returns The max number of active particles.
  69191. */
  69192. getCapacity(): number;
  69193. /**
  69194. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  69195. * to override the particles.
  69196. */
  69197. forceDepthWrite: boolean;
  69198. /**
  69199. * Gets or set the number of active particles
  69200. */
  69201. get activeParticleCount(): number;
  69202. set activeParticleCount(value: number);
  69203. private _preWarmDone;
  69204. /**
  69205. * Specifies if the particles are updated in emitter local space or world space.
  69206. */
  69207. isLocal: boolean;
  69208. /**
  69209. * Is this system ready to be used/rendered
  69210. * @return true if the system is ready
  69211. */
  69212. isReady(): boolean;
  69213. /**
  69214. * Gets if the system has been started. (Note: this will still be true after stop is called)
  69215. * @returns True if it has been started, otherwise false.
  69216. */
  69217. isStarted(): boolean;
  69218. /**
  69219. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  69220. * @returns True if it has been stopped, otherwise false.
  69221. */
  69222. isStopped(): boolean;
  69223. /**
  69224. * Gets a boolean indicating that the system is stopping
  69225. * @returns true if the system is currently stopping
  69226. */
  69227. isStopping(): boolean;
  69228. /**
  69229. * Gets the number of particles active at the same time.
  69230. * @returns The number of active particles.
  69231. */
  69232. getActiveCount(): number;
  69233. /**
  69234. * Starts the particle system and begins to emit
  69235. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  69236. */
  69237. start(delay?: number): void;
  69238. /**
  69239. * Stops the particle system.
  69240. */
  69241. stop(): void;
  69242. /**
  69243. * Remove all active particles
  69244. */
  69245. reset(): void;
  69246. /**
  69247. * Returns the string "GPUParticleSystem"
  69248. * @returns a string containing the class name
  69249. */
  69250. getClassName(): string;
  69251. /**
  69252. * Gets the custom effect used to render the particles
  69253. * @param blendMode Blend mode for which the effect should be retrieved
  69254. * @returns The effect
  69255. */
  69256. getCustomEffect(blendMode?: number): Nullable<Effect>;
  69257. /**
  69258. * Sets the custom effect used to render the particles
  69259. * @param effect The effect to set
  69260. * @param blendMode Blend mode for which the effect should be set
  69261. */
  69262. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  69263. /** @hidden */
  69264. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  69265. /**
  69266. * Observable that will be called just before the particles are drawn
  69267. */
  69268. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  69269. /**
  69270. * Gets the name of the particle vertex shader
  69271. */
  69272. get vertexShaderName(): string;
  69273. private _colorGradientsTexture;
  69274. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  69275. /**
  69276. * Adds a new color gradient
  69277. * @param gradient defines the gradient to use (between 0 and 1)
  69278. * @param color1 defines the color to affect to the specified gradient
  69279. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  69280. * @returns the current particle system
  69281. */
  69282. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  69283. private _refreshColorGradient;
  69284. /** Force the system to rebuild all gradients that need to be resync */
  69285. forceRefreshGradients(): void;
  69286. /**
  69287. * Remove a specific color gradient
  69288. * @param gradient defines the gradient to remove
  69289. * @returns the current particle system
  69290. */
  69291. removeColorGradient(gradient: number): GPUParticleSystem;
  69292. private _angularSpeedGradientsTexture;
  69293. private _sizeGradientsTexture;
  69294. private _velocityGradientsTexture;
  69295. private _limitVelocityGradientsTexture;
  69296. private _dragGradientsTexture;
  69297. private _addFactorGradient;
  69298. /**
  69299. * Adds a new size gradient
  69300. * @param gradient defines the gradient to use (between 0 and 1)
  69301. * @param factor defines the size factor to affect to the specified gradient
  69302. * @returns the current particle system
  69303. */
  69304. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  69305. /**
  69306. * Remove a specific size gradient
  69307. * @param gradient defines the gradient to remove
  69308. * @returns the current particle system
  69309. */
  69310. removeSizeGradient(gradient: number): GPUParticleSystem;
  69311. private _refreshFactorGradient;
  69312. /**
  69313. * Adds a new angular speed gradient
  69314. * @param gradient defines the gradient to use (between 0 and 1)
  69315. * @param factor defines the angular speed to affect to the specified gradient
  69316. * @returns the current particle system
  69317. */
  69318. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  69319. /**
  69320. * Remove a specific angular speed gradient
  69321. * @param gradient defines the gradient to remove
  69322. * @returns the current particle system
  69323. */
  69324. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  69325. /**
  69326. * Adds a new velocity gradient
  69327. * @param gradient defines the gradient to use (between 0 and 1)
  69328. * @param factor defines the velocity to affect to the specified gradient
  69329. * @returns the current particle system
  69330. */
  69331. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  69332. /**
  69333. * Remove a specific velocity gradient
  69334. * @param gradient defines the gradient to remove
  69335. * @returns the current particle system
  69336. */
  69337. removeVelocityGradient(gradient: number): GPUParticleSystem;
  69338. /**
  69339. * Adds a new limit velocity gradient
  69340. * @param gradient defines the gradient to use (between 0 and 1)
  69341. * @param factor defines the limit velocity value to affect to the specified gradient
  69342. * @returns the current particle system
  69343. */
  69344. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  69345. /**
  69346. * Remove a specific limit velocity gradient
  69347. * @param gradient defines the gradient to remove
  69348. * @returns the current particle system
  69349. */
  69350. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  69351. /**
  69352. * Adds a new drag gradient
  69353. * @param gradient defines the gradient to use (between 0 and 1)
  69354. * @param factor defines the drag value to affect to the specified gradient
  69355. * @returns the current particle system
  69356. */
  69357. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  69358. /**
  69359. * Remove a specific drag gradient
  69360. * @param gradient defines the gradient to remove
  69361. * @returns the current particle system
  69362. */
  69363. removeDragGradient(gradient: number): GPUParticleSystem;
  69364. /**
  69365. * Not supported by GPUParticleSystem
  69366. * @param gradient defines the gradient to use (between 0 and 1)
  69367. * @param factor defines the emit rate value to affect to the specified gradient
  69368. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  69369. * @returns the current particle system
  69370. */
  69371. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  69372. /**
  69373. * Not supported by GPUParticleSystem
  69374. * @param gradient defines the gradient to remove
  69375. * @returns the current particle system
  69376. */
  69377. removeEmitRateGradient(gradient: number): IParticleSystem;
  69378. /**
  69379. * Not supported by GPUParticleSystem
  69380. * @param gradient defines the gradient to use (between 0 and 1)
  69381. * @param factor defines the start size value to affect to the specified gradient
  69382. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  69383. * @returns the current particle system
  69384. */
  69385. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  69386. /**
  69387. * Not supported by GPUParticleSystem
  69388. * @param gradient defines the gradient to remove
  69389. * @returns the current particle system
  69390. */
  69391. removeStartSizeGradient(gradient: number): IParticleSystem;
  69392. /**
  69393. * Not supported by GPUParticleSystem
  69394. * @param gradient defines the gradient to use (between 0 and 1)
  69395. * @param min defines the color remap minimal range
  69396. * @param max defines the color remap maximal range
  69397. * @returns the current particle system
  69398. */
  69399. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  69400. /**
  69401. * Not supported by GPUParticleSystem
  69402. * @param gradient defines the gradient to remove
  69403. * @returns the current particle system
  69404. */
  69405. removeColorRemapGradient(): IParticleSystem;
  69406. /**
  69407. * Not supported by GPUParticleSystem
  69408. * @param gradient defines the gradient to use (between 0 and 1)
  69409. * @param min defines the alpha remap minimal range
  69410. * @param max defines the alpha remap maximal range
  69411. * @returns the current particle system
  69412. */
  69413. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  69414. /**
  69415. * Not supported by GPUParticleSystem
  69416. * @param gradient defines the gradient to remove
  69417. * @returns the current particle system
  69418. */
  69419. removeAlphaRemapGradient(): IParticleSystem;
  69420. /**
  69421. * Not supported by GPUParticleSystem
  69422. * @param gradient defines the gradient to use (between 0 and 1)
  69423. * @param color defines the color to affect to the specified gradient
  69424. * @returns the current particle system
  69425. */
  69426. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  69427. /**
  69428. * Not supported by GPUParticleSystem
  69429. * @param gradient defines the gradient to remove
  69430. * @returns the current particle system
  69431. */
  69432. removeRampGradient(): IParticleSystem;
  69433. /**
  69434. * Not supported by GPUParticleSystem
  69435. * @returns the list of ramp gradients
  69436. */
  69437. getRampGradients(): Nullable<Array<Color3Gradient>>;
  69438. /**
  69439. * Not supported by GPUParticleSystem
  69440. * Gets or sets a boolean indicating that ramp gradients must be used
  69441. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  69442. */
  69443. get useRampGradients(): boolean;
  69444. set useRampGradients(value: boolean);
  69445. /**
  69446. * Not supported by GPUParticleSystem
  69447. * @param gradient defines the gradient to use (between 0 and 1)
  69448. * @param factor defines the life time factor to affect to the specified gradient
  69449. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  69450. * @returns the current particle system
  69451. */
  69452. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  69453. /**
  69454. * Not supported by GPUParticleSystem
  69455. * @param gradient defines the gradient to remove
  69456. * @returns the current particle system
  69457. */
  69458. removeLifeTimeGradient(gradient: number): IParticleSystem;
  69459. /**
  69460. * Instantiates a GPU particle system.
  69461. * 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.
  69462. * @param name The name of the particle system
  69463. * @param options The options used to create the system
  69464. * @param scene The scene the particle system belongs to
  69465. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  69466. * @param customEffect a custom effect used to change the way particles are rendered by default
  69467. */
  69468. constructor(name: string, options: Partial<{
  69469. capacity: number;
  69470. randomTextureSize: number;
  69471. }>, scene: Scene, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  69472. protected _reset(): void;
  69473. private _createUpdateVAO;
  69474. private _createRenderVAO;
  69475. private _initialize;
  69476. /** @hidden */
  69477. _recreateUpdateEffect(): void;
  69478. private _getEffect;
  69479. /**
  69480. * Fill the defines array according to the current settings of the particle system
  69481. * @param defines Array to be updated
  69482. * @param blendMode blend mode to take into account when updating the array
  69483. */
  69484. fillDefines(defines: Array<string>, blendMode?: number): void;
  69485. /**
  69486. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  69487. * @param uniforms Uniforms array to fill
  69488. * @param attributes Attributes array to fill
  69489. * @param samplers Samplers array to fill
  69490. */
  69491. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  69492. /** @hidden */
  69493. _recreateRenderEffect(): Effect;
  69494. /**
  69495. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  69496. * @param preWarm defines if we are in the pre-warmimg phase
  69497. */
  69498. animate(preWarm?: boolean): void;
  69499. private _createFactorGradientTexture;
  69500. private _createSizeGradientTexture;
  69501. private _createAngularSpeedGradientTexture;
  69502. private _createVelocityGradientTexture;
  69503. private _createLimitVelocityGradientTexture;
  69504. private _createDragGradientTexture;
  69505. private _createColorGradientTexture;
  69506. /**
  69507. * Renders the particle system in its current state
  69508. * @param preWarm defines if the system should only update the particles but not render them
  69509. * @returns the current number of particles
  69510. */
  69511. render(preWarm?: boolean): number;
  69512. /**
  69513. * Rebuilds the particle system
  69514. */
  69515. rebuild(): void;
  69516. private _releaseBuffers;
  69517. private _releaseVAOs;
  69518. /**
  69519. * Disposes the particle system and free the associated resources
  69520. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  69521. */
  69522. dispose(disposeTexture?: boolean): void;
  69523. /**
  69524. * Clones the particle system.
  69525. * @param name The name of the cloned object
  69526. * @param newEmitter The new emitter to use
  69527. * @returns the cloned particle system
  69528. */
  69529. clone(name: string, newEmitter: any): GPUParticleSystem;
  69530. /**
  69531. * Serializes the particle system to a JSON object
  69532. * @param serializeTexture defines if the texture must be serialized as well
  69533. * @returns the JSON object
  69534. */
  69535. serialize(serializeTexture?: boolean): any;
  69536. /**
  69537. * Parses a JSON object to create a GPU particle system.
  69538. * @param parsedParticleSystem The JSON object to parse
  69539. * @param scene The scene to create the particle system in
  69540. * @param rootUrl The root url to use to load external dependencies like texture
  69541. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  69542. * @returns the parsed GPU particle system
  69543. */
  69544. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  69545. }
  69546. }
  69547. declare module "babylonjs/Particles/particleSystemSet" {
  69548. import { Nullable } from "babylonjs/types";
  69549. import { Color3 } from "babylonjs/Maths/math.color";
  69550. import { TransformNode } from "babylonjs/Meshes/transformNode";
  69551. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69552. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  69553. import { Scene, IDisposable } from "babylonjs/scene";
  69554. /**
  69555. * Represents a set of particle systems working together to create a specific effect
  69556. */
  69557. export class ParticleSystemSet implements IDisposable {
  69558. /**
  69559. * Gets or sets base Assets URL
  69560. */
  69561. static BaseAssetsUrl: string;
  69562. private _emitterCreationOptions;
  69563. private _emitterNode;
  69564. /**
  69565. * Gets the particle system list
  69566. */
  69567. systems: IParticleSystem[];
  69568. /**
  69569. * Gets the emitter node used with this set
  69570. */
  69571. get emitterNode(): Nullable<TransformNode>;
  69572. /**
  69573. * Creates a new emitter mesh as a sphere
  69574. * @param options defines the options used to create the sphere
  69575. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  69576. * @param scene defines the hosting scene
  69577. */
  69578. setEmitterAsSphere(options: {
  69579. diameter: number;
  69580. segments: number;
  69581. color: Color3;
  69582. }, renderingGroupId: number, scene: Scene): void;
  69583. /**
  69584. * Starts all particle systems of the set
  69585. * @param emitter defines an optional mesh to use as emitter for the particle systems
  69586. */
  69587. start(emitter?: AbstractMesh): void;
  69588. /**
  69589. * Release all associated resources
  69590. */
  69591. dispose(): void;
  69592. /**
  69593. * Serialize the set into a JSON compatible object
  69594. * @param serializeTexture defines if the texture must be serialized as well
  69595. * @returns a JSON compatible representation of the set
  69596. */
  69597. serialize(serializeTexture?: boolean): any;
  69598. /**
  69599. * Parse a new ParticleSystemSet from a serialized source
  69600. * @param data defines a JSON compatible representation of the set
  69601. * @param scene defines the hosting scene
  69602. * @param gpu defines if we want GPU particles or CPU particles
  69603. * @returns a new ParticleSystemSet
  69604. */
  69605. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  69606. }
  69607. }
  69608. declare module "babylonjs/Particles/particleHelper" {
  69609. import { Nullable } from "babylonjs/types";
  69610. import { Scene } from "babylonjs/scene";
  69611. import { Vector3 } from "babylonjs/Maths/math.vector";
  69612. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69613. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  69614. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  69615. /**
  69616. * This class is made for on one-liner static method to help creating particle system set.
  69617. */
  69618. export class ParticleHelper {
  69619. /**
  69620. * Gets or sets base Assets URL
  69621. */
  69622. static BaseAssetsUrl: string;
  69623. /** Define the Url to load snippets */
  69624. static SnippetUrl: string;
  69625. /**
  69626. * Create a default particle system that you can tweak
  69627. * @param emitter defines the emitter to use
  69628. * @param capacity defines the system capacity (default is 500 particles)
  69629. * @param scene defines the hosting scene
  69630. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  69631. * @returns the new Particle system
  69632. */
  69633. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  69634. /**
  69635. * This is the main static method (one-liner) of this helper to create different particle systems
  69636. * @param type This string represents the type to the particle system to create
  69637. * @param scene The scene where the particle system should live
  69638. * @param gpu If the system will use gpu
  69639. * @returns the ParticleSystemSet created
  69640. */
  69641. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  69642. /**
  69643. * Static function used to export a particle system to a ParticleSystemSet variable.
  69644. * Please note that the emitter shape is not exported
  69645. * @param systems defines the particle systems to export
  69646. * @returns the created particle system set
  69647. */
  69648. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  69649. /**
  69650. * Creates a particle system from a snippet saved in a remote file
  69651. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  69652. * @param url defines the url to load from
  69653. * @param scene defines the hosting scene
  69654. * @param gpu If the system will use gpu
  69655. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  69656. * @returns a promise that will resolve to the new particle system
  69657. */
  69658. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  69659. /**
  69660. * Creates a particle system from a snippet saved by the particle system editor
  69661. * @param snippetId defines the snippet to load
  69662. * @param scene defines the hosting scene
  69663. * @param gpu If the system will use gpu
  69664. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  69665. * @returns a promise that will resolve to the new particle system
  69666. */
  69667. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  69668. }
  69669. }
  69670. declare module "babylonjs/Particles/particleSystemComponent" {
  69671. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  69672. import { Effect } from "babylonjs/Materials/effect";
  69673. import "babylonjs/Shaders/particles.vertex";
  69674. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  69675. module "babylonjs/Engines/engine" {
  69676. interface Engine {
  69677. /**
  69678. * Create an effect to use with particle systems.
  69679. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  69680. * the particle system for which you want to create a custom effect in the last parameter
  69681. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  69682. * @param uniformsNames defines a list of attribute names
  69683. * @param samplers defines an array of string used to represent textures
  69684. * @param defines defines the string containing the defines to use to compile the shaders
  69685. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  69686. * @param onCompiled defines a function to call when the effect creation is successful
  69687. * @param onError defines a function to call when the effect creation has failed
  69688. * @param particleSystem the particle system you want to create the effect for
  69689. * @returns the new Effect
  69690. */
  69691. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  69692. }
  69693. }
  69694. module "babylonjs/Meshes/mesh" {
  69695. interface Mesh {
  69696. /**
  69697. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  69698. * @returns an array of IParticleSystem
  69699. */
  69700. getEmittedParticleSystems(): IParticleSystem[];
  69701. /**
  69702. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  69703. * @returns an array of IParticleSystem
  69704. */
  69705. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  69706. }
  69707. }
  69708. }
  69709. declare module "babylonjs/Particles/pointsCloudSystem" {
  69710. import { Color4 } from "babylonjs/Maths/math";
  69711. import { Mesh } from "babylonjs/Meshes/mesh";
  69712. import { Scene, IDisposable } from "babylonjs/scene";
  69713. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  69714. /** Defines the 4 color options */
  69715. export enum PointColor {
  69716. /** color value */
  69717. Color = 2,
  69718. /** uv value */
  69719. UV = 1,
  69720. /** random value */
  69721. Random = 0,
  69722. /** stated value */
  69723. Stated = 3
  69724. }
  69725. /**
  69726. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  69727. * 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.
  69728. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  69729. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  69730. *
  69731. * Full documentation here : TO BE ENTERED
  69732. */
  69733. export class PointsCloudSystem implements IDisposable {
  69734. /**
  69735. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  69736. * Example : var p = SPS.particles[i];
  69737. */
  69738. particles: CloudPoint[];
  69739. /**
  69740. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  69741. */
  69742. nbParticles: number;
  69743. /**
  69744. * This a counter for your own usage. It's not set by any SPS functions.
  69745. */
  69746. counter: number;
  69747. /**
  69748. * The PCS name. This name is also given to the underlying mesh.
  69749. */
  69750. name: string;
  69751. /**
  69752. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  69753. */
  69754. mesh: Mesh;
  69755. /**
  69756. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  69757. * Please read :
  69758. */
  69759. vars: any;
  69760. /**
  69761. * @hidden
  69762. */
  69763. _size: number;
  69764. private _scene;
  69765. private _promises;
  69766. private _positions;
  69767. private _indices;
  69768. private _normals;
  69769. private _colors;
  69770. private _uvs;
  69771. private _indices32;
  69772. private _positions32;
  69773. private _colors32;
  69774. private _uvs32;
  69775. private _updatable;
  69776. private _isVisibilityBoxLocked;
  69777. private _alwaysVisible;
  69778. private _groups;
  69779. private _groupCounter;
  69780. private _computeParticleColor;
  69781. private _computeParticleTexture;
  69782. private _computeParticleRotation;
  69783. private _computeBoundingBox;
  69784. private _isReady;
  69785. /**
  69786. * Creates a PCS (Points Cloud System) object
  69787. * @param name (String) is the PCS name, this will be the underlying mesh name
  69788. * @param pointSize (number) is the size for each point
  69789. * @param scene (Scene) is the scene in which the PCS is added
  69790. * @param options defines the options of the PCS e.g.
  69791. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  69792. */
  69793. constructor(name: string, pointSize: number, scene: Scene, options?: {
  69794. updatable?: boolean;
  69795. });
  69796. /**
  69797. * Builds the PCS underlying mesh. Returns a standard Mesh.
  69798. * If no points were added to the PCS, the returned mesh is just a single point.
  69799. * @returns a promise for the created mesh
  69800. */
  69801. buildMeshAsync(): Promise<Mesh>;
  69802. /**
  69803. * @hidden
  69804. */
  69805. private _buildMesh;
  69806. private _addParticle;
  69807. private _randomUnitVector;
  69808. private _getColorIndicesForCoord;
  69809. private _setPointsColorOrUV;
  69810. private _colorFromTexture;
  69811. private _calculateDensity;
  69812. /**
  69813. * Adds points to the PCS in random positions within a unit sphere
  69814. * @param nb (positive integer) the number of particles to be created from this model
  69815. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  69816. * @returns the number of groups in the system
  69817. */
  69818. addPoints(nb: number, pointFunction?: any): number;
  69819. /**
  69820. * Adds points to the PCS from the surface of the model shape
  69821. * @param mesh is any Mesh object that will be used as a surface model for the points
  69822. * @param nb (positive integer) the number of particles to be created from this model
  69823. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  69824. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  69825. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  69826. * @returns the number of groups in the system
  69827. */
  69828. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  69829. /**
  69830. * Adds points to the PCS inside the model shape
  69831. * @param mesh is any Mesh object that will be used as a surface model for the points
  69832. * @param nb (positive integer) the number of particles to be created from this model
  69833. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  69834. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  69835. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  69836. * @returns the number of groups in the system
  69837. */
  69838. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  69839. /**
  69840. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  69841. * This method calls `updateParticle()` for each particle of the SPS.
  69842. * For an animated SPS, it is usually called within the render loop.
  69843. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  69844. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  69845. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  69846. * @returns the PCS.
  69847. */
  69848. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  69849. /**
  69850. * Disposes the PCS.
  69851. */
  69852. dispose(): void;
  69853. /**
  69854. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  69855. * doc :
  69856. * @returns the PCS.
  69857. */
  69858. refreshVisibleSize(): PointsCloudSystem;
  69859. /**
  69860. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  69861. * @param size the size (float) of the visibility box
  69862. * note : this doesn't lock the PCS mesh bounding box.
  69863. * doc :
  69864. */
  69865. setVisibilityBox(size: number): void;
  69866. /**
  69867. * Gets whether the PCS is always visible or not
  69868. * doc :
  69869. */
  69870. get isAlwaysVisible(): boolean;
  69871. /**
  69872. * Sets the PCS as always visible or not
  69873. * doc :
  69874. */
  69875. set isAlwaysVisible(val: boolean);
  69876. /**
  69877. * Tells to `setParticles()` to compute the particle rotations or not
  69878. * Default value : false. The PCS is faster when it's set to false
  69879. * Note : particle rotations are only applied to parent particles
  69880. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  69881. */
  69882. set computeParticleRotation(val: boolean);
  69883. /**
  69884. * Tells to `setParticles()` to compute the particle colors or not.
  69885. * Default value : true. The PCS is faster when it's set to false.
  69886. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  69887. */
  69888. set computeParticleColor(val: boolean);
  69889. set computeParticleTexture(val: boolean);
  69890. /**
  69891. * Gets if `setParticles()` computes the particle colors or not.
  69892. * Default value : false. The PCS is faster when it's set to false.
  69893. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  69894. */
  69895. get computeParticleColor(): boolean;
  69896. /**
  69897. * Gets if `setParticles()` computes the particle textures or not.
  69898. * Default value : false. The PCS is faster when it's set to false.
  69899. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  69900. */
  69901. get computeParticleTexture(): boolean;
  69902. /**
  69903. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  69904. */
  69905. set computeBoundingBox(val: boolean);
  69906. /**
  69907. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  69908. */
  69909. get computeBoundingBox(): boolean;
  69910. /**
  69911. * This function does nothing. It may be overwritten to set all the particle first values.
  69912. * The PCS doesn't call this function, you may have to call it by your own.
  69913. * doc :
  69914. */
  69915. initParticles(): void;
  69916. /**
  69917. * This function does nothing. It may be overwritten to recycle a particle
  69918. * The PCS doesn't call this function, you can to call it
  69919. * doc :
  69920. * @param particle The particle to recycle
  69921. * @returns the recycled particle
  69922. */
  69923. recycleParticle(particle: CloudPoint): CloudPoint;
  69924. /**
  69925. * Updates a particle : this function should be overwritten by the user.
  69926. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  69927. * doc :
  69928. * @example : just set a particle position or velocity and recycle conditions
  69929. * @param particle The particle to update
  69930. * @returns the updated particle
  69931. */
  69932. updateParticle(particle: CloudPoint): CloudPoint;
  69933. /**
  69934. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  69935. * This does nothing and may be overwritten by the user.
  69936. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  69937. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  69938. * @param update the boolean update value actually passed to setParticles()
  69939. */
  69940. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  69941. /**
  69942. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  69943. * This will be passed three parameters.
  69944. * This does nothing and may be overwritten by the user.
  69945. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  69946. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  69947. * @param update the boolean update value actually passed to setParticles()
  69948. */
  69949. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  69950. }
  69951. }
  69952. declare module "babylonjs/Particles/cloudPoint" {
  69953. import { Nullable } from "babylonjs/types";
  69954. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  69955. import { Mesh } from "babylonjs/Meshes/mesh";
  69956. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  69957. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  69958. /**
  69959. * Represents one particle of a points cloud system.
  69960. */
  69961. export class CloudPoint {
  69962. /**
  69963. * particle global index
  69964. */
  69965. idx: number;
  69966. /**
  69967. * The color of the particle
  69968. */
  69969. color: Nullable<Color4>;
  69970. /**
  69971. * The world space position of the particle.
  69972. */
  69973. position: Vector3;
  69974. /**
  69975. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  69976. */
  69977. rotation: Vector3;
  69978. /**
  69979. * The world space rotation quaternion of the particle.
  69980. */
  69981. rotationQuaternion: Nullable<Quaternion>;
  69982. /**
  69983. * The uv of the particle.
  69984. */
  69985. uv: Nullable<Vector2>;
  69986. /**
  69987. * The current speed of the particle.
  69988. */
  69989. velocity: Vector3;
  69990. /**
  69991. * The pivot point in the particle local space.
  69992. */
  69993. pivot: Vector3;
  69994. /**
  69995. * Must the particle be translated from its pivot point in its local space ?
  69996. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  69997. * Default : false
  69998. */
  69999. translateFromPivot: boolean;
  70000. /**
  70001. * Index of this particle in the global "positions" array (Internal use)
  70002. * @hidden
  70003. */
  70004. _pos: number;
  70005. /**
  70006. * @hidden Index of this particle in the global "indices" array (Internal use)
  70007. */
  70008. _ind: number;
  70009. /**
  70010. * Group this particle belongs to
  70011. */
  70012. _group: PointsGroup;
  70013. /**
  70014. * Group id of this particle
  70015. */
  70016. groupId: number;
  70017. /**
  70018. * Index of the particle in its group id (Internal use)
  70019. */
  70020. idxInGroup: number;
  70021. /**
  70022. * @hidden Particle BoundingInfo object (Internal use)
  70023. */
  70024. _boundingInfo: BoundingInfo;
  70025. /**
  70026. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  70027. */
  70028. _pcs: PointsCloudSystem;
  70029. /**
  70030. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  70031. */
  70032. _stillInvisible: boolean;
  70033. /**
  70034. * @hidden Last computed particle rotation matrix
  70035. */
  70036. _rotationMatrix: number[];
  70037. /**
  70038. * Parent particle Id, if any.
  70039. * Default null.
  70040. */
  70041. parentId: Nullable<number>;
  70042. /**
  70043. * @hidden Internal global position in the PCS.
  70044. */
  70045. _globalPosition: Vector3;
  70046. /**
  70047. * Creates a Point Cloud object.
  70048. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  70049. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  70050. * @param group (PointsGroup) is the group the particle belongs to
  70051. * @param groupId (integer) is the group identifier in the PCS.
  70052. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  70053. * @param pcs defines the PCS it is associated to
  70054. */
  70055. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  70056. /**
  70057. * get point size
  70058. */
  70059. get size(): Vector3;
  70060. /**
  70061. * Set point size
  70062. */
  70063. set size(scale: Vector3);
  70064. /**
  70065. * Legacy support, changed quaternion to rotationQuaternion
  70066. */
  70067. get quaternion(): Nullable<Quaternion>;
  70068. /**
  70069. * Legacy support, changed quaternion to rotationQuaternion
  70070. */
  70071. set quaternion(q: Nullable<Quaternion>);
  70072. /**
  70073. * Returns a boolean. True if the particle intersects a mesh, else false
  70074. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  70075. * @param target is the object (point or mesh) what the intersection is computed against
  70076. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  70077. * @returns true if it intersects
  70078. */
  70079. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  70080. /**
  70081. * get the rotation matrix of the particle
  70082. * @hidden
  70083. */
  70084. getRotationMatrix(m: Matrix): void;
  70085. }
  70086. /**
  70087. * Represents a group of points in a points cloud system
  70088. * * PCS internal tool, don't use it manually.
  70089. */
  70090. export class PointsGroup {
  70091. /**
  70092. * The group id
  70093. * @hidden
  70094. */
  70095. groupID: number;
  70096. /**
  70097. * image data for group (internal use)
  70098. * @hidden
  70099. */
  70100. _groupImageData: Nullable<ArrayBufferView>;
  70101. /**
  70102. * Image Width (internal use)
  70103. * @hidden
  70104. */
  70105. _groupImgWidth: number;
  70106. /**
  70107. * Image Height (internal use)
  70108. * @hidden
  70109. */
  70110. _groupImgHeight: number;
  70111. /**
  70112. * Custom position function (internal use)
  70113. * @hidden
  70114. */
  70115. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  70116. /**
  70117. * density per facet for surface points
  70118. * @hidden
  70119. */
  70120. _groupDensity: number[];
  70121. /**
  70122. * Only when points are colored by texture carries pointer to texture list array
  70123. * @hidden
  70124. */
  70125. _textureNb: number;
  70126. /**
  70127. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  70128. * PCS internal tool, don't use it manually.
  70129. * @hidden
  70130. */
  70131. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  70132. }
  70133. }
  70134. declare module "babylonjs/Particles/index" {
  70135. export * from "babylonjs/Particles/baseParticleSystem";
  70136. export * from "babylonjs/Particles/EmitterTypes/index";
  70137. export * from "babylonjs/Particles/gpuParticleSystem";
  70138. export * from "babylonjs/Particles/IParticleSystem";
  70139. export * from "babylonjs/Particles/particle";
  70140. export * from "babylonjs/Particles/particleHelper";
  70141. export * from "babylonjs/Particles/particleSystem";
  70142. import "babylonjs/Particles/particleSystemComponent";
  70143. export * from "babylonjs/Particles/particleSystemComponent";
  70144. export * from "babylonjs/Particles/particleSystemSet";
  70145. export * from "babylonjs/Particles/solidParticle";
  70146. export * from "babylonjs/Particles/solidParticleSystem";
  70147. export * from "babylonjs/Particles/cloudPoint";
  70148. export * from "babylonjs/Particles/pointsCloudSystem";
  70149. export * from "babylonjs/Particles/subEmitter";
  70150. }
  70151. declare module "babylonjs/Physics/physicsEngineComponent" {
  70152. import { Nullable } from "babylonjs/types";
  70153. import { Observable, Observer } from "babylonjs/Misc/observable";
  70154. import { Vector3 } from "babylonjs/Maths/math.vector";
  70155. import { Mesh } from "babylonjs/Meshes/mesh";
  70156. import { ISceneComponent } from "babylonjs/sceneComponent";
  70157. import { Scene } from "babylonjs/scene";
  70158. import { Node } from "babylonjs/node";
  70159. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  70160. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  70161. module "babylonjs/scene" {
  70162. interface Scene {
  70163. /** @hidden (Backing field) */
  70164. _physicsEngine: Nullable<IPhysicsEngine>;
  70165. /** @hidden */
  70166. _physicsTimeAccumulator: number;
  70167. /**
  70168. * Gets the current physics engine
  70169. * @returns a IPhysicsEngine or null if none attached
  70170. */
  70171. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  70172. /**
  70173. * Enables physics to the current scene
  70174. * @param gravity defines the scene's gravity for the physics engine
  70175. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  70176. * @return a boolean indicating if the physics engine was initialized
  70177. */
  70178. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  70179. /**
  70180. * Disables and disposes the physics engine associated with the scene
  70181. */
  70182. disablePhysicsEngine(): void;
  70183. /**
  70184. * Gets a boolean indicating if there is an active physics engine
  70185. * @returns a boolean indicating if there is an active physics engine
  70186. */
  70187. isPhysicsEnabled(): boolean;
  70188. /**
  70189. * Deletes a physics compound impostor
  70190. * @param compound defines the compound to delete
  70191. */
  70192. deleteCompoundImpostor(compound: any): void;
  70193. /**
  70194. * An event triggered when physic simulation is about to be run
  70195. */
  70196. onBeforePhysicsObservable: Observable<Scene>;
  70197. /**
  70198. * An event triggered when physic simulation has been done
  70199. */
  70200. onAfterPhysicsObservable: Observable<Scene>;
  70201. }
  70202. }
  70203. module "babylonjs/Meshes/abstractMesh" {
  70204. interface AbstractMesh {
  70205. /** @hidden */
  70206. _physicsImpostor: Nullable<PhysicsImpostor>;
  70207. /**
  70208. * Gets or sets impostor used for physic simulation
  70209. * @see http://doc.babylonjs.com/features/physics_engine
  70210. */
  70211. physicsImpostor: Nullable<PhysicsImpostor>;
  70212. /**
  70213. * Gets the current physics impostor
  70214. * @see http://doc.babylonjs.com/features/physics_engine
  70215. * @returns a physics impostor or null
  70216. */
  70217. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  70218. /** Apply a physic impulse to the mesh
  70219. * @param force defines the force to apply
  70220. * @param contactPoint defines where to apply the force
  70221. * @returns the current mesh
  70222. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  70223. */
  70224. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  70225. /**
  70226. * Creates a physic joint between two meshes
  70227. * @param otherMesh defines the other mesh to use
  70228. * @param pivot1 defines the pivot to use on this mesh
  70229. * @param pivot2 defines the pivot to use on the other mesh
  70230. * @param options defines additional options (can be plugin dependent)
  70231. * @returns the current mesh
  70232. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  70233. */
  70234. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  70235. /** @hidden */
  70236. _disposePhysicsObserver: Nullable<Observer<Node>>;
  70237. }
  70238. }
  70239. /**
  70240. * Defines the physics engine scene component responsible to manage a physics engine
  70241. */
  70242. export class PhysicsEngineSceneComponent implements ISceneComponent {
  70243. /**
  70244. * The component name helpful to identify the component in the list of scene components.
  70245. */
  70246. readonly name: string;
  70247. /**
  70248. * The scene the component belongs to.
  70249. */
  70250. scene: Scene;
  70251. /**
  70252. * Creates a new instance of the component for the given scene
  70253. * @param scene Defines the scene to register the component in
  70254. */
  70255. constructor(scene: Scene);
  70256. /**
  70257. * Registers the component in a given scene
  70258. */
  70259. register(): void;
  70260. /**
  70261. * Rebuilds the elements related to this component in case of
  70262. * context lost for instance.
  70263. */
  70264. rebuild(): void;
  70265. /**
  70266. * Disposes the component and the associated ressources
  70267. */
  70268. dispose(): void;
  70269. }
  70270. }
  70271. declare module "babylonjs/Physics/physicsHelper" {
  70272. import { Nullable } from "babylonjs/types";
  70273. import { Vector3 } from "babylonjs/Maths/math.vector";
  70274. import { Mesh } from "babylonjs/Meshes/mesh";
  70275. import { Scene } from "babylonjs/scene";
  70276. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  70277. /**
  70278. * A helper for physics simulations
  70279. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70280. */
  70281. export class PhysicsHelper {
  70282. private _scene;
  70283. private _physicsEngine;
  70284. /**
  70285. * Initializes the Physics helper
  70286. * @param scene Babylon.js scene
  70287. */
  70288. constructor(scene: Scene);
  70289. /**
  70290. * Applies a radial explosion impulse
  70291. * @param origin the origin of the explosion
  70292. * @param radiusOrEventOptions the radius or the options of radial explosion
  70293. * @param strength the explosion strength
  70294. * @param falloff possible options: Constant & Linear. Defaults to Constant
  70295. * @returns A physics radial explosion event, or null
  70296. */
  70297. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  70298. /**
  70299. * Applies a radial explosion force
  70300. * @param origin the origin of the explosion
  70301. * @param radiusOrEventOptions the radius or the options of radial explosion
  70302. * @param strength the explosion strength
  70303. * @param falloff possible options: Constant & Linear. Defaults to Constant
  70304. * @returns A physics radial explosion event, or null
  70305. */
  70306. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  70307. /**
  70308. * Creates a gravitational field
  70309. * @param origin the origin of the explosion
  70310. * @param radiusOrEventOptions the radius or the options of radial explosion
  70311. * @param strength the explosion strength
  70312. * @param falloff possible options: Constant & Linear. Defaults to Constant
  70313. * @returns A physics gravitational field event, or null
  70314. */
  70315. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  70316. /**
  70317. * Creates a physics updraft event
  70318. * @param origin the origin of the updraft
  70319. * @param radiusOrEventOptions the radius or the options of the updraft
  70320. * @param strength the strength of the updraft
  70321. * @param height the height of the updraft
  70322. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  70323. * @returns A physics updraft event, or null
  70324. */
  70325. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  70326. /**
  70327. * Creates a physics vortex event
  70328. * @param origin the of the vortex
  70329. * @param radiusOrEventOptions the radius or the options of the vortex
  70330. * @param strength the strength of the vortex
  70331. * @param height the height of the vortex
  70332. * @returns a Physics vortex event, or null
  70333. * A physics vortex event or null
  70334. */
  70335. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  70336. }
  70337. /**
  70338. * Represents a physics radial explosion event
  70339. */
  70340. class PhysicsRadialExplosionEvent {
  70341. private _scene;
  70342. private _options;
  70343. private _sphere;
  70344. private _dataFetched;
  70345. /**
  70346. * Initializes a radial explosioin event
  70347. * @param _scene BabylonJS scene
  70348. * @param _options The options for the vortex event
  70349. */
  70350. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  70351. /**
  70352. * Returns the data related to the radial explosion event (sphere).
  70353. * @returns The radial explosion event data
  70354. */
  70355. getData(): PhysicsRadialExplosionEventData;
  70356. /**
  70357. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  70358. * @param impostor A physics imposter
  70359. * @param origin the origin of the explosion
  70360. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  70361. */
  70362. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  70363. /**
  70364. * Triggers affecterd impostors callbacks
  70365. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  70366. */
  70367. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  70368. /**
  70369. * Disposes the sphere.
  70370. * @param force Specifies if the sphere should be disposed by force
  70371. */
  70372. dispose(force?: boolean): void;
  70373. /*** Helpers ***/
  70374. private _prepareSphere;
  70375. private _intersectsWithSphere;
  70376. }
  70377. /**
  70378. * Represents a gravitational field event
  70379. */
  70380. class PhysicsGravitationalFieldEvent {
  70381. private _physicsHelper;
  70382. private _scene;
  70383. private _origin;
  70384. private _options;
  70385. private _tickCallback;
  70386. private _sphere;
  70387. private _dataFetched;
  70388. /**
  70389. * Initializes the physics gravitational field event
  70390. * @param _physicsHelper A physics helper
  70391. * @param _scene BabylonJS scene
  70392. * @param _origin The origin position of the gravitational field event
  70393. * @param _options The options for the vortex event
  70394. */
  70395. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  70396. /**
  70397. * Returns the data related to the gravitational field event (sphere).
  70398. * @returns A gravitational field event
  70399. */
  70400. getData(): PhysicsGravitationalFieldEventData;
  70401. /**
  70402. * Enables the gravitational field.
  70403. */
  70404. enable(): void;
  70405. /**
  70406. * Disables the gravitational field.
  70407. */
  70408. disable(): void;
  70409. /**
  70410. * Disposes the sphere.
  70411. * @param force The force to dispose from the gravitational field event
  70412. */
  70413. dispose(force?: boolean): void;
  70414. private _tick;
  70415. }
  70416. /**
  70417. * Represents a physics updraft event
  70418. */
  70419. class PhysicsUpdraftEvent {
  70420. private _scene;
  70421. private _origin;
  70422. private _options;
  70423. private _physicsEngine;
  70424. private _originTop;
  70425. private _originDirection;
  70426. private _tickCallback;
  70427. private _cylinder;
  70428. private _cylinderPosition;
  70429. private _dataFetched;
  70430. /**
  70431. * Initializes the physics updraft event
  70432. * @param _scene BabylonJS scene
  70433. * @param _origin The origin position of the updraft
  70434. * @param _options The options for the updraft event
  70435. */
  70436. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  70437. /**
  70438. * Returns the data related to the updraft event (cylinder).
  70439. * @returns A physics updraft event
  70440. */
  70441. getData(): PhysicsUpdraftEventData;
  70442. /**
  70443. * Enables the updraft.
  70444. */
  70445. enable(): void;
  70446. /**
  70447. * Disables the updraft.
  70448. */
  70449. disable(): void;
  70450. /**
  70451. * Disposes the cylinder.
  70452. * @param force Specifies if the updraft should be disposed by force
  70453. */
  70454. dispose(force?: boolean): void;
  70455. private getImpostorHitData;
  70456. private _tick;
  70457. /*** Helpers ***/
  70458. private _prepareCylinder;
  70459. private _intersectsWithCylinder;
  70460. }
  70461. /**
  70462. * Represents a physics vortex event
  70463. */
  70464. class PhysicsVortexEvent {
  70465. private _scene;
  70466. private _origin;
  70467. private _options;
  70468. private _physicsEngine;
  70469. private _originTop;
  70470. private _tickCallback;
  70471. private _cylinder;
  70472. private _cylinderPosition;
  70473. private _dataFetched;
  70474. /**
  70475. * Initializes the physics vortex event
  70476. * @param _scene The BabylonJS scene
  70477. * @param _origin The origin position of the vortex
  70478. * @param _options The options for the vortex event
  70479. */
  70480. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  70481. /**
  70482. * Returns the data related to the vortex event (cylinder).
  70483. * @returns The physics vortex event data
  70484. */
  70485. getData(): PhysicsVortexEventData;
  70486. /**
  70487. * Enables the vortex.
  70488. */
  70489. enable(): void;
  70490. /**
  70491. * Disables the cortex.
  70492. */
  70493. disable(): void;
  70494. /**
  70495. * Disposes the sphere.
  70496. * @param force
  70497. */
  70498. dispose(force?: boolean): void;
  70499. private getImpostorHitData;
  70500. private _tick;
  70501. /*** Helpers ***/
  70502. private _prepareCylinder;
  70503. private _intersectsWithCylinder;
  70504. }
  70505. /**
  70506. * Options fot the radial explosion event
  70507. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70508. */
  70509. export class PhysicsRadialExplosionEventOptions {
  70510. /**
  70511. * The radius of the sphere for the radial explosion.
  70512. */
  70513. radius: number;
  70514. /**
  70515. * The strenth of the explosion.
  70516. */
  70517. strength: number;
  70518. /**
  70519. * The strenght of the force in correspondence to the distance of the affected object
  70520. */
  70521. falloff: PhysicsRadialImpulseFalloff;
  70522. /**
  70523. * Sphere options for the radial explosion.
  70524. */
  70525. sphere: {
  70526. segments: number;
  70527. diameter: number;
  70528. };
  70529. /**
  70530. * Sphere options for the radial explosion.
  70531. */
  70532. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  70533. }
  70534. /**
  70535. * Options fot the updraft event
  70536. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70537. */
  70538. export class PhysicsUpdraftEventOptions {
  70539. /**
  70540. * The radius of the cylinder for the vortex
  70541. */
  70542. radius: number;
  70543. /**
  70544. * The strenth of the updraft.
  70545. */
  70546. strength: number;
  70547. /**
  70548. * The height of the cylinder for the updraft.
  70549. */
  70550. height: number;
  70551. /**
  70552. * The mode for the the updraft.
  70553. */
  70554. updraftMode: PhysicsUpdraftMode;
  70555. }
  70556. /**
  70557. * Options fot the vortex event
  70558. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70559. */
  70560. export class PhysicsVortexEventOptions {
  70561. /**
  70562. * The radius of the cylinder for the vortex
  70563. */
  70564. radius: number;
  70565. /**
  70566. * The strenth of the vortex.
  70567. */
  70568. strength: number;
  70569. /**
  70570. * The height of the cylinder for the vortex.
  70571. */
  70572. height: number;
  70573. /**
  70574. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  70575. */
  70576. centripetalForceThreshold: number;
  70577. /**
  70578. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  70579. */
  70580. centripetalForceMultiplier: number;
  70581. /**
  70582. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  70583. */
  70584. centrifugalForceMultiplier: number;
  70585. /**
  70586. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  70587. */
  70588. updraftForceMultiplier: number;
  70589. }
  70590. /**
  70591. * The strenght of the force in correspondence to the distance of the affected object
  70592. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70593. */
  70594. export enum PhysicsRadialImpulseFalloff {
  70595. /** Defines that impulse is constant in strength across it's whole radius */
  70596. Constant = 0,
  70597. /** Defines that impulse gets weaker if it's further from the origin */
  70598. Linear = 1
  70599. }
  70600. /**
  70601. * The strength of the force in correspondence to the distance of the affected object
  70602. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70603. */
  70604. export enum PhysicsUpdraftMode {
  70605. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  70606. Center = 0,
  70607. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  70608. Perpendicular = 1
  70609. }
  70610. /**
  70611. * Interface for a physics hit data
  70612. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70613. */
  70614. export interface PhysicsHitData {
  70615. /**
  70616. * The force applied at the contact point
  70617. */
  70618. force: Vector3;
  70619. /**
  70620. * The contact point
  70621. */
  70622. contactPoint: Vector3;
  70623. /**
  70624. * The distance from the origin to the contact point
  70625. */
  70626. distanceFromOrigin: number;
  70627. }
  70628. /**
  70629. * Interface for radial explosion event data
  70630. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70631. */
  70632. export interface PhysicsRadialExplosionEventData {
  70633. /**
  70634. * A sphere used for the radial explosion event
  70635. */
  70636. sphere: Mesh;
  70637. }
  70638. /**
  70639. * Interface for gravitational field event data
  70640. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70641. */
  70642. export interface PhysicsGravitationalFieldEventData {
  70643. /**
  70644. * A sphere mesh used for the gravitational field event
  70645. */
  70646. sphere: Mesh;
  70647. }
  70648. /**
  70649. * Interface for updraft event data
  70650. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70651. */
  70652. export interface PhysicsUpdraftEventData {
  70653. /**
  70654. * A cylinder used for the updraft event
  70655. */
  70656. cylinder: Mesh;
  70657. }
  70658. /**
  70659. * Interface for vortex event data
  70660. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70661. */
  70662. export interface PhysicsVortexEventData {
  70663. /**
  70664. * A cylinder used for the vortex event
  70665. */
  70666. cylinder: Mesh;
  70667. }
  70668. /**
  70669. * Interface for an affected physics impostor
  70670. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70671. */
  70672. export interface PhysicsAffectedImpostorWithData {
  70673. /**
  70674. * The impostor affected by the effect
  70675. */
  70676. impostor: PhysicsImpostor;
  70677. /**
  70678. * The data about the hit/horce from the explosion
  70679. */
  70680. hitData: PhysicsHitData;
  70681. }
  70682. }
  70683. declare module "babylonjs/Physics/Plugins/index" {
  70684. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  70685. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  70686. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  70687. }
  70688. declare module "babylonjs/Physics/index" {
  70689. export * from "babylonjs/Physics/IPhysicsEngine";
  70690. export * from "babylonjs/Physics/physicsEngine";
  70691. export * from "babylonjs/Physics/physicsEngineComponent";
  70692. export * from "babylonjs/Physics/physicsHelper";
  70693. export * from "babylonjs/Physics/physicsImpostor";
  70694. export * from "babylonjs/Physics/physicsJoint";
  70695. export * from "babylonjs/Physics/Plugins/index";
  70696. }
  70697. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  70698. /** @hidden */
  70699. export var blackAndWhitePixelShader: {
  70700. name: string;
  70701. shader: string;
  70702. };
  70703. }
  70704. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  70705. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70706. import { Camera } from "babylonjs/Cameras/camera";
  70707. import { Engine } from "babylonjs/Engines/engine";
  70708. import "babylonjs/Shaders/blackAndWhite.fragment";
  70709. /**
  70710. * Post process used to render in black and white
  70711. */
  70712. export class BlackAndWhitePostProcess extends PostProcess {
  70713. /**
  70714. * Linear about to convert he result to black and white (default: 1)
  70715. */
  70716. degree: number;
  70717. /**
  70718. * Creates a black and white post process
  70719. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  70720. * @param name The name of the effect.
  70721. * @param options The required width/height ratio to downsize to before computing the render pass.
  70722. * @param camera The camera to apply the render pass to.
  70723. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70724. * @param engine The engine which the post process will be applied. (default: current engine)
  70725. * @param reusable If the post process can be reused on the same frame. (default: false)
  70726. */
  70727. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70728. }
  70729. }
  70730. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  70731. import { Nullable } from "babylonjs/types";
  70732. import { Camera } from "babylonjs/Cameras/camera";
  70733. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  70734. import { Engine } from "babylonjs/Engines/engine";
  70735. /**
  70736. * This represents a set of one or more post processes in Babylon.
  70737. * A post process can be used to apply a shader to a texture after it is rendered.
  70738. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70739. */
  70740. export class PostProcessRenderEffect {
  70741. private _postProcesses;
  70742. private _getPostProcesses;
  70743. private _singleInstance;
  70744. private _cameras;
  70745. private _indicesForCamera;
  70746. /**
  70747. * Name of the effect
  70748. * @hidden
  70749. */
  70750. _name: string;
  70751. /**
  70752. * Instantiates a post process render effect.
  70753. * A post process can be used to apply a shader to a texture after it is rendered.
  70754. * @param engine The engine the effect is tied to
  70755. * @param name The name of the effect
  70756. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  70757. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  70758. */
  70759. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  70760. /**
  70761. * Checks if all the post processes in the effect are supported.
  70762. */
  70763. get isSupported(): boolean;
  70764. /**
  70765. * Updates the current state of the effect
  70766. * @hidden
  70767. */
  70768. _update(): void;
  70769. /**
  70770. * Attaches the effect on cameras
  70771. * @param cameras The camera to attach to.
  70772. * @hidden
  70773. */
  70774. _attachCameras(cameras: Camera): void;
  70775. /**
  70776. * Attaches the effect on cameras
  70777. * @param cameras The camera to attach to.
  70778. * @hidden
  70779. */
  70780. _attachCameras(cameras: Camera[]): void;
  70781. /**
  70782. * Detaches the effect on cameras
  70783. * @param cameras The camera to detatch from.
  70784. * @hidden
  70785. */
  70786. _detachCameras(cameras: Camera): void;
  70787. /**
  70788. * Detatches the effect on cameras
  70789. * @param cameras The camera to detatch from.
  70790. * @hidden
  70791. */
  70792. _detachCameras(cameras: Camera[]): void;
  70793. /**
  70794. * Enables the effect on given cameras
  70795. * @param cameras The camera to enable.
  70796. * @hidden
  70797. */
  70798. _enable(cameras: Camera): void;
  70799. /**
  70800. * Enables the effect on given cameras
  70801. * @param cameras The camera to enable.
  70802. * @hidden
  70803. */
  70804. _enable(cameras: Nullable<Camera[]>): void;
  70805. /**
  70806. * Disables the effect on the given cameras
  70807. * @param cameras The camera to disable.
  70808. * @hidden
  70809. */
  70810. _disable(cameras: Camera): void;
  70811. /**
  70812. * Disables the effect on the given cameras
  70813. * @param cameras The camera to disable.
  70814. * @hidden
  70815. */
  70816. _disable(cameras: Nullable<Camera[]>): void;
  70817. /**
  70818. * Gets a list of the post processes contained in the effect.
  70819. * @param camera The camera to get the post processes on.
  70820. * @returns The list of the post processes in the effect.
  70821. */
  70822. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  70823. }
  70824. }
  70825. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  70826. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  70827. /** @hidden */
  70828. export var extractHighlightsPixelShader: {
  70829. name: string;
  70830. shader: string;
  70831. };
  70832. }
  70833. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  70834. import { Nullable } from "babylonjs/types";
  70835. import { Camera } from "babylonjs/Cameras/camera";
  70836. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70837. import { Engine } from "babylonjs/Engines/engine";
  70838. import "babylonjs/Shaders/extractHighlights.fragment";
  70839. /**
  70840. * 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.
  70841. */
  70842. export class ExtractHighlightsPostProcess extends PostProcess {
  70843. /**
  70844. * The luminance threshold, pixels below this value will be set to black.
  70845. */
  70846. threshold: number;
  70847. /** @hidden */
  70848. _exposure: number;
  70849. /**
  70850. * Post process which has the input texture to be used when performing highlight extraction
  70851. * @hidden
  70852. */
  70853. _inputPostProcess: Nullable<PostProcess>;
  70854. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70855. }
  70856. }
  70857. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  70858. /** @hidden */
  70859. export var bloomMergePixelShader: {
  70860. name: string;
  70861. shader: string;
  70862. };
  70863. }
  70864. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  70865. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70866. import { Nullable } from "babylonjs/types";
  70867. import { Engine } from "babylonjs/Engines/engine";
  70868. import { Camera } from "babylonjs/Cameras/camera";
  70869. import "babylonjs/Shaders/bloomMerge.fragment";
  70870. /**
  70871. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  70872. */
  70873. export class BloomMergePostProcess extends PostProcess {
  70874. /** Weight of the bloom to be added to the original input. */
  70875. weight: number;
  70876. /**
  70877. * Creates a new instance of @see BloomMergePostProcess
  70878. * @param name The name of the effect.
  70879. * @param originalFromInput Post process which's input will be used for the merge.
  70880. * @param blurred Blurred highlights post process which's output will be used.
  70881. * @param weight Weight of the bloom to be added to the original input.
  70882. * @param options The required width/height ratio to downsize to before computing the render pass.
  70883. * @param camera The camera to apply the render pass to.
  70884. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70885. * @param engine The engine which the post process will be applied. (default: current engine)
  70886. * @param reusable If the post process can be reused on the same frame. (default: false)
  70887. * @param textureType Type of textures used when performing the post process. (default: 0)
  70888. * @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)
  70889. */
  70890. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  70891. /** Weight of the bloom to be added to the original input. */
  70892. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70893. }
  70894. }
  70895. declare module "babylonjs/PostProcesses/bloomEffect" {
  70896. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  70897. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  70898. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  70899. import { Camera } from "babylonjs/Cameras/camera";
  70900. import { Scene } from "babylonjs/scene";
  70901. /**
  70902. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  70903. */
  70904. export class BloomEffect extends PostProcessRenderEffect {
  70905. private bloomScale;
  70906. /**
  70907. * @hidden Internal
  70908. */
  70909. _effects: Array<PostProcess>;
  70910. /**
  70911. * @hidden Internal
  70912. */
  70913. _downscale: ExtractHighlightsPostProcess;
  70914. private _blurX;
  70915. private _blurY;
  70916. private _merge;
  70917. /**
  70918. * The luminance threshold to find bright areas of the image to bloom.
  70919. */
  70920. get threshold(): number;
  70921. set threshold(value: number);
  70922. /**
  70923. * The strength of the bloom.
  70924. */
  70925. get weight(): number;
  70926. set weight(value: number);
  70927. /**
  70928. * Specifies the size of the bloom blur kernel, relative to the final output size
  70929. */
  70930. get kernel(): number;
  70931. set kernel(value: number);
  70932. /**
  70933. * Creates a new instance of @see BloomEffect
  70934. * @param scene The scene the effect belongs to.
  70935. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  70936. * @param bloomKernel The size of the kernel to be used when applying the blur.
  70937. * @param bloomWeight The the strength of bloom.
  70938. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  70939. * @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)
  70940. */
  70941. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  70942. /**
  70943. * Disposes each of the internal effects for a given camera.
  70944. * @param camera The camera to dispose the effect on.
  70945. */
  70946. disposeEffects(camera: Camera): void;
  70947. /**
  70948. * @hidden Internal
  70949. */
  70950. _updateEffects(): void;
  70951. /**
  70952. * Internal
  70953. * @returns if all the contained post processes are ready.
  70954. * @hidden
  70955. */
  70956. _isReady(): boolean;
  70957. }
  70958. }
  70959. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  70960. /** @hidden */
  70961. export var chromaticAberrationPixelShader: {
  70962. name: string;
  70963. shader: string;
  70964. };
  70965. }
  70966. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  70967. import { Vector2 } from "babylonjs/Maths/math.vector";
  70968. import { Nullable } from "babylonjs/types";
  70969. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70970. import { Camera } from "babylonjs/Cameras/camera";
  70971. import { Engine } from "babylonjs/Engines/engine";
  70972. import "babylonjs/Shaders/chromaticAberration.fragment";
  70973. /**
  70974. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  70975. */
  70976. export class ChromaticAberrationPostProcess extends PostProcess {
  70977. /**
  70978. * The amount of seperation of rgb channels (default: 30)
  70979. */
  70980. aberrationAmount: number;
  70981. /**
  70982. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  70983. */
  70984. radialIntensity: number;
  70985. /**
  70986. * 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))
  70987. */
  70988. direction: Vector2;
  70989. /**
  70990. * 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))
  70991. */
  70992. centerPosition: Vector2;
  70993. /**
  70994. * Creates a new instance ChromaticAberrationPostProcess
  70995. * @param name The name of the effect.
  70996. * @param screenWidth The width of the screen to apply the effect on.
  70997. * @param screenHeight The height of the screen to apply the effect on.
  70998. * @param options The required width/height ratio to downsize to before computing the render pass.
  70999. * @param camera The camera to apply the render pass to.
  71000. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71001. * @param engine The engine which the post process will be applied. (default: current engine)
  71002. * @param reusable If the post process can be reused on the same frame. (default: false)
  71003. * @param textureType Type of textures used when performing the post process. (default: 0)
  71004. * @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)
  71005. */
  71006. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71007. }
  71008. }
  71009. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  71010. /** @hidden */
  71011. export var circleOfConfusionPixelShader: {
  71012. name: string;
  71013. shader: string;
  71014. };
  71015. }
  71016. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  71017. import { Nullable } from "babylonjs/types";
  71018. import { Engine } from "babylonjs/Engines/engine";
  71019. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71020. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  71021. import { Camera } from "babylonjs/Cameras/camera";
  71022. import "babylonjs/Shaders/circleOfConfusion.fragment";
  71023. /**
  71024. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  71025. */
  71026. export class CircleOfConfusionPostProcess extends PostProcess {
  71027. /**
  71028. * 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.
  71029. */
  71030. lensSize: number;
  71031. /**
  71032. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  71033. */
  71034. fStop: number;
  71035. /**
  71036. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  71037. */
  71038. focusDistance: number;
  71039. /**
  71040. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  71041. */
  71042. focalLength: number;
  71043. private _depthTexture;
  71044. /**
  71045. * Creates a new instance CircleOfConfusionPostProcess
  71046. * @param name The name of the effect.
  71047. * @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.
  71048. * @param options The required width/height ratio to downsize to before computing the render pass.
  71049. * @param camera The camera to apply the render pass to.
  71050. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71051. * @param engine The engine which the post process will be applied. (default: current engine)
  71052. * @param reusable If the post process can be reused on the same frame. (default: false)
  71053. * @param textureType Type of textures used when performing the post process. (default: 0)
  71054. * @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)
  71055. */
  71056. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71057. /**
  71058. * 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.
  71059. */
  71060. set depthTexture(value: RenderTargetTexture);
  71061. }
  71062. }
  71063. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  71064. /** @hidden */
  71065. export var colorCorrectionPixelShader: {
  71066. name: string;
  71067. shader: string;
  71068. };
  71069. }
  71070. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  71071. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71072. import { Engine } from "babylonjs/Engines/engine";
  71073. import { Camera } from "babylonjs/Cameras/camera";
  71074. import "babylonjs/Shaders/colorCorrection.fragment";
  71075. /**
  71076. *
  71077. * This post-process allows the modification of rendered colors by using
  71078. * a 'look-up table' (LUT). This effect is also called Color Grading.
  71079. *
  71080. * The object needs to be provided an url to a texture containing the color
  71081. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  71082. * Use an image editing software to tweak the LUT to match your needs.
  71083. *
  71084. * For an example of a color LUT, see here:
  71085. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  71086. * For explanations on color grading, see here:
  71087. * @see http://udn.epicgames.com/Three/ColorGrading.html
  71088. *
  71089. */
  71090. export class ColorCorrectionPostProcess extends PostProcess {
  71091. private _colorTableTexture;
  71092. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71093. }
  71094. }
  71095. declare module "babylonjs/Shaders/convolution.fragment" {
  71096. /** @hidden */
  71097. export var convolutionPixelShader: {
  71098. name: string;
  71099. shader: string;
  71100. };
  71101. }
  71102. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  71103. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71104. import { Nullable } from "babylonjs/types";
  71105. import { Camera } from "babylonjs/Cameras/camera";
  71106. import { Engine } from "babylonjs/Engines/engine";
  71107. import "babylonjs/Shaders/convolution.fragment";
  71108. /**
  71109. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  71110. * input texture to perform effects such as edge detection or sharpening
  71111. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  71112. */
  71113. export class ConvolutionPostProcess extends PostProcess {
  71114. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  71115. kernel: number[];
  71116. /**
  71117. * Creates a new instance ConvolutionPostProcess
  71118. * @param name The name of the effect.
  71119. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  71120. * @param options The required width/height ratio to downsize to before computing the render pass.
  71121. * @param camera The camera to apply the render pass to.
  71122. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71123. * @param engine The engine which the post process will be applied. (default: current engine)
  71124. * @param reusable If the post process can be reused on the same frame. (default: false)
  71125. * @param textureType Type of textures used when performing the post process. (default: 0)
  71126. */
  71127. constructor(name: string,
  71128. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  71129. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  71130. /**
  71131. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71132. */
  71133. static EdgeDetect0Kernel: number[];
  71134. /**
  71135. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71136. */
  71137. static EdgeDetect1Kernel: number[];
  71138. /**
  71139. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71140. */
  71141. static EdgeDetect2Kernel: number[];
  71142. /**
  71143. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71144. */
  71145. static SharpenKernel: number[];
  71146. /**
  71147. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71148. */
  71149. static EmbossKernel: number[];
  71150. /**
  71151. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71152. */
  71153. static GaussianKernel: number[];
  71154. }
  71155. }
  71156. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  71157. import { Nullable } from "babylonjs/types";
  71158. import { Vector2 } from "babylonjs/Maths/math.vector";
  71159. import { Camera } from "babylonjs/Cameras/camera";
  71160. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71161. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  71162. import { Engine } from "babylonjs/Engines/engine";
  71163. import { Scene } from "babylonjs/scene";
  71164. /**
  71165. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  71166. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  71167. * based on samples that have a large difference in distance than the center pixel.
  71168. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  71169. */
  71170. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  71171. direction: Vector2;
  71172. /**
  71173. * Creates a new instance CircleOfConfusionPostProcess
  71174. * @param name The name of the effect.
  71175. * @param scene The scene the effect belongs to.
  71176. * @param direction The direction the blur should be applied.
  71177. * @param kernel The size of the kernel used to blur.
  71178. * @param options The required width/height ratio to downsize to before computing the render pass.
  71179. * @param camera The camera to apply the render pass to.
  71180. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  71181. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  71182. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71183. * @param engine The engine which the post process will be applied. (default: current engine)
  71184. * @param reusable If the post process can be reused on the same frame. (default: false)
  71185. * @param textureType Type of textures used when performing the post process. (default: 0)
  71186. * @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)
  71187. */
  71188. 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);
  71189. }
  71190. }
  71191. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  71192. /** @hidden */
  71193. export var depthOfFieldMergePixelShader: {
  71194. name: string;
  71195. shader: string;
  71196. };
  71197. }
  71198. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  71199. import { Nullable } from "babylonjs/types";
  71200. import { Camera } from "babylonjs/Cameras/camera";
  71201. import { Effect } from "babylonjs/Materials/effect";
  71202. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71203. import { Engine } from "babylonjs/Engines/engine";
  71204. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  71205. /**
  71206. * Options to be set when merging outputs from the default pipeline.
  71207. */
  71208. export class DepthOfFieldMergePostProcessOptions {
  71209. /**
  71210. * The original image to merge on top of
  71211. */
  71212. originalFromInput: PostProcess;
  71213. /**
  71214. * Parameters to perform the merge of the depth of field effect
  71215. */
  71216. depthOfField?: {
  71217. circleOfConfusion: PostProcess;
  71218. blurSteps: Array<PostProcess>;
  71219. };
  71220. /**
  71221. * Parameters to perform the merge of bloom effect
  71222. */
  71223. bloom?: {
  71224. blurred: PostProcess;
  71225. weight: number;
  71226. };
  71227. }
  71228. /**
  71229. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  71230. */
  71231. export class DepthOfFieldMergePostProcess extends PostProcess {
  71232. private blurSteps;
  71233. /**
  71234. * Creates a new instance of DepthOfFieldMergePostProcess
  71235. * @param name The name of the effect.
  71236. * @param originalFromInput Post process which's input will be used for the merge.
  71237. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  71238. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  71239. * @param options The required width/height ratio to downsize to before computing the render pass.
  71240. * @param camera The camera to apply the render pass to.
  71241. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71242. * @param engine The engine which the post process will be applied. (default: current engine)
  71243. * @param reusable If the post process can be reused on the same frame. (default: false)
  71244. * @param textureType Type of textures used when performing the post process. (default: 0)
  71245. * @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)
  71246. */
  71247. 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);
  71248. /**
  71249. * Updates the effect with the current post process compile time values and recompiles the shader.
  71250. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  71251. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  71252. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  71253. * @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
  71254. * @param onCompiled Called when the shader has been compiled.
  71255. * @param onError Called if there is an error when compiling a shader.
  71256. */
  71257. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  71258. }
  71259. }
  71260. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  71261. import { Nullable } from "babylonjs/types";
  71262. import { Camera } from "babylonjs/Cameras/camera";
  71263. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  71264. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  71265. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  71266. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  71267. import { Scene } from "babylonjs/scene";
  71268. /**
  71269. * Specifies the level of max blur that should be applied when using the depth of field effect
  71270. */
  71271. export enum DepthOfFieldEffectBlurLevel {
  71272. /**
  71273. * Subtle blur
  71274. */
  71275. Low = 0,
  71276. /**
  71277. * Medium blur
  71278. */
  71279. Medium = 1,
  71280. /**
  71281. * Large blur
  71282. */
  71283. High = 2
  71284. }
  71285. /**
  71286. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  71287. */
  71288. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  71289. private _circleOfConfusion;
  71290. /**
  71291. * @hidden Internal, blurs from high to low
  71292. */
  71293. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  71294. private _depthOfFieldBlurY;
  71295. private _dofMerge;
  71296. /**
  71297. * @hidden Internal post processes in depth of field effect
  71298. */
  71299. _effects: Array<PostProcess>;
  71300. /**
  71301. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  71302. */
  71303. set focalLength(value: number);
  71304. get focalLength(): number;
  71305. /**
  71306. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  71307. */
  71308. set fStop(value: number);
  71309. get fStop(): number;
  71310. /**
  71311. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  71312. */
  71313. set focusDistance(value: number);
  71314. get focusDistance(): number;
  71315. /**
  71316. * 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.
  71317. */
  71318. set lensSize(value: number);
  71319. get lensSize(): number;
  71320. /**
  71321. * Creates a new instance DepthOfFieldEffect
  71322. * @param scene The scene the effect belongs to.
  71323. * @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.
  71324. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  71325. * @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)
  71326. */
  71327. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  71328. /**
  71329. * Get the current class name of the current effet
  71330. * @returns "DepthOfFieldEffect"
  71331. */
  71332. getClassName(): string;
  71333. /**
  71334. * 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.
  71335. */
  71336. set depthTexture(value: RenderTargetTexture);
  71337. /**
  71338. * Disposes each of the internal effects for a given camera.
  71339. * @param camera The camera to dispose the effect on.
  71340. */
  71341. disposeEffects(camera: Camera): void;
  71342. /**
  71343. * @hidden Internal
  71344. */
  71345. _updateEffects(): void;
  71346. /**
  71347. * Internal
  71348. * @returns if all the contained post processes are ready.
  71349. * @hidden
  71350. */
  71351. _isReady(): boolean;
  71352. }
  71353. }
  71354. declare module "babylonjs/Shaders/displayPass.fragment" {
  71355. /** @hidden */
  71356. export var displayPassPixelShader: {
  71357. name: string;
  71358. shader: string;
  71359. };
  71360. }
  71361. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  71362. import { Nullable } from "babylonjs/types";
  71363. import { Camera } from "babylonjs/Cameras/camera";
  71364. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71365. import { Engine } from "babylonjs/Engines/engine";
  71366. import "babylonjs/Shaders/displayPass.fragment";
  71367. /**
  71368. * DisplayPassPostProcess which produces an output the same as it's input
  71369. */
  71370. export class DisplayPassPostProcess extends PostProcess {
  71371. /**
  71372. * Creates the DisplayPassPostProcess
  71373. * @param name The name of the effect.
  71374. * @param options The required width/height ratio to downsize to before computing the render pass.
  71375. * @param camera The camera to apply the render pass to.
  71376. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71377. * @param engine The engine which the post process will be applied. (default: current engine)
  71378. * @param reusable If the post process can be reused on the same frame. (default: false)
  71379. */
  71380. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71381. }
  71382. }
  71383. declare module "babylonjs/Shaders/filter.fragment" {
  71384. /** @hidden */
  71385. export var filterPixelShader: {
  71386. name: string;
  71387. shader: string;
  71388. };
  71389. }
  71390. declare module "babylonjs/PostProcesses/filterPostProcess" {
  71391. import { Nullable } from "babylonjs/types";
  71392. import { Matrix } from "babylonjs/Maths/math.vector";
  71393. import { Camera } from "babylonjs/Cameras/camera";
  71394. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71395. import { Engine } from "babylonjs/Engines/engine";
  71396. import "babylonjs/Shaders/filter.fragment";
  71397. /**
  71398. * Applies a kernel filter to the image
  71399. */
  71400. export class FilterPostProcess extends PostProcess {
  71401. /** The matrix to be applied to the image */
  71402. kernelMatrix: Matrix;
  71403. /**
  71404. *
  71405. * @param name The name of the effect.
  71406. * @param kernelMatrix The matrix to be applied to the image
  71407. * @param options The required width/height ratio to downsize to before computing the render pass.
  71408. * @param camera The camera to apply the render pass to.
  71409. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71410. * @param engine The engine which the post process will be applied. (default: current engine)
  71411. * @param reusable If the post process can be reused on the same frame. (default: false)
  71412. */
  71413. constructor(name: string,
  71414. /** The matrix to be applied to the image */
  71415. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71416. }
  71417. }
  71418. declare module "babylonjs/Shaders/fxaa.fragment" {
  71419. /** @hidden */
  71420. export var fxaaPixelShader: {
  71421. name: string;
  71422. shader: string;
  71423. };
  71424. }
  71425. declare module "babylonjs/Shaders/fxaa.vertex" {
  71426. /** @hidden */
  71427. export var fxaaVertexShader: {
  71428. name: string;
  71429. shader: string;
  71430. };
  71431. }
  71432. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  71433. import { Nullable } from "babylonjs/types";
  71434. import { Camera } from "babylonjs/Cameras/camera";
  71435. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71436. import { Engine } from "babylonjs/Engines/engine";
  71437. import "babylonjs/Shaders/fxaa.fragment";
  71438. import "babylonjs/Shaders/fxaa.vertex";
  71439. /**
  71440. * Fxaa post process
  71441. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  71442. */
  71443. export class FxaaPostProcess extends PostProcess {
  71444. /** @hidden */
  71445. texelWidth: number;
  71446. /** @hidden */
  71447. texelHeight: number;
  71448. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  71449. private _getDefines;
  71450. }
  71451. }
  71452. declare module "babylonjs/Shaders/grain.fragment" {
  71453. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  71454. /** @hidden */
  71455. export var grainPixelShader: {
  71456. name: string;
  71457. shader: string;
  71458. };
  71459. }
  71460. declare module "babylonjs/PostProcesses/grainPostProcess" {
  71461. import { Nullable } from "babylonjs/types";
  71462. import { Camera } from "babylonjs/Cameras/camera";
  71463. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71464. import { Engine } from "babylonjs/Engines/engine";
  71465. import "babylonjs/Shaders/grain.fragment";
  71466. /**
  71467. * The GrainPostProcess adds noise to the image at mid luminance levels
  71468. */
  71469. export class GrainPostProcess extends PostProcess {
  71470. /**
  71471. * The intensity of the grain added (default: 30)
  71472. */
  71473. intensity: number;
  71474. /**
  71475. * If the grain should be randomized on every frame
  71476. */
  71477. animated: boolean;
  71478. /**
  71479. * Creates a new instance of @see GrainPostProcess
  71480. * @param name The name of the effect.
  71481. * @param options The required width/height ratio to downsize to before computing the render pass.
  71482. * @param camera The camera to apply the render pass to.
  71483. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71484. * @param engine The engine which the post process will be applied. (default: current engine)
  71485. * @param reusable If the post process can be reused on the same frame. (default: false)
  71486. * @param textureType Type of textures used when performing the post process. (default: 0)
  71487. * @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)
  71488. */
  71489. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71490. }
  71491. }
  71492. declare module "babylonjs/Shaders/highlights.fragment" {
  71493. /** @hidden */
  71494. export var highlightsPixelShader: {
  71495. name: string;
  71496. shader: string;
  71497. };
  71498. }
  71499. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  71500. import { Nullable } from "babylonjs/types";
  71501. import { Camera } from "babylonjs/Cameras/camera";
  71502. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71503. import { Engine } from "babylonjs/Engines/engine";
  71504. import "babylonjs/Shaders/highlights.fragment";
  71505. /**
  71506. * Extracts highlights from the image
  71507. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  71508. */
  71509. export class HighlightsPostProcess extends PostProcess {
  71510. /**
  71511. * Extracts highlights from the image
  71512. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  71513. * @param name The name of the effect.
  71514. * @param options The required width/height ratio to downsize to before computing the render pass.
  71515. * @param camera The camera to apply the render pass to.
  71516. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71517. * @param engine The engine which the post process will be applied. (default: current engine)
  71518. * @param reusable If the post process can be reused on the same frame. (default: false)
  71519. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  71520. */
  71521. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  71522. }
  71523. }
  71524. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  71525. /** @hidden */
  71526. export var mrtFragmentDeclaration: {
  71527. name: string;
  71528. shader: string;
  71529. };
  71530. }
  71531. declare module "babylonjs/Shaders/geometry.fragment" {
  71532. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  71533. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  71534. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  71535. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  71536. /** @hidden */
  71537. export var geometryPixelShader: {
  71538. name: string;
  71539. shader: string;
  71540. };
  71541. }
  71542. declare module "babylonjs/Shaders/geometry.vertex" {
  71543. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  71544. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  71545. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  71546. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  71547. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  71548. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  71549. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  71550. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  71551. /** @hidden */
  71552. export var geometryVertexShader: {
  71553. name: string;
  71554. shader: string;
  71555. };
  71556. }
  71557. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  71558. import { Matrix } from "babylonjs/Maths/math.vector";
  71559. import { SubMesh } from "babylonjs/Meshes/subMesh";
  71560. import { Mesh } from "babylonjs/Meshes/mesh";
  71561. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  71562. import { Effect } from "babylonjs/Materials/effect";
  71563. import { Scene } from "babylonjs/scene";
  71564. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  71565. import "babylonjs/Shaders/geometry.fragment";
  71566. import "babylonjs/Shaders/geometry.vertex";
  71567. /** @hidden */
  71568. interface ISavedTransformationMatrix {
  71569. world: Matrix;
  71570. viewProjection: Matrix;
  71571. }
  71572. /**
  71573. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  71574. */
  71575. export class GeometryBufferRenderer {
  71576. /**
  71577. * Constant used to retrieve the position texture index in the G-Buffer textures array
  71578. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  71579. */
  71580. static readonly POSITION_TEXTURE_TYPE: number;
  71581. /**
  71582. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  71583. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  71584. */
  71585. static readonly VELOCITY_TEXTURE_TYPE: number;
  71586. /**
  71587. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  71588. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  71589. */
  71590. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  71591. /**
  71592. * Dictionary used to store the previous transformation matrices of each rendered mesh
  71593. * in order to compute objects velocities when enableVelocity is set to "true"
  71594. * @hidden
  71595. */
  71596. _previousTransformationMatrices: {
  71597. [index: number]: ISavedTransformationMatrix;
  71598. };
  71599. /**
  71600. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  71601. * in order to compute objects velocities when enableVelocity is set to "true"
  71602. * @hidden
  71603. */
  71604. _previousBonesTransformationMatrices: {
  71605. [index: number]: Float32Array;
  71606. };
  71607. /**
  71608. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  71609. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  71610. */
  71611. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  71612. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  71613. renderTransparentMeshes: boolean;
  71614. private _scene;
  71615. private _multiRenderTarget;
  71616. private _ratio;
  71617. private _enablePosition;
  71618. private _enableVelocity;
  71619. private _enableReflectivity;
  71620. private _positionIndex;
  71621. private _velocityIndex;
  71622. private _reflectivityIndex;
  71623. protected _effect: Effect;
  71624. protected _cachedDefines: string;
  71625. /**
  71626. * Set the render list (meshes to be rendered) used in the G buffer.
  71627. */
  71628. set renderList(meshes: Mesh[]);
  71629. /**
  71630. * Gets wether or not G buffer are supported by the running hardware.
  71631. * This requires draw buffer supports
  71632. */
  71633. get isSupported(): boolean;
  71634. /**
  71635. * Returns the index of the given texture type in the G-Buffer textures array
  71636. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  71637. * @returns the index of the given texture type in the G-Buffer textures array
  71638. */
  71639. getTextureIndex(textureType: number): number;
  71640. /**
  71641. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  71642. */
  71643. get enablePosition(): boolean;
  71644. /**
  71645. * Sets whether or not objects positions are enabled for the G buffer.
  71646. */
  71647. set enablePosition(enable: boolean);
  71648. /**
  71649. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  71650. */
  71651. get enableVelocity(): boolean;
  71652. /**
  71653. * Sets wether or not objects velocities are enabled for the G buffer.
  71654. */
  71655. set enableVelocity(enable: boolean);
  71656. /**
  71657. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  71658. */
  71659. get enableReflectivity(): boolean;
  71660. /**
  71661. * Sets wether or not objects roughness are enabled for the G buffer.
  71662. */
  71663. set enableReflectivity(enable: boolean);
  71664. /**
  71665. * Gets the scene associated with the buffer.
  71666. */
  71667. get scene(): Scene;
  71668. /**
  71669. * Gets the ratio used by the buffer during its creation.
  71670. * How big is the buffer related to the main canvas.
  71671. */
  71672. get ratio(): number;
  71673. /** @hidden */
  71674. static _SceneComponentInitialization: (scene: Scene) => void;
  71675. /**
  71676. * Creates a new G Buffer for the scene
  71677. * @param scene The scene the buffer belongs to
  71678. * @param ratio How big is the buffer related to the main canvas.
  71679. */
  71680. constructor(scene: Scene, ratio?: number);
  71681. /**
  71682. * Checks wether everything is ready to render a submesh to the G buffer.
  71683. * @param subMesh the submesh to check readiness for
  71684. * @param useInstances is the mesh drawn using instance or not
  71685. * @returns true if ready otherwise false
  71686. */
  71687. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  71688. /**
  71689. * Gets the current underlying G Buffer.
  71690. * @returns the buffer
  71691. */
  71692. getGBuffer(): MultiRenderTarget;
  71693. /**
  71694. * Gets the number of samples used to render the buffer (anti aliasing).
  71695. */
  71696. get samples(): number;
  71697. /**
  71698. * Sets the number of samples used to render the buffer (anti aliasing).
  71699. */
  71700. set samples(value: number);
  71701. /**
  71702. * Disposes the renderer and frees up associated resources.
  71703. */
  71704. dispose(): void;
  71705. protected _createRenderTargets(): void;
  71706. private _copyBonesTransformationMatrices;
  71707. }
  71708. }
  71709. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  71710. import { Nullable } from "babylonjs/types";
  71711. import { Scene } from "babylonjs/scene";
  71712. import { ISceneComponent } from "babylonjs/sceneComponent";
  71713. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  71714. module "babylonjs/scene" {
  71715. interface Scene {
  71716. /** @hidden (Backing field) */
  71717. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  71718. /**
  71719. * Gets or Sets the current geometry buffer associated to the scene.
  71720. */
  71721. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  71722. /**
  71723. * Enables a GeometryBufferRender and associates it with the scene
  71724. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  71725. * @returns the GeometryBufferRenderer
  71726. */
  71727. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  71728. /**
  71729. * Disables the GeometryBufferRender associated with the scene
  71730. */
  71731. disableGeometryBufferRenderer(): void;
  71732. }
  71733. }
  71734. /**
  71735. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  71736. * in several rendering techniques.
  71737. */
  71738. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  71739. /**
  71740. * The component name helpful to identify the component in the list of scene components.
  71741. */
  71742. readonly name: string;
  71743. /**
  71744. * The scene the component belongs to.
  71745. */
  71746. scene: Scene;
  71747. /**
  71748. * Creates a new instance of the component for the given scene
  71749. * @param scene Defines the scene to register the component in
  71750. */
  71751. constructor(scene: Scene);
  71752. /**
  71753. * Registers the component in a given scene
  71754. */
  71755. register(): void;
  71756. /**
  71757. * Rebuilds the elements related to this component in case of
  71758. * context lost for instance.
  71759. */
  71760. rebuild(): void;
  71761. /**
  71762. * Disposes the component and the associated ressources
  71763. */
  71764. dispose(): void;
  71765. private _gatherRenderTargets;
  71766. }
  71767. }
  71768. declare module "babylonjs/Shaders/motionBlur.fragment" {
  71769. /** @hidden */
  71770. export var motionBlurPixelShader: {
  71771. name: string;
  71772. shader: string;
  71773. };
  71774. }
  71775. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  71776. import { Nullable } from "babylonjs/types";
  71777. import { Camera } from "babylonjs/Cameras/camera";
  71778. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71779. import { Scene } from "babylonjs/scene";
  71780. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  71781. import "babylonjs/Animations/animatable";
  71782. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  71783. import "babylonjs/Shaders/motionBlur.fragment";
  71784. import { Engine } from "babylonjs/Engines/engine";
  71785. /**
  71786. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  71787. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  71788. * As an example, all you have to do is to create the post-process:
  71789. * var mb = new BABYLON.MotionBlurPostProcess(
  71790. * 'mb', // The name of the effect.
  71791. * scene, // The scene containing the objects to blur according to their velocity.
  71792. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  71793. * camera // The camera to apply the render pass to.
  71794. * );
  71795. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  71796. */
  71797. export class MotionBlurPostProcess extends PostProcess {
  71798. /**
  71799. * Defines how much the image is blurred by the movement. Default value is equal to 1
  71800. */
  71801. motionStrength: number;
  71802. /**
  71803. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  71804. */
  71805. get motionBlurSamples(): number;
  71806. /**
  71807. * Sets the number of iterations to be used for motion blur quality
  71808. */
  71809. set motionBlurSamples(samples: number);
  71810. private _motionBlurSamples;
  71811. private _geometryBufferRenderer;
  71812. /**
  71813. * Creates a new instance MotionBlurPostProcess
  71814. * @param name The name of the effect.
  71815. * @param scene The scene containing the objects to blur according to their velocity.
  71816. * @param options The required width/height ratio to downsize to before computing the render pass.
  71817. * @param camera The camera to apply the render pass to.
  71818. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71819. * @param engine The engine which the post process will be applied. (default: current engine)
  71820. * @param reusable If the post process can be reused on the same frame. (default: false)
  71821. * @param textureType Type of textures used when performing the post process. (default: 0)
  71822. * @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)
  71823. */
  71824. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71825. /**
  71826. * Excludes the given skinned mesh from computing bones velocities.
  71827. * 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.
  71828. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  71829. */
  71830. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  71831. /**
  71832. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  71833. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  71834. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  71835. */
  71836. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  71837. /**
  71838. * Disposes the post process.
  71839. * @param camera The camera to dispose the post process on.
  71840. */
  71841. dispose(camera?: Camera): void;
  71842. }
  71843. }
  71844. declare module "babylonjs/Shaders/refraction.fragment" {
  71845. /** @hidden */
  71846. export var refractionPixelShader: {
  71847. name: string;
  71848. shader: string;
  71849. };
  71850. }
  71851. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  71852. import { Color3 } from "babylonjs/Maths/math.color";
  71853. import { Camera } from "babylonjs/Cameras/camera";
  71854. import { Texture } from "babylonjs/Materials/Textures/texture";
  71855. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71856. import { Engine } from "babylonjs/Engines/engine";
  71857. import "babylonjs/Shaders/refraction.fragment";
  71858. /**
  71859. * Post process which applies a refractin texture
  71860. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  71861. */
  71862. export class RefractionPostProcess extends PostProcess {
  71863. /** the base color of the refraction (used to taint the rendering) */
  71864. color: Color3;
  71865. /** simulated refraction depth */
  71866. depth: number;
  71867. /** the coefficient of the base color (0 to remove base color tainting) */
  71868. colorLevel: number;
  71869. private _refTexture;
  71870. private _ownRefractionTexture;
  71871. /**
  71872. * Gets or sets the refraction texture
  71873. * Please note that you are responsible for disposing the texture if you set it manually
  71874. */
  71875. get refractionTexture(): Texture;
  71876. set refractionTexture(value: Texture);
  71877. /**
  71878. * Initializes the RefractionPostProcess
  71879. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  71880. * @param name The name of the effect.
  71881. * @param refractionTextureUrl Url of the refraction texture to use
  71882. * @param color the base color of the refraction (used to taint the rendering)
  71883. * @param depth simulated refraction depth
  71884. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  71885. * @param camera The camera to apply the render pass to.
  71886. * @param options The required width/height ratio to downsize to before computing the render pass.
  71887. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71888. * @param engine The engine which the post process will be applied. (default: current engine)
  71889. * @param reusable If the post process can be reused on the same frame. (default: false)
  71890. */
  71891. constructor(name: string, refractionTextureUrl: string,
  71892. /** the base color of the refraction (used to taint the rendering) */
  71893. color: Color3,
  71894. /** simulated refraction depth */
  71895. depth: number,
  71896. /** the coefficient of the base color (0 to remove base color tainting) */
  71897. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71898. /**
  71899. * Disposes of the post process
  71900. * @param camera Camera to dispose post process on
  71901. */
  71902. dispose(camera: Camera): void;
  71903. }
  71904. }
  71905. declare module "babylonjs/Shaders/sharpen.fragment" {
  71906. /** @hidden */
  71907. export var sharpenPixelShader: {
  71908. name: string;
  71909. shader: string;
  71910. };
  71911. }
  71912. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  71913. import { Nullable } from "babylonjs/types";
  71914. import { Camera } from "babylonjs/Cameras/camera";
  71915. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71916. import "babylonjs/Shaders/sharpen.fragment";
  71917. import { Engine } from "babylonjs/Engines/engine";
  71918. /**
  71919. * The SharpenPostProcess applies a sharpen kernel to every pixel
  71920. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  71921. */
  71922. export class SharpenPostProcess extends PostProcess {
  71923. /**
  71924. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  71925. */
  71926. colorAmount: number;
  71927. /**
  71928. * How much sharpness should be applied (default: 0.3)
  71929. */
  71930. edgeAmount: number;
  71931. /**
  71932. * Creates a new instance ConvolutionPostProcess
  71933. * @param name The name of the effect.
  71934. * @param options The required width/height ratio to downsize to before computing the render pass.
  71935. * @param camera The camera to apply the render pass to.
  71936. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71937. * @param engine The engine which the post process will be applied. (default: current engine)
  71938. * @param reusable If the post process can be reused on the same frame. (default: false)
  71939. * @param textureType Type of textures used when performing the post process. (default: 0)
  71940. * @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)
  71941. */
  71942. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71943. }
  71944. }
  71945. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  71946. import { Nullable } from "babylonjs/types";
  71947. import { Camera } from "babylonjs/Cameras/camera";
  71948. import { Engine } from "babylonjs/Engines/engine";
  71949. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  71950. import { IInspectable } from "babylonjs/Misc/iInspectable";
  71951. /**
  71952. * PostProcessRenderPipeline
  71953. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71954. */
  71955. export class PostProcessRenderPipeline {
  71956. private engine;
  71957. private _renderEffects;
  71958. private _renderEffectsForIsolatedPass;
  71959. /**
  71960. * List of inspectable custom properties (used by the Inspector)
  71961. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  71962. */
  71963. inspectableCustomProperties: IInspectable[];
  71964. /**
  71965. * @hidden
  71966. */
  71967. protected _cameras: Camera[];
  71968. /** @hidden */
  71969. _name: string;
  71970. /**
  71971. * Gets pipeline name
  71972. */
  71973. get name(): string;
  71974. /** Gets the list of attached cameras */
  71975. get cameras(): Camera[];
  71976. /**
  71977. * Initializes a PostProcessRenderPipeline
  71978. * @param engine engine to add the pipeline to
  71979. * @param name name of the pipeline
  71980. */
  71981. constructor(engine: Engine, name: string);
  71982. /**
  71983. * Gets the class name
  71984. * @returns "PostProcessRenderPipeline"
  71985. */
  71986. getClassName(): string;
  71987. /**
  71988. * If all the render effects in the pipeline are supported
  71989. */
  71990. get isSupported(): boolean;
  71991. /**
  71992. * Adds an effect to the pipeline
  71993. * @param renderEffect the effect to add
  71994. */
  71995. addEffect(renderEffect: PostProcessRenderEffect): void;
  71996. /** @hidden */
  71997. _rebuild(): void;
  71998. /** @hidden */
  71999. _enableEffect(renderEffectName: string, cameras: Camera): void;
  72000. /** @hidden */
  72001. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  72002. /** @hidden */
  72003. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  72004. /** @hidden */
  72005. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  72006. /** @hidden */
  72007. _attachCameras(cameras: Camera, unique: boolean): void;
  72008. /** @hidden */
  72009. _attachCameras(cameras: Camera[], unique: boolean): void;
  72010. /** @hidden */
  72011. _detachCameras(cameras: Camera): void;
  72012. /** @hidden */
  72013. _detachCameras(cameras: Nullable<Camera[]>): void;
  72014. /** @hidden */
  72015. _update(): void;
  72016. /** @hidden */
  72017. _reset(): void;
  72018. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  72019. /**
  72020. * Disposes of the pipeline
  72021. */
  72022. dispose(): void;
  72023. }
  72024. }
  72025. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  72026. import { Camera } from "babylonjs/Cameras/camera";
  72027. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  72028. /**
  72029. * PostProcessRenderPipelineManager class
  72030. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  72031. */
  72032. export class PostProcessRenderPipelineManager {
  72033. private _renderPipelines;
  72034. /**
  72035. * Initializes a PostProcessRenderPipelineManager
  72036. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  72037. */
  72038. constructor();
  72039. /**
  72040. * Gets the list of supported render pipelines
  72041. */
  72042. get supportedPipelines(): PostProcessRenderPipeline[];
  72043. /**
  72044. * Adds a pipeline to the manager
  72045. * @param renderPipeline The pipeline to add
  72046. */
  72047. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  72048. /**
  72049. * Attaches a camera to the pipeline
  72050. * @param renderPipelineName The name of the pipeline to attach to
  72051. * @param cameras the camera to attach
  72052. * @param unique if the camera can be attached multiple times to the pipeline
  72053. */
  72054. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  72055. /**
  72056. * Detaches a camera from the pipeline
  72057. * @param renderPipelineName The name of the pipeline to detach from
  72058. * @param cameras the camera to detach
  72059. */
  72060. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  72061. /**
  72062. * Enables an effect by name on a pipeline
  72063. * @param renderPipelineName the name of the pipeline to enable the effect in
  72064. * @param renderEffectName the name of the effect to enable
  72065. * @param cameras the cameras that the effect should be enabled on
  72066. */
  72067. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  72068. /**
  72069. * Disables an effect by name on a pipeline
  72070. * @param renderPipelineName the name of the pipeline to disable the effect in
  72071. * @param renderEffectName the name of the effect to disable
  72072. * @param cameras the cameras that the effect should be disabled on
  72073. */
  72074. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  72075. /**
  72076. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  72077. */
  72078. update(): void;
  72079. /** @hidden */
  72080. _rebuild(): void;
  72081. /**
  72082. * Disposes of the manager and pipelines
  72083. */
  72084. dispose(): void;
  72085. }
  72086. }
  72087. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  72088. import { ISceneComponent } from "babylonjs/sceneComponent";
  72089. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  72090. import { Scene } from "babylonjs/scene";
  72091. module "babylonjs/scene" {
  72092. interface Scene {
  72093. /** @hidden (Backing field) */
  72094. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  72095. /**
  72096. * Gets the postprocess render pipeline manager
  72097. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  72098. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  72099. */
  72100. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  72101. }
  72102. }
  72103. /**
  72104. * Defines the Render Pipeline scene component responsible to rendering pipelines
  72105. */
  72106. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  72107. /**
  72108. * The component name helpfull to identify the component in the list of scene components.
  72109. */
  72110. readonly name: string;
  72111. /**
  72112. * The scene the component belongs to.
  72113. */
  72114. scene: Scene;
  72115. /**
  72116. * Creates a new instance of the component for the given scene
  72117. * @param scene Defines the scene to register the component in
  72118. */
  72119. constructor(scene: Scene);
  72120. /**
  72121. * Registers the component in a given scene
  72122. */
  72123. register(): void;
  72124. /**
  72125. * Rebuilds the elements related to this component in case of
  72126. * context lost for instance.
  72127. */
  72128. rebuild(): void;
  72129. /**
  72130. * Disposes the component and the associated ressources
  72131. */
  72132. dispose(): void;
  72133. private _gatherRenderTargets;
  72134. }
  72135. }
  72136. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  72137. import { Nullable } from "babylonjs/types";
  72138. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  72139. import { Camera } from "babylonjs/Cameras/camera";
  72140. import { IDisposable } from "babylonjs/scene";
  72141. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  72142. import { Scene } from "babylonjs/scene";
  72143. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  72144. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  72145. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  72146. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  72147. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  72148. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  72149. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  72150. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  72151. import { Animation } from "babylonjs/Animations/animation";
  72152. /**
  72153. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  72154. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  72155. */
  72156. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  72157. private _scene;
  72158. private _camerasToBeAttached;
  72159. /**
  72160. * ID of the sharpen post process,
  72161. */
  72162. private readonly SharpenPostProcessId;
  72163. /**
  72164. * @ignore
  72165. * ID of the image processing post process;
  72166. */
  72167. readonly ImageProcessingPostProcessId: string;
  72168. /**
  72169. * @ignore
  72170. * ID of the Fast Approximate Anti-Aliasing post process;
  72171. */
  72172. readonly FxaaPostProcessId: string;
  72173. /**
  72174. * ID of the chromatic aberration post process,
  72175. */
  72176. private readonly ChromaticAberrationPostProcessId;
  72177. /**
  72178. * ID of the grain post process
  72179. */
  72180. private readonly GrainPostProcessId;
  72181. /**
  72182. * Sharpen post process which will apply a sharpen convolution to enhance edges
  72183. */
  72184. sharpen: SharpenPostProcess;
  72185. private _sharpenEffect;
  72186. private bloom;
  72187. /**
  72188. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  72189. */
  72190. depthOfField: DepthOfFieldEffect;
  72191. /**
  72192. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  72193. */
  72194. fxaa: FxaaPostProcess;
  72195. /**
  72196. * Image post processing pass used to perform operations such as tone mapping or color grading.
  72197. */
  72198. imageProcessing: ImageProcessingPostProcess;
  72199. /**
  72200. * Chromatic aberration post process which will shift rgb colors in the image
  72201. */
  72202. chromaticAberration: ChromaticAberrationPostProcess;
  72203. private _chromaticAberrationEffect;
  72204. /**
  72205. * Grain post process which add noise to the image
  72206. */
  72207. grain: GrainPostProcess;
  72208. private _grainEffect;
  72209. /**
  72210. * Glow post process which adds a glow to emissive areas of the image
  72211. */
  72212. private _glowLayer;
  72213. /**
  72214. * Animations which can be used to tweak settings over a period of time
  72215. */
  72216. animations: Animation[];
  72217. private _imageProcessingConfigurationObserver;
  72218. private _sharpenEnabled;
  72219. private _bloomEnabled;
  72220. private _depthOfFieldEnabled;
  72221. private _depthOfFieldBlurLevel;
  72222. private _fxaaEnabled;
  72223. private _imageProcessingEnabled;
  72224. private _defaultPipelineTextureType;
  72225. private _bloomScale;
  72226. private _chromaticAberrationEnabled;
  72227. private _grainEnabled;
  72228. private _buildAllowed;
  72229. /**
  72230. * Gets active scene
  72231. */
  72232. get scene(): Scene;
  72233. /**
  72234. * Enable or disable the sharpen process from the pipeline
  72235. */
  72236. set sharpenEnabled(enabled: boolean);
  72237. get sharpenEnabled(): boolean;
  72238. private _resizeObserver;
  72239. private _hardwareScaleLevel;
  72240. private _bloomKernel;
  72241. /**
  72242. * Specifies the size of the bloom blur kernel, relative to the final output size
  72243. */
  72244. get bloomKernel(): number;
  72245. set bloomKernel(value: number);
  72246. /**
  72247. * Specifies the weight of the bloom in the final rendering
  72248. */
  72249. private _bloomWeight;
  72250. /**
  72251. * Specifies the luma threshold for the area that will be blurred by the bloom
  72252. */
  72253. private _bloomThreshold;
  72254. private _hdr;
  72255. /**
  72256. * The strength of the bloom.
  72257. */
  72258. set bloomWeight(value: number);
  72259. get bloomWeight(): number;
  72260. /**
  72261. * The strength of the bloom.
  72262. */
  72263. set bloomThreshold(value: number);
  72264. get bloomThreshold(): number;
  72265. /**
  72266. * The scale of the bloom, lower value will provide better performance.
  72267. */
  72268. set bloomScale(value: number);
  72269. get bloomScale(): number;
  72270. /**
  72271. * Enable or disable the bloom from the pipeline
  72272. */
  72273. set bloomEnabled(enabled: boolean);
  72274. get bloomEnabled(): boolean;
  72275. private _rebuildBloom;
  72276. /**
  72277. * If the depth of field is enabled.
  72278. */
  72279. get depthOfFieldEnabled(): boolean;
  72280. set depthOfFieldEnabled(enabled: boolean);
  72281. /**
  72282. * Blur level of the depth of field effect. (Higher blur will effect performance)
  72283. */
  72284. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  72285. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  72286. /**
  72287. * If the anti aliasing is enabled.
  72288. */
  72289. set fxaaEnabled(enabled: boolean);
  72290. get fxaaEnabled(): boolean;
  72291. private _samples;
  72292. /**
  72293. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  72294. */
  72295. set samples(sampleCount: number);
  72296. get samples(): number;
  72297. /**
  72298. * If image processing is enabled.
  72299. */
  72300. set imageProcessingEnabled(enabled: boolean);
  72301. get imageProcessingEnabled(): boolean;
  72302. /**
  72303. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  72304. */
  72305. set glowLayerEnabled(enabled: boolean);
  72306. get glowLayerEnabled(): boolean;
  72307. /**
  72308. * Gets the glow layer (or null if not defined)
  72309. */
  72310. get glowLayer(): Nullable<GlowLayer>;
  72311. /**
  72312. * Enable or disable the chromaticAberration process from the pipeline
  72313. */
  72314. set chromaticAberrationEnabled(enabled: boolean);
  72315. get chromaticAberrationEnabled(): boolean;
  72316. /**
  72317. * Enable or disable the grain process from the pipeline
  72318. */
  72319. set grainEnabled(enabled: boolean);
  72320. get grainEnabled(): boolean;
  72321. /**
  72322. * @constructor
  72323. * @param name - The rendering pipeline name (default: "")
  72324. * @param hdr - If high dynamic range textures should be used (default: true)
  72325. * @param scene - The scene linked to this pipeline (default: the last created scene)
  72326. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  72327. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  72328. */
  72329. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  72330. /**
  72331. * Get the class name
  72332. * @returns "DefaultRenderingPipeline"
  72333. */
  72334. getClassName(): string;
  72335. /**
  72336. * Force the compilation of the entire pipeline.
  72337. */
  72338. prepare(): void;
  72339. private _hasCleared;
  72340. private _prevPostProcess;
  72341. private _prevPrevPostProcess;
  72342. private _setAutoClearAndTextureSharing;
  72343. private _depthOfFieldSceneObserver;
  72344. private _buildPipeline;
  72345. private _disposePostProcesses;
  72346. /**
  72347. * Adds a camera to the pipeline
  72348. * @param camera the camera to be added
  72349. */
  72350. addCamera(camera: Camera): void;
  72351. /**
  72352. * Removes a camera from the pipeline
  72353. * @param camera the camera to remove
  72354. */
  72355. removeCamera(camera: Camera): void;
  72356. /**
  72357. * Dispose of the pipeline and stop all post processes
  72358. */
  72359. dispose(): void;
  72360. /**
  72361. * Serialize the rendering pipeline (Used when exporting)
  72362. * @returns the serialized object
  72363. */
  72364. serialize(): any;
  72365. /**
  72366. * Parse the serialized pipeline
  72367. * @param source Source pipeline.
  72368. * @param scene The scene to load the pipeline to.
  72369. * @param rootUrl The URL of the serialized pipeline.
  72370. * @returns An instantiated pipeline from the serialized object.
  72371. */
  72372. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  72373. }
  72374. }
  72375. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  72376. /** @hidden */
  72377. export var lensHighlightsPixelShader: {
  72378. name: string;
  72379. shader: string;
  72380. };
  72381. }
  72382. declare module "babylonjs/Shaders/depthOfField.fragment" {
  72383. /** @hidden */
  72384. export var depthOfFieldPixelShader: {
  72385. name: string;
  72386. shader: string;
  72387. };
  72388. }
  72389. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  72390. import { Camera } from "babylonjs/Cameras/camera";
  72391. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  72392. import { Scene } from "babylonjs/scene";
  72393. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  72394. import "babylonjs/Shaders/chromaticAberration.fragment";
  72395. import "babylonjs/Shaders/lensHighlights.fragment";
  72396. import "babylonjs/Shaders/depthOfField.fragment";
  72397. /**
  72398. * BABYLON.JS Chromatic Aberration GLSL Shader
  72399. * Author: Olivier Guyot
  72400. * Separates very slightly R, G and B colors on the edges of the screen
  72401. * Inspired by Francois Tarlier & Martins Upitis
  72402. */
  72403. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  72404. /**
  72405. * @ignore
  72406. * The chromatic aberration PostProcess id in the pipeline
  72407. */
  72408. LensChromaticAberrationEffect: string;
  72409. /**
  72410. * @ignore
  72411. * The highlights enhancing PostProcess id in the pipeline
  72412. */
  72413. HighlightsEnhancingEffect: string;
  72414. /**
  72415. * @ignore
  72416. * The depth-of-field PostProcess id in the pipeline
  72417. */
  72418. LensDepthOfFieldEffect: string;
  72419. private _scene;
  72420. private _depthTexture;
  72421. private _grainTexture;
  72422. private _chromaticAberrationPostProcess;
  72423. private _highlightsPostProcess;
  72424. private _depthOfFieldPostProcess;
  72425. private _edgeBlur;
  72426. private _grainAmount;
  72427. private _chromaticAberration;
  72428. private _distortion;
  72429. private _highlightsGain;
  72430. private _highlightsThreshold;
  72431. private _dofDistance;
  72432. private _dofAperture;
  72433. private _dofDarken;
  72434. private _dofPentagon;
  72435. private _blurNoise;
  72436. /**
  72437. * @constructor
  72438. *
  72439. * Effect parameters are as follow:
  72440. * {
  72441. * chromatic_aberration: number; // from 0 to x (1 for realism)
  72442. * edge_blur: number; // from 0 to x (1 for realism)
  72443. * distortion: number; // from 0 to x (1 for realism)
  72444. * grain_amount: number; // from 0 to 1
  72445. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  72446. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  72447. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  72448. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  72449. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  72450. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  72451. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  72452. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  72453. * }
  72454. * Note: if an effect parameter is unset, effect is disabled
  72455. *
  72456. * @param name The rendering pipeline name
  72457. * @param parameters - An object containing all parameters (see above)
  72458. * @param scene The scene linked to this pipeline
  72459. * @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)
  72460. * @param cameras The array of cameras that the rendering pipeline will be attached to
  72461. */
  72462. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  72463. /**
  72464. * Get the class name
  72465. * @returns "LensRenderingPipeline"
  72466. */
  72467. getClassName(): string;
  72468. /**
  72469. * Gets associated scene
  72470. */
  72471. get scene(): Scene;
  72472. /**
  72473. * Gets or sets the edge blur
  72474. */
  72475. get edgeBlur(): number;
  72476. set edgeBlur(value: number);
  72477. /**
  72478. * Gets or sets the grain amount
  72479. */
  72480. get grainAmount(): number;
  72481. set grainAmount(value: number);
  72482. /**
  72483. * Gets or sets the chromatic aberration amount
  72484. */
  72485. get chromaticAberration(): number;
  72486. set chromaticAberration(value: number);
  72487. /**
  72488. * Gets or sets the depth of field aperture
  72489. */
  72490. get dofAperture(): number;
  72491. set dofAperture(value: number);
  72492. /**
  72493. * Gets or sets the edge distortion
  72494. */
  72495. get edgeDistortion(): number;
  72496. set edgeDistortion(value: number);
  72497. /**
  72498. * Gets or sets the depth of field distortion
  72499. */
  72500. get dofDistortion(): number;
  72501. set dofDistortion(value: number);
  72502. /**
  72503. * Gets or sets the darken out of focus amount
  72504. */
  72505. get darkenOutOfFocus(): number;
  72506. set darkenOutOfFocus(value: number);
  72507. /**
  72508. * Gets or sets a boolean indicating if blur noise is enabled
  72509. */
  72510. get blurNoise(): boolean;
  72511. set blurNoise(value: boolean);
  72512. /**
  72513. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  72514. */
  72515. get pentagonBokeh(): boolean;
  72516. set pentagonBokeh(value: boolean);
  72517. /**
  72518. * Gets or sets the highlight grain amount
  72519. */
  72520. get highlightsGain(): number;
  72521. set highlightsGain(value: number);
  72522. /**
  72523. * Gets or sets the highlight threshold
  72524. */
  72525. get highlightsThreshold(): number;
  72526. set highlightsThreshold(value: number);
  72527. /**
  72528. * Sets the amount of blur at the edges
  72529. * @param amount blur amount
  72530. */
  72531. setEdgeBlur(amount: number): void;
  72532. /**
  72533. * Sets edge blur to 0
  72534. */
  72535. disableEdgeBlur(): void;
  72536. /**
  72537. * Sets the amout of grain
  72538. * @param amount Amount of grain
  72539. */
  72540. setGrainAmount(amount: number): void;
  72541. /**
  72542. * Set grain amount to 0
  72543. */
  72544. disableGrain(): void;
  72545. /**
  72546. * Sets the chromatic aberration amount
  72547. * @param amount amount of chromatic aberration
  72548. */
  72549. setChromaticAberration(amount: number): void;
  72550. /**
  72551. * Sets chromatic aberration amount to 0
  72552. */
  72553. disableChromaticAberration(): void;
  72554. /**
  72555. * Sets the EdgeDistortion amount
  72556. * @param amount amount of EdgeDistortion
  72557. */
  72558. setEdgeDistortion(amount: number): void;
  72559. /**
  72560. * Sets edge distortion to 0
  72561. */
  72562. disableEdgeDistortion(): void;
  72563. /**
  72564. * Sets the FocusDistance amount
  72565. * @param amount amount of FocusDistance
  72566. */
  72567. setFocusDistance(amount: number): void;
  72568. /**
  72569. * Disables depth of field
  72570. */
  72571. disableDepthOfField(): void;
  72572. /**
  72573. * Sets the Aperture amount
  72574. * @param amount amount of Aperture
  72575. */
  72576. setAperture(amount: number): void;
  72577. /**
  72578. * Sets the DarkenOutOfFocus amount
  72579. * @param amount amount of DarkenOutOfFocus
  72580. */
  72581. setDarkenOutOfFocus(amount: number): void;
  72582. private _pentagonBokehIsEnabled;
  72583. /**
  72584. * Creates a pentagon bokeh effect
  72585. */
  72586. enablePentagonBokeh(): void;
  72587. /**
  72588. * Disables the pentagon bokeh effect
  72589. */
  72590. disablePentagonBokeh(): void;
  72591. /**
  72592. * Enables noise blur
  72593. */
  72594. enableNoiseBlur(): void;
  72595. /**
  72596. * Disables noise blur
  72597. */
  72598. disableNoiseBlur(): void;
  72599. /**
  72600. * Sets the HighlightsGain amount
  72601. * @param amount amount of HighlightsGain
  72602. */
  72603. setHighlightsGain(amount: number): void;
  72604. /**
  72605. * Sets the HighlightsThreshold amount
  72606. * @param amount amount of HighlightsThreshold
  72607. */
  72608. setHighlightsThreshold(amount: number): void;
  72609. /**
  72610. * Disables highlights
  72611. */
  72612. disableHighlights(): void;
  72613. /**
  72614. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  72615. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  72616. */
  72617. dispose(disableDepthRender?: boolean): void;
  72618. private _createChromaticAberrationPostProcess;
  72619. private _createHighlightsPostProcess;
  72620. private _createDepthOfFieldPostProcess;
  72621. private _createGrainTexture;
  72622. }
  72623. }
  72624. declare module "babylonjs/Shaders/ssao2.fragment" {
  72625. /** @hidden */
  72626. export var ssao2PixelShader: {
  72627. name: string;
  72628. shader: string;
  72629. };
  72630. }
  72631. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  72632. /** @hidden */
  72633. export var ssaoCombinePixelShader: {
  72634. name: string;
  72635. shader: string;
  72636. };
  72637. }
  72638. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  72639. import { Camera } from "babylonjs/Cameras/camera";
  72640. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  72641. import { Scene } from "babylonjs/scene";
  72642. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  72643. import "babylonjs/Shaders/ssao2.fragment";
  72644. import "babylonjs/Shaders/ssaoCombine.fragment";
  72645. /**
  72646. * Render pipeline to produce ssao effect
  72647. */
  72648. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  72649. /**
  72650. * @ignore
  72651. * The PassPostProcess id in the pipeline that contains the original scene color
  72652. */
  72653. SSAOOriginalSceneColorEffect: string;
  72654. /**
  72655. * @ignore
  72656. * The SSAO PostProcess id in the pipeline
  72657. */
  72658. SSAORenderEffect: string;
  72659. /**
  72660. * @ignore
  72661. * The horizontal blur PostProcess id in the pipeline
  72662. */
  72663. SSAOBlurHRenderEffect: string;
  72664. /**
  72665. * @ignore
  72666. * The vertical blur PostProcess id in the pipeline
  72667. */
  72668. SSAOBlurVRenderEffect: string;
  72669. /**
  72670. * @ignore
  72671. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  72672. */
  72673. SSAOCombineRenderEffect: string;
  72674. /**
  72675. * The output strength of the SSAO post-process. Default value is 1.0.
  72676. */
  72677. totalStrength: number;
  72678. /**
  72679. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  72680. */
  72681. maxZ: number;
  72682. /**
  72683. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  72684. */
  72685. minZAspect: number;
  72686. private _samples;
  72687. /**
  72688. * Number of samples used for the SSAO calculations. Default value is 8
  72689. */
  72690. set samples(n: number);
  72691. get samples(): number;
  72692. private _textureSamples;
  72693. /**
  72694. * Number of samples to use for antialiasing
  72695. */
  72696. set textureSamples(n: number);
  72697. get textureSamples(): number;
  72698. /**
  72699. * Ratio object used for SSAO ratio and blur ratio
  72700. */
  72701. private _ratio;
  72702. /**
  72703. * Dynamically generated sphere sampler.
  72704. */
  72705. private _sampleSphere;
  72706. /**
  72707. * Blur filter offsets
  72708. */
  72709. private _samplerOffsets;
  72710. private _expensiveBlur;
  72711. /**
  72712. * If bilateral blur should be used
  72713. */
  72714. set expensiveBlur(b: boolean);
  72715. get expensiveBlur(): boolean;
  72716. /**
  72717. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  72718. */
  72719. radius: number;
  72720. /**
  72721. * The base color of the SSAO post-process
  72722. * The final result is "base + ssao" between [0, 1]
  72723. */
  72724. base: number;
  72725. /**
  72726. * Support test.
  72727. */
  72728. static get IsSupported(): boolean;
  72729. private _scene;
  72730. private _depthTexture;
  72731. private _normalTexture;
  72732. private _randomTexture;
  72733. private _originalColorPostProcess;
  72734. private _ssaoPostProcess;
  72735. private _blurHPostProcess;
  72736. private _blurVPostProcess;
  72737. private _ssaoCombinePostProcess;
  72738. /**
  72739. * Gets active scene
  72740. */
  72741. get scene(): Scene;
  72742. /**
  72743. * @constructor
  72744. * @param name The rendering pipeline name
  72745. * @param scene The scene linked to this pipeline
  72746. * @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 }
  72747. * @param cameras The array of cameras that the rendering pipeline will be attached to
  72748. */
  72749. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  72750. /**
  72751. * Get the class name
  72752. * @returns "SSAO2RenderingPipeline"
  72753. */
  72754. getClassName(): string;
  72755. /**
  72756. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  72757. */
  72758. dispose(disableGeometryBufferRenderer?: boolean): void;
  72759. private _createBlurPostProcess;
  72760. /** @hidden */
  72761. _rebuild(): void;
  72762. private _bits;
  72763. private _radicalInverse_VdC;
  72764. private _hammersley;
  72765. private _hemisphereSample_uniform;
  72766. private _generateHemisphere;
  72767. private _createSSAOPostProcess;
  72768. private _createSSAOCombinePostProcess;
  72769. private _createRandomTexture;
  72770. /**
  72771. * Serialize the rendering pipeline (Used when exporting)
  72772. * @returns the serialized object
  72773. */
  72774. serialize(): any;
  72775. /**
  72776. * Parse the serialized pipeline
  72777. * @param source Source pipeline.
  72778. * @param scene The scene to load the pipeline to.
  72779. * @param rootUrl The URL of the serialized pipeline.
  72780. * @returns An instantiated pipeline from the serialized object.
  72781. */
  72782. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  72783. }
  72784. }
  72785. declare module "babylonjs/Shaders/ssao.fragment" {
  72786. /** @hidden */
  72787. export var ssaoPixelShader: {
  72788. name: string;
  72789. shader: string;
  72790. };
  72791. }
  72792. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  72793. import { Camera } from "babylonjs/Cameras/camera";
  72794. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  72795. import { Scene } from "babylonjs/scene";
  72796. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  72797. import "babylonjs/Shaders/ssao.fragment";
  72798. import "babylonjs/Shaders/ssaoCombine.fragment";
  72799. /**
  72800. * Render pipeline to produce ssao effect
  72801. */
  72802. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  72803. /**
  72804. * @ignore
  72805. * The PassPostProcess id in the pipeline that contains the original scene color
  72806. */
  72807. SSAOOriginalSceneColorEffect: string;
  72808. /**
  72809. * @ignore
  72810. * The SSAO PostProcess id in the pipeline
  72811. */
  72812. SSAORenderEffect: string;
  72813. /**
  72814. * @ignore
  72815. * The horizontal blur PostProcess id in the pipeline
  72816. */
  72817. SSAOBlurHRenderEffect: string;
  72818. /**
  72819. * @ignore
  72820. * The vertical blur PostProcess id in the pipeline
  72821. */
  72822. SSAOBlurVRenderEffect: string;
  72823. /**
  72824. * @ignore
  72825. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  72826. */
  72827. SSAOCombineRenderEffect: string;
  72828. /**
  72829. * The output strength of the SSAO post-process. Default value is 1.0.
  72830. */
  72831. totalStrength: number;
  72832. /**
  72833. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  72834. */
  72835. radius: number;
  72836. /**
  72837. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  72838. * Must not be equal to fallOff and superior to fallOff.
  72839. * Default value is 0.0075
  72840. */
  72841. area: number;
  72842. /**
  72843. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  72844. * Must not be equal to area and inferior to area.
  72845. * Default value is 0.000001
  72846. */
  72847. fallOff: number;
  72848. /**
  72849. * The base color of the SSAO post-process
  72850. * The final result is "base + ssao" between [0, 1]
  72851. */
  72852. base: number;
  72853. private _scene;
  72854. private _depthTexture;
  72855. private _randomTexture;
  72856. private _originalColorPostProcess;
  72857. private _ssaoPostProcess;
  72858. private _blurHPostProcess;
  72859. private _blurVPostProcess;
  72860. private _ssaoCombinePostProcess;
  72861. private _firstUpdate;
  72862. /**
  72863. * Gets active scene
  72864. */
  72865. get scene(): Scene;
  72866. /**
  72867. * @constructor
  72868. * @param name - The rendering pipeline name
  72869. * @param scene - The scene linked to this pipeline
  72870. * @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 }
  72871. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  72872. */
  72873. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  72874. /**
  72875. * Get the class name
  72876. * @returns "SSAORenderingPipeline"
  72877. */
  72878. getClassName(): string;
  72879. /**
  72880. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  72881. */
  72882. dispose(disableDepthRender?: boolean): void;
  72883. private _createBlurPostProcess;
  72884. /** @hidden */
  72885. _rebuild(): void;
  72886. private _createSSAOPostProcess;
  72887. private _createSSAOCombinePostProcess;
  72888. private _createRandomTexture;
  72889. }
  72890. }
  72891. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  72892. /** @hidden */
  72893. export var screenSpaceReflectionPixelShader: {
  72894. name: string;
  72895. shader: string;
  72896. };
  72897. }
  72898. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  72899. import { Nullable } from "babylonjs/types";
  72900. import { Camera } from "babylonjs/Cameras/camera";
  72901. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72902. import { Scene } from "babylonjs/scene";
  72903. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  72904. import { Engine } from "babylonjs/Engines/engine";
  72905. /**
  72906. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  72907. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  72908. */
  72909. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  72910. /**
  72911. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  72912. */
  72913. threshold: number;
  72914. /**
  72915. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  72916. */
  72917. strength: number;
  72918. /**
  72919. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  72920. */
  72921. reflectionSpecularFalloffExponent: number;
  72922. /**
  72923. * 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]
  72924. */
  72925. step: number;
  72926. /**
  72927. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  72928. */
  72929. roughnessFactor: number;
  72930. private _geometryBufferRenderer;
  72931. private _enableSmoothReflections;
  72932. private _reflectionSamples;
  72933. private _smoothSteps;
  72934. /**
  72935. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  72936. * @param name The name of the effect.
  72937. * @param scene The scene containing the objects to calculate reflections.
  72938. * @param options The required width/height ratio to downsize to before computing the render pass.
  72939. * @param camera The camera to apply the render pass to.
  72940. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72941. * @param engine The engine which the post process will be applied. (default: current engine)
  72942. * @param reusable If the post process can be reused on the same frame. (default: false)
  72943. * @param textureType Type of textures used when performing the post process. (default: 0)
  72944. * @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)
  72945. */
  72946. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72947. /**
  72948. * Gets wether or not smoothing reflections is enabled.
  72949. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  72950. */
  72951. get enableSmoothReflections(): boolean;
  72952. /**
  72953. * Sets wether or not smoothing reflections is enabled.
  72954. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  72955. */
  72956. set enableSmoothReflections(enabled: boolean);
  72957. /**
  72958. * Gets the number of samples taken while computing reflections. More samples count is high,
  72959. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  72960. */
  72961. get reflectionSamples(): number;
  72962. /**
  72963. * Sets the number of samples taken while computing reflections. More samples count is high,
  72964. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  72965. */
  72966. set reflectionSamples(samples: number);
  72967. /**
  72968. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  72969. * more the post-process will require GPU power and can generate a drop in FPS.
  72970. * Default value (5.0) work pretty well in all cases but can be adjusted.
  72971. */
  72972. get smoothSteps(): number;
  72973. set smoothSteps(steps: number);
  72974. private _updateEffectDefines;
  72975. }
  72976. }
  72977. declare module "babylonjs/Shaders/standard.fragment" {
  72978. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  72979. /** @hidden */
  72980. export var standardPixelShader: {
  72981. name: string;
  72982. shader: string;
  72983. };
  72984. }
  72985. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  72986. import { Nullable } from "babylonjs/types";
  72987. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  72988. import { Camera } from "babylonjs/Cameras/camera";
  72989. import { Texture } from "babylonjs/Materials/Textures/texture";
  72990. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  72991. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  72992. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  72993. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  72994. import { IDisposable } from "babylonjs/scene";
  72995. import { SpotLight } from "babylonjs/Lights/spotLight";
  72996. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  72997. import { Scene } from "babylonjs/scene";
  72998. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  72999. import { Animation } from "babylonjs/Animations/animation";
  73000. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  73001. import "babylonjs/Shaders/standard.fragment";
  73002. /**
  73003. * Standard rendering pipeline
  73004. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  73005. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  73006. */
  73007. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  73008. /**
  73009. * Public members
  73010. */
  73011. /**
  73012. * Post-process which contains the original scene color before the pipeline applies all the effects
  73013. */
  73014. originalPostProcess: Nullable<PostProcess>;
  73015. /**
  73016. * Post-process used to down scale an image x4
  73017. */
  73018. downSampleX4PostProcess: Nullable<PostProcess>;
  73019. /**
  73020. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  73021. */
  73022. brightPassPostProcess: Nullable<PostProcess>;
  73023. /**
  73024. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  73025. */
  73026. blurHPostProcesses: PostProcess[];
  73027. /**
  73028. * Post-process array storing all the vertical blur post-processes used by the pipeline
  73029. */
  73030. blurVPostProcesses: PostProcess[];
  73031. /**
  73032. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  73033. */
  73034. textureAdderPostProcess: Nullable<PostProcess>;
  73035. /**
  73036. * Post-process used to create volumetric lighting effect
  73037. */
  73038. volumetricLightPostProcess: Nullable<PostProcess>;
  73039. /**
  73040. * Post-process used to smooth the previous volumetric light post-process on the X axis
  73041. */
  73042. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  73043. /**
  73044. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  73045. */
  73046. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  73047. /**
  73048. * Post-process used to merge the volumetric light effect and the real scene color
  73049. */
  73050. volumetricLightMergePostProces: Nullable<PostProcess>;
  73051. /**
  73052. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  73053. */
  73054. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  73055. /**
  73056. * Base post-process used to calculate the average luminance of the final image for HDR
  73057. */
  73058. luminancePostProcess: Nullable<PostProcess>;
  73059. /**
  73060. * Post-processes used to create down sample post-processes in order to get
  73061. * the average luminance of the final image for HDR
  73062. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  73063. */
  73064. luminanceDownSamplePostProcesses: PostProcess[];
  73065. /**
  73066. * Post-process used to create a HDR effect (light adaptation)
  73067. */
  73068. hdrPostProcess: Nullable<PostProcess>;
  73069. /**
  73070. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  73071. */
  73072. textureAdderFinalPostProcess: Nullable<PostProcess>;
  73073. /**
  73074. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  73075. */
  73076. lensFlareFinalPostProcess: Nullable<PostProcess>;
  73077. /**
  73078. * Post-process used to merge the final HDR post-process and the real scene color
  73079. */
  73080. hdrFinalPostProcess: Nullable<PostProcess>;
  73081. /**
  73082. * Post-process used to create a lens flare effect
  73083. */
  73084. lensFlarePostProcess: Nullable<PostProcess>;
  73085. /**
  73086. * Post-process that merges the result of the lens flare post-process and the real scene color
  73087. */
  73088. lensFlareComposePostProcess: Nullable<PostProcess>;
  73089. /**
  73090. * Post-process used to create a motion blur effect
  73091. */
  73092. motionBlurPostProcess: Nullable<PostProcess>;
  73093. /**
  73094. * Post-process used to create a depth of field effect
  73095. */
  73096. depthOfFieldPostProcess: Nullable<PostProcess>;
  73097. /**
  73098. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  73099. */
  73100. fxaaPostProcess: Nullable<FxaaPostProcess>;
  73101. /**
  73102. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  73103. */
  73104. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  73105. /**
  73106. * Represents the brightness threshold in order to configure the illuminated surfaces
  73107. */
  73108. brightThreshold: number;
  73109. /**
  73110. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  73111. */
  73112. blurWidth: number;
  73113. /**
  73114. * Sets if the blur for highlighted surfaces must be only horizontal
  73115. */
  73116. horizontalBlur: boolean;
  73117. /**
  73118. * Gets the overall exposure used by the pipeline
  73119. */
  73120. get exposure(): number;
  73121. /**
  73122. * Sets the overall exposure used by the pipeline
  73123. */
  73124. set exposure(value: number);
  73125. /**
  73126. * Texture used typically to simulate "dirty" on camera lens
  73127. */
  73128. lensTexture: Nullable<Texture>;
  73129. /**
  73130. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  73131. */
  73132. volumetricLightCoefficient: number;
  73133. /**
  73134. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  73135. */
  73136. volumetricLightPower: number;
  73137. /**
  73138. * Used the set the blur intensity to smooth the volumetric lights
  73139. */
  73140. volumetricLightBlurScale: number;
  73141. /**
  73142. * Light (spot or directional) used to generate the volumetric lights rays
  73143. * The source light must have a shadow generate so the pipeline can get its
  73144. * depth map
  73145. */
  73146. sourceLight: Nullable<SpotLight | DirectionalLight>;
  73147. /**
  73148. * For eye adaptation, represents the minimum luminance the eye can see
  73149. */
  73150. hdrMinimumLuminance: number;
  73151. /**
  73152. * For eye adaptation, represents the decrease luminance speed
  73153. */
  73154. hdrDecreaseRate: number;
  73155. /**
  73156. * For eye adaptation, represents the increase luminance speed
  73157. */
  73158. hdrIncreaseRate: number;
  73159. /**
  73160. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  73161. */
  73162. get hdrAutoExposure(): boolean;
  73163. /**
  73164. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  73165. */
  73166. set hdrAutoExposure(value: boolean);
  73167. /**
  73168. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  73169. */
  73170. lensColorTexture: Nullable<Texture>;
  73171. /**
  73172. * The overall strengh for the lens flare effect
  73173. */
  73174. lensFlareStrength: number;
  73175. /**
  73176. * Dispersion coefficient for lens flare ghosts
  73177. */
  73178. lensFlareGhostDispersal: number;
  73179. /**
  73180. * Main lens flare halo width
  73181. */
  73182. lensFlareHaloWidth: number;
  73183. /**
  73184. * Based on the lens distortion effect, defines how much the lens flare result
  73185. * is distorted
  73186. */
  73187. lensFlareDistortionStrength: number;
  73188. /**
  73189. * Configures the blur intensity used for for lens flare (halo)
  73190. */
  73191. lensFlareBlurWidth: number;
  73192. /**
  73193. * Lens star texture must be used to simulate rays on the flares and is available
  73194. * in the documentation
  73195. */
  73196. lensStarTexture: Nullable<Texture>;
  73197. /**
  73198. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  73199. * flare effect by taking account of the dirt texture
  73200. */
  73201. lensFlareDirtTexture: Nullable<Texture>;
  73202. /**
  73203. * Represents the focal length for the depth of field effect
  73204. */
  73205. depthOfFieldDistance: number;
  73206. /**
  73207. * Represents the blur intensity for the blurred part of the depth of field effect
  73208. */
  73209. depthOfFieldBlurWidth: number;
  73210. /**
  73211. * Gets how much the image is blurred by the movement while using the motion blur post-process
  73212. */
  73213. get motionStrength(): number;
  73214. /**
  73215. * Sets how much the image is blurred by the movement while using the motion blur post-process
  73216. */
  73217. set motionStrength(strength: number);
  73218. /**
  73219. * Gets wether or not the motion blur post-process is object based or screen based.
  73220. */
  73221. get objectBasedMotionBlur(): boolean;
  73222. /**
  73223. * Sets wether or not the motion blur post-process should be object based or screen based
  73224. */
  73225. set objectBasedMotionBlur(value: boolean);
  73226. /**
  73227. * List of animations for the pipeline (IAnimatable implementation)
  73228. */
  73229. animations: Animation[];
  73230. /**
  73231. * Private members
  73232. */
  73233. private _scene;
  73234. private _currentDepthOfFieldSource;
  73235. private _basePostProcess;
  73236. private _fixedExposure;
  73237. private _currentExposure;
  73238. private _hdrAutoExposure;
  73239. private _hdrCurrentLuminance;
  73240. private _motionStrength;
  73241. private _isObjectBasedMotionBlur;
  73242. private _floatTextureType;
  73243. private _camerasToBeAttached;
  73244. private _ratio;
  73245. private _bloomEnabled;
  73246. private _depthOfFieldEnabled;
  73247. private _vlsEnabled;
  73248. private _lensFlareEnabled;
  73249. private _hdrEnabled;
  73250. private _motionBlurEnabled;
  73251. private _fxaaEnabled;
  73252. private _screenSpaceReflectionsEnabled;
  73253. private _motionBlurSamples;
  73254. private _volumetricLightStepsCount;
  73255. private _samples;
  73256. /**
  73257. * @ignore
  73258. * Specifies if the bloom pipeline is enabled
  73259. */
  73260. get BloomEnabled(): boolean;
  73261. set BloomEnabled(enabled: boolean);
  73262. /**
  73263. * @ignore
  73264. * Specifies if the depth of field pipeline is enabed
  73265. */
  73266. get DepthOfFieldEnabled(): boolean;
  73267. set DepthOfFieldEnabled(enabled: boolean);
  73268. /**
  73269. * @ignore
  73270. * Specifies if the lens flare pipeline is enabed
  73271. */
  73272. get LensFlareEnabled(): boolean;
  73273. set LensFlareEnabled(enabled: boolean);
  73274. /**
  73275. * @ignore
  73276. * Specifies if the HDR pipeline is enabled
  73277. */
  73278. get HDREnabled(): boolean;
  73279. set HDREnabled(enabled: boolean);
  73280. /**
  73281. * @ignore
  73282. * Specifies if the volumetric lights scattering effect is enabled
  73283. */
  73284. get VLSEnabled(): boolean;
  73285. set VLSEnabled(enabled: boolean);
  73286. /**
  73287. * @ignore
  73288. * Specifies if the motion blur effect is enabled
  73289. */
  73290. get MotionBlurEnabled(): boolean;
  73291. set MotionBlurEnabled(enabled: boolean);
  73292. /**
  73293. * Specifies if anti-aliasing is enabled
  73294. */
  73295. get fxaaEnabled(): boolean;
  73296. set fxaaEnabled(enabled: boolean);
  73297. /**
  73298. * Specifies if screen space reflections are enabled.
  73299. */
  73300. get screenSpaceReflectionsEnabled(): boolean;
  73301. set screenSpaceReflectionsEnabled(enabled: boolean);
  73302. /**
  73303. * Specifies the number of steps used to calculate the volumetric lights
  73304. * Typically in interval [50, 200]
  73305. */
  73306. get volumetricLightStepsCount(): number;
  73307. set volumetricLightStepsCount(count: number);
  73308. /**
  73309. * Specifies the number of samples used for the motion blur effect
  73310. * Typically in interval [16, 64]
  73311. */
  73312. get motionBlurSamples(): number;
  73313. set motionBlurSamples(samples: number);
  73314. /**
  73315. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  73316. */
  73317. get samples(): number;
  73318. set samples(sampleCount: number);
  73319. /**
  73320. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  73321. * @constructor
  73322. * @param name The rendering pipeline name
  73323. * @param scene The scene linked to this pipeline
  73324. * @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)
  73325. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  73326. * @param cameras The array of cameras that the rendering pipeline will be attached to
  73327. */
  73328. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  73329. private _buildPipeline;
  73330. private _createDownSampleX4PostProcess;
  73331. private _createBrightPassPostProcess;
  73332. private _createBlurPostProcesses;
  73333. private _createTextureAdderPostProcess;
  73334. private _createVolumetricLightPostProcess;
  73335. private _createLuminancePostProcesses;
  73336. private _createHdrPostProcess;
  73337. private _createLensFlarePostProcess;
  73338. private _createDepthOfFieldPostProcess;
  73339. private _createMotionBlurPostProcess;
  73340. private _getDepthTexture;
  73341. private _disposePostProcesses;
  73342. /**
  73343. * Dispose of the pipeline and stop all post processes
  73344. */
  73345. dispose(): void;
  73346. /**
  73347. * Serialize the rendering pipeline (Used when exporting)
  73348. * @returns the serialized object
  73349. */
  73350. serialize(): any;
  73351. /**
  73352. * Parse the serialized pipeline
  73353. * @param source Source pipeline.
  73354. * @param scene The scene to load the pipeline to.
  73355. * @param rootUrl The URL of the serialized pipeline.
  73356. * @returns An instantiated pipeline from the serialized object.
  73357. */
  73358. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  73359. /**
  73360. * Luminance steps
  73361. */
  73362. static LuminanceSteps: number;
  73363. }
  73364. }
  73365. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  73366. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  73367. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  73368. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  73369. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  73370. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  73371. }
  73372. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  73373. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  73374. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  73375. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  73376. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  73377. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  73378. }
  73379. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  73380. /** @hidden */
  73381. export var stereoscopicInterlacePixelShader: {
  73382. name: string;
  73383. shader: string;
  73384. };
  73385. }
  73386. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  73387. import { Camera } from "babylonjs/Cameras/camera";
  73388. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73389. import { Engine } from "babylonjs/Engines/engine";
  73390. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  73391. /**
  73392. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  73393. */
  73394. export class StereoscopicInterlacePostProcessI extends PostProcess {
  73395. private _stepSize;
  73396. private _passedProcess;
  73397. /**
  73398. * Initializes a StereoscopicInterlacePostProcessI
  73399. * @param name The name of the effect.
  73400. * @param rigCameras The rig cameras to be appled to the post process
  73401. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  73402. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  73403. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73404. * @param engine The engine which the post process will be applied. (default: current engine)
  73405. * @param reusable If the post process can be reused on the same frame. (default: false)
  73406. */
  73407. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73408. }
  73409. /**
  73410. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  73411. */
  73412. export class StereoscopicInterlacePostProcess extends PostProcess {
  73413. private _stepSize;
  73414. private _passedProcess;
  73415. /**
  73416. * Initializes a StereoscopicInterlacePostProcess
  73417. * @param name The name of the effect.
  73418. * @param rigCameras The rig cameras to be appled to the post process
  73419. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  73420. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73421. * @param engine The engine which the post process will be applied. (default: current engine)
  73422. * @param reusable If the post process can be reused on the same frame. (default: false)
  73423. */
  73424. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73425. }
  73426. }
  73427. declare module "babylonjs/Shaders/tonemap.fragment" {
  73428. /** @hidden */
  73429. export var tonemapPixelShader: {
  73430. name: string;
  73431. shader: string;
  73432. };
  73433. }
  73434. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  73435. import { Camera } from "babylonjs/Cameras/camera";
  73436. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73437. import "babylonjs/Shaders/tonemap.fragment";
  73438. import { Engine } from "babylonjs/Engines/engine";
  73439. /** Defines operator used for tonemapping */
  73440. export enum TonemappingOperator {
  73441. /** Hable */
  73442. Hable = 0,
  73443. /** Reinhard */
  73444. Reinhard = 1,
  73445. /** HejiDawson */
  73446. HejiDawson = 2,
  73447. /** Photographic */
  73448. Photographic = 3
  73449. }
  73450. /**
  73451. * Defines a post process to apply tone mapping
  73452. */
  73453. export class TonemapPostProcess extends PostProcess {
  73454. private _operator;
  73455. /** Defines the required exposure adjustement */
  73456. exposureAdjustment: number;
  73457. /**
  73458. * Creates a new TonemapPostProcess
  73459. * @param name defines the name of the postprocess
  73460. * @param _operator defines the operator to use
  73461. * @param exposureAdjustment defines the required exposure adjustement
  73462. * @param camera defines the camera to use (can be null)
  73463. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  73464. * @param engine defines the hosting engine (can be ignore if camera is set)
  73465. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  73466. */
  73467. constructor(name: string, _operator: TonemappingOperator,
  73468. /** Defines the required exposure adjustement */
  73469. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  73470. }
  73471. }
  73472. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  73473. /** @hidden */
  73474. export var volumetricLightScatteringPixelShader: {
  73475. name: string;
  73476. shader: string;
  73477. };
  73478. }
  73479. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  73480. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  73481. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  73482. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  73483. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  73484. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  73485. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  73486. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  73487. /** @hidden */
  73488. export var volumetricLightScatteringPassVertexShader: {
  73489. name: string;
  73490. shader: string;
  73491. };
  73492. }
  73493. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  73494. /** @hidden */
  73495. export var volumetricLightScatteringPassPixelShader: {
  73496. name: string;
  73497. shader: string;
  73498. };
  73499. }
  73500. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  73501. import { Vector3 } from "babylonjs/Maths/math.vector";
  73502. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73503. import { Mesh } from "babylonjs/Meshes/mesh";
  73504. import { Camera } from "babylonjs/Cameras/camera";
  73505. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  73506. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73507. import { Scene } from "babylonjs/scene";
  73508. import "babylonjs/Meshes/Builders/planeBuilder";
  73509. import "babylonjs/Shaders/depth.vertex";
  73510. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  73511. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  73512. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  73513. import { Engine } from "babylonjs/Engines/engine";
  73514. /**
  73515. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  73516. */
  73517. export class VolumetricLightScatteringPostProcess extends PostProcess {
  73518. private _volumetricLightScatteringPass;
  73519. private _volumetricLightScatteringRTT;
  73520. private _viewPort;
  73521. private _screenCoordinates;
  73522. private _cachedDefines;
  73523. /**
  73524. * If not undefined, the mesh position is computed from the attached node position
  73525. */
  73526. attachedNode: {
  73527. position: Vector3;
  73528. };
  73529. /**
  73530. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  73531. */
  73532. customMeshPosition: Vector3;
  73533. /**
  73534. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  73535. */
  73536. useCustomMeshPosition: boolean;
  73537. /**
  73538. * If the post-process should inverse the light scattering direction
  73539. */
  73540. invert: boolean;
  73541. /**
  73542. * The internal mesh used by the post-process
  73543. */
  73544. mesh: Mesh;
  73545. /**
  73546. * @hidden
  73547. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  73548. */
  73549. get useDiffuseColor(): boolean;
  73550. set useDiffuseColor(useDiffuseColor: boolean);
  73551. /**
  73552. * Array containing the excluded meshes not rendered in the internal pass
  73553. */
  73554. excludedMeshes: AbstractMesh[];
  73555. /**
  73556. * Controls the overall intensity of the post-process
  73557. */
  73558. exposure: number;
  73559. /**
  73560. * Dissipates each sample's contribution in range [0, 1]
  73561. */
  73562. decay: number;
  73563. /**
  73564. * Controls the overall intensity of each sample
  73565. */
  73566. weight: number;
  73567. /**
  73568. * Controls the density of each sample
  73569. */
  73570. density: number;
  73571. /**
  73572. * @constructor
  73573. * @param name The post-process name
  73574. * @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)
  73575. * @param camera The camera that the post-process will be attached to
  73576. * @param mesh The mesh used to create the light scattering
  73577. * @param samples The post-process quality, default 100
  73578. * @param samplingModeThe post-process filtering mode
  73579. * @param engine The babylon engine
  73580. * @param reusable If the post-process is reusable
  73581. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  73582. */
  73583. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  73584. /**
  73585. * Returns the string "VolumetricLightScatteringPostProcess"
  73586. * @returns "VolumetricLightScatteringPostProcess"
  73587. */
  73588. getClassName(): string;
  73589. private _isReady;
  73590. /**
  73591. * Sets the new light position for light scattering effect
  73592. * @param position The new custom light position
  73593. */
  73594. setCustomMeshPosition(position: Vector3): void;
  73595. /**
  73596. * Returns the light position for light scattering effect
  73597. * @return Vector3 The custom light position
  73598. */
  73599. getCustomMeshPosition(): Vector3;
  73600. /**
  73601. * Disposes the internal assets and detaches the post-process from the camera
  73602. */
  73603. dispose(camera: Camera): void;
  73604. /**
  73605. * Returns the render target texture used by the post-process
  73606. * @return the render target texture used by the post-process
  73607. */
  73608. getPass(): RenderTargetTexture;
  73609. private _meshExcluded;
  73610. private _createPass;
  73611. private _updateMeshScreenCoordinates;
  73612. /**
  73613. * Creates a default mesh for the Volumeric Light Scattering post-process
  73614. * @param name The mesh name
  73615. * @param scene The scene where to create the mesh
  73616. * @return the default mesh
  73617. */
  73618. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  73619. }
  73620. }
  73621. declare module "babylonjs/PostProcesses/index" {
  73622. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  73623. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  73624. export * from "babylonjs/PostProcesses/bloomEffect";
  73625. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  73626. export * from "babylonjs/PostProcesses/blurPostProcess";
  73627. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  73628. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  73629. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  73630. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  73631. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  73632. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  73633. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  73634. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  73635. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  73636. export * from "babylonjs/PostProcesses/filterPostProcess";
  73637. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  73638. export * from "babylonjs/PostProcesses/grainPostProcess";
  73639. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  73640. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  73641. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  73642. export * from "babylonjs/PostProcesses/passPostProcess";
  73643. export * from "babylonjs/PostProcesses/postProcess";
  73644. export * from "babylonjs/PostProcesses/postProcessManager";
  73645. export * from "babylonjs/PostProcesses/refractionPostProcess";
  73646. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  73647. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  73648. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  73649. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  73650. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  73651. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  73652. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  73653. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  73654. }
  73655. declare module "babylonjs/Probes/index" {
  73656. export * from "babylonjs/Probes/reflectionProbe";
  73657. }
  73658. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  73659. import { Scene } from "babylonjs/scene";
  73660. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73661. import { SmartArray } from "babylonjs/Misc/smartArray";
  73662. import { ISceneComponent } from "babylonjs/sceneComponent";
  73663. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  73664. import "babylonjs/Meshes/Builders/boxBuilder";
  73665. import "babylonjs/Shaders/color.fragment";
  73666. import "babylonjs/Shaders/color.vertex";
  73667. import { Color3 } from "babylonjs/Maths/math.color";
  73668. import { Observable } from "babylonjs/Misc/observable";
  73669. module "babylonjs/scene" {
  73670. interface Scene {
  73671. /** @hidden (Backing field) */
  73672. _boundingBoxRenderer: BoundingBoxRenderer;
  73673. /** @hidden (Backing field) */
  73674. _forceShowBoundingBoxes: boolean;
  73675. /**
  73676. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  73677. */
  73678. forceShowBoundingBoxes: boolean;
  73679. /**
  73680. * Gets the bounding box renderer associated with the scene
  73681. * @returns a BoundingBoxRenderer
  73682. */
  73683. getBoundingBoxRenderer(): BoundingBoxRenderer;
  73684. }
  73685. }
  73686. module "babylonjs/Meshes/abstractMesh" {
  73687. interface AbstractMesh {
  73688. /** @hidden (Backing field) */
  73689. _showBoundingBox: boolean;
  73690. /**
  73691. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  73692. */
  73693. showBoundingBox: boolean;
  73694. }
  73695. }
  73696. /**
  73697. * Component responsible of rendering the bounding box of the meshes in a scene.
  73698. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  73699. */
  73700. export class BoundingBoxRenderer implements ISceneComponent {
  73701. /**
  73702. * The component name helpfull to identify the component in the list of scene components.
  73703. */
  73704. readonly name: string;
  73705. /**
  73706. * The scene the component belongs to.
  73707. */
  73708. scene: Scene;
  73709. /**
  73710. * Color of the bounding box lines placed in front of an object
  73711. */
  73712. frontColor: Color3;
  73713. /**
  73714. * Color of the bounding box lines placed behind an object
  73715. */
  73716. backColor: Color3;
  73717. /**
  73718. * Defines if the renderer should show the back lines or not
  73719. */
  73720. showBackLines: boolean;
  73721. /**
  73722. * Observable raised before rendering a bounding box
  73723. */
  73724. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  73725. /**
  73726. * Observable raised after rendering a bounding box
  73727. */
  73728. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  73729. /**
  73730. * @hidden
  73731. */
  73732. renderList: SmartArray<BoundingBox>;
  73733. private _colorShader;
  73734. private _vertexBuffers;
  73735. private _indexBuffer;
  73736. private _fillIndexBuffer;
  73737. private _fillIndexData;
  73738. /**
  73739. * Instantiates a new bounding box renderer in a scene.
  73740. * @param scene the scene the renderer renders in
  73741. */
  73742. constructor(scene: Scene);
  73743. /**
  73744. * Registers the component in a given scene
  73745. */
  73746. register(): void;
  73747. private _evaluateSubMesh;
  73748. private _activeMesh;
  73749. private _prepareRessources;
  73750. private _createIndexBuffer;
  73751. /**
  73752. * Rebuilds the elements related to this component in case of
  73753. * context lost for instance.
  73754. */
  73755. rebuild(): void;
  73756. /**
  73757. * @hidden
  73758. */
  73759. reset(): void;
  73760. /**
  73761. * Render the bounding boxes of a specific rendering group
  73762. * @param renderingGroupId defines the rendering group to render
  73763. */
  73764. render(renderingGroupId: number): void;
  73765. /**
  73766. * In case of occlusion queries, we can render the occlusion bounding box through this method
  73767. * @param mesh Define the mesh to render the occlusion bounding box for
  73768. */
  73769. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  73770. /**
  73771. * Dispose and release the resources attached to this renderer.
  73772. */
  73773. dispose(): void;
  73774. }
  73775. }
  73776. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  73777. import { Nullable } from "babylonjs/types";
  73778. import { Scene } from "babylonjs/scene";
  73779. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  73780. import { Camera } from "babylonjs/Cameras/camera";
  73781. import { ISceneComponent } from "babylonjs/sceneComponent";
  73782. module "babylonjs/scene" {
  73783. interface Scene {
  73784. /** @hidden (Backing field) */
  73785. _depthRenderer: {
  73786. [id: string]: DepthRenderer;
  73787. };
  73788. /**
  73789. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  73790. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  73791. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  73792. * @returns the created depth renderer
  73793. */
  73794. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  73795. /**
  73796. * Disables a depth renderer for a given camera
  73797. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  73798. */
  73799. disableDepthRenderer(camera?: Nullable<Camera>): void;
  73800. }
  73801. }
  73802. /**
  73803. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  73804. * in several rendering techniques.
  73805. */
  73806. export class DepthRendererSceneComponent implements ISceneComponent {
  73807. /**
  73808. * The component name helpfull to identify the component in the list of scene components.
  73809. */
  73810. readonly name: string;
  73811. /**
  73812. * The scene the component belongs to.
  73813. */
  73814. scene: Scene;
  73815. /**
  73816. * Creates a new instance of the component for the given scene
  73817. * @param scene Defines the scene to register the component in
  73818. */
  73819. constructor(scene: Scene);
  73820. /**
  73821. * Registers the component in a given scene
  73822. */
  73823. register(): void;
  73824. /**
  73825. * Rebuilds the elements related to this component in case of
  73826. * context lost for instance.
  73827. */
  73828. rebuild(): void;
  73829. /**
  73830. * Disposes the component and the associated ressources
  73831. */
  73832. dispose(): void;
  73833. private _gatherRenderTargets;
  73834. private _gatherActiveCameraRenderTargets;
  73835. }
  73836. }
  73837. declare module "babylonjs/Shaders/outline.fragment" {
  73838. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  73839. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  73840. /** @hidden */
  73841. export var outlinePixelShader: {
  73842. name: string;
  73843. shader: string;
  73844. };
  73845. }
  73846. declare module "babylonjs/Shaders/outline.vertex" {
  73847. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  73848. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  73849. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  73850. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  73851. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  73852. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  73853. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  73854. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  73855. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  73856. /** @hidden */
  73857. export var outlineVertexShader: {
  73858. name: string;
  73859. shader: string;
  73860. };
  73861. }
  73862. declare module "babylonjs/Rendering/outlineRenderer" {
  73863. import { SubMesh } from "babylonjs/Meshes/subMesh";
  73864. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  73865. import { Scene } from "babylonjs/scene";
  73866. import { ISceneComponent } from "babylonjs/sceneComponent";
  73867. import "babylonjs/Shaders/outline.fragment";
  73868. import "babylonjs/Shaders/outline.vertex";
  73869. module "babylonjs/scene" {
  73870. interface Scene {
  73871. /** @hidden */
  73872. _outlineRenderer: OutlineRenderer;
  73873. /**
  73874. * Gets the outline renderer associated with the scene
  73875. * @returns a OutlineRenderer
  73876. */
  73877. getOutlineRenderer(): OutlineRenderer;
  73878. }
  73879. }
  73880. module "babylonjs/Meshes/abstractMesh" {
  73881. interface AbstractMesh {
  73882. /** @hidden (Backing field) */
  73883. _renderOutline: boolean;
  73884. /**
  73885. * Gets or sets a boolean indicating if the outline must be rendered as well
  73886. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  73887. */
  73888. renderOutline: boolean;
  73889. /** @hidden (Backing field) */
  73890. _renderOverlay: boolean;
  73891. /**
  73892. * Gets or sets a boolean indicating if the overlay must be rendered as well
  73893. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  73894. */
  73895. renderOverlay: boolean;
  73896. }
  73897. }
  73898. /**
  73899. * This class is responsible to draw bothe outline/overlay of meshes.
  73900. * It should not be used directly but through the available method on mesh.
  73901. */
  73902. export class OutlineRenderer implements ISceneComponent {
  73903. /**
  73904. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  73905. */
  73906. private static _StencilReference;
  73907. /**
  73908. * The name of the component. Each component must have a unique name.
  73909. */
  73910. name: string;
  73911. /**
  73912. * The scene the component belongs to.
  73913. */
  73914. scene: Scene;
  73915. /**
  73916. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  73917. */
  73918. zOffset: number;
  73919. private _engine;
  73920. private _effect;
  73921. private _cachedDefines;
  73922. private _savedDepthWrite;
  73923. /**
  73924. * Instantiates a new outline renderer. (There could be only one per scene).
  73925. * @param scene Defines the scene it belongs to
  73926. */
  73927. constructor(scene: Scene);
  73928. /**
  73929. * Register the component to one instance of a scene.
  73930. */
  73931. register(): void;
  73932. /**
  73933. * Rebuilds the elements related to this component in case of
  73934. * context lost for instance.
  73935. */
  73936. rebuild(): void;
  73937. /**
  73938. * Disposes the component and the associated ressources.
  73939. */
  73940. dispose(): void;
  73941. /**
  73942. * Renders the outline in the canvas.
  73943. * @param subMesh Defines the sumesh to render
  73944. * @param batch Defines the batch of meshes in case of instances
  73945. * @param useOverlay Defines if the rendering is for the overlay or the outline
  73946. */
  73947. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  73948. /**
  73949. * Returns whether or not the outline renderer is ready for a given submesh.
  73950. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  73951. * @param subMesh Defines the submesh to check readyness for
  73952. * @param useInstances Defines wheter wee are trying to render instances or not
  73953. * @returns true if ready otherwise false
  73954. */
  73955. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  73956. private _beforeRenderingMesh;
  73957. private _afterRenderingMesh;
  73958. }
  73959. }
  73960. declare module "babylonjs/Rendering/index" {
  73961. export * from "babylonjs/Rendering/boundingBoxRenderer";
  73962. export * from "babylonjs/Rendering/depthRenderer";
  73963. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  73964. export * from "babylonjs/Rendering/edgesRenderer";
  73965. export * from "babylonjs/Rendering/geometryBufferRenderer";
  73966. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  73967. export * from "babylonjs/Rendering/outlineRenderer";
  73968. export * from "babylonjs/Rendering/renderingGroup";
  73969. export * from "babylonjs/Rendering/renderingManager";
  73970. export * from "babylonjs/Rendering/utilityLayerRenderer";
  73971. }
  73972. declare module "babylonjs/Sprites/ISprites" {
  73973. /**
  73974. * Defines the basic options interface of a Sprite Frame Source Size.
  73975. */
  73976. export interface ISpriteJSONSpriteSourceSize {
  73977. /**
  73978. * number of the original width of the Frame
  73979. */
  73980. w: number;
  73981. /**
  73982. * number of the original height of the Frame
  73983. */
  73984. h: number;
  73985. }
  73986. /**
  73987. * Defines the basic options interface of a Sprite Frame Data.
  73988. */
  73989. export interface ISpriteJSONSpriteFrameData {
  73990. /**
  73991. * number of the x offset of the Frame
  73992. */
  73993. x: number;
  73994. /**
  73995. * number of the y offset of the Frame
  73996. */
  73997. y: number;
  73998. /**
  73999. * number of the width of the Frame
  74000. */
  74001. w: number;
  74002. /**
  74003. * number of the height of the Frame
  74004. */
  74005. h: number;
  74006. }
  74007. /**
  74008. * Defines the basic options interface of a JSON Sprite.
  74009. */
  74010. export interface ISpriteJSONSprite {
  74011. /**
  74012. * string name of the Frame
  74013. */
  74014. filename: string;
  74015. /**
  74016. * ISpriteJSONSpriteFrame basic object of the frame data
  74017. */
  74018. frame: ISpriteJSONSpriteFrameData;
  74019. /**
  74020. * boolean to flag is the frame was rotated.
  74021. */
  74022. rotated: boolean;
  74023. /**
  74024. * boolean to flag is the frame was trimmed.
  74025. */
  74026. trimmed: boolean;
  74027. /**
  74028. * ISpriteJSONSpriteFrame basic object of the source data
  74029. */
  74030. spriteSourceSize: ISpriteJSONSpriteFrameData;
  74031. /**
  74032. * ISpriteJSONSpriteFrame basic object of the source data
  74033. */
  74034. sourceSize: ISpriteJSONSpriteSourceSize;
  74035. }
  74036. /**
  74037. * Defines the basic options interface of a JSON atlas.
  74038. */
  74039. export interface ISpriteJSONAtlas {
  74040. /**
  74041. * Array of objects that contain the frame data.
  74042. */
  74043. frames: Array<ISpriteJSONSprite>;
  74044. /**
  74045. * object basic object containing the sprite meta data.
  74046. */
  74047. meta?: object;
  74048. }
  74049. }
  74050. declare module "babylonjs/Shaders/spriteMap.fragment" {
  74051. /** @hidden */
  74052. export var spriteMapPixelShader: {
  74053. name: string;
  74054. shader: string;
  74055. };
  74056. }
  74057. declare module "babylonjs/Shaders/spriteMap.vertex" {
  74058. /** @hidden */
  74059. export var spriteMapVertexShader: {
  74060. name: string;
  74061. shader: string;
  74062. };
  74063. }
  74064. declare module "babylonjs/Sprites/spriteMap" {
  74065. import { IDisposable, Scene } from "babylonjs/scene";
  74066. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  74067. import { Texture } from "babylonjs/Materials/Textures/texture";
  74068. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  74069. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  74070. import "babylonjs/Meshes/Builders/planeBuilder";
  74071. import "babylonjs/Shaders/spriteMap.fragment";
  74072. import "babylonjs/Shaders/spriteMap.vertex";
  74073. /**
  74074. * Defines the basic options interface of a SpriteMap
  74075. */
  74076. export interface ISpriteMapOptions {
  74077. /**
  74078. * Vector2 of the number of cells in the grid.
  74079. */
  74080. stageSize?: Vector2;
  74081. /**
  74082. * Vector2 of the size of the output plane in World Units.
  74083. */
  74084. outputSize?: Vector2;
  74085. /**
  74086. * Vector3 of the position of the output plane in World Units.
  74087. */
  74088. outputPosition?: Vector3;
  74089. /**
  74090. * Vector3 of the rotation of the output plane.
  74091. */
  74092. outputRotation?: Vector3;
  74093. /**
  74094. * number of layers that the system will reserve in resources.
  74095. */
  74096. layerCount?: number;
  74097. /**
  74098. * number of max animation frames a single cell will reserve in resources.
  74099. */
  74100. maxAnimationFrames?: number;
  74101. /**
  74102. * number cell index of the base tile when the system compiles.
  74103. */
  74104. baseTile?: number;
  74105. /**
  74106. * boolean flip the sprite after its been repositioned by the framing data.
  74107. */
  74108. flipU?: boolean;
  74109. /**
  74110. * Vector3 scalar of the global RGB values of the SpriteMap.
  74111. */
  74112. colorMultiply?: Vector3;
  74113. }
  74114. /**
  74115. * Defines the IDisposable interface in order to be cleanable from resources.
  74116. */
  74117. export interface ISpriteMap extends IDisposable {
  74118. /**
  74119. * String name of the SpriteMap.
  74120. */
  74121. name: string;
  74122. /**
  74123. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  74124. */
  74125. atlasJSON: ISpriteJSONAtlas;
  74126. /**
  74127. * Texture of the SpriteMap.
  74128. */
  74129. spriteSheet: Texture;
  74130. /**
  74131. * The parameters to initialize the SpriteMap with.
  74132. */
  74133. options: ISpriteMapOptions;
  74134. }
  74135. /**
  74136. * Class used to manage a grid restricted sprite deployment on an Output plane.
  74137. */
  74138. export class SpriteMap implements ISpriteMap {
  74139. /** The Name of the spriteMap */
  74140. name: string;
  74141. /** The JSON file with the frame and meta data */
  74142. atlasJSON: ISpriteJSONAtlas;
  74143. /** The systems Sprite Sheet Texture */
  74144. spriteSheet: Texture;
  74145. /** Arguments passed with the Constructor */
  74146. options: ISpriteMapOptions;
  74147. /** Public Sprite Storage array, parsed from atlasJSON */
  74148. sprites: Array<ISpriteJSONSprite>;
  74149. /** Returns the Number of Sprites in the System */
  74150. get spriteCount(): number;
  74151. /** Returns the Position of Output Plane*/
  74152. get position(): Vector3;
  74153. /** Returns the Position of Output Plane*/
  74154. set position(v: Vector3);
  74155. /** Returns the Rotation of Output Plane*/
  74156. get rotation(): Vector3;
  74157. /** Returns the Rotation of Output Plane*/
  74158. set rotation(v: Vector3);
  74159. /** Sets the AnimationMap*/
  74160. get animationMap(): RawTexture;
  74161. /** Sets the AnimationMap*/
  74162. set animationMap(v: RawTexture);
  74163. /** Scene that the SpriteMap was created in */
  74164. private _scene;
  74165. /** Texture Buffer of Float32 that holds tile frame data*/
  74166. private _frameMap;
  74167. /** Texture Buffers of Float32 that holds tileMap data*/
  74168. private _tileMaps;
  74169. /** Texture Buffer of Float32 that holds Animation Data*/
  74170. private _animationMap;
  74171. /** Custom ShaderMaterial Central to the System*/
  74172. private _material;
  74173. /** Custom ShaderMaterial Central to the System*/
  74174. private _output;
  74175. /** Systems Time Ticker*/
  74176. private _time;
  74177. /**
  74178. * Creates a new SpriteMap
  74179. * @param name defines the SpriteMaps Name
  74180. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  74181. * @param spriteSheet is the Texture that the Sprites are on.
  74182. * @param options a basic deployment configuration
  74183. * @param scene The Scene that the map is deployed on
  74184. */
  74185. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  74186. /**
  74187. * Returns tileID location
  74188. * @returns Vector2 the cell position ID
  74189. */
  74190. getTileID(): Vector2;
  74191. /**
  74192. * Gets the UV location of the mouse over the SpriteMap.
  74193. * @returns Vector2 the UV position of the mouse interaction
  74194. */
  74195. getMousePosition(): Vector2;
  74196. /**
  74197. * Creates the "frame" texture Buffer
  74198. * -------------------------------------
  74199. * Structure of frames
  74200. * "filename": "Falling-Water-2.png",
  74201. * "frame": {"x":69,"y":103,"w":24,"h":32},
  74202. * "rotated": true,
  74203. * "trimmed": true,
  74204. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  74205. * "sourceSize": {"w":32,"h":32}
  74206. * @returns RawTexture of the frameMap
  74207. */
  74208. private _createFrameBuffer;
  74209. /**
  74210. * Creates the tileMap texture Buffer
  74211. * @param buffer normally and array of numbers, or a false to generate from scratch
  74212. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  74213. * @returns RawTexture of the tileMap
  74214. */
  74215. private _createTileBuffer;
  74216. /**
  74217. * Modifies the data of the tileMaps
  74218. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  74219. * @param pos is the iVector2 Coordinates of the Tile
  74220. * @param tile The SpriteIndex of the new Tile
  74221. */
  74222. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  74223. /**
  74224. * Creates the animationMap texture Buffer
  74225. * @param buffer normally and array of numbers, or a false to generate from scratch
  74226. * @returns RawTexture of the animationMap
  74227. */
  74228. private _createTileAnimationBuffer;
  74229. /**
  74230. * Modifies the data of the animationMap
  74231. * @param cellID is the Index of the Sprite
  74232. * @param _frame is the target Animation frame
  74233. * @param toCell is the Target Index of the next frame of the animation
  74234. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  74235. * @param speed is a global scalar of the time variable on the map.
  74236. */
  74237. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  74238. /**
  74239. * Exports the .tilemaps file
  74240. */
  74241. saveTileMaps(): void;
  74242. /**
  74243. * Imports the .tilemaps file
  74244. * @param url of the .tilemaps file
  74245. */
  74246. loadTileMaps(url: string): void;
  74247. /**
  74248. * Release associated resources
  74249. */
  74250. dispose(): void;
  74251. }
  74252. }
  74253. declare module "babylonjs/Sprites/spritePackedManager" {
  74254. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  74255. import { Scene } from "babylonjs/scene";
  74256. /**
  74257. * Class used to manage multiple sprites of different sizes on the same spritesheet
  74258. * @see http://doc.babylonjs.com/babylon101/sprites
  74259. */
  74260. export class SpritePackedManager extends SpriteManager {
  74261. /** defines the packed manager's name */
  74262. name: string;
  74263. /**
  74264. * Creates a new sprite manager from a packed sprite sheet
  74265. * @param name defines the manager's name
  74266. * @param imgUrl defines the sprite sheet url
  74267. * @param capacity defines the maximum allowed number of sprites
  74268. * @param scene defines the hosting scene
  74269. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  74270. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  74271. * @param samplingMode defines the smapling mode to use with spritesheet
  74272. * @param fromPacked set to true; do not alter
  74273. */
  74274. constructor(
  74275. /** defines the packed manager's name */
  74276. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  74277. }
  74278. }
  74279. declare module "babylonjs/Sprites/index" {
  74280. export * from "babylonjs/Sprites/sprite";
  74281. export * from "babylonjs/Sprites/ISprites";
  74282. export * from "babylonjs/Sprites/spriteManager";
  74283. export * from "babylonjs/Sprites/spriteMap";
  74284. export * from "babylonjs/Sprites/spritePackedManager";
  74285. export * from "babylonjs/Sprites/spriteSceneComponent";
  74286. }
  74287. declare module "babylonjs/States/index" {
  74288. export * from "babylonjs/States/alphaCullingState";
  74289. export * from "babylonjs/States/depthCullingState";
  74290. export * from "babylonjs/States/stencilState";
  74291. }
  74292. declare module "babylonjs/Misc/assetsManager" {
  74293. import { Scene } from "babylonjs/scene";
  74294. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  74295. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  74296. import { Skeleton } from "babylonjs/Bones/skeleton";
  74297. import { Observable } from "babylonjs/Misc/observable";
  74298. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  74299. import { Texture } from "babylonjs/Materials/Textures/texture";
  74300. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  74301. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  74302. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  74303. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  74304. /**
  74305. * Defines the list of states available for a task inside a AssetsManager
  74306. */
  74307. export enum AssetTaskState {
  74308. /**
  74309. * Initialization
  74310. */
  74311. INIT = 0,
  74312. /**
  74313. * Running
  74314. */
  74315. RUNNING = 1,
  74316. /**
  74317. * Done
  74318. */
  74319. DONE = 2,
  74320. /**
  74321. * Error
  74322. */
  74323. ERROR = 3
  74324. }
  74325. /**
  74326. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  74327. */
  74328. export abstract class AbstractAssetTask {
  74329. /**
  74330. * Task name
  74331. */ name: string;
  74332. /**
  74333. * Callback called when the task is successful
  74334. */
  74335. onSuccess: (task: any) => void;
  74336. /**
  74337. * Callback called when the task is not successful
  74338. */
  74339. onError: (task: any, message?: string, exception?: any) => void;
  74340. /**
  74341. * Creates a new AssetsManager
  74342. * @param name defines the name of the task
  74343. */
  74344. constructor(
  74345. /**
  74346. * Task name
  74347. */ name: string);
  74348. private _isCompleted;
  74349. private _taskState;
  74350. private _errorObject;
  74351. /**
  74352. * Get if the task is completed
  74353. */
  74354. get isCompleted(): boolean;
  74355. /**
  74356. * Gets the current state of the task
  74357. */
  74358. get taskState(): AssetTaskState;
  74359. /**
  74360. * Gets the current error object (if task is in error)
  74361. */
  74362. get errorObject(): {
  74363. message?: string;
  74364. exception?: any;
  74365. };
  74366. /**
  74367. * Internal only
  74368. * @hidden
  74369. */
  74370. _setErrorObject(message?: string, exception?: any): void;
  74371. /**
  74372. * Execute the current task
  74373. * @param scene defines the scene where you want your assets to be loaded
  74374. * @param onSuccess is a callback called when the task is successfully executed
  74375. * @param onError is a callback called if an error occurs
  74376. */
  74377. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74378. /**
  74379. * Execute the current task
  74380. * @param scene defines the scene where you want your assets to be loaded
  74381. * @param onSuccess is a callback called when the task is successfully executed
  74382. * @param onError is a callback called if an error occurs
  74383. */
  74384. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74385. /**
  74386. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  74387. * This can be used with failed tasks that have the reason for failure fixed.
  74388. */
  74389. reset(): void;
  74390. private onErrorCallback;
  74391. private onDoneCallback;
  74392. }
  74393. /**
  74394. * Define the interface used by progress events raised during assets loading
  74395. */
  74396. export interface IAssetsProgressEvent {
  74397. /**
  74398. * Defines the number of remaining tasks to process
  74399. */
  74400. remainingCount: number;
  74401. /**
  74402. * Defines the total number of tasks
  74403. */
  74404. totalCount: number;
  74405. /**
  74406. * Defines the task that was just processed
  74407. */
  74408. task: AbstractAssetTask;
  74409. }
  74410. /**
  74411. * Class used to share progress information about assets loading
  74412. */
  74413. export class AssetsProgressEvent implements IAssetsProgressEvent {
  74414. /**
  74415. * Defines the number of remaining tasks to process
  74416. */
  74417. remainingCount: number;
  74418. /**
  74419. * Defines the total number of tasks
  74420. */
  74421. totalCount: number;
  74422. /**
  74423. * Defines the task that was just processed
  74424. */
  74425. task: AbstractAssetTask;
  74426. /**
  74427. * Creates a AssetsProgressEvent
  74428. * @param remainingCount defines the number of remaining tasks to process
  74429. * @param totalCount defines the total number of tasks
  74430. * @param task defines the task that was just processed
  74431. */
  74432. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  74433. }
  74434. /**
  74435. * Define a task used by AssetsManager to load meshes
  74436. */
  74437. export class MeshAssetTask extends AbstractAssetTask {
  74438. /**
  74439. * Defines the name of the task
  74440. */
  74441. name: string;
  74442. /**
  74443. * Defines the list of mesh's names you want to load
  74444. */
  74445. meshesNames: any;
  74446. /**
  74447. * Defines the root url to use as a base to load your meshes and associated resources
  74448. */
  74449. rootUrl: string;
  74450. /**
  74451. * Defines the filename or File of the scene to load from
  74452. */
  74453. sceneFilename: string | File;
  74454. /**
  74455. * Gets the list of loaded meshes
  74456. */
  74457. loadedMeshes: Array<AbstractMesh>;
  74458. /**
  74459. * Gets the list of loaded particle systems
  74460. */
  74461. loadedParticleSystems: Array<IParticleSystem>;
  74462. /**
  74463. * Gets the list of loaded skeletons
  74464. */
  74465. loadedSkeletons: Array<Skeleton>;
  74466. /**
  74467. * Gets the list of loaded animation groups
  74468. */
  74469. loadedAnimationGroups: Array<AnimationGroup>;
  74470. /**
  74471. * Callback called when the task is successful
  74472. */
  74473. onSuccess: (task: MeshAssetTask) => void;
  74474. /**
  74475. * Callback called when the task is successful
  74476. */
  74477. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  74478. /**
  74479. * Creates a new MeshAssetTask
  74480. * @param name defines the name of the task
  74481. * @param meshesNames defines the list of mesh's names you want to load
  74482. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  74483. * @param sceneFilename defines the filename or File of the scene to load from
  74484. */
  74485. constructor(
  74486. /**
  74487. * Defines the name of the task
  74488. */
  74489. name: string,
  74490. /**
  74491. * Defines the list of mesh's names you want to load
  74492. */
  74493. meshesNames: any,
  74494. /**
  74495. * Defines the root url to use as a base to load your meshes and associated resources
  74496. */
  74497. rootUrl: string,
  74498. /**
  74499. * Defines the filename or File of the scene to load from
  74500. */
  74501. sceneFilename: string | File);
  74502. /**
  74503. * Execute the current task
  74504. * @param scene defines the scene where you want your assets to be loaded
  74505. * @param onSuccess is a callback called when the task is successfully executed
  74506. * @param onError is a callback called if an error occurs
  74507. */
  74508. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74509. }
  74510. /**
  74511. * Define a task used by AssetsManager to load text content
  74512. */
  74513. export class TextFileAssetTask extends AbstractAssetTask {
  74514. /**
  74515. * Defines the name of the task
  74516. */
  74517. name: string;
  74518. /**
  74519. * Defines the location of the file to load
  74520. */
  74521. url: string;
  74522. /**
  74523. * Gets the loaded text string
  74524. */
  74525. text: string;
  74526. /**
  74527. * Callback called when the task is successful
  74528. */
  74529. onSuccess: (task: TextFileAssetTask) => void;
  74530. /**
  74531. * Callback called when the task is successful
  74532. */
  74533. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  74534. /**
  74535. * Creates a new TextFileAssetTask object
  74536. * @param name defines the name of the task
  74537. * @param url defines the location of the file to load
  74538. */
  74539. constructor(
  74540. /**
  74541. * Defines the name of the task
  74542. */
  74543. name: string,
  74544. /**
  74545. * Defines the location of the file to load
  74546. */
  74547. url: string);
  74548. /**
  74549. * Execute the current task
  74550. * @param scene defines the scene where you want your assets to be loaded
  74551. * @param onSuccess is a callback called when the task is successfully executed
  74552. * @param onError is a callback called if an error occurs
  74553. */
  74554. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74555. }
  74556. /**
  74557. * Define a task used by AssetsManager to load binary data
  74558. */
  74559. export class BinaryFileAssetTask extends AbstractAssetTask {
  74560. /**
  74561. * Defines the name of the task
  74562. */
  74563. name: string;
  74564. /**
  74565. * Defines the location of the file to load
  74566. */
  74567. url: string;
  74568. /**
  74569. * Gets the lodaded data (as an array buffer)
  74570. */
  74571. data: ArrayBuffer;
  74572. /**
  74573. * Callback called when the task is successful
  74574. */
  74575. onSuccess: (task: BinaryFileAssetTask) => void;
  74576. /**
  74577. * Callback called when the task is successful
  74578. */
  74579. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  74580. /**
  74581. * Creates a new BinaryFileAssetTask object
  74582. * @param name defines the name of the new task
  74583. * @param url defines the location of the file to load
  74584. */
  74585. constructor(
  74586. /**
  74587. * Defines the name of the task
  74588. */
  74589. name: string,
  74590. /**
  74591. * Defines the location of the file to load
  74592. */
  74593. url: string);
  74594. /**
  74595. * Execute the current task
  74596. * @param scene defines the scene where you want your assets to be loaded
  74597. * @param onSuccess is a callback called when the task is successfully executed
  74598. * @param onError is a callback called if an error occurs
  74599. */
  74600. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74601. }
  74602. /**
  74603. * Define a task used by AssetsManager to load images
  74604. */
  74605. export class ImageAssetTask extends AbstractAssetTask {
  74606. /**
  74607. * Defines the name of the task
  74608. */
  74609. name: string;
  74610. /**
  74611. * Defines the location of the image to load
  74612. */
  74613. url: string;
  74614. /**
  74615. * Gets the loaded images
  74616. */
  74617. image: HTMLImageElement;
  74618. /**
  74619. * Callback called when the task is successful
  74620. */
  74621. onSuccess: (task: ImageAssetTask) => void;
  74622. /**
  74623. * Callback called when the task is successful
  74624. */
  74625. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  74626. /**
  74627. * Creates a new ImageAssetTask
  74628. * @param name defines the name of the task
  74629. * @param url defines the location of the image to load
  74630. */
  74631. constructor(
  74632. /**
  74633. * Defines the name of the task
  74634. */
  74635. name: string,
  74636. /**
  74637. * Defines the location of the image to load
  74638. */
  74639. url: string);
  74640. /**
  74641. * Execute the current task
  74642. * @param scene defines the scene where you want your assets to be loaded
  74643. * @param onSuccess is a callback called when the task is successfully executed
  74644. * @param onError is a callback called if an error occurs
  74645. */
  74646. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74647. }
  74648. /**
  74649. * Defines the interface used by texture loading tasks
  74650. */
  74651. export interface ITextureAssetTask<TEX extends BaseTexture> {
  74652. /**
  74653. * Gets the loaded texture
  74654. */
  74655. texture: TEX;
  74656. }
  74657. /**
  74658. * Define a task used by AssetsManager to load 2D textures
  74659. */
  74660. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  74661. /**
  74662. * Defines the name of the task
  74663. */
  74664. name: string;
  74665. /**
  74666. * Defines the location of the file to load
  74667. */
  74668. url: string;
  74669. /**
  74670. * Defines if mipmap should not be generated (default is false)
  74671. */
  74672. noMipmap?: boolean | undefined;
  74673. /**
  74674. * Defines if texture must be inverted on Y axis (default is true)
  74675. */
  74676. invertY: boolean;
  74677. /**
  74678. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  74679. */
  74680. samplingMode: number;
  74681. /**
  74682. * Gets the loaded texture
  74683. */
  74684. texture: Texture;
  74685. /**
  74686. * Callback called when the task is successful
  74687. */
  74688. onSuccess: (task: TextureAssetTask) => void;
  74689. /**
  74690. * Callback called when the task is successful
  74691. */
  74692. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  74693. /**
  74694. * Creates a new TextureAssetTask object
  74695. * @param name defines the name of the task
  74696. * @param url defines the location of the file to load
  74697. * @param noMipmap defines if mipmap should not be generated (default is false)
  74698. * @param invertY defines if texture must be inverted on Y axis (default is true)
  74699. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  74700. */
  74701. constructor(
  74702. /**
  74703. * Defines the name of the task
  74704. */
  74705. name: string,
  74706. /**
  74707. * Defines the location of the file to load
  74708. */
  74709. url: string,
  74710. /**
  74711. * Defines if mipmap should not be generated (default is false)
  74712. */
  74713. noMipmap?: boolean | undefined,
  74714. /**
  74715. * Defines if texture must be inverted on Y axis (default is true)
  74716. */
  74717. invertY?: boolean,
  74718. /**
  74719. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  74720. */
  74721. samplingMode?: number);
  74722. /**
  74723. * Execute the current task
  74724. * @param scene defines the scene where you want your assets to be loaded
  74725. * @param onSuccess is a callback called when the task is successfully executed
  74726. * @param onError is a callback called if an error occurs
  74727. */
  74728. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74729. }
  74730. /**
  74731. * Define a task used by AssetsManager to load cube textures
  74732. */
  74733. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  74734. /**
  74735. * Defines the name of the task
  74736. */
  74737. name: string;
  74738. /**
  74739. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  74740. */
  74741. url: string;
  74742. /**
  74743. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  74744. */
  74745. extensions?: string[] | undefined;
  74746. /**
  74747. * Defines if mipmaps should not be generated (default is false)
  74748. */
  74749. noMipmap?: boolean | undefined;
  74750. /**
  74751. * Defines the explicit list of files (undefined by default)
  74752. */
  74753. files?: string[] | undefined;
  74754. /**
  74755. * Gets the loaded texture
  74756. */
  74757. texture: CubeTexture;
  74758. /**
  74759. * Callback called when the task is successful
  74760. */
  74761. onSuccess: (task: CubeTextureAssetTask) => void;
  74762. /**
  74763. * Callback called when the task is successful
  74764. */
  74765. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  74766. /**
  74767. * Creates a new CubeTextureAssetTask
  74768. * @param name defines the name of the task
  74769. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  74770. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  74771. * @param noMipmap defines if mipmaps should not be generated (default is false)
  74772. * @param files defines the explicit list of files (undefined by default)
  74773. */
  74774. constructor(
  74775. /**
  74776. * Defines the name of the task
  74777. */
  74778. name: string,
  74779. /**
  74780. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  74781. */
  74782. url: string,
  74783. /**
  74784. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  74785. */
  74786. extensions?: string[] | undefined,
  74787. /**
  74788. * Defines if mipmaps should not be generated (default is false)
  74789. */
  74790. noMipmap?: boolean | undefined,
  74791. /**
  74792. * Defines the explicit list of files (undefined by default)
  74793. */
  74794. files?: string[] | undefined);
  74795. /**
  74796. * Execute the current task
  74797. * @param scene defines the scene where you want your assets to be loaded
  74798. * @param onSuccess is a callback called when the task is successfully executed
  74799. * @param onError is a callback called if an error occurs
  74800. */
  74801. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74802. }
  74803. /**
  74804. * Define a task used by AssetsManager to load HDR cube textures
  74805. */
  74806. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  74807. /**
  74808. * Defines the name of the task
  74809. */
  74810. name: string;
  74811. /**
  74812. * Defines the location of the file to load
  74813. */
  74814. url: string;
  74815. /**
  74816. * Defines the desired size (the more it increases the longer the generation will be)
  74817. */
  74818. size: number;
  74819. /**
  74820. * Defines if mipmaps should not be generated (default is false)
  74821. */
  74822. noMipmap: boolean;
  74823. /**
  74824. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  74825. */
  74826. generateHarmonics: boolean;
  74827. /**
  74828. * 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)
  74829. */
  74830. gammaSpace: boolean;
  74831. /**
  74832. * Internal Use Only
  74833. */
  74834. reserved: boolean;
  74835. /**
  74836. * Gets the loaded texture
  74837. */
  74838. texture: HDRCubeTexture;
  74839. /**
  74840. * Callback called when the task is successful
  74841. */
  74842. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  74843. /**
  74844. * Callback called when the task is successful
  74845. */
  74846. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  74847. /**
  74848. * Creates a new HDRCubeTextureAssetTask object
  74849. * @param name defines the name of the task
  74850. * @param url defines the location of the file to load
  74851. * @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.
  74852. * @param noMipmap defines if mipmaps should not be generated (default is false)
  74853. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  74854. * @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)
  74855. * @param reserved Internal use only
  74856. */
  74857. constructor(
  74858. /**
  74859. * Defines the name of the task
  74860. */
  74861. name: string,
  74862. /**
  74863. * Defines the location of the file to load
  74864. */
  74865. url: string,
  74866. /**
  74867. * Defines the desired size (the more it increases the longer the generation will be)
  74868. */
  74869. size: number,
  74870. /**
  74871. * Defines if mipmaps should not be generated (default is false)
  74872. */
  74873. noMipmap?: boolean,
  74874. /**
  74875. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  74876. */
  74877. generateHarmonics?: boolean,
  74878. /**
  74879. * 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)
  74880. */
  74881. gammaSpace?: boolean,
  74882. /**
  74883. * Internal Use Only
  74884. */
  74885. reserved?: boolean);
  74886. /**
  74887. * Execute the current task
  74888. * @param scene defines the scene where you want your assets to be loaded
  74889. * @param onSuccess is a callback called when the task is successfully executed
  74890. * @param onError is a callback called if an error occurs
  74891. */
  74892. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74893. }
  74894. /**
  74895. * Define a task used by AssetsManager to load Equirectangular cube textures
  74896. */
  74897. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  74898. /**
  74899. * Defines the name of the task
  74900. */
  74901. name: string;
  74902. /**
  74903. * Defines the location of the file to load
  74904. */
  74905. url: string;
  74906. /**
  74907. * Defines the desired size (the more it increases the longer the generation will be)
  74908. */
  74909. size: number;
  74910. /**
  74911. * Defines if mipmaps should not be generated (default is false)
  74912. */
  74913. noMipmap: boolean;
  74914. /**
  74915. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  74916. * but the standard material would require them in Gamma space) (default is true)
  74917. */
  74918. gammaSpace: boolean;
  74919. /**
  74920. * Gets the loaded texture
  74921. */
  74922. texture: EquiRectangularCubeTexture;
  74923. /**
  74924. * Callback called when the task is successful
  74925. */
  74926. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  74927. /**
  74928. * Callback called when the task is successful
  74929. */
  74930. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  74931. /**
  74932. * Creates a new EquiRectangularCubeTextureAssetTask object
  74933. * @param name defines the name of the task
  74934. * @param url defines the location of the file to load
  74935. * @param size defines the desired size (the more it increases the longer the generation will be)
  74936. * If the size is omitted this implies you are using a preprocessed cubemap.
  74937. * @param noMipmap defines if mipmaps should not be generated (default is false)
  74938. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  74939. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  74940. * (default is true)
  74941. */
  74942. constructor(
  74943. /**
  74944. * Defines the name of the task
  74945. */
  74946. name: string,
  74947. /**
  74948. * Defines the location of the file to load
  74949. */
  74950. url: string,
  74951. /**
  74952. * Defines the desired size (the more it increases the longer the generation will be)
  74953. */
  74954. size: number,
  74955. /**
  74956. * Defines if mipmaps should not be generated (default is false)
  74957. */
  74958. noMipmap?: boolean,
  74959. /**
  74960. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  74961. * but the standard material would require them in Gamma space) (default is true)
  74962. */
  74963. gammaSpace?: boolean);
  74964. /**
  74965. * Execute the current task
  74966. * @param scene defines the scene where you want your assets to be loaded
  74967. * @param onSuccess is a callback called when the task is successfully executed
  74968. * @param onError is a callback called if an error occurs
  74969. */
  74970. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74971. }
  74972. /**
  74973. * This class can be used to easily import assets into a scene
  74974. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  74975. */
  74976. export class AssetsManager {
  74977. private _scene;
  74978. private _isLoading;
  74979. protected _tasks: AbstractAssetTask[];
  74980. protected _waitingTasksCount: number;
  74981. protected _totalTasksCount: number;
  74982. /**
  74983. * Callback called when all tasks are processed
  74984. */
  74985. onFinish: (tasks: AbstractAssetTask[]) => void;
  74986. /**
  74987. * Callback called when a task is successful
  74988. */
  74989. onTaskSuccess: (task: AbstractAssetTask) => void;
  74990. /**
  74991. * Callback called when a task had an error
  74992. */
  74993. onTaskError: (task: AbstractAssetTask) => void;
  74994. /**
  74995. * Callback called when a task is done (whatever the result is)
  74996. */
  74997. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  74998. /**
  74999. * Observable called when all tasks are processed
  75000. */
  75001. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  75002. /**
  75003. * Observable called when a task had an error
  75004. */
  75005. onTaskErrorObservable: Observable<AbstractAssetTask>;
  75006. /**
  75007. * Observable called when all tasks were executed
  75008. */
  75009. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  75010. /**
  75011. * Observable called when a task is done (whatever the result is)
  75012. */
  75013. onProgressObservable: Observable<IAssetsProgressEvent>;
  75014. /**
  75015. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  75016. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  75017. */
  75018. useDefaultLoadingScreen: boolean;
  75019. /**
  75020. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  75021. * when all assets have been downloaded.
  75022. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  75023. */
  75024. autoHideLoadingUI: boolean;
  75025. /**
  75026. * Creates a new AssetsManager
  75027. * @param scene defines the scene to work on
  75028. */
  75029. constructor(scene: Scene);
  75030. /**
  75031. * Add a MeshAssetTask to the list of active tasks
  75032. * @param taskName defines the name of the new task
  75033. * @param meshesNames defines the name of meshes to load
  75034. * @param rootUrl defines the root url to use to locate files
  75035. * @param sceneFilename defines the filename of the scene file
  75036. * @returns a new MeshAssetTask object
  75037. */
  75038. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  75039. /**
  75040. * Add a TextFileAssetTask to the list of active tasks
  75041. * @param taskName defines the name of the new task
  75042. * @param url defines the url of the file to load
  75043. * @returns a new TextFileAssetTask object
  75044. */
  75045. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  75046. /**
  75047. * Add a BinaryFileAssetTask to the list of active tasks
  75048. * @param taskName defines the name of the new task
  75049. * @param url defines the url of the file to load
  75050. * @returns a new BinaryFileAssetTask object
  75051. */
  75052. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  75053. /**
  75054. * Add a ImageAssetTask to the list of active tasks
  75055. * @param taskName defines the name of the new task
  75056. * @param url defines the url of the file to load
  75057. * @returns a new ImageAssetTask object
  75058. */
  75059. addImageTask(taskName: string, url: string): ImageAssetTask;
  75060. /**
  75061. * Add a TextureAssetTask to the list of active tasks
  75062. * @param taskName defines the name of the new task
  75063. * @param url defines the url of the file to load
  75064. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  75065. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  75066. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  75067. * @returns a new TextureAssetTask object
  75068. */
  75069. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  75070. /**
  75071. * Add a CubeTextureAssetTask to the list of active tasks
  75072. * @param taskName defines the name of the new task
  75073. * @param url defines the url of the file to load
  75074. * @param extensions defines the extension to use to load the cube map (can be null)
  75075. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  75076. * @param files defines the list of files to load (can be null)
  75077. * @returns a new CubeTextureAssetTask object
  75078. */
  75079. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  75080. /**
  75081. *
  75082. * Add a HDRCubeTextureAssetTask to the list of active tasks
  75083. * @param taskName defines the name of the new task
  75084. * @param url defines the url of the file to load
  75085. * @param size defines the size you want for the cubemap (can be null)
  75086. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  75087. * @param generateHarmonics defines if you want to automatically generate (true by default)
  75088. * @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)
  75089. * @param reserved Internal use only
  75090. * @returns a new HDRCubeTextureAssetTask object
  75091. */
  75092. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  75093. /**
  75094. *
  75095. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  75096. * @param taskName defines the name of the new task
  75097. * @param url defines the url of the file to load
  75098. * @param size defines the size you want for the cubemap (can be null)
  75099. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  75100. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  75101. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  75102. * @returns a new EquiRectangularCubeTextureAssetTask object
  75103. */
  75104. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  75105. /**
  75106. * Remove a task from the assets manager.
  75107. * @param task the task to remove
  75108. */
  75109. removeTask(task: AbstractAssetTask): void;
  75110. private _decreaseWaitingTasksCount;
  75111. private _runTask;
  75112. /**
  75113. * Reset the AssetsManager and remove all tasks
  75114. * @return the current instance of the AssetsManager
  75115. */
  75116. reset(): AssetsManager;
  75117. /**
  75118. * Start the loading process
  75119. * @return the current instance of the AssetsManager
  75120. */
  75121. load(): AssetsManager;
  75122. /**
  75123. * Start the loading process as an async operation
  75124. * @return a promise returning the list of failed tasks
  75125. */
  75126. loadAsync(): Promise<void>;
  75127. }
  75128. }
  75129. declare module "babylonjs/Misc/deferred" {
  75130. /**
  75131. * Wrapper class for promise with external resolve and reject.
  75132. */
  75133. export class Deferred<T> {
  75134. /**
  75135. * The promise associated with this deferred object.
  75136. */
  75137. readonly promise: Promise<T>;
  75138. private _resolve;
  75139. private _reject;
  75140. /**
  75141. * The resolve method of the promise associated with this deferred object.
  75142. */
  75143. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  75144. /**
  75145. * The reject method of the promise associated with this deferred object.
  75146. */
  75147. get reject(): (reason?: any) => void;
  75148. /**
  75149. * Constructor for this deferred object.
  75150. */
  75151. constructor();
  75152. }
  75153. }
  75154. declare module "babylonjs/Misc/meshExploder" {
  75155. import { Mesh } from "babylonjs/Meshes/mesh";
  75156. /**
  75157. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  75158. */
  75159. export class MeshExploder {
  75160. private _centerMesh;
  75161. private _meshes;
  75162. private _meshesOrigins;
  75163. private _toCenterVectors;
  75164. private _scaledDirection;
  75165. private _newPosition;
  75166. private _centerPosition;
  75167. /**
  75168. * Explodes meshes from a center mesh.
  75169. * @param meshes The meshes to explode.
  75170. * @param centerMesh The mesh to be center of explosion.
  75171. */
  75172. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  75173. private _setCenterMesh;
  75174. /**
  75175. * Get class name
  75176. * @returns "MeshExploder"
  75177. */
  75178. getClassName(): string;
  75179. /**
  75180. * "Exploded meshes"
  75181. * @returns Array of meshes with the centerMesh at index 0.
  75182. */
  75183. getMeshes(): Array<Mesh>;
  75184. /**
  75185. * Explodes meshes giving a specific direction
  75186. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  75187. */
  75188. explode(direction?: number): void;
  75189. }
  75190. }
  75191. declare module "babylonjs/Misc/filesInput" {
  75192. import { Engine } from "babylonjs/Engines/engine";
  75193. import { Scene } from "babylonjs/scene";
  75194. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  75195. /**
  75196. * Class used to help managing file picking and drag'n'drop
  75197. */
  75198. export class FilesInput {
  75199. /**
  75200. * List of files ready to be loaded
  75201. */
  75202. static get FilesToLoad(): {
  75203. [key: string]: File;
  75204. };
  75205. /**
  75206. * Callback called when a file is processed
  75207. */
  75208. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  75209. private _engine;
  75210. private _currentScene;
  75211. private _sceneLoadedCallback;
  75212. private _progressCallback;
  75213. private _additionalRenderLoopLogicCallback;
  75214. private _textureLoadingCallback;
  75215. private _startingProcessingFilesCallback;
  75216. private _onReloadCallback;
  75217. private _errorCallback;
  75218. private _elementToMonitor;
  75219. private _sceneFileToLoad;
  75220. private _filesToLoad;
  75221. /**
  75222. * Creates a new FilesInput
  75223. * @param engine defines the rendering engine
  75224. * @param scene defines the hosting scene
  75225. * @param sceneLoadedCallback callback called when scene is loaded
  75226. * @param progressCallback callback called to track progress
  75227. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  75228. * @param textureLoadingCallback callback called when a texture is loading
  75229. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  75230. * @param onReloadCallback callback called when a reload is requested
  75231. * @param errorCallback callback call if an error occurs
  75232. */
  75233. 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);
  75234. private _dragEnterHandler;
  75235. private _dragOverHandler;
  75236. private _dropHandler;
  75237. /**
  75238. * Calls this function to listen to drag'n'drop events on a specific DOM element
  75239. * @param elementToMonitor defines the DOM element to track
  75240. */
  75241. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  75242. /**
  75243. * Release all associated resources
  75244. */
  75245. dispose(): void;
  75246. private renderFunction;
  75247. private drag;
  75248. private drop;
  75249. private _traverseFolder;
  75250. private _processFiles;
  75251. /**
  75252. * Load files from a drop event
  75253. * @param event defines the drop event to use as source
  75254. */
  75255. loadFiles(event: any): void;
  75256. private _processReload;
  75257. /**
  75258. * Reload the current scene from the loaded files
  75259. */
  75260. reload(): void;
  75261. }
  75262. }
  75263. declare module "babylonjs/Misc/HighDynamicRange/index" {
  75264. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  75265. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  75266. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  75267. }
  75268. declare module "babylonjs/Misc/sceneOptimizer" {
  75269. import { Scene, IDisposable } from "babylonjs/scene";
  75270. import { Observable } from "babylonjs/Misc/observable";
  75271. /**
  75272. * Defines the root class used to create scene optimization to use with SceneOptimizer
  75273. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75274. */
  75275. export class SceneOptimization {
  75276. /**
  75277. * Defines the priority of this optimization (0 by default which means first in the list)
  75278. */
  75279. priority: number;
  75280. /**
  75281. * Gets a string describing the action executed by the current optimization
  75282. * @returns description string
  75283. */
  75284. getDescription(): string;
  75285. /**
  75286. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75287. * @param scene defines the current scene where to apply this optimization
  75288. * @param optimizer defines the current optimizer
  75289. * @returns true if everything that can be done was applied
  75290. */
  75291. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75292. /**
  75293. * Creates the SceneOptimization object
  75294. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  75295. * @param desc defines the description associated with the optimization
  75296. */
  75297. constructor(
  75298. /**
  75299. * Defines the priority of this optimization (0 by default which means first in the list)
  75300. */
  75301. priority?: number);
  75302. }
  75303. /**
  75304. * Defines an optimization used to reduce the size of render target textures
  75305. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75306. */
  75307. export class TextureOptimization extends SceneOptimization {
  75308. /**
  75309. * Defines the priority of this optimization (0 by default which means first in the list)
  75310. */
  75311. priority: number;
  75312. /**
  75313. * 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
  75314. */
  75315. maximumSize: number;
  75316. /**
  75317. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  75318. */
  75319. step: number;
  75320. /**
  75321. * Gets a string describing the action executed by the current optimization
  75322. * @returns description string
  75323. */
  75324. getDescription(): string;
  75325. /**
  75326. * Creates the TextureOptimization object
  75327. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  75328. * @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
  75329. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  75330. */
  75331. constructor(
  75332. /**
  75333. * Defines the priority of this optimization (0 by default which means first in the list)
  75334. */
  75335. priority?: number,
  75336. /**
  75337. * 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
  75338. */
  75339. maximumSize?: number,
  75340. /**
  75341. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  75342. */
  75343. step?: number);
  75344. /**
  75345. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75346. * @param scene defines the current scene where to apply this optimization
  75347. * @param optimizer defines the current optimizer
  75348. * @returns true if everything that can be done was applied
  75349. */
  75350. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75351. }
  75352. /**
  75353. * Defines an optimization used to increase or decrease the rendering resolution
  75354. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75355. */
  75356. export class HardwareScalingOptimization extends SceneOptimization {
  75357. /**
  75358. * Defines the priority of this optimization (0 by default which means first in the list)
  75359. */
  75360. priority: number;
  75361. /**
  75362. * Defines the maximum scale to use (2 by default)
  75363. */
  75364. maximumScale: number;
  75365. /**
  75366. * Defines the step to use between two passes (0.5 by default)
  75367. */
  75368. step: number;
  75369. private _currentScale;
  75370. private _directionOffset;
  75371. /**
  75372. * Gets a string describing the action executed by the current optimization
  75373. * @return description string
  75374. */
  75375. getDescription(): string;
  75376. /**
  75377. * Creates the HardwareScalingOptimization object
  75378. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  75379. * @param maximumScale defines the maximum scale to use (2 by default)
  75380. * @param step defines the step to use between two passes (0.5 by default)
  75381. */
  75382. constructor(
  75383. /**
  75384. * Defines the priority of this optimization (0 by default which means first in the list)
  75385. */
  75386. priority?: number,
  75387. /**
  75388. * Defines the maximum scale to use (2 by default)
  75389. */
  75390. maximumScale?: number,
  75391. /**
  75392. * Defines the step to use between two passes (0.5 by default)
  75393. */
  75394. step?: number);
  75395. /**
  75396. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75397. * @param scene defines the current scene where to apply this optimization
  75398. * @param optimizer defines the current optimizer
  75399. * @returns true if everything that can be done was applied
  75400. */
  75401. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75402. }
  75403. /**
  75404. * Defines an optimization used to remove shadows
  75405. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75406. */
  75407. export class ShadowsOptimization extends SceneOptimization {
  75408. /**
  75409. * Gets a string describing the action executed by the current optimization
  75410. * @return description string
  75411. */
  75412. getDescription(): string;
  75413. /**
  75414. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75415. * @param scene defines the current scene where to apply this optimization
  75416. * @param optimizer defines the current optimizer
  75417. * @returns true if everything that can be done was applied
  75418. */
  75419. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75420. }
  75421. /**
  75422. * Defines an optimization used to turn post-processes off
  75423. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75424. */
  75425. export class PostProcessesOptimization extends SceneOptimization {
  75426. /**
  75427. * Gets a string describing the action executed by the current optimization
  75428. * @return description string
  75429. */
  75430. getDescription(): string;
  75431. /**
  75432. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75433. * @param scene defines the current scene where to apply this optimization
  75434. * @param optimizer defines the current optimizer
  75435. * @returns true if everything that can be done was applied
  75436. */
  75437. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75438. }
  75439. /**
  75440. * Defines an optimization used to turn lens flares off
  75441. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75442. */
  75443. export class LensFlaresOptimization extends SceneOptimization {
  75444. /**
  75445. * Gets a string describing the action executed by the current optimization
  75446. * @return description string
  75447. */
  75448. getDescription(): string;
  75449. /**
  75450. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75451. * @param scene defines the current scene where to apply this optimization
  75452. * @param optimizer defines the current optimizer
  75453. * @returns true if everything that can be done was applied
  75454. */
  75455. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75456. }
  75457. /**
  75458. * Defines an optimization based on user defined callback.
  75459. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75460. */
  75461. export class CustomOptimization extends SceneOptimization {
  75462. /**
  75463. * Callback called to apply the custom optimization.
  75464. */
  75465. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  75466. /**
  75467. * Callback called to get custom description
  75468. */
  75469. onGetDescription: () => string;
  75470. /**
  75471. * Gets a string describing the action executed by the current optimization
  75472. * @returns description string
  75473. */
  75474. getDescription(): string;
  75475. /**
  75476. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75477. * @param scene defines the current scene where to apply this optimization
  75478. * @param optimizer defines the current optimizer
  75479. * @returns true if everything that can be done was applied
  75480. */
  75481. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75482. }
  75483. /**
  75484. * Defines an optimization used to turn particles off
  75485. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75486. */
  75487. export class ParticlesOptimization extends SceneOptimization {
  75488. /**
  75489. * Gets a string describing the action executed by the current optimization
  75490. * @return description string
  75491. */
  75492. getDescription(): string;
  75493. /**
  75494. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75495. * @param scene defines the current scene where to apply this optimization
  75496. * @param optimizer defines the current optimizer
  75497. * @returns true if everything that can be done was applied
  75498. */
  75499. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75500. }
  75501. /**
  75502. * Defines an optimization used to turn render targets off
  75503. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75504. */
  75505. export class RenderTargetsOptimization extends SceneOptimization {
  75506. /**
  75507. * Gets a string describing the action executed by the current optimization
  75508. * @return description string
  75509. */
  75510. getDescription(): string;
  75511. /**
  75512. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75513. * @param scene defines the current scene where to apply this optimization
  75514. * @param optimizer defines the current optimizer
  75515. * @returns true if everything that can be done was applied
  75516. */
  75517. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75518. }
  75519. /**
  75520. * Defines an optimization used to merge meshes with compatible materials
  75521. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75522. */
  75523. export class MergeMeshesOptimization extends SceneOptimization {
  75524. private static _UpdateSelectionTree;
  75525. /**
  75526. * Gets or sets a boolean which defines if optimization octree has to be updated
  75527. */
  75528. static get UpdateSelectionTree(): boolean;
  75529. /**
  75530. * Gets or sets a boolean which defines if optimization octree has to be updated
  75531. */
  75532. static set UpdateSelectionTree(value: boolean);
  75533. /**
  75534. * Gets a string describing the action executed by the current optimization
  75535. * @return description string
  75536. */
  75537. getDescription(): string;
  75538. private _canBeMerged;
  75539. /**
  75540. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75541. * @param scene defines the current scene where to apply this optimization
  75542. * @param optimizer defines the current optimizer
  75543. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  75544. * @returns true if everything that can be done was applied
  75545. */
  75546. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  75547. }
  75548. /**
  75549. * Defines a list of options used by SceneOptimizer
  75550. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75551. */
  75552. export class SceneOptimizerOptions {
  75553. /**
  75554. * Defines the target frame rate to reach (60 by default)
  75555. */
  75556. targetFrameRate: number;
  75557. /**
  75558. * Defines the interval between two checkes (2000ms by default)
  75559. */
  75560. trackerDuration: number;
  75561. /**
  75562. * Gets the list of optimizations to apply
  75563. */
  75564. optimizations: SceneOptimization[];
  75565. /**
  75566. * Creates a new list of options used by SceneOptimizer
  75567. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  75568. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  75569. */
  75570. constructor(
  75571. /**
  75572. * Defines the target frame rate to reach (60 by default)
  75573. */
  75574. targetFrameRate?: number,
  75575. /**
  75576. * Defines the interval between two checkes (2000ms by default)
  75577. */
  75578. trackerDuration?: number);
  75579. /**
  75580. * Add a new optimization
  75581. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  75582. * @returns the current SceneOptimizerOptions
  75583. */
  75584. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  75585. /**
  75586. * Add a new custom optimization
  75587. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  75588. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  75589. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  75590. * @returns the current SceneOptimizerOptions
  75591. */
  75592. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  75593. /**
  75594. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  75595. * @param targetFrameRate defines the target frame rate (60 by default)
  75596. * @returns a SceneOptimizerOptions object
  75597. */
  75598. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  75599. /**
  75600. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  75601. * @param targetFrameRate defines the target frame rate (60 by default)
  75602. * @returns a SceneOptimizerOptions object
  75603. */
  75604. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  75605. /**
  75606. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  75607. * @param targetFrameRate defines the target frame rate (60 by default)
  75608. * @returns a SceneOptimizerOptions object
  75609. */
  75610. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  75611. }
  75612. /**
  75613. * Class used to run optimizations in order to reach a target frame rate
  75614. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75615. */
  75616. export class SceneOptimizer implements IDisposable {
  75617. private _isRunning;
  75618. private _options;
  75619. private _scene;
  75620. private _currentPriorityLevel;
  75621. private _targetFrameRate;
  75622. private _trackerDuration;
  75623. private _currentFrameRate;
  75624. private _sceneDisposeObserver;
  75625. private _improvementMode;
  75626. /**
  75627. * Defines an observable called when the optimizer reaches the target frame rate
  75628. */
  75629. onSuccessObservable: Observable<SceneOptimizer>;
  75630. /**
  75631. * Defines an observable called when the optimizer enables an optimization
  75632. */
  75633. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  75634. /**
  75635. * Defines an observable called when the optimizer is not able to reach the target frame rate
  75636. */
  75637. onFailureObservable: Observable<SceneOptimizer>;
  75638. /**
  75639. * Gets a boolean indicating if the optimizer is in improvement mode
  75640. */
  75641. get isInImprovementMode(): boolean;
  75642. /**
  75643. * Gets the current priority level (0 at start)
  75644. */
  75645. get currentPriorityLevel(): number;
  75646. /**
  75647. * Gets the current frame rate checked by the SceneOptimizer
  75648. */
  75649. get currentFrameRate(): number;
  75650. /**
  75651. * Gets or sets the current target frame rate (60 by default)
  75652. */
  75653. get targetFrameRate(): number;
  75654. /**
  75655. * Gets or sets the current target frame rate (60 by default)
  75656. */
  75657. set targetFrameRate(value: number);
  75658. /**
  75659. * Gets or sets the current interval between two checks (every 2000ms by default)
  75660. */
  75661. get trackerDuration(): number;
  75662. /**
  75663. * Gets or sets the current interval between two checks (every 2000ms by default)
  75664. */
  75665. set trackerDuration(value: number);
  75666. /**
  75667. * Gets the list of active optimizations
  75668. */
  75669. get optimizations(): SceneOptimization[];
  75670. /**
  75671. * Creates a new SceneOptimizer
  75672. * @param scene defines the scene to work on
  75673. * @param options defines the options to use with the SceneOptimizer
  75674. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  75675. * @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)
  75676. */
  75677. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  75678. /**
  75679. * Stops the current optimizer
  75680. */
  75681. stop(): void;
  75682. /**
  75683. * Reset the optimizer to initial step (current priority level = 0)
  75684. */
  75685. reset(): void;
  75686. /**
  75687. * Start the optimizer. By default it will try to reach a specific framerate
  75688. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  75689. */
  75690. start(): void;
  75691. private _checkCurrentState;
  75692. /**
  75693. * Release all resources
  75694. */
  75695. dispose(): void;
  75696. /**
  75697. * Helper function to create a SceneOptimizer with one single line of code
  75698. * @param scene defines the scene to work on
  75699. * @param options defines the options to use with the SceneOptimizer
  75700. * @param onSuccess defines a callback to call on success
  75701. * @param onFailure defines a callback to call on failure
  75702. * @returns the new SceneOptimizer object
  75703. */
  75704. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  75705. }
  75706. }
  75707. declare module "babylonjs/Misc/sceneSerializer" {
  75708. import { Scene } from "babylonjs/scene";
  75709. /**
  75710. * Class used to serialize a scene into a string
  75711. */
  75712. export class SceneSerializer {
  75713. /**
  75714. * Clear cache used by a previous serialization
  75715. */
  75716. static ClearCache(): void;
  75717. /**
  75718. * Serialize a scene into a JSON compatible object
  75719. * @param scene defines the scene to serialize
  75720. * @returns a JSON compatible object
  75721. */
  75722. static Serialize(scene: Scene): any;
  75723. /**
  75724. * Serialize a mesh into a JSON compatible object
  75725. * @param toSerialize defines the mesh to serialize
  75726. * @param withParents defines if parents must be serialized as well
  75727. * @param withChildren defines if children must be serialized as well
  75728. * @returns a JSON compatible object
  75729. */
  75730. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  75731. }
  75732. }
  75733. declare module "babylonjs/Misc/textureTools" {
  75734. import { Texture } from "babylonjs/Materials/Textures/texture";
  75735. /**
  75736. * Class used to host texture specific utilities
  75737. */
  75738. export class TextureTools {
  75739. /**
  75740. * Uses the GPU to create a copy texture rescaled at a given size
  75741. * @param texture Texture to copy from
  75742. * @param width defines the desired width
  75743. * @param height defines the desired height
  75744. * @param useBilinearMode defines if bilinear mode has to be used
  75745. * @return the generated texture
  75746. */
  75747. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  75748. }
  75749. }
  75750. declare module "babylonjs/Misc/videoRecorder" {
  75751. import { Nullable } from "babylonjs/types";
  75752. import { Engine } from "babylonjs/Engines/engine";
  75753. /**
  75754. * This represents the different options available for the video capture.
  75755. */
  75756. export interface VideoRecorderOptions {
  75757. /** Defines the mime type of the video. */
  75758. mimeType: string;
  75759. /** Defines the FPS the video should be recorded at. */
  75760. fps: number;
  75761. /** Defines the chunk size for the recording data. */
  75762. recordChunckSize: number;
  75763. /** The audio tracks to attach to the recording. */
  75764. audioTracks?: MediaStreamTrack[];
  75765. }
  75766. /**
  75767. * This can help with recording videos from BabylonJS.
  75768. * This is based on the available WebRTC functionalities of the browser.
  75769. *
  75770. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  75771. */
  75772. export class VideoRecorder {
  75773. private static readonly _defaultOptions;
  75774. /**
  75775. * Returns whether or not the VideoRecorder is available in your browser.
  75776. * @param engine Defines the Babylon Engine.
  75777. * @returns true if supported otherwise false.
  75778. */
  75779. static IsSupported(engine: Engine): boolean;
  75780. private readonly _options;
  75781. private _canvas;
  75782. private _mediaRecorder;
  75783. private _recordedChunks;
  75784. private _fileName;
  75785. private _resolve;
  75786. private _reject;
  75787. /**
  75788. * True when a recording is already in progress.
  75789. */
  75790. get isRecording(): boolean;
  75791. /**
  75792. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  75793. * @param engine Defines the BabylonJS Engine you wish to record.
  75794. * @param options Defines options that can be used to customize the capture.
  75795. */
  75796. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  75797. /**
  75798. * Stops the current recording before the default capture timeout passed in the startRecording function.
  75799. */
  75800. stopRecording(): void;
  75801. /**
  75802. * Starts recording the canvas for a max duration specified in parameters.
  75803. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  75804. * If null no automatic download will start and you can rely on the promise to get the data back.
  75805. * @param maxDuration Defines the maximum recording time in seconds.
  75806. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  75807. * @return A promise callback at the end of the recording with the video data in Blob.
  75808. */
  75809. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  75810. /**
  75811. * Releases internal resources used during the recording.
  75812. */
  75813. dispose(): void;
  75814. private _handleDataAvailable;
  75815. private _handleError;
  75816. private _handleStop;
  75817. }
  75818. }
  75819. declare module "babylonjs/Misc/screenshotTools" {
  75820. import { Camera } from "babylonjs/Cameras/camera";
  75821. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  75822. import { Engine } from "babylonjs/Engines/engine";
  75823. /**
  75824. * Class containing a set of static utilities functions for screenshots
  75825. */
  75826. export class ScreenshotTools {
  75827. /**
  75828. * Captures a screenshot of the current rendering
  75829. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  75830. * @param engine defines the rendering engine
  75831. * @param camera defines the source camera
  75832. * @param size This parameter can be set to a single number or to an object with the
  75833. * following (optional) properties: precision, width, height. If a single number is passed,
  75834. * it will be used for both width and height. If an object is passed, the screenshot size
  75835. * will be derived from the parameters. The precision property is a multiplier allowing
  75836. * rendering at a higher or lower resolution
  75837. * @param successCallback defines the callback receives a single parameter which contains the
  75838. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  75839. * src parameter of an <img> to display it
  75840. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  75841. * Check your browser for supported MIME types
  75842. */
  75843. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  75844. /**
  75845. * Captures a screenshot of the current rendering
  75846. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  75847. * @param engine defines the rendering engine
  75848. * @param camera defines the source camera
  75849. * @param size This parameter can be set to a single number or to an object with the
  75850. * following (optional) properties: precision, width, height. If a single number is passed,
  75851. * it will be used for both width and height. If an object is passed, the screenshot size
  75852. * will be derived from the parameters. The precision property is a multiplier allowing
  75853. * rendering at a higher or lower resolution
  75854. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  75855. * Check your browser for supported MIME types
  75856. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  75857. * to the src parameter of an <img> to display it
  75858. */
  75859. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  75860. /**
  75861. * Generates an image screenshot from the specified camera.
  75862. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  75863. * @param engine The engine to use for rendering
  75864. * @param camera The camera to use for rendering
  75865. * @param size This parameter can be set to a single number or to an object with the
  75866. * following (optional) properties: precision, width, height. If a single number is passed,
  75867. * it will be used for both width and height. If an object is passed, the screenshot size
  75868. * will be derived from the parameters. The precision property is a multiplier allowing
  75869. * rendering at a higher or lower resolution
  75870. * @param successCallback The callback receives a single parameter which contains the
  75871. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  75872. * src parameter of an <img> to display it
  75873. * @param mimeType The MIME type of the screenshot image (default: image/png).
  75874. * Check your browser for supported MIME types
  75875. * @param samples Texture samples (default: 1)
  75876. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  75877. * @param fileName A name for for the downloaded file.
  75878. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  75879. */
  75880. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  75881. /**
  75882. * Generates an image screenshot from the specified camera.
  75883. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  75884. * @param engine The engine to use for rendering
  75885. * @param camera The camera to use for rendering
  75886. * @param size This parameter can be set to a single number or to an object with the
  75887. * following (optional) properties: precision, width, height. If a single number is passed,
  75888. * it will be used for both width and height. If an object is passed, the screenshot size
  75889. * will be derived from the parameters. The precision property is a multiplier allowing
  75890. * rendering at a higher or lower resolution
  75891. * @param mimeType The MIME type of the screenshot image (default: image/png).
  75892. * Check your browser for supported MIME types
  75893. * @param samples Texture samples (default: 1)
  75894. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  75895. * @param fileName A name for for the downloaded file.
  75896. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  75897. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  75898. * to the src parameter of an <img> to display it
  75899. */
  75900. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  75901. /**
  75902. * Gets height and width for screenshot size
  75903. * @private
  75904. */
  75905. private static _getScreenshotSize;
  75906. }
  75907. }
  75908. declare module "babylonjs/Misc/dataReader" {
  75909. /**
  75910. * Interface for a data buffer
  75911. */
  75912. export interface IDataBuffer {
  75913. /**
  75914. * Reads bytes from the data buffer.
  75915. * @param byteOffset The byte offset to read
  75916. * @param byteLength The byte length to read
  75917. * @returns A promise that resolves when the bytes are read
  75918. */
  75919. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  75920. /**
  75921. * The byte length of the buffer.
  75922. */
  75923. readonly byteLength: number;
  75924. }
  75925. /**
  75926. * Utility class for reading from a data buffer
  75927. */
  75928. export class DataReader {
  75929. /**
  75930. * The data buffer associated with this data reader.
  75931. */
  75932. readonly buffer: IDataBuffer;
  75933. /**
  75934. * The current byte offset from the beginning of the data buffer.
  75935. */
  75936. byteOffset: number;
  75937. private _dataView;
  75938. private _dataByteOffset;
  75939. /**
  75940. * Constructor
  75941. * @param buffer The buffer to read
  75942. */
  75943. constructor(buffer: IDataBuffer);
  75944. /**
  75945. * Loads the given byte length.
  75946. * @param byteLength The byte length to load
  75947. * @returns A promise that resolves when the load is complete
  75948. */
  75949. loadAsync(byteLength: number): Promise<void>;
  75950. /**
  75951. * Read a unsigned 32-bit integer from the currently loaded data range.
  75952. * @returns The 32-bit integer read
  75953. */
  75954. readUint32(): number;
  75955. /**
  75956. * Read a byte array from the currently loaded data range.
  75957. * @param byteLength The byte length to read
  75958. * @returns The byte array read
  75959. */
  75960. readUint8Array(byteLength: number): Uint8Array;
  75961. /**
  75962. * Read a string from the currently loaded data range.
  75963. * @param byteLength The byte length to read
  75964. * @returns The string read
  75965. */
  75966. readString(byteLength: number): string;
  75967. /**
  75968. * Skips the given byte length the currently loaded data range.
  75969. * @param byteLength The byte length to skip
  75970. */
  75971. skipBytes(byteLength: number): void;
  75972. }
  75973. }
  75974. declare module "babylonjs/Misc/dataStorage" {
  75975. /**
  75976. * Class for storing data to local storage if available or in-memory storage otherwise
  75977. */
  75978. export class DataStorage {
  75979. private static _Storage;
  75980. private static _GetStorage;
  75981. /**
  75982. * Reads a string from the data storage
  75983. * @param key The key to read
  75984. * @param defaultValue The value if the key doesn't exist
  75985. * @returns The string value
  75986. */
  75987. static ReadString(key: string, defaultValue: string): string;
  75988. /**
  75989. * Writes a string to the data storage
  75990. * @param key The key to write
  75991. * @param value The value to write
  75992. */
  75993. static WriteString(key: string, value: string): void;
  75994. /**
  75995. * Reads a boolean from the data storage
  75996. * @param key The key to read
  75997. * @param defaultValue The value if the key doesn't exist
  75998. * @returns The boolean value
  75999. */
  76000. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  76001. /**
  76002. * Writes a boolean to the data storage
  76003. * @param key The key to write
  76004. * @param value The value to write
  76005. */
  76006. static WriteBoolean(key: string, value: boolean): void;
  76007. /**
  76008. * Reads a number from the data storage
  76009. * @param key The key to read
  76010. * @param defaultValue The value if the key doesn't exist
  76011. * @returns The number value
  76012. */
  76013. static ReadNumber(key: string, defaultValue: number): number;
  76014. /**
  76015. * Writes a number to the data storage
  76016. * @param key The key to write
  76017. * @param value The value to write
  76018. */
  76019. static WriteNumber(key: string, value: number): void;
  76020. }
  76021. }
  76022. declare module "babylonjs/Misc/index" {
  76023. export * from "babylonjs/Misc/andOrNotEvaluator";
  76024. export * from "babylonjs/Misc/assetsManager";
  76025. export * from "babylonjs/Misc/basis";
  76026. export * from "babylonjs/Misc/dds";
  76027. export * from "babylonjs/Misc/decorators";
  76028. export * from "babylonjs/Misc/deferred";
  76029. export * from "babylonjs/Misc/environmentTextureTools";
  76030. export * from "babylonjs/Misc/meshExploder";
  76031. export * from "babylonjs/Misc/filesInput";
  76032. export * from "babylonjs/Misc/HighDynamicRange/index";
  76033. export * from "babylonjs/Misc/khronosTextureContainer";
  76034. export * from "babylonjs/Misc/observable";
  76035. export * from "babylonjs/Misc/performanceMonitor";
  76036. export * from "babylonjs/Misc/promise";
  76037. export * from "babylonjs/Misc/sceneOptimizer";
  76038. export * from "babylonjs/Misc/sceneSerializer";
  76039. export * from "babylonjs/Misc/smartArray";
  76040. export * from "babylonjs/Misc/stringDictionary";
  76041. export * from "babylonjs/Misc/tags";
  76042. export * from "babylonjs/Misc/textureTools";
  76043. export * from "babylonjs/Misc/tga";
  76044. export * from "babylonjs/Misc/tools";
  76045. export * from "babylonjs/Misc/videoRecorder";
  76046. export * from "babylonjs/Misc/virtualJoystick";
  76047. export * from "babylonjs/Misc/workerPool";
  76048. export * from "babylonjs/Misc/logger";
  76049. export * from "babylonjs/Misc/typeStore";
  76050. export * from "babylonjs/Misc/filesInputStore";
  76051. export * from "babylonjs/Misc/deepCopier";
  76052. export * from "babylonjs/Misc/pivotTools";
  76053. export * from "babylonjs/Misc/precisionDate";
  76054. export * from "babylonjs/Misc/screenshotTools";
  76055. export * from "babylonjs/Misc/typeStore";
  76056. export * from "babylonjs/Misc/webRequest";
  76057. export * from "babylonjs/Misc/iInspectable";
  76058. export * from "babylonjs/Misc/brdfTextureTools";
  76059. export * from "babylonjs/Misc/rgbdTextureTools";
  76060. export * from "babylonjs/Misc/gradients";
  76061. export * from "babylonjs/Misc/perfCounter";
  76062. export * from "babylonjs/Misc/fileRequest";
  76063. export * from "babylonjs/Misc/customAnimationFrameRequester";
  76064. export * from "babylonjs/Misc/retryStrategy";
  76065. export * from "babylonjs/Misc/interfaces/screenshotSize";
  76066. export * from "babylonjs/Misc/canvasGenerator";
  76067. export * from "babylonjs/Misc/fileTools";
  76068. export * from "babylonjs/Misc/stringTools";
  76069. export * from "babylonjs/Misc/dataReader";
  76070. export * from "babylonjs/Misc/minMaxReducer";
  76071. export * from "babylonjs/Misc/depthReducer";
  76072. export * from "babylonjs/Misc/dataStorage";
  76073. }
  76074. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  76075. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  76076. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  76077. import { Observable } from "babylonjs/Misc/observable";
  76078. import { Matrix } from "babylonjs/Maths/math.vector";
  76079. import { TransformNode } from "babylonjs/Meshes/transformNode";
  76080. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  76081. /**
  76082. * An interface for all Hit test features
  76083. */
  76084. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  76085. /**
  76086. * Triggered when new babylon (transformed) hit test results are available
  76087. */
  76088. onHitTestResultObservable: Observable<T[]>;
  76089. }
  76090. /**
  76091. * Options used for hit testing
  76092. */
  76093. export interface IWebXRLegacyHitTestOptions {
  76094. /**
  76095. * Only test when user interacted with the scene. Default - hit test every frame
  76096. */
  76097. testOnPointerDownOnly?: boolean;
  76098. /**
  76099. * The node to use to transform the local results to world coordinates
  76100. */
  76101. worldParentNode?: TransformNode;
  76102. }
  76103. /**
  76104. * Interface defining the babylon result of raycasting/hit-test
  76105. */
  76106. export interface IWebXRLegacyHitResult {
  76107. /**
  76108. * Transformation matrix that can be applied to a node that will put it in the hit point location
  76109. */
  76110. transformationMatrix: Matrix;
  76111. /**
  76112. * The native hit test result
  76113. */
  76114. xrHitResult: XRHitResult | XRHitTestResult;
  76115. }
  76116. /**
  76117. * The currently-working hit-test module.
  76118. * Hit test (or Ray-casting) is used to interact with the real world.
  76119. * For further information read here - https://github.com/immersive-web/hit-test
  76120. */
  76121. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  76122. /**
  76123. * options to use when constructing this feature
  76124. */
  76125. readonly options: IWebXRLegacyHitTestOptions;
  76126. private _direction;
  76127. private _mat;
  76128. private _onSelectEnabled;
  76129. private _origin;
  76130. /**
  76131. * The module's name
  76132. */
  76133. static readonly Name: string;
  76134. /**
  76135. * The (Babylon) version of this module.
  76136. * This is an integer representing the implementation version.
  76137. * This number does not correspond to the WebXR specs version
  76138. */
  76139. static readonly Version: number;
  76140. /**
  76141. * Populated with the last native XR Hit Results
  76142. */
  76143. lastNativeXRHitResults: XRHitResult[];
  76144. /**
  76145. * Triggered when new babylon (transformed) hit test results are available
  76146. */
  76147. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  76148. /**
  76149. * Creates a new instance of the (legacy version) hit test feature
  76150. * @param _xrSessionManager an instance of WebXRSessionManager
  76151. * @param options options to use when constructing this feature
  76152. */
  76153. constructor(_xrSessionManager: WebXRSessionManager,
  76154. /**
  76155. * options to use when constructing this feature
  76156. */
  76157. options?: IWebXRLegacyHitTestOptions);
  76158. /**
  76159. * execute a hit test with an XR Ray
  76160. *
  76161. * @param xrSession a native xrSession that will execute this hit test
  76162. * @param xrRay the ray (position and direction) to use for ray-casting
  76163. * @param referenceSpace native XR reference space to use for the hit-test
  76164. * @param filter filter function that will filter the results
  76165. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  76166. */
  76167. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  76168. /**
  76169. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  76170. * @param event the (select) event to use to select with
  76171. * @param referenceSpace the reference space to use for this hit test
  76172. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  76173. */
  76174. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  76175. /**
  76176. * attach this feature
  76177. * Will usually be called by the features manager
  76178. *
  76179. * @returns true if successful.
  76180. */
  76181. attach(): boolean;
  76182. /**
  76183. * detach this feature.
  76184. * Will usually be called by the features manager
  76185. *
  76186. * @returns true if successful.
  76187. */
  76188. detach(): boolean;
  76189. /**
  76190. * Dispose this feature and all of the resources attached
  76191. */
  76192. dispose(): void;
  76193. protected _onXRFrame(frame: XRFrame): void;
  76194. private _onHitTestResults;
  76195. private _onSelect;
  76196. }
  76197. }
  76198. declare module "babylonjs/XR/features/WebXRHitTest" {
  76199. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  76200. import { Observable } from "babylonjs/Misc/observable";
  76201. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  76202. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  76203. import { IWebXRLegacyHitTestOptions, IWebXRLegacyHitResult, IWebXRHitTestFeature } from "babylonjs/XR/features/WebXRHitTestLegacy";
  76204. /**
  76205. * Options used for hit testing (version 2)
  76206. */
  76207. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  76208. /**
  76209. * Do not create a permanent hit test. Will usually be used when only
  76210. * transient inputs are needed.
  76211. */
  76212. disablePermanentHitTest?: boolean;
  76213. /**
  76214. * Enable transient (for example touch-based) hit test inspections
  76215. */
  76216. enableTransientHitTest?: boolean;
  76217. /**
  76218. * Offset ray for the permanent hit test
  76219. */
  76220. offsetRay?: Vector3;
  76221. /**
  76222. * Offset ray for the transient hit test
  76223. */
  76224. transientOffsetRay?: Vector3;
  76225. /**
  76226. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  76227. */
  76228. useReferenceSpace?: boolean;
  76229. }
  76230. /**
  76231. * Interface defining the babylon result of hit-test
  76232. */
  76233. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  76234. /**
  76235. * The input source that generated this hit test (if transient)
  76236. */
  76237. inputSource?: XRInputSource;
  76238. /**
  76239. * Is this a transient hit test
  76240. */
  76241. isTransient?: boolean;
  76242. /**
  76243. * Position of the hit test result
  76244. */
  76245. position: Vector3;
  76246. /**
  76247. * Rotation of the hit test result
  76248. */
  76249. rotationQuaternion: Quaternion;
  76250. /**
  76251. * The native hit test result
  76252. */
  76253. xrHitResult: XRHitTestResult;
  76254. }
  76255. /**
  76256. * The currently-working hit-test module.
  76257. * Hit test (or Ray-casting) is used to interact with the real world.
  76258. * For further information read here - https://github.com/immersive-web/hit-test
  76259. *
  76260. * Tested on chrome (mobile) 80.
  76261. */
  76262. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  76263. /**
  76264. * options to use when constructing this feature
  76265. */
  76266. readonly options: IWebXRHitTestOptions;
  76267. private _tmpMat;
  76268. private _tmpPos;
  76269. private _tmpQuat;
  76270. private _transientXrHitTestSource;
  76271. private _xrHitTestSource;
  76272. private initHitTestSource;
  76273. /**
  76274. * The module's name
  76275. */
  76276. static readonly Name: string;
  76277. /**
  76278. * The (Babylon) version of this module.
  76279. * This is an integer representing the implementation version.
  76280. * This number does not correspond to the WebXR specs version
  76281. */
  76282. static readonly Version: number;
  76283. /**
  76284. * When set to true, each hit test will have its own position/rotation objects
  76285. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  76286. * the developers will clone them or copy them as they see fit.
  76287. */
  76288. autoCloneTransformation: boolean;
  76289. /**
  76290. * Triggered when new babylon (transformed) hit test results are available
  76291. */
  76292. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  76293. /**
  76294. * Use this to temporarily pause hit test checks.
  76295. */
  76296. paused: boolean;
  76297. /**
  76298. * Creates a new instance of the hit test feature
  76299. * @param _xrSessionManager an instance of WebXRSessionManager
  76300. * @param options options to use when constructing this feature
  76301. */
  76302. constructor(_xrSessionManager: WebXRSessionManager,
  76303. /**
  76304. * options to use when constructing this feature
  76305. */
  76306. options?: IWebXRHitTestOptions);
  76307. /**
  76308. * attach this feature
  76309. * Will usually be called by the features manager
  76310. *
  76311. * @returns true if successful.
  76312. */
  76313. attach(): boolean;
  76314. /**
  76315. * detach this feature.
  76316. * Will usually be called by the features manager
  76317. *
  76318. * @returns true if successful.
  76319. */
  76320. detach(): boolean;
  76321. /**
  76322. * Dispose this feature and all of the resources attached
  76323. */
  76324. dispose(): void;
  76325. protected _onXRFrame(frame: XRFrame): void;
  76326. private _processWebXRHitTestResult;
  76327. }
  76328. }
  76329. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  76330. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  76331. import { Observable } from "babylonjs/Misc/observable";
  76332. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  76333. import { TransformNode } from "babylonjs/Meshes/transformNode";
  76334. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  76335. import { IWebXRHitResult } from "babylonjs/XR/features/WebXRHitTest";
  76336. /**
  76337. * Configuration options of the anchor system
  76338. */
  76339. export interface IWebXRAnchorSystemOptions {
  76340. /**
  76341. * a node that will be used to convert local to world coordinates
  76342. */
  76343. worldParentNode?: TransformNode;
  76344. /**
  76345. * If set to true a reference of the created anchors will be kept until the next session starts
  76346. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  76347. */
  76348. doNotRemoveAnchorsOnSessionEnded?: boolean;
  76349. }
  76350. /**
  76351. * A babylon container for an XR Anchor
  76352. */
  76353. export interface IWebXRAnchor {
  76354. /**
  76355. * A babylon-assigned ID for this anchor
  76356. */
  76357. id: number;
  76358. /**
  76359. * Transformation matrix to apply to an object attached to this anchor
  76360. */
  76361. transformationMatrix: Matrix;
  76362. /**
  76363. * The native anchor object
  76364. */
  76365. xrAnchor: XRAnchor;
  76366. /**
  76367. * if defined, this object will be constantly updated by the anchor's position and rotation
  76368. */
  76369. attachedNode?: TransformNode;
  76370. }
  76371. /**
  76372. * An implementation of the anchor system for WebXR.
  76373. * For further information see https://github.com/immersive-web/anchors/
  76374. */
  76375. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  76376. private _options;
  76377. private _lastFrameDetected;
  76378. private _trackedAnchors;
  76379. private _referenceSpaceForFrameAnchors;
  76380. private _futureAnchors;
  76381. /**
  76382. * The module's name
  76383. */
  76384. static readonly Name: string;
  76385. /**
  76386. * The (Babylon) version of this module.
  76387. * This is an integer representing the implementation version.
  76388. * This number does not correspond to the WebXR specs version
  76389. */
  76390. static readonly Version: number;
  76391. /**
  76392. * Observers registered here will be executed when a new anchor was added to the session
  76393. */
  76394. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  76395. /**
  76396. * Observers registered here will be executed when an anchor was removed from the session
  76397. */
  76398. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  76399. /**
  76400. * Observers registered here will be executed when an existing anchor updates
  76401. * This can execute N times every frame
  76402. */
  76403. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  76404. /**
  76405. * Set the reference space to use for anchor creation, when not using a hit test.
  76406. * Will default to the session's reference space if not defined
  76407. */
  76408. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  76409. /**
  76410. * constructs a new anchor system
  76411. * @param _xrSessionManager an instance of WebXRSessionManager
  76412. * @param _options configuration object for this feature
  76413. */
  76414. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  76415. private _tmpVector;
  76416. private _tmpQuaternion;
  76417. private _populateTmpTransformation;
  76418. /**
  76419. * Create a new anchor point using a hit test result at a specific point in the scene
  76420. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  76421. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  76422. *
  76423. * @param hitTestResult The hit test result to use for this anchor creation
  76424. * @param position an optional position offset for this anchor
  76425. * @param rotationQuaternion an optional rotation offset for this anchor
  76426. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  76427. */
  76428. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  76429. /**
  76430. * Add a new anchor at a specific position and rotation
  76431. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  76432. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  76433. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  76434. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  76435. *
  76436. * @param position the position in which to add an anchor
  76437. * @param rotationQuaternion an optional rotation for the anchor transformation
  76438. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  76439. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  76440. */
  76441. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  76442. /**
  76443. * detach this feature.
  76444. * Will usually be called by the features manager
  76445. *
  76446. * @returns true if successful.
  76447. */
  76448. detach(): boolean;
  76449. /**
  76450. * Dispose this feature and all of the resources attached
  76451. */
  76452. dispose(): void;
  76453. protected _onXRFrame(frame: XRFrame): void;
  76454. /**
  76455. * avoiding using Array.find for global support.
  76456. * @param xrAnchor the plane to find in the array
  76457. */
  76458. private _findIndexInAnchorArray;
  76459. private _updateAnchorWithXRFrame;
  76460. private _createAnchorAtTransformation;
  76461. }
  76462. }
  76463. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  76464. import { TransformNode } from "babylonjs/Meshes/transformNode";
  76465. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  76466. import { Observable } from "babylonjs/Misc/observable";
  76467. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  76468. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  76469. /**
  76470. * Options used in the plane detector module
  76471. */
  76472. export interface IWebXRPlaneDetectorOptions {
  76473. /**
  76474. * The node to use to transform the local results to world coordinates
  76475. */
  76476. worldParentNode?: TransformNode;
  76477. /**
  76478. * If set to true a reference of the created planes will be kept until the next session starts
  76479. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  76480. */
  76481. doNotRemovePlanesOnSessionEnded?: boolean;
  76482. }
  76483. /**
  76484. * A babylon interface for a WebXR plane.
  76485. * A Plane is actually a polygon, built from N points in space
  76486. *
  76487. * Supported in chrome 79, not supported in canary 81 ATM
  76488. */
  76489. export interface IWebXRPlane {
  76490. /**
  76491. * a babylon-assigned ID for this polygon
  76492. */
  76493. id: number;
  76494. /**
  76495. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  76496. */
  76497. polygonDefinition: Array<Vector3>;
  76498. /**
  76499. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  76500. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  76501. */
  76502. transformationMatrix: Matrix;
  76503. /**
  76504. * the native xr-plane object
  76505. */
  76506. xrPlane: XRPlane;
  76507. }
  76508. /**
  76509. * The plane detector is used to detect planes in the real world when in AR
  76510. * For more information see https://github.com/immersive-web/real-world-geometry/
  76511. */
  76512. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  76513. private _options;
  76514. private _detectedPlanes;
  76515. private _enabled;
  76516. private _lastFrameDetected;
  76517. /**
  76518. * The module's name
  76519. */
  76520. static readonly Name: string;
  76521. /**
  76522. * The (Babylon) version of this module.
  76523. * This is an integer representing the implementation version.
  76524. * This number does not correspond to the WebXR specs version
  76525. */
  76526. static readonly Version: number;
  76527. /**
  76528. * Observers registered here will be executed when a new plane was added to the session
  76529. */
  76530. onPlaneAddedObservable: Observable<IWebXRPlane>;
  76531. /**
  76532. * Observers registered here will be executed when a plane is no longer detected in the session
  76533. */
  76534. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  76535. /**
  76536. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  76537. * This can execute N times every frame
  76538. */
  76539. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  76540. /**
  76541. * construct a new Plane Detector
  76542. * @param _xrSessionManager an instance of xr Session manager
  76543. * @param _options configuration to use when constructing this feature
  76544. */
  76545. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  76546. /**
  76547. * detach this feature.
  76548. * Will usually be called by the features manager
  76549. *
  76550. * @returns true if successful.
  76551. */
  76552. detach(): boolean;
  76553. /**
  76554. * Dispose this feature and all of the resources attached
  76555. */
  76556. dispose(): void;
  76557. protected _onXRFrame(frame: XRFrame): void;
  76558. private _init;
  76559. private _updatePlaneWithXRPlane;
  76560. /**
  76561. * avoiding using Array.find for global support.
  76562. * @param xrPlane the plane to find in the array
  76563. */
  76564. private findIndexInPlaneArray;
  76565. }
  76566. }
  76567. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  76568. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  76569. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  76570. import { Observable } from "babylonjs/Misc/observable";
  76571. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  76572. /**
  76573. * Options interface for the background remover plugin
  76574. */
  76575. export interface IWebXRBackgroundRemoverOptions {
  76576. /**
  76577. * Further background meshes to disable when entering AR
  76578. */
  76579. backgroundMeshes?: AbstractMesh[];
  76580. /**
  76581. * flags to configure the removal of the environment helper.
  76582. * If not set, the entire background will be removed. If set, flags should be set as well.
  76583. */
  76584. environmentHelperRemovalFlags?: {
  76585. /**
  76586. * Should the skybox be removed (default false)
  76587. */
  76588. skyBox?: boolean;
  76589. /**
  76590. * Should the ground be removed (default false)
  76591. */
  76592. ground?: boolean;
  76593. };
  76594. /**
  76595. * don't disable the environment helper
  76596. */
  76597. ignoreEnvironmentHelper?: boolean;
  76598. }
  76599. /**
  76600. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  76601. */
  76602. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  76603. /**
  76604. * read-only options to be used in this module
  76605. */
  76606. readonly options: IWebXRBackgroundRemoverOptions;
  76607. /**
  76608. * The module's name
  76609. */
  76610. static readonly Name: string;
  76611. /**
  76612. * The (Babylon) version of this module.
  76613. * This is an integer representing the implementation version.
  76614. * This number does not correspond to the WebXR specs version
  76615. */
  76616. static readonly Version: number;
  76617. /**
  76618. * registered observers will be triggered when the background state changes
  76619. */
  76620. onBackgroundStateChangedObservable: Observable<boolean>;
  76621. /**
  76622. * constructs a new background remover module
  76623. * @param _xrSessionManager the session manager for this module
  76624. * @param options read-only options to be used in this module
  76625. */
  76626. constructor(_xrSessionManager: WebXRSessionManager,
  76627. /**
  76628. * read-only options to be used in this module
  76629. */
  76630. options?: IWebXRBackgroundRemoverOptions);
  76631. /**
  76632. * attach this feature
  76633. * Will usually be called by the features manager
  76634. *
  76635. * @returns true if successful.
  76636. */
  76637. attach(): boolean;
  76638. /**
  76639. * detach this feature.
  76640. * Will usually be called by the features manager
  76641. *
  76642. * @returns true if successful.
  76643. */
  76644. detach(): boolean;
  76645. /**
  76646. * Dispose this feature and all of the resources attached
  76647. */
  76648. dispose(): void;
  76649. protected _onXRFrame(_xrFrame: XRFrame): void;
  76650. private _setBackgroundState;
  76651. }
  76652. }
  76653. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  76654. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  76655. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  76656. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  76657. import { WebXRInput } from "babylonjs/XR/webXRInput";
  76658. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  76659. import { Nullable } from "babylonjs/types";
  76660. /**
  76661. * Options for the controller physics feature
  76662. */
  76663. export class IWebXRControllerPhysicsOptions {
  76664. /**
  76665. * Should the headset get its own impostor
  76666. */
  76667. enableHeadsetImpostor?: boolean;
  76668. /**
  76669. * Optional parameters for the headset impostor
  76670. */
  76671. headsetImpostorParams?: {
  76672. /**
  76673. * The type of impostor to create. Default is sphere
  76674. */
  76675. impostorType: number;
  76676. /**
  76677. * the size of the impostor. Defaults to 10cm
  76678. */
  76679. impostorSize?: number | {
  76680. width: number;
  76681. height: number;
  76682. depth: number;
  76683. };
  76684. /**
  76685. * Friction definitions
  76686. */
  76687. friction?: number;
  76688. /**
  76689. * Restitution
  76690. */
  76691. restitution?: number;
  76692. };
  76693. /**
  76694. * The physics properties of the future impostors
  76695. */
  76696. physicsProperties?: {
  76697. /**
  76698. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  76699. * Note that this requires a physics engine that supports mesh impostors!
  76700. */
  76701. useControllerMesh?: boolean;
  76702. /**
  76703. * The type of impostor to create. Default is sphere
  76704. */
  76705. impostorType?: number;
  76706. /**
  76707. * the size of the impostor. Defaults to 10cm
  76708. */
  76709. impostorSize?: number | {
  76710. width: number;
  76711. height: number;
  76712. depth: number;
  76713. };
  76714. /**
  76715. * Friction definitions
  76716. */
  76717. friction?: number;
  76718. /**
  76719. * Restitution
  76720. */
  76721. restitution?: number;
  76722. };
  76723. /**
  76724. * the xr input to use with this pointer selection
  76725. */
  76726. xrInput: WebXRInput;
  76727. }
  76728. /**
  76729. * Add physics impostor to your webxr controllers,
  76730. * including naive calculation of their linear and angular velocity
  76731. */
  76732. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  76733. private readonly _options;
  76734. private _attachController;
  76735. private _controllers;
  76736. private _debugMode;
  76737. private _delta;
  76738. private _headsetImpostor?;
  76739. private _headsetMesh?;
  76740. private _lastTimestamp;
  76741. private _tmpQuaternion;
  76742. private _tmpVector;
  76743. /**
  76744. * The module's name
  76745. */
  76746. static readonly Name: string;
  76747. /**
  76748. * The (Babylon) version of this module.
  76749. * This is an integer representing the implementation version.
  76750. * This number does not correspond to the webxr specs version
  76751. */
  76752. static readonly Version: number;
  76753. /**
  76754. * Construct a new Controller Physics Feature
  76755. * @param _xrSessionManager the corresponding xr session manager
  76756. * @param _options options to create this feature with
  76757. */
  76758. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  76759. /**
  76760. * @hidden
  76761. * enable debugging - will show console outputs and the impostor mesh
  76762. */
  76763. _enablePhysicsDebug(): void;
  76764. /**
  76765. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  76766. * @param xrController the controller to add
  76767. */
  76768. addController(xrController: WebXRInputSource): void;
  76769. /**
  76770. * attach this feature
  76771. * Will usually be called by the features manager
  76772. *
  76773. * @returns true if successful.
  76774. */
  76775. attach(): boolean;
  76776. /**
  76777. * detach this feature.
  76778. * Will usually be called by the features manager
  76779. *
  76780. * @returns true if successful.
  76781. */
  76782. detach(): boolean;
  76783. /**
  76784. * Get the headset impostor, if enabled
  76785. * @returns the impostor
  76786. */
  76787. getHeadsetImpostor(): PhysicsImpostor | undefined;
  76788. /**
  76789. * Get the physics impostor of a specific controller.
  76790. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  76791. * @param controller the controller or the controller id of which to get the impostor
  76792. * @returns the impostor or null
  76793. */
  76794. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  76795. /**
  76796. * Update the physics properties provided in the constructor
  76797. * @param newProperties the new properties object
  76798. */
  76799. setPhysicsProperties(newProperties: {
  76800. impostorType?: number;
  76801. impostorSize?: number | {
  76802. width: number;
  76803. height: number;
  76804. depth: number;
  76805. };
  76806. friction?: number;
  76807. restitution?: number;
  76808. }): void;
  76809. protected _onXRFrame(_xrFrame: any): void;
  76810. private _detachController;
  76811. }
  76812. }
  76813. declare module "babylonjs/XR/features/index" {
  76814. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  76815. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  76816. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  76817. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  76818. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  76819. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  76820. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  76821. export * from "babylonjs/XR/features/WebXRHitTest";
  76822. }
  76823. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  76824. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  76825. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  76826. import { Scene } from "babylonjs/scene";
  76827. /**
  76828. * The motion controller class for all microsoft mixed reality controllers
  76829. */
  76830. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  76831. protected readonly _mapping: {
  76832. defaultButton: {
  76833. valueNodeName: string;
  76834. unpressedNodeName: string;
  76835. pressedNodeName: string;
  76836. };
  76837. defaultAxis: {
  76838. valueNodeName: string;
  76839. minNodeName: string;
  76840. maxNodeName: string;
  76841. };
  76842. buttons: {
  76843. "xr-standard-trigger": {
  76844. rootNodeName: string;
  76845. componentProperty: string;
  76846. states: string[];
  76847. };
  76848. "xr-standard-squeeze": {
  76849. rootNodeName: string;
  76850. componentProperty: string;
  76851. states: string[];
  76852. };
  76853. "xr-standard-touchpad": {
  76854. rootNodeName: string;
  76855. labelAnchorNodeName: string;
  76856. touchPointNodeName: string;
  76857. };
  76858. "xr-standard-thumbstick": {
  76859. rootNodeName: string;
  76860. componentProperty: string;
  76861. states: string[];
  76862. };
  76863. };
  76864. axes: {
  76865. "xr-standard-touchpad": {
  76866. "x-axis": {
  76867. rootNodeName: string;
  76868. };
  76869. "y-axis": {
  76870. rootNodeName: string;
  76871. };
  76872. };
  76873. "xr-standard-thumbstick": {
  76874. "x-axis": {
  76875. rootNodeName: string;
  76876. };
  76877. "y-axis": {
  76878. rootNodeName: string;
  76879. };
  76880. };
  76881. };
  76882. };
  76883. /**
  76884. * The base url used to load the left and right controller models
  76885. */
  76886. static MODEL_BASE_URL: string;
  76887. /**
  76888. * The name of the left controller model file
  76889. */
  76890. static MODEL_LEFT_FILENAME: string;
  76891. /**
  76892. * The name of the right controller model file
  76893. */
  76894. static MODEL_RIGHT_FILENAME: string;
  76895. profileId: string;
  76896. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  76897. protected _getFilenameAndPath(): {
  76898. filename: string;
  76899. path: string;
  76900. };
  76901. protected _getModelLoadingConstraints(): boolean;
  76902. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  76903. protected _setRootMesh(meshes: AbstractMesh[]): void;
  76904. protected _updateModel(): void;
  76905. }
  76906. }
  76907. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  76908. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  76909. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  76910. import { Scene } from "babylonjs/scene";
  76911. /**
  76912. * The motion controller class for oculus touch (quest, rift).
  76913. * This class supports legacy mapping as well the standard xr mapping
  76914. */
  76915. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  76916. private _forceLegacyControllers;
  76917. private _modelRootNode;
  76918. /**
  76919. * The base url used to load the left and right controller models
  76920. */
  76921. static MODEL_BASE_URL: string;
  76922. /**
  76923. * The name of the left controller model file
  76924. */
  76925. static MODEL_LEFT_FILENAME: string;
  76926. /**
  76927. * The name of the right controller model file
  76928. */
  76929. static MODEL_RIGHT_FILENAME: string;
  76930. /**
  76931. * Base Url for the Quest controller model.
  76932. */
  76933. static QUEST_MODEL_BASE_URL: string;
  76934. profileId: string;
  76935. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  76936. protected _getFilenameAndPath(): {
  76937. filename: string;
  76938. path: string;
  76939. };
  76940. protected _getModelLoadingConstraints(): boolean;
  76941. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  76942. protected _setRootMesh(meshes: AbstractMesh[]): void;
  76943. protected _updateModel(): void;
  76944. /**
  76945. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  76946. * between the touch and touch 2.
  76947. */
  76948. private _isQuest;
  76949. }
  76950. }
  76951. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  76952. import { IMinimalMotionControllerObject, MotionControllerHandedness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  76953. import { Scene } from "babylonjs/scene";
  76954. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  76955. /**
  76956. * The motion controller class for the standard HTC-Vive controllers
  76957. */
  76958. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  76959. private _modelRootNode;
  76960. /**
  76961. * The base url used to load the left and right controller models
  76962. */
  76963. static MODEL_BASE_URL: string;
  76964. /**
  76965. * File name for the controller model.
  76966. */
  76967. static MODEL_FILENAME: string;
  76968. profileId: string;
  76969. /**
  76970. * Create a new Vive motion controller object
  76971. * @param scene the scene to use to create this controller
  76972. * @param gamepadObject the corresponding gamepad object
  76973. * @param handedness the handedness of the controller
  76974. */
  76975. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  76976. protected _getFilenameAndPath(): {
  76977. filename: string;
  76978. path: string;
  76979. };
  76980. protected _getModelLoadingConstraints(): boolean;
  76981. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  76982. protected _setRootMesh(meshes: AbstractMesh[]): void;
  76983. protected _updateModel(): void;
  76984. }
  76985. }
  76986. declare module "babylonjs/XR/motionController/index" {
  76987. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  76988. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  76989. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  76990. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  76991. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  76992. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  76993. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  76994. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  76995. }
  76996. declare module "babylonjs/XR/index" {
  76997. export * from "babylonjs/XR/webXRCamera";
  76998. export * from "babylonjs/XR/webXREnterExitUI";
  76999. export * from "babylonjs/XR/webXRExperienceHelper";
  77000. export * from "babylonjs/XR/webXRInput";
  77001. export * from "babylonjs/XR/webXRInputSource";
  77002. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  77003. export * from "babylonjs/XR/webXRTypes";
  77004. export * from "babylonjs/XR/webXRSessionManager";
  77005. export * from "babylonjs/XR/webXRDefaultExperience";
  77006. export * from "babylonjs/XR/webXRFeaturesManager";
  77007. export * from "babylonjs/XR/features/index";
  77008. export * from "babylonjs/XR/motionController/index";
  77009. }
  77010. declare module "babylonjs/index" {
  77011. export * from "babylonjs/abstractScene";
  77012. export * from "babylonjs/Actions/index";
  77013. export * from "babylonjs/Animations/index";
  77014. export * from "babylonjs/assetContainer";
  77015. export * from "babylonjs/Audio/index";
  77016. export * from "babylonjs/Behaviors/index";
  77017. export * from "babylonjs/Bones/index";
  77018. export * from "babylonjs/Cameras/index";
  77019. export * from "babylonjs/Collisions/index";
  77020. export * from "babylonjs/Culling/index";
  77021. export * from "babylonjs/Debug/index";
  77022. export * from "babylonjs/DeviceInput/index";
  77023. export * from "babylonjs/Engines/index";
  77024. export * from "babylonjs/Events/index";
  77025. export * from "babylonjs/Gamepads/index";
  77026. export * from "babylonjs/Gizmos/index";
  77027. export * from "babylonjs/Helpers/index";
  77028. export * from "babylonjs/Instrumentation/index";
  77029. export * from "babylonjs/Layers/index";
  77030. export * from "babylonjs/LensFlares/index";
  77031. export * from "babylonjs/Lights/index";
  77032. export * from "babylonjs/Loading/index";
  77033. export * from "babylonjs/Materials/index";
  77034. export * from "babylonjs/Maths/index";
  77035. export * from "babylonjs/Meshes/index";
  77036. export * from "babylonjs/Morph/index";
  77037. export * from "babylonjs/Navigation/index";
  77038. export * from "babylonjs/node";
  77039. export * from "babylonjs/Offline/index";
  77040. export * from "babylonjs/Particles/index";
  77041. export * from "babylonjs/Physics/index";
  77042. export * from "babylonjs/PostProcesses/index";
  77043. export * from "babylonjs/Probes/index";
  77044. export * from "babylonjs/Rendering/index";
  77045. export * from "babylonjs/scene";
  77046. export * from "babylonjs/sceneComponent";
  77047. export * from "babylonjs/Sprites/index";
  77048. export * from "babylonjs/States/index";
  77049. export * from "babylonjs/Misc/index";
  77050. export * from "babylonjs/XR/index";
  77051. export * from "babylonjs/types";
  77052. }
  77053. declare module "babylonjs/Animations/pathCursor" {
  77054. import { Vector3 } from "babylonjs/Maths/math.vector";
  77055. import { Path2 } from "babylonjs/Maths/math.path";
  77056. /**
  77057. * A cursor which tracks a point on a path
  77058. */
  77059. export class PathCursor {
  77060. private path;
  77061. /**
  77062. * Stores path cursor callbacks for when an onchange event is triggered
  77063. */
  77064. private _onchange;
  77065. /**
  77066. * The value of the path cursor
  77067. */
  77068. value: number;
  77069. /**
  77070. * The animation array of the path cursor
  77071. */
  77072. animations: Animation[];
  77073. /**
  77074. * Initializes the path cursor
  77075. * @param path The path to track
  77076. */
  77077. constructor(path: Path2);
  77078. /**
  77079. * Gets the cursor point on the path
  77080. * @returns A point on the path cursor at the cursor location
  77081. */
  77082. getPoint(): Vector3;
  77083. /**
  77084. * Moves the cursor ahead by the step amount
  77085. * @param step The amount to move the cursor forward
  77086. * @returns This path cursor
  77087. */
  77088. moveAhead(step?: number): PathCursor;
  77089. /**
  77090. * Moves the cursor behind by the step amount
  77091. * @param step The amount to move the cursor back
  77092. * @returns This path cursor
  77093. */
  77094. moveBack(step?: number): PathCursor;
  77095. /**
  77096. * Moves the cursor by the step amount
  77097. * If the step amount is greater than one, an exception is thrown
  77098. * @param step The amount to move the cursor
  77099. * @returns This path cursor
  77100. */
  77101. move(step: number): PathCursor;
  77102. /**
  77103. * Ensures that the value is limited between zero and one
  77104. * @returns This path cursor
  77105. */
  77106. private ensureLimits;
  77107. /**
  77108. * Runs onchange callbacks on change (used by the animation engine)
  77109. * @returns This path cursor
  77110. */
  77111. private raiseOnChange;
  77112. /**
  77113. * Executes a function on change
  77114. * @param f A path cursor onchange callback
  77115. * @returns This path cursor
  77116. */
  77117. onchange(f: (cursor: PathCursor) => void): PathCursor;
  77118. }
  77119. }
  77120. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  77121. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  77122. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  77123. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  77124. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  77125. }
  77126. declare module "babylonjs/Engines/Processors/Expressions/index" {
  77127. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  77128. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  77129. }
  77130. declare module "babylonjs/Engines/Processors/index" {
  77131. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  77132. export * from "babylonjs/Engines/Processors/Expressions/index";
  77133. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  77134. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  77135. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  77136. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  77137. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  77138. export * from "babylonjs/Engines/Processors/shaderProcessor";
  77139. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  77140. }
  77141. declare module "babylonjs/Legacy/legacy" {
  77142. import * as Babylon from "babylonjs/index";
  77143. export * from "babylonjs/index";
  77144. }
  77145. declare module "babylonjs/Shaders/blur.fragment" {
  77146. /** @hidden */
  77147. export var blurPixelShader: {
  77148. name: string;
  77149. shader: string;
  77150. };
  77151. }
  77152. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  77153. /** @hidden */
  77154. export var pointCloudVertexDeclaration: {
  77155. name: string;
  77156. shader: string;
  77157. };
  77158. }
  77159. declare module "babylonjs" {
  77160. export * from "babylonjs/Legacy/legacy";
  77161. }
  77162. declare module BABYLON {
  77163. /** Alias type for value that can be null */
  77164. export type Nullable<T> = T | null;
  77165. /**
  77166. * Alias type for number that are floats
  77167. * @ignorenaming
  77168. */
  77169. export type float = number;
  77170. /**
  77171. * Alias type for number that are doubles.
  77172. * @ignorenaming
  77173. */
  77174. export type double = number;
  77175. /**
  77176. * Alias type for number that are integer
  77177. * @ignorenaming
  77178. */
  77179. export type int = number;
  77180. /** Alias type for number array or Float32Array */
  77181. export type FloatArray = number[] | Float32Array;
  77182. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  77183. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  77184. /**
  77185. * Alias for types that can be used by a Buffer or VertexBuffer.
  77186. */
  77187. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  77188. /**
  77189. * Alias type for primitive types
  77190. * @ignorenaming
  77191. */
  77192. type Primitive = undefined | null | boolean | string | number | Function;
  77193. /**
  77194. * Type modifier to make all the properties of an object Readonly
  77195. */
  77196. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  77197. /**
  77198. * Type modifier to make all the properties of an object Readonly recursively
  77199. */
  77200. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  77201. /**
  77202. * Type modifier to make object properties readonly.
  77203. */
  77204. export type DeepImmutableObject<T> = {
  77205. readonly [K in keyof T]: DeepImmutable<T[K]>;
  77206. };
  77207. /** @hidden */
  77208. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  77209. }
  77210. }
  77211. declare module BABYLON {
  77212. /**
  77213. * A class serves as a medium between the observable and its observers
  77214. */
  77215. export class EventState {
  77216. /**
  77217. * Create a new EventState
  77218. * @param mask defines the mask associated with this state
  77219. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  77220. * @param target defines the original target of the state
  77221. * @param currentTarget defines the current target of the state
  77222. */
  77223. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  77224. /**
  77225. * Initialize the current event state
  77226. * @param mask defines the mask associated with this state
  77227. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  77228. * @param target defines the original target of the state
  77229. * @param currentTarget defines the current target of the state
  77230. * @returns the current event state
  77231. */
  77232. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  77233. /**
  77234. * An Observer can set this property to true to prevent subsequent observers of being notified
  77235. */
  77236. skipNextObservers: boolean;
  77237. /**
  77238. * Get the mask value that were used to trigger the event corresponding to this EventState object
  77239. */
  77240. mask: number;
  77241. /**
  77242. * The object that originally notified the event
  77243. */
  77244. target?: any;
  77245. /**
  77246. * The current object in the bubbling phase
  77247. */
  77248. currentTarget?: any;
  77249. /**
  77250. * This will be populated with the return value of the last function that was executed.
  77251. * If it is the first function in the callback chain it will be the event data.
  77252. */
  77253. lastReturnValue?: any;
  77254. }
  77255. /**
  77256. * Represent an Observer registered to a given Observable object.
  77257. */
  77258. export class Observer<T> {
  77259. /**
  77260. * Defines the callback to call when the observer is notified
  77261. */
  77262. callback: (eventData: T, eventState: EventState) => void;
  77263. /**
  77264. * Defines the mask of the observer (used to filter notifications)
  77265. */
  77266. mask: number;
  77267. /**
  77268. * Defines the current scope used to restore the JS context
  77269. */
  77270. scope: any;
  77271. /** @hidden */
  77272. _willBeUnregistered: boolean;
  77273. /**
  77274. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  77275. */
  77276. unregisterOnNextCall: boolean;
  77277. /**
  77278. * Creates a new observer
  77279. * @param callback defines the callback to call when the observer is notified
  77280. * @param mask defines the mask of the observer (used to filter notifications)
  77281. * @param scope defines the current scope used to restore the JS context
  77282. */
  77283. constructor(
  77284. /**
  77285. * Defines the callback to call when the observer is notified
  77286. */
  77287. callback: (eventData: T, eventState: EventState) => void,
  77288. /**
  77289. * Defines the mask of the observer (used to filter notifications)
  77290. */
  77291. mask: number,
  77292. /**
  77293. * Defines the current scope used to restore the JS context
  77294. */
  77295. scope?: any);
  77296. }
  77297. /**
  77298. * Represent a list of observers registered to multiple Observables object.
  77299. */
  77300. export class MultiObserver<T> {
  77301. private _observers;
  77302. private _observables;
  77303. /**
  77304. * Release associated resources
  77305. */
  77306. dispose(): void;
  77307. /**
  77308. * Raise a callback when one of the observable will notify
  77309. * @param observables defines a list of observables to watch
  77310. * @param callback defines the callback to call on notification
  77311. * @param mask defines the mask used to filter notifications
  77312. * @param scope defines the current scope used to restore the JS context
  77313. * @returns the new MultiObserver
  77314. */
  77315. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  77316. }
  77317. /**
  77318. * The Observable class is a simple implementation of the Observable pattern.
  77319. *
  77320. * 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.
  77321. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  77322. * 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).
  77323. * 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.
  77324. */
  77325. export class Observable<T> {
  77326. private _observers;
  77327. private _eventState;
  77328. private _onObserverAdded;
  77329. /**
  77330. * Gets the list of observers
  77331. */
  77332. get observers(): Array<Observer<T>>;
  77333. /**
  77334. * Creates a new observable
  77335. * @param onObserverAdded defines a callback to call when a new observer is added
  77336. */
  77337. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  77338. /**
  77339. * Create a new Observer with the specified callback
  77340. * @param callback the callback that will be executed for that Observer
  77341. * @param mask the mask used to filter observers
  77342. * @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.
  77343. * @param scope optional scope for the callback to be called from
  77344. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  77345. * @returns the new observer created for the callback
  77346. */
  77347. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  77348. /**
  77349. * Create a new Observer with the specified callback and unregisters after the next notification
  77350. * @param callback the callback that will be executed for that Observer
  77351. * @returns the new observer created for the callback
  77352. */
  77353. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  77354. /**
  77355. * Remove an Observer from the Observable object
  77356. * @param observer the instance of the Observer to remove
  77357. * @returns false if it doesn't belong to this Observable
  77358. */
  77359. remove(observer: Nullable<Observer<T>>): boolean;
  77360. /**
  77361. * Remove a callback from the Observable object
  77362. * @param callback the callback to remove
  77363. * @param scope optional scope. If used only the callbacks with this scope will be removed
  77364. * @returns false if it doesn't belong to this Observable
  77365. */
  77366. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  77367. private _deferUnregister;
  77368. private _remove;
  77369. /**
  77370. * Moves the observable to the top of the observer list making it get called first when notified
  77371. * @param observer the observer to move
  77372. */
  77373. makeObserverTopPriority(observer: Observer<T>): void;
  77374. /**
  77375. * Moves the observable to the bottom of the observer list making it get called last when notified
  77376. * @param observer the observer to move
  77377. */
  77378. makeObserverBottomPriority(observer: Observer<T>): void;
  77379. /**
  77380. * Notify all Observers by calling their respective callback with the given data
  77381. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  77382. * @param eventData defines the data to send to all observers
  77383. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  77384. * @param target defines the original target of the state
  77385. * @param currentTarget defines the current target of the state
  77386. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  77387. */
  77388. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  77389. /**
  77390. * Calling this will execute each callback, expecting it to be a promise or return a value.
  77391. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  77392. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  77393. * and it is crucial that all callbacks will be executed.
  77394. * The order of the callbacks is kept, callbacks are not executed parallel.
  77395. *
  77396. * @param eventData The data to be sent to each callback
  77397. * @param mask is used to filter observers defaults to -1
  77398. * @param target defines the callback target (see EventState)
  77399. * @param currentTarget defines he current object in the bubbling phase
  77400. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  77401. */
  77402. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  77403. /**
  77404. * Notify a specific observer
  77405. * @param observer defines the observer to notify
  77406. * @param eventData defines the data to be sent to each callback
  77407. * @param mask is used to filter observers defaults to -1
  77408. */
  77409. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  77410. /**
  77411. * Gets a boolean indicating if the observable has at least one observer
  77412. * @returns true is the Observable has at least one Observer registered
  77413. */
  77414. hasObservers(): boolean;
  77415. /**
  77416. * Clear the list of observers
  77417. */
  77418. clear(): void;
  77419. /**
  77420. * Clone the current observable
  77421. * @returns a new observable
  77422. */
  77423. clone(): Observable<T>;
  77424. /**
  77425. * Does this observable handles observer registered with a given mask
  77426. * @param mask defines the mask to be tested
  77427. * @return whether or not one observer registered with the given mask is handeled
  77428. **/
  77429. hasSpecificMask(mask?: number): boolean;
  77430. }
  77431. }
  77432. declare module BABYLON {
  77433. /**
  77434. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  77435. * Babylon.js
  77436. */
  77437. export class DomManagement {
  77438. /**
  77439. * Checks if the window object exists
  77440. * @returns true if the window object exists
  77441. */
  77442. static IsWindowObjectExist(): boolean;
  77443. /**
  77444. * Checks if the navigator object exists
  77445. * @returns true if the navigator object exists
  77446. */
  77447. static IsNavigatorAvailable(): boolean;
  77448. /**
  77449. * Check if the document object exists
  77450. * @returns true if the document object exists
  77451. */
  77452. static IsDocumentAvailable(): boolean;
  77453. /**
  77454. * Extracts text content from a DOM element hierarchy
  77455. * @param element defines the root element
  77456. * @returns a string
  77457. */
  77458. static GetDOMTextContent(element: HTMLElement): string;
  77459. }
  77460. }
  77461. declare module BABYLON {
  77462. /**
  77463. * Logger used througouht the application to allow configuration of
  77464. * the log level required for the messages.
  77465. */
  77466. export class Logger {
  77467. /**
  77468. * No log
  77469. */
  77470. static readonly NoneLogLevel: number;
  77471. /**
  77472. * Only message logs
  77473. */
  77474. static readonly MessageLogLevel: number;
  77475. /**
  77476. * Only warning logs
  77477. */
  77478. static readonly WarningLogLevel: number;
  77479. /**
  77480. * Only error logs
  77481. */
  77482. static readonly ErrorLogLevel: number;
  77483. /**
  77484. * All logs
  77485. */
  77486. static readonly AllLogLevel: number;
  77487. private static _LogCache;
  77488. /**
  77489. * Gets a value indicating the number of loading errors
  77490. * @ignorenaming
  77491. */
  77492. static errorsCount: number;
  77493. /**
  77494. * Callback called when a new log is added
  77495. */
  77496. static OnNewCacheEntry: (entry: string) => void;
  77497. private static _AddLogEntry;
  77498. private static _FormatMessage;
  77499. private static _LogDisabled;
  77500. private static _LogEnabled;
  77501. private static _WarnDisabled;
  77502. private static _WarnEnabled;
  77503. private static _ErrorDisabled;
  77504. private static _ErrorEnabled;
  77505. /**
  77506. * Log a message to the console
  77507. */
  77508. static Log: (message: string) => void;
  77509. /**
  77510. * Write a warning message to the console
  77511. */
  77512. static Warn: (message: string) => void;
  77513. /**
  77514. * Write an error message to the console
  77515. */
  77516. static Error: (message: string) => void;
  77517. /**
  77518. * Gets current log cache (list of logs)
  77519. */
  77520. static get LogCache(): string;
  77521. /**
  77522. * Clears the log cache
  77523. */
  77524. static ClearLogCache(): void;
  77525. /**
  77526. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  77527. */
  77528. static set LogLevels(level: number);
  77529. }
  77530. }
  77531. declare module BABYLON {
  77532. /** @hidden */
  77533. export class _TypeStore {
  77534. /** @hidden */
  77535. static RegisteredTypes: {
  77536. [key: string]: Object;
  77537. };
  77538. /** @hidden */
  77539. static GetClass(fqdn: string): any;
  77540. }
  77541. }
  77542. declare module BABYLON {
  77543. /**
  77544. * Helper to manipulate strings
  77545. */
  77546. export class StringTools {
  77547. /**
  77548. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  77549. * @param str Source string
  77550. * @param suffix Suffix to search for in the source string
  77551. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  77552. */
  77553. static EndsWith(str: string, suffix: string): boolean;
  77554. /**
  77555. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  77556. * @param str Source string
  77557. * @param suffix Suffix to search for in the source string
  77558. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  77559. */
  77560. static StartsWith(str: string, suffix: string): boolean;
  77561. /**
  77562. * Decodes a buffer into a string
  77563. * @param buffer The buffer to decode
  77564. * @returns The decoded string
  77565. */
  77566. static Decode(buffer: Uint8Array | Uint16Array): string;
  77567. /**
  77568. * Encode a buffer to a base64 string
  77569. * @param buffer defines the buffer to encode
  77570. * @returns the encoded string
  77571. */
  77572. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  77573. /**
  77574. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  77575. * @param num the number to convert and pad
  77576. * @param length the expected length of the string
  77577. * @returns the padded string
  77578. */
  77579. static PadNumber(num: number, length: number): string;
  77580. }
  77581. }
  77582. declare module BABYLON {
  77583. /**
  77584. * Class containing a set of static utilities functions for deep copy.
  77585. */
  77586. export class DeepCopier {
  77587. /**
  77588. * Tries to copy an object by duplicating every property
  77589. * @param source defines the source object
  77590. * @param destination defines the target object
  77591. * @param doNotCopyList defines a list of properties to avoid
  77592. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  77593. */
  77594. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  77595. }
  77596. }
  77597. declare module BABYLON {
  77598. /**
  77599. * Class containing a set of static utilities functions for precision date
  77600. */
  77601. export class PrecisionDate {
  77602. /**
  77603. * Gets either window.performance.now() if supported or Date.now() else
  77604. */
  77605. static get Now(): number;
  77606. }
  77607. }
  77608. declare module BABYLON {
  77609. /** @hidden */
  77610. export class _DevTools {
  77611. static WarnImport(name: string): string;
  77612. }
  77613. }
  77614. declare module BABYLON {
  77615. /**
  77616. * Interface used to define the mechanism to get data from the network
  77617. */
  77618. export interface IWebRequest {
  77619. /**
  77620. * Returns client's response url
  77621. */
  77622. responseURL: string;
  77623. /**
  77624. * Returns client's status
  77625. */
  77626. status: number;
  77627. /**
  77628. * Returns client's status as a text
  77629. */
  77630. statusText: string;
  77631. }
  77632. }
  77633. declare module BABYLON {
  77634. /**
  77635. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  77636. */
  77637. export class WebRequest implements IWebRequest {
  77638. private _xhr;
  77639. /**
  77640. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  77641. * i.e. when loading files, where the server/service expects an Authorization header
  77642. */
  77643. static CustomRequestHeaders: {
  77644. [key: string]: string;
  77645. };
  77646. /**
  77647. * Add callback functions in this array to update all the requests before they get sent to the network
  77648. */
  77649. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  77650. private _injectCustomRequestHeaders;
  77651. /**
  77652. * Gets or sets a function to be called when loading progress changes
  77653. */
  77654. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  77655. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  77656. /**
  77657. * Returns client's state
  77658. */
  77659. get readyState(): number;
  77660. /**
  77661. * Returns client's status
  77662. */
  77663. get status(): number;
  77664. /**
  77665. * Returns client's status as a text
  77666. */
  77667. get statusText(): string;
  77668. /**
  77669. * Returns client's response
  77670. */
  77671. get response(): any;
  77672. /**
  77673. * Returns client's response url
  77674. */
  77675. get responseURL(): string;
  77676. /**
  77677. * Returns client's response as text
  77678. */
  77679. get responseText(): string;
  77680. /**
  77681. * Gets or sets the expected response type
  77682. */
  77683. get responseType(): XMLHttpRequestResponseType;
  77684. set responseType(value: XMLHttpRequestResponseType);
  77685. /** @hidden */
  77686. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  77687. /** @hidden */
  77688. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  77689. /**
  77690. * Cancels any network activity
  77691. */
  77692. abort(): void;
  77693. /**
  77694. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  77695. * @param body defines an optional request body
  77696. */
  77697. send(body?: Document | BodyInit | null): void;
  77698. /**
  77699. * Sets the request method, request URL
  77700. * @param method defines the method to use (GET, POST, etc..)
  77701. * @param url defines the url to connect with
  77702. */
  77703. open(method: string, url: string): void;
  77704. /**
  77705. * Sets the value of a request header.
  77706. * @param name The name of the header whose value is to be set
  77707. * @param value The value to set as the body of the header
  77708. */
  77709. setRequestHeader(name: string, value: string): void;
  77710. /**
  77711. * Get the string containing the text of a particular header's value.
  77712. * @param name The name of the header
  77713. * @returns The string containing the text of the given header name
  77714. */
  77715. getResponseHeader(name: string): Nullable<string>;
  77716. }
  77717. }
  77718. declare module BABYLON {
  77719. /**
  77720. * File request interface
  77721. */
  77722. export interface IFileRequest {
  77723. /**
  77724. * Raised when the request is complete (success or error).
  77725. */
  77726. onCompleteObservable: Observable<IFileRequest>;
  77727. /**
  77728. * Aborts the request for a file.
  77729. */
  77730. abort: () => void;
  77731. }
  77732. }
  77733. declare module BABYLON {
  77734. /**
  77735. * Define options used to create a render target texture
  77736. */
  77737. export class RenderTargetCreationOptions {
  77738. /**
  77739. * Specifies is mipmaps must be generated
  77740. */
  77741. generateMipMaps?: boolean;
  77742. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  77743. generateDepthBuffer?: boolean;
  77744. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  77745. generateStencilBuffer?: boolean;
  77746. /** Defines texture type (int by default) */
  77747. type?: number;
  77748. /** Defines sampling mode (trilinear by default) */
  77749. samplingMode?: number;
  77750. /** Defines format (RGBA by default) */
  77751. format?: number;
  77752. }
  77753. }
  77754. declare module BABYLON {
  77755. /** Defines the cross module used constants to avoid circular dependncies */
  77756. export class Constants {
  77757. /** Defines that alpha blending is disabled */
  77758. static readonly ALPHA_DISABLE: number;
  77759. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  77760. static readonly ALPHA_ADD: number;
  77761. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  77762. static readonly ALPHA_COMBINE: number;
  77763. /** Defines that alpha blending is DEST - SRC * DEST */
  77764. static readonly ALPHA_SUBTRACT: number;
  77765. /** Defines that alpha blending is SRC * DEST */
  77766. static readonly ALPHA_MULTIPLY: number;
  77767. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  77768. static readonly ALPHA_MAXIMIZED: number;
  77769. /** Defines that alpha blending is SRC + DEST */
  77770. static readonly ALPHA_ONEONE: number;
  77771. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  77772. static readonly ALPHA_PREMULTIPLIED: number;
  77773. /**
  77774. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  77775. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  77776. */
  77777. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  77778. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  77779. static readonly ALPHA_INTERPOLATE: number;
  77780. /**
  77781. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  77782. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  77783. */
  77784. static readonly ALPHA_SCREENMODE: number;
  77785. /**
  77786. * Defines that alpha blending is SRC + DST
  77787. * Alpha will be set to SRC ALPHA + DST ALPHA
  77788. */
  77789. static readonly ALPHA_ONEONE_ONEONE: number;
  77790. /**
  77791. * Defines that alpha blending is SRC * DST ALPHA + DST
  77792. * Alpha will be set to 0
  77793. */
  77794. static readonly ALPHA_ALPHATOCOLOR: number;
  77795. /**
  77796. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  77797. */
  77798. static readonly ALPHA_REVERSEONEMINUS: number;
  77799. /**
  77800. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  77801. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  77802. */
  77803. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  77804. /**
  77805. * Defines that alpha blending is SRC + DST
  77806. * Alpha will be set to SRC ALPHA
  77807. */
  77808. static readonly ALPHA_ONEONE_ONEZERO: number;
  77809. /**
  77810. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  77811. * Alpha will be set to DST ALPHA
  77812. */
  77813. static readonly ALPHA_EXCLUSION: number;
  77814. /** Defines that alpha blending equation a SUM */
  77815. static readonly ALPHA_EQUATION_ADD: number;
  77816. /** Defines that alpha blending equation a SUBSTRACTION */
  77817. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  77818. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  77819. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  77820. /** Defines that alpha blending equation a MAX operation */
  77821. static readonly ALPHA_EQUATION_MAX: number;
  77822. /** Defines that alpha blending equation a MIN operation */
  77823. static readonly ALPHA_EQUATION_MIN: number;
  77824. /**
  77825. * Defines that alpha blending equation a DARKEN operation:
  77826. * It takes the min of the src and sums the alpha channels.
  77827. */
  77828. static readonly ALPHA_EQUATION_DARKEN: number;
  77829. /** Defines that the ressource is not delayed*/
  77830. static readonly DELAYLOADSTATE_NONE: number;
  77831. /** Defines that the ressource was successfully delay loaded */
  77832. static readonly DELAYLOADSTATE_LOADED: number;
  77833. /** Defines that the ressource is currently delay loading */
  77834. static readonly DELAYLOADSTATE_LOADING: number;
  77835. /** Defines that the ressource is delayed and has not started loading */
  77836. static readonly DELAYLOADSTATE_NOTLOADED: number;
  77837. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  77838. static readonly NEVER: number;
  77839. /** 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 */
  77840. static readonly ALWAYS: number;
  77841. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  77842. static readonly LESS: number;
  77843. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  77844. static readonly EQUAL: number;
  77845. /** 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 */
  77846. static readonly LEQUAL: number;
  77847. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  77848. static readonly GREATER: number;
  77849. /** 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 */
  77850. static readonly GEQUAL: number;
  77851. /** 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 */
  77852. static readonly NOTEQUAL: number;
  77853. /** Passed to stencilOperation to specify that stencil value must be kept */
  77854. static readonly KEEP: number;
  77855. /** Passed to stencilOperation to specify that stencil value must be replaced */
  77856. static readonly REPLACE: number;
  77857. /** Passed to stencilOperation to specify that stencil value must be incremented */
  77858. static readonly INCR: number;
  77859. /** Passed to stencilOperation to specify that stencil value must be decremented */
  77860. static readonly DECR: number;
  77861. /** Passed to stencilOperation to specify that stencil value must be inverted */
  77862. static readonly INVERT: number;
  77863. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  77864. static readonly INCR_WRAP: number;
  77865. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  77866. static readonly DECR_WRAP: number;
  77867. /** Texture is not repeating outside of 0..1 UVs */
  77868. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  77869. /** Texture is repeating outside of 0..1 UVs */
  77870. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  77871. /** Texture is repeating and mirrored */
  77872. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  77873. /** ALPHA */
  77874. static readonly TEXTUREFORMAT_ALPHA: number;
  77875. /** LUMINANCE */
  77876. static readonly TEXTUREFORMAT_LUMINANCE: number;
  77877. /** LUMINANCE_ALPHA */
  77878. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  77879. /** RGB */
  77880. static readonly TEXTUREFORMAT_RGB: number;
  77881. /** RGBA */
  77882. static readonly TEXTUREFORMAT_RGBA: number;
  77883. /** RED */
  77884. static readonly TEXTUREFORMAT_RED: number;
  77885. /** RED (2nd reference) */
  77886. static readonly TEXTUREFORMAT_R: number;
  77887. /** RG */
  77888. static readonly TEXTUREFORMAT_RG: number;
  77889. /** RED_INTEGER */
  77890. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  77891. /** RED_INTEGER (2nd reference) */
  77892. static readonly TEXTUREFORMAT_R_INTEGER: number;
  77893. /** RG_INTEGER */
  77894. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  77895. /** RGB_INTEGER */
  77896. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  77897. /** RGBA_INTEGER */
  77898. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  77899. /** UNSIGNED_BYTE */
  77900. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  77901. /** UNSIGNED_BYTE (2nd reference) */
  77902. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  77903. /** FLOAT */
  77904. static readonly TEXTURETYPE_FLOAT: number;
  77905. /** HALF_FLOAT */
  77906. static readonly TEXTURETYPE_HALF_FLOAT: number;
  77907. /** BYTE */
  77908. static readonly TEXTURETYPE_BYTE: number;
  77909. /** SHORT */
  77910. static readonly TEXTURETYPE_SHORT: number;
  77911. /** UNSIGNED_SHORT */
  77912. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  77913. /** INT */
  77914. static readonly TEXTURETYPE_INT: number;
  77915. /** UNSIGNED_INT */
  77916. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  77917. /** UNSIGNED_SHORT_4_4_4_4 */
  77918. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  77919. /** UNSIGNED_SHORT_5_5_5_1 */
  77920. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  77921. /** UNSIGNED_SHORT_5_6_5 */
  77922. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  77923. /** UNSIGNED_INT_2_10_10_10_REV */
  77924. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  77925. /** UNSIGNED_INT_24_8 */
  77926. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  77927. /** UNSIGNED_INT_10F_11F_11F_REV */
  77928. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  77929. /** UNSIGNED_INT_5_9_9_9_REV */
  77930. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  77931. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  77932. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  77933. /** nearest is mag = nearest and min = nearest and no mip */
  77934. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  77935. /** mag = nearest and min = nearest and mip = none */
  77936. static readonly TEXTURE_NEAREST_NEAREST: number;
  77937. /** Bilinear is mag = linear and min = linear and no mip */
  77938. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  77939. /** mag = linear and min = linear and mip = none */
  77940. static readonly TEXTURE_LINEAR_LINEAR: number;
  77941. /** Trilinear is mag = linear and min = linear and mip = linear */
  77942. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  77943. /** Trilinear is mag = linear and min = linear and mip = linear */
  77944. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  77945. /** mag = nearest and min = nearest and mip = nearest */
  77946. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  77947. /** mag = nearest and min = linear and mip = nearest */
  77948. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  77949. /** mag = nearest and min = linear and mip = linear */
  77950. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  77951. /** mag = nearest and min = linear and mip = none */
  77952. static readonly TEXTURE_NEAREST_LINEAR: number;
  77953. /** nearest is mag = nearest and min = nearest and mip = linear */
  77954. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  77955. /** mag = linear and min = nearest and mip = nearest */
  77956. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  77957. /** mag = linear and min = nearest and mip = linear */
  77958. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  77959. /** Bilinear is mag = linear and min = linear and mip = nearest */
  77960. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  77961. /** mag = linear and min = nearest and mip = none */
  77962. static readonly TEXTURE_LINEAR_NEAREST: number;
  77963. /** Explicit coordinates mode */
  77964. static readonly TEXTURE_EXPLICIT_MODE: number;
  77965. /** Spherical coordinates mode */
  77966. static readonly TEXTURE_SPHERICAL_MODE: number;
  77967. /** Planar coordinates mode */
  77968. static readonly TEXTURE_PLANAR_MODE: number;
  77969. /** Cubic coordinates mode */
  77970. static readonly TEXTURE_CUBIC_MODE: number;
  77971. /** Projection coordinates mode */
  77972. static readonly TEXTURE_PROJECTION_MODE: number;
  77973. /** Skybox coordinates mode */
  77974. static readonly TEXTURE_SKYBOX_MODE: number;
  77975. /** Inverse Cubic coordinates mode */
  77976. static readonly TEXTURE_INVCUBIC_MODE: number;
  77977. /** Equirectangular coordinates mode */
  77978. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  77979. /** Equirectangular Fixed coordinates mode */
  77980. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  77981. /** Equirectangular Fixed Mirrored coordinates mode */
  77982. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  77983. /** Offline (baking) quality for texture filtering */
  77984. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  77985. /** High quality for texture filtering */
  77986. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  77987. /** Medium quality for texture filtering */
  77988. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  77989. /** Low quality for texture filtering */
  77990. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  77991. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  77992. static readonly SCALEMODE_FLOOR: number;
  77993. /** Defines that texture rescaling will look for the nearest power of 2 size */
  77994. static readonly SCALEMODE_NEAREST: number;
  77995. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  77996. static readonly SCALEMODE_CEILING: number;
  77997. /**
  77998. * The dirty texture flag value
  77999. */
  78000. static readonly MATERIAL_TextureDirtyFlag: number;
  78001. /**
  78002. * The dirty light flag value
  78003. */
  78004. static readonly MATERIAL_LightDirtyFlag: number;
  78005. /**
  78006. * The dirty fresnel flag value
  78007. */
  78008. static readonly MATERIAL_FresnelDirtyFlag: number;
  78009. /**
  78010. * The dirty attribute flag value
  78011. */
  78012. static readonly MATERIAL_AttributesDirtyFlag: number;
  78013. /**
  78014. * The dirty misc flag value
  78015. */
  78016. static readonly MATERIAL_MiscDirtyFlag: number;
  78017. /**
  78018. * The all dirty flag value
  78019. */
  78020. static readonly MATERIAL_AllDirtyFlag: number;
  78021. /**
  78022. * Returns the triangle fill mode
  78023. */
  78024. static readonly MATERIAL_TriangleFillMode: number;
  78025. /**
  78026. * Returns the wireframe mode
  78027. */
  78028. static readonly MATERIAL_WireFrameFillMode: number;
  78029. /**
  78030. * Returns the point fill mode
  78031. */
  78032. static readonly MATERIAL_PointFillMode: number;
  78033. /**
  78034. * Returns the point list draw mode
  78035. */
  78036. static readonly MATERIAL_PointListDrawMode: number;
  78037. /**
  78038. * Returns the line list draw mode
  78039. */
  78040. static readonly MATERIAL_LineListDrawMode: number;
  78041. /**
  78042. * Returns the line loop draw mode
  78043. */
  78044. static readonly MATERIAL_LineLoopDrawMode: number;
  78045. /**
  78046. * Returns the line strip draw mode
  78047. */
  78048. static readonly MATERIAL_LineStripDrawMode: number;
  78049. /**
  78050. * Returns the triangle strip draw mode
  78051. */
  78052. static readonly MATERIAL_TriangleStripDrawMode: number;
  78053. /**
  78054. * Returns the triangle fan draw mode
  78055. */
  78056. static readonly MATERIAL_TriangleFanDrawMode: number;
  78057. /**
  78058. * Stores the clock-wise side orientation
  78059. */
  78060. static readonly MATERIAL_ClockWiseSideOrientation: number;
  78061. /**
  78062. * Stores the counter clock-wise side orientation
  78063. */
  78064. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  78065. /**
  78066. * Nothing
  78067. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78068. */
  78069. static readonly ACTION_NothingTrigger: number;
  78070. /**
  78071. * On pick
  78072. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78073. */
  78074. static readonly ACTION_OnPickTrigger: number;
  78075. /**
  78076. * On left pick
  78077. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78078. */
  78079. static readonly ACTION_OnLeftPickTrigger: number;
  78080. /**
  78081. * On right pick
  78082. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78083. */
  78084. static readonly ACTION_OnRightPickTrigger: number;
  78085. /**
  78086. * On center pick
  78087. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78088. */
  78089. static readonly ACTION_OnCenterPickTrigger: number;
  78090. /**
  78091. * On pick down
  78092. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78093. */
  78094. static readonly ACTION_OnPickDownTrigger: number;
  78095. /**
  78096. * On double pick
  78097. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78098. */
  78099. static readonly ACTION_OnDoublePickTrigger: number;
  78100. /**
  78101. * On pick up
  78102. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78103. */
  78104. static readonly ACTION_OnPickUpTrigger: number;
  78105. /**
  78106. * On pick out.
  78107. * This trigger will only be raised if you also declared a OnPickDown
  78108. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78109. */
  78110. static readonly ACTION_OnPickOutTrigger: number;
  78111. /**
  78112. * On long press
  78113. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78114. */
  78115. static readonly ACTION_OnLongPressTrigger: number;
  78116. /**
  78117. * On pointer over
  78118. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78119. */
  78120. static readonly ACTION_OnPointerOverTrigger: number;
  78121. /**
  78122. * On pointer out
  78123. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78124. */
  78125. static readonly ACTION_OnPointerOutTrigger: number;
  78126. /**
  78127. * On every frame
  78128. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78129. */
  78130. static readonly ACTION_OnEveryFrameTrigger: number;
  78131. /**
  78132. * On intersection enter
  78133. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78134. */
  78135. static readonly ACTION_OnIntersectionEnterTrigger: number;
  78136. /**
  78137. * On intersection exit
  78138. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78139. */
  78140. static readonly ACTION_OnIntersectionExitTrigger: number;
  78141. /**
  78142. * On key down
  78143. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78144. */
  78145. static readonly ACTION_OnKeyDownTrigger: number;
  78146. /**
  78147. * On key up
  78148. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78149. */
  78150. static readonly ACTION_OnKeyUpTrigger: number;
  78151. /**
  78152. * Billboard mode will only apply to Y axis
  78153. */
  78154. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  78155. /**
  78156. * Billboard mode will apply to all axes
  78157. */
  78158. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  78159. /**
  78160. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  78161. */
  78162. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  78163. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  78164. * Test order :
  78165. * Is the bounding sphere outside the frustum ?
  78166. * If not, are the bounding box vertices outside the frustum ?
  78167. * It not, then the cullable object is in the frustum.
  78168. */
  78169. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  78170. /** Culling strategy : Bounding Sphere Only.
  78171. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  78172. * It's also less accurate than the standard because some not visible objects can still be selected.
  78173. * Test : is the bounding sphere outside the frustum ?
  78174. * If not, then the cullable object is in the frustum.
  78175. */
  78176. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  78177. /** Culling strategy : Optimistic Inclusion.
  78178. * This in an inclusion test first, then the standard exclusion test.
  78179. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  78180. * 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.
  78181. * Anyway, it's as accurate as the standard strategy.
  78182. * Test :
  78183. * Is the cullable object bounding sphere center in the frustum ?
  78184. * If not, apply the default culling strategy.
  78185. */
  78186. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  78187. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  78188. * This in an inclusion test first, then the bounding sphere only exclusion test.
  78189. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  78190. * 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.
  78191. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  78192. * Test :
  78193. * Is the cullable object bounding sphere center in the frustum ?
  78194. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  78195. */
  78196. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  78197. /**
  78198. * No logging while loading
  78199. */
  78200. static readonly SCENELOADER_NO_LOGGING: number;
  78201. /**
  78202. * Minimal logging while loading
  78203. */
  78204. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  78205. /**
  78206. * Summary logging while loading
  78207. */
  78208. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  78209. /**
  78210. * Detailled logging while loading
  78211. */
  78212. static readonly SCENELOADER_DETAILED_LOGGING: number;
  78213. }
  78214. }
  78215. declare module BABYLON {
  78216. /**
  78217. * This represents the required contract to create a new type of texture loader.
  78218. */
  78219. export interface IInternalTextureLoader {
  78220. /**
  78221. * Defines wether the loader supports cascade loading the different faces.
  78222. */
  78223. supportCascades: boolean;
  78224. /**
  78225. * This returns if the loader support the current file information.
  78226. * @param extension defines the file extension of the file being loaded
  78227. * @returns true if the loader can load the specified file
  78228. */
  78229. canLoad(extension: string): boolean;
  78230. /**
  78231. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  78232. * @param data contains the texture data
  78233. * @param texture defines the BabylonJS internal texture
  78234. * @param createPolynomials will be true if polynomials have been requested
  78235. * @param onLoad defines the callback to trigger once the texture is ready
  78236. * @param onError defines the callback to trigger in case of error
  78237. */
  78238. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  78239. /**
  78240. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  78241. * @param data contains the texture data
  78242. * @param texture defines the BabylonJS internal texture
  78243. * @param callback defines the method to call once ready to upload
  78244. */
  78245. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  78246. }
  78247. }
  78248. declare module BABYLON {
  78249. /**
  78250. * Class used to store and describe the pipeline context associated with an effect
  78251. */
  78252. export interface IPipelineContext {
  78253. /**
  78254. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  78255. */
  78256. isAsync: boolean;
  78257. /**
  78258. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  78259. */
  78260. isReady: boolean;
  78261. /** @hidden */
  78262. _getVertexShaderCode(): string | null;
  78263. /** @hidden */
  78264. _getFragmentShaderCode(): string | null;
  78265. /** @hidden */
  78266. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  78267. }
  78268. }
  78269. declare module BABYLON {
  78270. /**
  78271. * Class used to store gfx data (like WebGLBuffer)
  78272. */
  78273. export class DataBuffer {
  78274. /**
  78275. * Gets or sets the number of objects referencing this buffer
  78276. */
  78277. references: number;
  78278. /** Gets or sets the size of the underlying buffer */
  78279. capacity: number;
  78280. /**
  78281. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  78282. */
  78283. is32Bits: boolean;
  78284. /**
  78285. * Gets the underlying buffer
  78286. */
  78287. get underlyingResource(): any;
  78288. }
  78289. }
  78290. declare module BABYLON {
  78291. /** @hidden */
  78292. export interface IShaderProcessor {
  78293. attributeProcessor?: (attribute: string) => string;
  78294. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  78295. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  78296. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  78297. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  78298. lineProcessor?: (line: string, isFragment: boolean) => string;
  78299. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  78300. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  78301. }
  78302. }
  78303. declare module BABYLON {
  78304. /** @hidden */
  78305. export interface ProcessingOptions {
  78306. defines: string[];
  78307. indexParameters: any;
  78308. isFragment: boolean;
  78309. shouldUseHighPrecisionShader: boolean;
  78310. supportsUniformBuffers: boolean;
  78311. shadersRepository: string;
  78312. includesShadersStore: {
  78313. [key: string]: string;
  78314. };
  78315. processor?: IShaderProcessor;
  78316. version: string;
  78317. platformName: string;
  78318. lookForClosingBracketForUniformBuffer?: boolean;
  78319. }
  78320. }
  78321. declare module BABYLON {
  78322. /** @hidden */
  78323. export class ShaderCodeNode {
  78324. line: string;
  78325. children: ShaderCodeNode[];
  78326. additionalDefineKey?: string;
  78327. additionalDefineValue?: string;
  78328. isValid(preprocessors: {
  78329. [key: string]: string;
  78330. }): boolean;
  78331. process(preprocessors: {
  78332. [key: string]: string;
  78333. }, options: ProcessingOptions): string;
  78334. }
  78335. }
  78336. declare module BABYLON {
  78337. /** @hidden */
  78338. export class ShaderCodeCursor {
  78339. private _lines;
  78340. lineIndex: number;
  78341. get currentLine(): string;
  78342. get canRead(): boolean;
  78343. set lines(value: string[]);
  78344. }
  78345. }
  78346. declare module BABYLON {
  78347. /** @hidden */
  78348. export class ShaderCodeConditionNode extends ShaderCodeNode {
  78349. process(preprocessors: {
  78350. [key: string]: string;
  78351. }, options: ProcessingOptions): string;
  78352. }
  78353. }
  78354. declare module BABYLON {
  78355. /** @hidden */
  78356. export class ShaderDefineExpression {
  78357. isTrue(preprocessors: {
  78358. [key: string]: string;
  78359. }): boolean;
  78360. private static _OperatorPriority;
  78361. private static _Stack;
  78362. static postfixToInfix(postfix: string[]): string;
  78363. static infixToPostfix(infix: string): string[];
  78364. }
  78365. }
  78366. declare module BABYLON {
  78367. /** @hidden */
  78368. export class ShaderCodeTestNode extends ShaderCodeNode {
  78369. testExpression: ShaderDefineExpression;
  78370. isValid(preprocessors: {
  78371. [key: string]: string;
  78372. }): boolean;
  78373. }
  78374. }
  78375. declare module BABYLON {
  78376. /** @hidden */
  78377. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  78378. define: string;
  78379. not: boolean;
  78380. constructor(define: string, not?: boolean);
  78381. isTrue(preprocessors: {
  78382. [key: string]: string;
  78383. }): boolean;
  78384. }
  78385. }
  78386. declare module BABYLON {
  78387. /** @hidden */
  78388. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  78389. leftOperand: ShaderDefineExpression;
  78390. rightOperand: ShaderDefineExpression;
  78391. isTrue(preprocessors: {
  78392. [key: string]: string;
  78393. }): boolean;
  78394. }
  78395. }
  78396. declare module BABYLON {
  78397. /** @hidden */
  78398. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  78399. leftOperand: ShaderDefineExpression;
  78400. rightOperand: ShaderDefineExpression;
  78401. isTrue(preprocessors: {
  78402. [key: string]: string;
  78403. }): boolean;
  78404. }
  78405. }
  78406. declare module BABYLON {
  78407. /** @hidden */
  78408. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  78409. define: string;
  78410. operand: string;
  78411. testValue: string;
  78412. constructor(define: string, operand: string, testValue: string);
  78413. isTrue(preprocessors: {
  78414. [key: string]: string;
  78415. }): boolean;
  78416. }
  78417. }
  78418. declare module BABYLON {
  78419. /**
  78420. * Class used to enable access to offline support
  78421. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  78422. */
  78423. export interface IOfflineProvider {
  78424. /**
  78425. * Gets a boolean indicating if scene must be saved in the database
  78426. */
  78427. enableSceneOffline: boolean;
  78428. /**
  78429. * Gets a boolean indicating if textures must be saved in the database
  78430. */
  78431. enableTexturesOffline: boolean;
  78432. /**
  78433. * Open the offline support and make it available
  78434. * @param successCallback defines the callback to call on success
  78435. * @param errorCallback defines the callback to call on error
  78436. */
  78437. open(successCallback: () => void, errorCallback: () => void): void;
  78438. /**
  78439. * Loads an image from the offline support
  78440. * @param url defines the url to load from
  78441. * @param image defines the target DOM image
  78442. */
  78443. loadImage(url: string, image: HTMLImageElement): void;
  78444. /**
  78445. * Loads a file from offline support
  78446. * @param url defines the URL to load from
  78447. * @param sceneLoaded defines a callback to call on success
  78448. * @param progressCallBack defines a callback to call when progress changed
  78449. * @param errorCallback defines a callback to call on error
  78450. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  78451. */
  78452. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  78453. }
  78454. }
  78455. declare module BABYLON {
  78456. /**
  78457. * Class used to help managing file picking and drag'n'drop
  78458. * File Storage
  78459. */
  78460. export class FilesInputStore {
  78461. /**
  78462. * List of files ready to be loaded
  78463. */
  78464. static FilesToLoad: {
  78465. [key: string]: File;
  78466. };
  78467. }
  78468. }
  78469. declare module BABYLON {
  78470. /**
  78471. * Class used to define a retry strategy when error happens while loading assets
  78472. */
  78473. export class RetryStrategy {
  78474. /**
  78475. * Function used to defines an exponential back off strategy
  78476. * @param maxRetries defines the maximum number of retries (3 by default)
  78477. * @param baseInterval defines the interval between retries
  78478. * @returns the strategy function to use
  78479. */
  78480. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  78481. }
  78482. }
  78483. declare module BABYLON {
  78484. /**
  78485. * @ignore
  78486. * Application error to support additional information when loading a file
  78487. */
  78488. export abstract class BaseError extends Error {
  78489. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  78490. }
  78491. }
  78492. declare module BABYLON {
  78493. /** @ignore */
  78494. export class LoadFileError extends BaseError {
  78495. request?: WebRequest;
  78496. file?: File;
  78497. /**
  78498. * Creates a new LoadFileError
  78499. * @param message defines the message of the error
  78500. * @param request defines the optional web request
  78501. * @param file defines the optional file
  78502. */
  78503. constructor(message: string, object?: WebRequest | File);
  78504. }
  78505. /** @ignore */
  78506. export class RequestFileError extends BaseError {
  78507. request: WebRequest;
  78508. /**
  78509. * Creates a new LoadFileError
  78510. * @param message defines the message of the error
  78511. * @param request defines the optional web request
  78512. */
  78513. constructor(message: string, request: WebRequest);
  78514. }
  78515. /** @ignore */
  78516. export class ReadFileError extends BaseError {
  78517. file: File;
  78518. /**
  78519. * Creates a new ReadFileError
  78520. * @param message defines the message of the error
  78521. * @param file defines the optional file
  78522. */
  78523. constructor(message: string, file: File);
  78524. }
  78525. /**
  78526. * @hidden
  78527. */
  78528. export class FileTools {
  78529. /**
  78530. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  78531. */
  78532. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  78533. /**
  78534. * Gets or sets the base URL to use to load assets
  78535. */
  78536. static BaseUrl: string;
  78537. /**
  78538. * Default behaviour for cors in the application.
  78539. * It can be a string if the expected behavior is identical in the entire app.
  78540. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  78541. */
  78542. static CorsBehavior: string | ((url: string | string[]) => string);
  78543. /**
  78544. * Gets or sets a function used to pre-process url before using them to load assets
  78545. */
  78546. static PreprocessUrl: (url: string) => string;
  78547. /**
  78548. * Removes unwanted characters from an url
  78549. * @param url defines the url to clean
  78550. * @returns the cleaned url
  78551. */
  78552. private static _CleanUrl;
  78553. /**
  78554. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  78555. * @param url define the url we are trying
  78556. * @param element define the dom element where to configure the cors policy
  78557. */
  78558. static SetCorsBehavior(url: string | string[], element: {
  78559. crossOrigin: string | null;
  78560. }): void;
  78561. /**
  78562. * Loads an image as an HTMLImageElement.
  78563. * @param input url string, ArrayBuffer, or Blob to load
  78564. * @param onLoad callback called when the image successfully loads
  78565. * @param onError callback called when the image fails to load
  78566. * @param offlineProvider offline provider for caching
  78567. * @param mimeType optional mime type
  78568. * @returns the HTMLImageElement of the loaded image
  78569. */
  78570. 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>;
  78571. /**
  78572. * Reads a file from a File object
  78573. * @param file defines the file to load
  78574. * @param onSuccess defines the callback to call when data is loaded
  78575. * @param onProgress defines the callback to call during loading process
  78576. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  78577. * @param onError defines the callback to call when an error occurs
  78578. * @returns a file request object
  78579. */
  78580. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  78581. /**
  78582. * Loads a file from a url
  78583. * @param url url to load
  78584. * @param onSuccess callback called when the file successfully loads
  78585. * @param onProgress callback called while file is loading (if the server supports this mode)
  78586. * @param offlineProvider defines the offline provider for caching
  78587. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  78588. * @param onError callback called when the file fails to load
  78589. * @returns a file request object
  78590. */
  78591. 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;
  78592. /**
  78593. * Loads a file
  78594. * @param url url to load
  78595. * @param onSuccess callback called when the file successfully loads
  78596. * @param onProgress callback called while file is loading (if the server supports this mode)
  78597. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  78598. * @param onError callback called when the file fails to load
  78599. * @param onOpened callback called when the web request is opened
  78600. * @returns a file request object
  78601. */
  78602. 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;
  78603. /**
  78604. * Checks if the loaded document was accessed via `file:`-Protocol.
  78605. * @returns boolean
  78606. */
  78607. static IsFileURL(): boolean;
  78608. }
  78609. }
  78610. declare module BABYLON {
  78611. /** @hidden */
  78612. export class ShaderProcessor {
  78613. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  78614. private static _ProcessPrecision;
  78615. private static _ExtractOperation;
  78616. private static _BuildSubExpression;
  78617. private static _BuildExpression;
  78618. private static _MoveCursorWithinIf;
  78619. private static _MoveCursor;
  78620. private static _EvaluatePreProcessors;
  78621. private static _PreparePreProcessors;
  78622. private static _ProcessShaderConversion;
  78623. private static _ProcessIncludes;
  78624. /**
  78625. * Loads a file from a url
  78626. * @param url url to load
  78627. * @param onSuccess callback called when the file successfully loads
  78628. * @param onProgress callback called while file is loading (if the server supports this mode)
  78629. * @param offlineProvider defines the offline provider for caching
  78630. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  78631. * @param onError callback called when the file fails to load
  78632. * @returns a file request object
  78633. * @hidden
  78634. */
  78635. 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;
  78636. }
  78637. }
  78638. declare module BABYLON {
  78639. /**
  78640. * @hidden
  78641. */
  78642. export interface IColor4Like {
  78643. r: float;
  78644. g: float;
  78645. b: float;
  78646. a: float;
  78647. }
  78648. /**
  78649. * @hidden
  78650. */
  78651. export interface IColor3Like {
  78652. r: float;
  78653. g: float;
  78654. b: float;
  78655. }
  78656. /**
  78657. * @hidden
  78658. */
  78659. export interface IVector4Like {
  78660. x: float;
  78661. y: float;
  78662. z: float;
  78663. w: float;
  78664. }
  78665. /**
  78666. * @hidden
  78667. */
  78668. export interface IVector3Like {
  78669. x: float;
  78670. y: float;
  78671. z: float;
  78672. }
  78673. /**
  78674. * @hidden
  78675. */
  78676. export interface IVector2Like {
  78677. x: float;
  78678. y: float;
  78679. }
  78680. /**
  78681. * @hidden
  78682. */
  78683. export interface IMatrixLike {
  78684. toArray(): DeepImmutable<Float32Array>;
  78685. updateFlag: int;
  78686. }
  78687. /**
  78688. * @hidden
  78689. */
  78690. export interface IViewportLike {
  78691. x: float;
  78692. y: float;
  78693. width: float;
  78694. height: float;
  78695. }
  78696. /**
  78697. * @hidden
  78698. */
  78699. export interface IPlaneLike {
  78700. normal: IVector3Like;
  78701. d: float;
  78702. normalize(): void;
  78703. }
  78704. }
  78705. declare module BABYLON {
  78706. /**
  78707. * Interface used to define common properties for effect fallbacks
  78708. */
  78709. export interface IEffectFallbacks {
  78710. /**
  78711. * Removes the defines that should be removed when falling back.
  78712. * @param currentDefines defines the current define statements for the shader.
  78713. * @param effect defines the current effect we try to compile
  78714. * @returns The resulting defines with defines of the current rank removed.
  78715. */
  78716. reduce(currentDefines: string, effect: Effect): string;
  78717. /**
  78718. * Removes the fallback from the bound mesh.
  78719. */
  78720. unBindMesh(): void;
  78721. /**
  78722. * Checks to see if more fallbacks are still availible.
  78723. */
  78724. hasMoreFallbacks: boolean;
  78725. }
  78726. }
  78727. declare module BABYLON {
  78728. /**
  78729. * Class used to evalaute queries containing `and` and `or` operators
  78730. */
  78731. export class AndOrNotEvaluator {
  78732. /**
  78733. * Evaluate a query
  78734. * @param query defines the query to evaluate
  78735. * @param evaluateCallback defines the callback used to filter result
  78736. * @returns true if the query matches
  78737. */
  78738. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  78739. private static _HandleParenthesisContent;
  78740. private static _SimplifyNegation;
  78741. }
  78742. }
  78743. declare module BABYLON {
  78744. /**
  78745. * Class used to store custom tags
  78746. */
  78747. export class Tags {
  78748. /**
  78749. * Adds support for tags on the given object
  78750. * @param obj defines the object to use
  78751. */
  78752. static EnableFor(obj: any): void;
  78753. /**
  78754. * Removes tags support
  78755. * @param obj defines the object to use
  78756. */
  78757. static DisableFor(obj: any): void;
  78758. /**
  78759. * Gets a boolean indicating if the given object has tags
  78760. * @param obj defines the object to use
  78761. * @returns a boolean
  78762. */
  78763. static HasTags(obj: any): boolean;
  78764. /**
  78765. * Gets the tags available on a given object
  78766. * @param obj defines the object to use
  78767. * @param asString defines if the tags must be returned as a string instead of an array of strings
  78768. * @returns the tags
  78769. */
  78770. static GetTags(obj: any, asString?: boolean): any;
  78771. /**
  78772. * Adds tags to an object
  78773. * @param obj defines the object to use
  78774. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  78775. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  78776. */
  78777. static AddTagsTo(obj: any, tagsString: string): void;
  78778. /**
  78779. * @hidden
  78780. */
  78781. static _AddTagTo(obj: any, tag: string): void;
  78782. /**
  78783. * Removes specific tags from a specific object
  78784. * @param obj defines the object to use
  78785. * @param tagsString defines the tags to remove
  78786. */
  78787. static RemoveTagsFrom(obj: any, tagsString: string): void;
  78788. /**
  78789. * @hidden
  78790. */
  78791. static _RemoveTagFrom(obj: any, tag: string): void;
  78792. /**
  78793. * Defines if tags hosted on an object match a given query
  78794. * @param obj defines the object to use
  78795. * @param tagsQuery defines the tag query
  78796. * @returns a boolean
  78797. */
  78798. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  78799. }
  78800. }
  78801. declare module BABYLON {
  78802. /**
  78803. * Scalar computation library
  78804. */
  78805. export class Scalar {
  78806. /**
  78807. * Two pi constants convenient for computation.
  78808. */
  78809. static TwoPi: number;
  78810. /**
  78811. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  78812. * @param a number
  78813. * @param b number
  78814. * @param epsilon (default = 1.401298E-45)
  78815. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  78816. */
  78817. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  78818. /**
  78819. * Returns a string : the upper case translation of the number i to hexadecimal.
  78820. * @param i number
  78821. * @returns the upper case translation of the number i to hexadecimal.
  78822. */
  78823. static ToHex(i: number): string;
  78824. /**
  78825. * Returns -1 if value is negative and +1 is value is positive.
  78826. * @param value the value
  78827. * @returns the value itself if it's equal to zero.
  78828. */
  78829. static Sign(value: number): number;
  78830. /**
  78831. * Returns the value itself if it's between min and max.
  78832. * Returns min if the value is lower than min.
  78833. * Returns max if the value is greater than max.
  78834. * @param value the value to clmap
  78835. * @param min the min value to clamp to (default: 0)
  78836. * @param max the max value to clamp to (default: 1)
  78837. * @returns the clamped value
  78838. */
  78839. static Clamp(value: number, min?: number, max?: number): number;
  78840. /**
  78841. * the log2 of value.
  78842. * @param value the value to compute log2 of
  78843. * @returns the log2 of value.
  78844. */
  78845. static Log2(value: number): number;
  78846. /**
  78847. * Loops the value, so that it is never larger than length and never smaller than 0.
  78848. *
  78849. * This is similar to the modulo operator but it works with floating point numbers.
  78850. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  78851. * With t = 5 and length = 2.5, the result would be 0.0.
  78852. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  78853. * @param value the value
  78854. * @param length the length
  78855. * @returns the looped value
  78856. */
  78857. static Repeat(value: number, length: number): number;
  78858. /**
  78859. * Normalize the value between 0.0 and 1.0 using min and max values
  78860. * @param value value to normalize
  78861. * @param min max to normalize between
  78862. * @param max min to normalize between
  78863. * @returns the normalized value
  78864. */
  78865. static Normalize(value: number, min: number, max: number): number;
  78866. /**
  78867. * Denormalize the value from 0.0 and 1.0 using min and max values
  78868. * @param normalized value to denormalize
  78869. * @param min max to denormalize between
  78870. * @param max min to denormalize between
  78871. * @returns the denormalized value
  78872. */
  78873. static Denormalize(normalized: number, min: number, max: number): number;
  78874. /**
  78875. * Calculates the shortest difference between two given angles given in degrees.
  78876. * @param current current angle in degrees
  78877. * @param target target angle in degrees
  78878. * @returns the delta
  78879. */
  78880. static DeltaAngle(current: number, target: number): number;
  78881. /**
  78882. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  78883. * @param tx value
  78884. * @param length length
  78885. * @returns The returned value will move back and forth between 0 and length
  78886. */
  78887. static PingPong(tx: number, length: number): number;
  78888. /**
  78889. * Interpolates between min and max with smoothing at the limits.
  78890. *
  78891. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  78892. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  78893. * @param from from
  78894. * @param to to
  78895. * @param tx value
  78896. * @returns the smooth stepped value
  78897. */
  78898. static SmoothStep(from: number, to: number, tx: number): number;
  78899. /**
  78900. * Moves a value current towards target.
  78901. *
  78902. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  78903. * Negative values of maxDelta pushes the value away from target.
  78904. * @param current current value
  78905. * @param target target value
  78906. * @param maxDelta max distance to move
  78907. * @returns resulting value
  78908. */
  78909. static MoveTowards(current: number, target: number, maxDelta: number): number;
  78910. /**
  78911. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  78912. *
  78913. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  78914. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  78915. * @param current current value
  78916. * @param target target value
  78917. * @param maxDelta max distance to move
  78918. * @returns resulting angle
  78919. */
  78920. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  78921. /**
  78922. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  78923. * @param start start value
  78924. * @param end target value
  78925. * @param amount amount to lerp between
  78926. * @returns the lerped value
  78927. */
  78928. static Lerp(start: number, end: number, amount: number): number;
  78929. /**
  78930. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  78931. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  78932. * @param start start value
  78933. * @param end target value
  78934. * @param amount amount to lerp between
  78935. * @returns the lerped value
  78936. */
  78937. static LerpAngle(start: number, end: number, amount: number): number;
  78938. /**
  78939. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  78940. * @param a start value
  78941. * @param b target value
  78942. * @param value value between a and b
  78943. * @returns the inverseLerp value
  78944. */
  78945. static InverseLerp(a: number, b: number, value: number): number;
  78946. /**
  78947. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  78948. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  78949. * @param value1 spline value
  78950. * @param tangent1 spline value
  78951. * @param value2 spline value
  78952. * @param tangent2 spline value
  78953. * @param amount input value
  78954. * @returns hermite result
  78955. */
  78956. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  78957. /**
  78958. * Returns a random float number between and min and max values
  78959. * @param min min value of random
  78960. * @param max max value of random
  78961. * @returns random value
  78962. */
  78963. static RandomRange(min: number, max: number): number;
  78964. /**
  78965. * This function returns percentage of a number in a given range.
  78966. *
  78967. * RangeToPercent(40,20,60) will return 0.5 (50%)
  78968. * RangeToPercent(34,0,100) will return 0.34 (34%)
  78969. * @param number to convert to percentage
  78970. * @param min min range
  78971. * @param max max range
  78972. * @returns the percentage
  78973. */
  78974. static RangeToPercent(number: number, min: number, max: number): number;
  78975. /**
  78976. * This function returns number that corresponds to the percentage in a given range.
  78977. *
  78978. * PercentToRange(0.34,0,100) will return 34.
  78979. * @param percent to convert to number
  78980. * @param min min range
  78981. * @param max max range
  78982. * @returns the number
  78983. */
  78984. static PercentToRange(percent: number, min: number, max: number): number;
  78985. /**
  78986. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  78987. * @param angle The angle to normalize in radian.
  78988. * @return The converted angle.
  78989. */
  78990. static NormalizeRadians(angle: number): number;
  78991. }
  78992. }
  78993. declare module BABYLON {
  78994. /**
  78995. * Constant used to convert a value to gamma space
  78996. * @ignorenaming
  78997. */
  78998. export const ToGammaSpace: number;
  78999. /**
  79000. * Constant used to convert a value to linear space
  79001. * @ignorenaming
  79002. */
  79003. export const ToLinearSpace = 2.2;
  79004. /**
  79005. * Constant used to define the minimal number value in Babylon.js
  79006. * @ignorenaming
  79007. */
  79008. let Epsilon: number;
  79009. }
  79010. declare module BABYLON {
  79011. /**
  79012. * Class used to represent a viewport on screen
  79013. */
  79014. export class Viewport {
  79015. /** viewport left coordinate */
  79016. x: number;
  79017. /** viewport top coordinate */
  79018. y: number;
  79019. /**viewport width */
  79020. width: number;
  79021. /** viewport height */
  79022. height: number;
  79023. /**
  79024. * Creates a Viewport object located at (x, y) and sized (width, height)
  79025. * @param x defines viewport left coordinate
  79026. * @param y defines viewport top coordinate
  79027. * @param width defines the viewport width
  79028. * @param height defines the viewport height
  79029. */
  79030. constructor(
  79031. /** viewport left coordinate */
  79032. x: number,
  79033. /** viewport top coordinate */
  79034. y: number,
  79035. /**viewport width */
  79036. width: number,
  79037. /** viewport height */
  79038. height: number);
  79039. /**
  79040. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  79041. * @param renderWidth defines the rendering width
  79042. * @param renderHeight defines the rendering height
  79043. * @returns a new Viewport
  79044. */
  79045. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  79046. /**
  79047. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  79048. * @param renderWidth defines the rendering width
  79049. * @param renderHeight defines the rendering height
  79050. * @param ref defines the target viewport
  79051. * @returns the current viewport
  79052. */
  79053. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  79054. /**
  79055. * Returns a new Viewport copied from the current one
  79056. * @returns a new Viewport
  79057. */
  79058. clone(): Viewport;
  79059. }
  79060. }
  79061. declare module BABYLON {
  79062. /**
  79063. * Class containing a set of static utilities functions for arrays.
  79064. */
  79065. export class ArrayTools {
  79066. /**
  79067. * Returns an array of the given size filled with element built from the given constructor and the paramters
  79068. * @param size the number of element to construct and put in the array
  79069. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  79070. * @returns a new array filled with new objects
  79071. */
  79072. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  79073. }
  79074. }
  79075. declare module BABYLON {
  79076. /**
  79077. * Represens a plane by the equation ax + by + cz + d = 0
  79078. */
  79079. export class Plane {
  79080. private static _TmpMatrix;
  79081. /**
  79082. * Normal of the plane (a,b,c)
  79083. */
  79084. normal: Vector3;
  79085. /**
  79086. * d component of the plane
  79087. */
  79088. d: number;
  79089. /**
  79090. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  79091. * @param a a component of the plane
  79092. * @param b b component of the plane
  79093. * @param c c component of the plane
  79094. * @param d d component of the plane
  79095. */
  79096. constructor(a: number, b: number, c: number, d: number);
  79097. /**
  79098. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  79099. */
  79100. asArray(): number[];
  79101. /**
  79102. * @returns a new plane copied from the current Plane.
  79103. */
  79104. clone(): Plane;
  79105. /**
  79106. * @returns the string "Plane".
  79107. */
  79108. getClassName(): string;
  79109. /**
  79110. * @returns the Plane hash code.
  79111. */
  79112. getHashCode(): number;
  79113. /**
  79114. * Normalize the current Plane in place.
  79115. * @returns the updated Plane.
  79116. */
  79117. normalize(): Plane;
  79118. /**
  79119. * Applies a transformation the plane and returns the result
  79120. * @param transformation the transformation matrix to be applied to the plane
  79121. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  79122. */
  79123. transform(transformation: DeepImmutable<Matrix>): Plane;
  79124. /**
  79125. * Compute the dot product between the point and the plane normal
  79126. * @param point point to calculate the dot product with
  79127. * @returns the dot product (float) of the point coordinates and the plane normal.
  79128. */
  79129. dotCoordinate(point: DeepImmutable<Vector3>): number;
  79130. /**
  79131. * Updates the current Plane from the plane defined by the three given points.
  79132. * @param point1 one of the points used to contruct the plane
  79133. * @param point2 one of the points used to contruct the plane
  79134. * @param point3 one of the points used to contruct the plane
  79135. * @returns the updated Plane.
  79136. */
  79137. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  79138. /**
  79139. * Checks if the plane is facing a given direction
  79140. * @param direction the direction to check if the plane is facing
  79141. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  79142. * @returns True is the vector "direction" is the same side than the plane normal.
  79143. */
  79144. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  79145. /**
  79146. * Calculates the distance to a point
  79147. * @param point point to calculate distance to
  79148. * @returns the signed distance (float) from the given point to the Plane.
  79149. */
  79150. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  79151. /**
  79152. * Creates a plane from an array
  79153. * @param array the array to create a plane from
  79154. * @returns a new Plane from the given array.
  79155. */
  79156. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  79157. /**
  79158. * Creates a plane from three points
  79159. * @param point1 point used to create the plane
  79160. * @param point2 point used to create the plane
  79161. * @param point3 point used to create the plane
  79162. * @returns a new Plane defined by the three given points.
  79163. */
  79164. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  79165. /**
  79166. * Creates a plane from an origin point and a normal
  79167. * @param origin origin of the plane to be constructed
  79168. * @param normal normal of the plane to be constructed
  79169. * @returns a new Plane the normal vector to this plane at the given origin point.
  79170. * Note : the vector "normal" is updated because normalized.
  79171. */
  79172. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  79173. /**
  79174. * Calculates the distance from a plane and a point
  79175. * @param origin origin of the plane to be constructed
  79176. * @param normal normal of the plane to be constructed
  79177. * @param point point to calculate distance to
  79178. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  79179. */
  79180. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  79181. }
  79182. }
  79183. declare module BABYLON {
  79184. /**
  79185. * Class representing a vector containing 2 coordinates
  79186. */
  79187. export class Vector2 {
  79188. /** defines the first coordinate */
  79189. x: number;
  79190. /** defines the second coordinate */
  79191. y: number;
  79192. /**
  79193. * Creates a new Vector2 from the given x and y coordinates
  79194. * @param x defines the first coordinate
  79195. * @param y defines the second coordinate
  79196. */
  79197. constructor(
  79198. /** defines the first coordinate */
  79199. x?: number,
  79200. /** defines the second coordinate */
  79201. y?: number);
  79202. /**
  79203. * Gets a string with the Vector2 coordinates
  79204. * @returns a string with the Vector2 coordinates
  79205. */
  79206. toString(): string;
  79207. /**
  79208. * Gets class name
  79209. * @returns the string "Vector2"
  79210. */
  79211. getClassName(): string;
  79212. /**
  79213. * Gets current vector hash code
  79214. * @returns the Vector2 hash code as a number
  79215. */
  79216. getHashCode(): number;
  79217. /**
  79218. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  79219. * @param array defines the source array
  79220. * @param index defines the offset in source array
  79221. * @returns the current Vector2
  79222. */
  79223. toArray(array: FloatArray, index?: number): Vector2;
  79224. /**
  79225. * Copy the current vector to an array
  79226. * @returns a new array with 2 elements: the Vector2 coordinates.
  79227. */
  79228. asArray(): number[];
  79229. /**
  79230. * Sets the Vector2 coordinates with the given Vector2 coordinates
  79231. * @param source defines the source Vector2
  79232. * @returns the current updated Vector2
  79233. */
  79234. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  79235. /**
  79236. * Sets the Vector2 coordinates with the given floats
  79237. * @param x defines the first coordinate
  79238. * @param y defines the second coordinate
  79239. * @returns the current updated Vector2
  79240. */
  79241. copyFromFloats(x: number, y: number): Vector2;
  79242. /**
  79243. * Sets the Vector2 coordinates with the given floats
  79244. * @param x defines the first coordinate
  79245. * @param y defines the second coordinate
  79246. * @returns the current updated Vector2
  79247. */
  79248. set(x: number, y: number): Vector2;
  79249. /**
  79250. * Add another vector with the current one
  79251. * @param otherVector defines the other vector
  79252. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  79253. */
  79254. add(otherVector: DeepImmutable<Vector2>): Vector2;
  79255. /**
  79256. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  79257. * @param otherVector defines the other vector
  79258. * @param result defines the target vector
  79259. * @returns the unmodified current Vector2
  79260. */
  79261. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  79262. /**
  79263. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  79264. * @param otherVector defines the other vector
  79265. * @returns the current updated Vector2
  79266. */
  79267. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  79268. /**
  79269. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  79270. * @param otherVector defines the other vector
  79271. * @returns a new Vector2
  79272. */
  79273. addVector3(otherVector: Vector3): Vector2;
  79274. /**
  79275. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  79276. * @param otherVector defines the other vector
  79277. * @returns a new Vector2
  79278. */
  79279. subtract(otherVector: Vector2): Vector2;
  79280. /**
  79281. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  79282. * @param otherVector defines the other vector
  79283. * @param result defines the target vector
  79284. * @returns the unmodified current Vector2
  79285. */
  79286. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  79287. /**
  79288. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  79289. * @param otherVector defines the other vector
  79290. * @returns the current updated Vector2
  79291. */
  79292. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  79293. /**
  79294. * Multiplies in place the current Vector2 coordinates by the given ones
  79295. * @param otherVector defines the other vector
  79296. * @returns the current updated Vector2
  79297. */
  79298. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  79299. /**
  79300. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  79301. * @param otherVector defines the other vector
  79302. * @returns a new Vector2
  79303. */
  79304. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  79305. /**
  79306. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  79307. * @param otherVector defines the other vector
  79308. * @param result defines the target vector
  79309. * @returns the unmodified current Vector2
  79310. */
  79311. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  79312. /**
  79313. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  79314. * @param x defines the first coordinate
  79315. * @param y defines the second coordinate
  79316. * @returns a new Vector2
  79317. */
  79318. multiplyByFloats(x: number, y: number): Vector2;
  79319. /**
  79320. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  79321. * @param otherVector defines the other vector
  79322. * @returns a new Vector2
  79323. */
  79324. divide(otherVector: Vector2): Vector2;
  79325. /**
  79326. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  79327. * @param otherVector defines the other vector
  79328. * @param result defines the target vector
  79329. * @returns the unmodified current Vector2
  79330. */
  79331. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  79332. /**
  79333. * Divides the current Vector2 coordinates by the given ones
  79334. * @param otherVector defines the other vector
  79335. * @returns the current updated Vector2
  79336. */
  79337. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  79338. /**
  79339. * Gets a new Vector2 with current Vector2 negated coordinates
  79340. * @returns a new Vector2
  79341. */
  79342. negate(): Vector2;
  79343. /**
  79344. * Negate this vector in place
  79345. * @returns this
  79346. */
  79347. negateInPlace(): Vector2;
  79348. /**
  79349. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  79350. * @param result defines the Vector3 object where to store the result
  79351. * @returns the current Vector2
  79352. */
  79353. negateToRef(result: Vector2): Vector2;
  79354. /**
  79355. * Multiply the Vector2 coordinates by scale
  79356. * @param scale defines the scaling factor
  79357. * @returns the current updated Vector2
  79358. */
  79359. scaleInPlace(scale: number): Vector2;
  79360. /**
  79361. * Returns a new Vector2 scaled by "scale" from the current Vector2
  79362. * @param scale defines the scaling factor
  79363. * @returns a new Vector2
  79364. */
  79365. scale(scale: number): Vector2;
  79366. /**
  79367. * Scale the current Vector2 values by a factor to a given Vector2
  79368. * @param scale defines the scale factor
  79369. * @param result defines the Vector2 object where to store the result
  79370. * @returns the unmodified current Vector2
  79371. */
  79372. scaleToRef(scale: number, result: Vector2): Vector2;
  79373. /**
  79374. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  79375. * @param scale defines the scale factor
  79376. * @param result defines the Vector2 object where to store the result
  79377. * @returns the unmodified current Vector2
  79378. */
  79379. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  79380. /**
  79381. * Gets a boolean if two vectors are equals
  79382. * @param otherVector defines the other vector
  79383. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  79384. */
  79385. equals(otherVector: DeepImmutable<Vector2>): boolean;
  79386. /**
  79387. * Gets a boolean if two vectors are equals (using an epsilon value)
  79388. * @param otherVector defines the other vector
  79389. * @param epsilon defines the minimal distance to consider equality
  79390. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  79391. */
  79392. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  79393. /**
  79394. * Gets a new Vector2 from current Vector2 floored values
  79395. * @returns a new Vector2
  79396. */
  79397. floor(): Vector2;
  79398. /**
  79399. * Gets a new Vector2 from current Vector2 floored values
  79400. * @returns a new Vector2
  79401. */
  79402. fract(): Vector2;
  79403. /**
  79404. * Gets the length of the vector
  79405. * @returns the vector length (float)
  79406. */
  79407. length(): number;
  79408. /**
  79409. * Gets the vector squared length
  79410. * @returns the vector squared length (float)
  79411. */
  79412. lengthSquared(): number;
  79413. /**
  79414. * Normalize the vector
  79415. * @returns the current updated Vector2
  79416. */
  79417. normalize(): Vector2;
  79418. /**
  79419. * Gets a new Vector2 copied from the Vector2
  79420. * @returns a new Vector2
  79421. */
  79422. clone(): Vector2;
  79423. /**
  79424. * Gets a new Vector2(0, 0)
  79425. * @returns a new Vector2
  79426. */
  79427. static Zero(): Vector2;
  79428. /**
  79429. * Gets a new Vector2(1, 1)
  79430. * @returns a new Vector2
  79431. */
  79432. static One(): Vector2;
  79433. /**
  79434. * Gets a new Vector2 set from the given index element of the given array
  79435. * @param array defines the data source
  79436. * @param offset defines the offset in the data source
  79437. * @returns a new Vector2
  79438. */
  79439. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  79440. /**
  79441. * Sets "result" from the given index element of the given array
  79442. * @param array defines the data source
  79443. * @param offset defines the offset in the data source
  79444. * @param result defines the target vector
  79445. */
  79446. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  79447. /**
  79448. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  79449. * @param value1 defines 1st point of control
  79450. * @param value2 defines 2nd point of control
  79451. * @param value3 defines 3rd point of control
  79452. * @param value4 defines 4th point of control
  79453. * @param amount defines the interpolation factor
  79454. * @returns a new Vector2
  79455. */
  79456. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  79457. /**
  79458. * 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".
  79459. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  79460. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  79461. * @param value defines the value to clamp
  79462. * @param min defines the lower limit
  79463. * @param max defines the upper limit
  79464. * @returns a new Vector2
  79465. */
  79466. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  79467. /**
  79468. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  79469. * @param value1 defines the 1st control point
  79470. * @param tangent1 defines the outgoing tangent
  79471. * @param value2 defines the 2nd control point
  79472. * @param tangent2 defines the incoming tangent
  79473. * @param amount defines the interpolation factor
  79474. * @returns a new Vector2
  79475. */
  79476. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  79477. /**
  79478. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  79479. * @param start defines the start vector
  79480. * @param end defines the end vector
  79481. * @param amount defines the interpolation factor
  79482. * @returns a new Vector2
  79483. */
  79484. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  79485. /**
  79486. * Gets the dot product of the vector "left" and the vector "right"
  79487. * @param left defines first vector
  79488. * @param right defines second vector
  79489. * @returns the dot product (float)
  79490. */
  79491. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  79492. /**
  79493. * Returns a new Vector2 equal to the normalized given vector
  79494. * @param vector defines the vector to normalize
  79495. * @returns a new Vector2
  79496. */
  79497. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  79498. /**
  79499. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  79500. * @param left defines 1st vector
  79501. * @param right defines 2nd vector
  79502. * @returns a new Vector2
  79503. */
  79504. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  79505. /**
  79506. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  79507. * @param left defines 1st vector
  79508. * @param right defines 2nd vector
  79509. * @returns a new Vector2
  79510. */
  79511. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  79512. /**
  79513. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  79514. * @param vector defines the vector to transform
  79515. * @param transformation defines the matrix to apply
  79516. * @returns a new Vector2
  79517. */
  79518. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  79519. /**
  79520. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  79521. * @param vector defines the vector to transform
  79522. * @param transformation defines the matrix to apply
  79523. * @param result defines the target vector
  79524. */
  79525. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  79526. /**
  79527. * Determines if a given vector is included in a triangle
  79528. * @param p defines the vector to test
  79529. * @param p0 defines 1st triangle point
  79530. * @param p1 defines 2nd triangle point
  79531. * @param p2 defines 3rd triangle point
  79532. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  79533. */
  79534. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  79535. /**
  79536. * Gets the distance between the vectors "value1" and "value2"
  79537. * @param value1 defines first vector
  79538. * @param value2 defines second vector
  79539. * @returns the distance between vectors
  79540. */
  79541. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  79542. /**
  79543. * Returns the squared distance between the vectors "value1" and "value2"
  79544. * @param value1 defines first vector
  79545. * @param value2 defines second vector
  79546. * @returns the squared distance between vectors
  79547. */
  79548. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  79549. /**
  79550. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  79551. * @param value1 defines first vector
  79552. * @param value2 defines second vector
  79553. * @returns a new Vector2
  79554. */
  79555. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  79556. /**
  79557. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  79558. * @param p defines the middle point
  79559. * @param segA defines one point of the segment
  79560. * @param segB defines the other point of the segment
  79561. * @returns the shortest distance
  79562. */
  79563. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  79564. }
  79565. /**
  79566. * Class used to store (x,y,z) vector representation
  79567. * A Vector3 is the main object used in 3D geometry
  79568. * It can represent etiher the coordinates of a point the space, either a direction
  79569. * Reminder: js uses a left handed forward facing system
  79570. */
  79571. export class Vector3 {
  79572. /**
  79573. * Defines the first coordinates (on X axis)
  79574. */
  79575. x: number;
  79576. /**
  79577. * Defines the second coordinates (on Y axis)
  79578. */
  79579. y: number;
  79580. /**
  79581. * Defines the third coordinates (on Z axis)
  79582. */
  79583. z: number;
  79584. private static _UpReadOnly;
  79585. private static _ZeroReadOnly;
  79586. /**
  79587. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  79588. * @param x defines the first coordinates (on X axis)
  79589. * @param y defines the second coordinates (on Y axis)
  79590. * @param z defines the third coordinates (on Z axis)
  79591. */
  79592. constructor(
  79593. /**
  79594. * Defines the first coordinates (on X axis)
  79595. */
  79596. x?: number,
  79597. /**
  79598. * Defines the second coordinates (on Y axis)
  79599. */
  79600. y?: number,
  79601. /**
  79602. * Defines the third coordinates (on Z axis)
  79603. */
  79604. z?: number);
  79605. /**
  79606. * Creates a string representation of the Vector3
  79607. * @returns a string with the Vector3 coordinates.
  79608. */
  79609. toString(): string;
  79610. /**
  79611. * Gets the class name
  79612. * @returns the string "Vector3"
  79613. */
  79614. getClassName(): string;
  79615. /**
  79616. * Creates the Vector3 hash code
  79617. * @returns a number which tends to be unique between Vector3 instances
  79618. */
  79619. getHashCode(): number;
  79620. /**
  79621. * Creates an array containing three elements : the coordinates of the Vector3
  79622. * @returns a new array of numbers
  79623. */
  79624. asArray(): number[];
  79625. /**
  79626. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  79627. * @param array defines the destination array
  79628. * @param index defines the offset in the destination array
  79629. * @returns the current Vector3
  79630. */
  79631. toArray(array: FloatArray, index?: number): Vector3;
  79632. /**
  79633. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  79634. * @returns a new Quaternion object, computed from the Vector3 coordinates
  79635. */
  79636. toQuaternion(): Quaternion;
  79637. /**
  79638. * Adds the given vector to the current Vector3
  79639. * @param otherVector defines the second operand
  79640. * @returns the current updated Vector3
  79641. */
  79642. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  79643. /**
  79644. * Adds the given coordinates to the current Vector3
  79645. * @param x defines the x coordinate of the operand
  79646. * @param y defines the y coordinate of the operand
  79647. * @param z defines the z coordinate of the operand
  79648. * @returns the current updated Vector3
  79649. */
  79650. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  79651. /**
  79652. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  79653. * @param otherVector defines the second operand
  79654. * @returns the resulting Vector3
  79655. */
  79656. add(otherVector: DeepImmutable<Vector3>): Vector3;
  79657. /**
  79658. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  79659. * @param otherVector defines the second operand
  79660. * @param result defines the Vector3 object where to store the result
  79661. * @returns the current Vector3
  79662. */
  79663. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  79664. /**
  79665. * Subtract the given vector from the current Vector3
  79666. * @param otherVector defines the second operand
  79667. * @returns the current updated Vector3
  79668. */
  79669. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  79670. /**
  79671. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  79672. * @param otherVector defines the second operand
  79673. * @returns the resulting Vector3
  79674. */
  79675. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  79676. /**
  79677. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  79678. * @param otherVector defines the second operand
  79679. * @param result defines the Vector3 object where to store the result
  79680. * @returns the current Vector3
  79681. */
  79682. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  79683. /**
  79684. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  79685. * @param x defines the x coordinate of the operand
  79686. * @param y defines the y coordinate of the operand
  79687. * @param z defines the z coordinate of the operand
  79688. * @returns the resulting Vector3
  79689. */
  79690. subtractFromFloats(x: number, y: number, z: number): Vector3;
  79691. /**
  79692. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  79693. * @param x defines the x coordinate of the operand
  79694. * @param y defines the y coordinate of the operand
  79695. * @param z defines the z coordinate of the operand
  79696. * @param result defines the Vector3 object where to store the result
  79697. * @returns the current Vector3
  79698. */
  79699. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  79700. /**
  79701. * Gets a new Vector3 set with the current Vector3 negated coordinates
  79702. * @returns a new Vector3
  79703. */
  79704. negate(): Vector3;
  79705. /**
  79706. * Negate this vector in place
  79707. * @returns this
  79708. */
  79709. negateInPlace(): Vector3;
  79710. /**
  79711. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  79712. * @param result defines the Vector3 object where to store the result
  79713. * @returns the current Vector3
  79714. */
  79715. negateToRef(result: Vector3): Vector3;
  79716. /**
  79717. * Multiplies the Vector3 coordinates by the float "scale"
  79718. * @param scale defines the multiplier factor
  79719. * @returns the current updated Vector3
  79720. */
  79721. scaleInPlace(scale: number): Vector3;
  79722. /**
  79723. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  79724. * @param scale defines the multiplier factor
  79725. * @returns a new Vector3
  79726. */
  79727. scale(scale: number): Vector3;
  79728. /**
  79729. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  79730. * @param scale defines the multiplier factor
  79731. * @param result defines the Vector3 object where to store the result
  79732. * @returns the current Vector3
  79733. */
  79734. scaleToRef(scale: number, result: Vector3): Vector3;
  79735. /**
  79736. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  79737. * @param scale defines the scale factor
  79738. * @param result defines the Vector3 object where to store the result
  79739. * @returns the unmodified current Vector3
  79740. */
  79741. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  79742. /**
  79743. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  79744. * @param origin defines the origin of the projection ray
  79745. * @param plane defines the plane to project to
  79746. * @returns the projected vector3
  79747. */
  79748. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  79749. /**
  79750. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  79751. * @param origin defines the origin of the projection ray
  79752. * @param plane defines the plane to project to
  79753. * @param result defines the Vector3 where to store the result
  79754. */
  79755. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  79756. /**
  79757. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  79758. * @param otherVector defines the second operand
  79759. * @returns true if both vectors are equals
  79760. */
  79761. equals(otherVector: DeepImmutable<Vector3>): boolean;
  79762. /**
  79763. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  79764. * @param otherVector defines the second operand
  79765. * @param epsilon defines the minimal distance to define values as equals
  79766. * @returns true if both vectors are distant less than epsilon
  79767. */
  79768. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  79769. /**
  79770. * Returns true if the current Vector3 coordinates equals the given floats
  79771. * @param x defines the x coordinate of the operand
  79772. * @param y defines the y coordinate of the operand
  79773. * @param z defines the z coordinate of the operand
  79774. * @returns true if both vectors are equals
  79775. */
  79776. equalsToFloats(x: number, y: number, z: number): boolean;
  79777. /**
  79778. * Multiplies the current Vector3 coordinates by the given ones
  79779. * @param otherVector defines the second operand
  79780. * @returns the current updated Vector3
  79781. */
  79782. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  79783. /**
  79784. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  79785. * @param otherVector defines the second operand
  79786. * @returns the new Vector3
  79787. */
  79788. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  79789. /**
  79790. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  79791. * @param otherVector defines the second operand
  79792. * @param result defines the Vector3 object where to store the result
  79793. * @returns the current Vector3
  79794. */
  79795. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  79796. /**
  79797. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  79798. * @param x defines the x coordinate of the operand
  79799. * @param y defines the y coordinate of the operand
  79800. * @param z defines the z coordinate of the operand
  79801. * @returns the new Vector3
  79802. */
  79803. multiplyByFloats(x: number, y: number, z: number): Vector3;
  79804. /**
  79805. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  79806. * @param otherVector defines the second operand
  79807. * @returns the new Vector3
  79808. */
  79809. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  79810. /**
  79811. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  79812. * @param otherVector defines the second operand
  79813. * @param result defines the Vector3 object where to store the result
  79814. * @returns the current Vector3
  79815. */
  79816. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  79817. /**
  79818. * Divides the current Vector3 coordinates by the given ones.
  79819. * @param otherVector defines the second operand
  79820. * @returns the current updated Vector3
  79821. */
  79822. divideInPlace(otherVector: Vector3): Vector3;
  79823. /**
  79824. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  79825. * @param other defines the second operand
  79826. * @returns the current updated Vector3
  79827. */
  79828. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  79829. /**
  79830. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  79831. * @param other defines the second operand
  79832. * @returns the current updated Vector3
  79833. */
  79834. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  79835. /**
  79836. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  79837. * @param x defines the x coordinate of the operand
  79838. * @param y defines the y coordinate of the operand
  79839. * @param z defines the z coordinate of the operand
  79840. * @returns the current updated Vector3
  79841. */
  79842. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  79843. /**
  79844. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  79845. * @param x defines the x coordinate of the operand
  79846. * @param y defines the y coordinate of the operand
  79847. * @param z defines the z coordinate of the operand
  79848. * @returns the current updated Vector3
  79849. */
  79850. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  79851. /**
  79852. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  79853. * Check if is non uniform within a certain amount of decimal places to account for this
  79854. * @param epsilon the amount the values can differ
  79855. * @returns if the the vector is non uniform to a certain number of decimal places
  79856. */
  79857. isNonUniformWithinEpsilon(epsilon: number): boolean;
  79858. /**
  79859. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  79860. */
  79861. get isNonUniform(): boolean;
  79862. /**
  79863. * Gets a new Vector3 from current Vector3 floored values
  79864. * @returns a new Vector3
  79865. */
  79866. floor(): Vector3;
  79867. /**
  79868. * Gets a new Vector3 from current Vector3 floored values
  79869. * @returns a new Vector3
  79870. */
  79871. fract(): Vector3;
  79872. /**
  79873. * Gets the length of the Vector3
  79874. * @returns the length of the Vector3
  79875. */
  79876. length(): number;
  79877. /**
  79878. * Gets the squared length of the Vector3
  79879. * @returns squared length of the Vector3
  79880. */
  79881. lengthSquared(): number;
  79882. /**
  79883. * Normalize the current Vector3.
  79884. * Please note that this is an in place operation.
  79885. * @returns the current updated Vector3
  79886. */
  79887. normalize(): Vector3;
  79888. /**
  79889. * Reorders the x y z properties of the vector in place
  79890. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  79891. * @returns the current updated vector
  79892. */
  79893. reorderInPlace(order: string): this;
  79894. /**
  79895. * Rotates the vector around 0,0,0 by a quaternion
  79896. * @param quaternion the rotation quaternion
  79897. * @param result vector to store the result
  79898. * @returns the resulting vector
  79899. */
  79900. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  79901. /**
  79902. * Rotates a vector around a given point
  79903. * @param quaternion the rotation quaternion
  79904. * @param point the point to rotate around
  79905. * @param result vector to store the result
  79906. * @returns the resulting vector
  79907. */
  79908. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  79909. /**
  79910. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  79911. * The cross product is then orthogonal to both current and "other"
  79912. * @param other defines the right operand
  79913. * @returns the cross product
  79914. */
  79915. cross(other: Vector3): Vector3;
  79916. /**
  79917. * Normalize the current Vector3 with the given input length.
  79918. * Please note that this is an in place operation.
  79919. * @param len the length of the vector
  79920. * @returns the current updated Vector3
  79921. */
  79922. normalizeFromLength(len: number): Vector3;
  79923. /**
  79924. * Normalize the current Vector3 to a new vector
  79925. * @returns the new Vector3
  79926. */
  79927. normalizeToNew(): Vector3;
  79928. /**
  79929. * Normalize the current Vector3 to the reference
  79930. * @param reference define the Vector3 to update
  79931. * @returns the updated Vector3
  79932. */
  79933. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  79934. /**
  79935. * Creates a new Vector3 copied from the current Vector3
  79936. * @returns the new Vector3
  79937. */
  79938. clone(): Vector3;
  79939. /**
  79940. * Copies the given vector coordinates to the current Vector3 ones
  79941. * @param source defines the source Vector3
  79942. * @returns the current updated Vector3
  79943. */
  79944. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  79945. /**
  79946. * Copies the given floats to the current Vector3 coordinates
  79947. * @param x defines the x coordinate of the operand
  79948. * @param y defines the y coordinate of the operand
  79949. * @param z defines the z coordinate of the operand
  79950. * @returns the current updated Vector3
  79951. */
  79952. copyFromFloats(x: number, y: number, z: number): Vector3;
  79953. /**
  79954. * Copies the given floats to the current Vector3 coordinates
  79955. * @param x defines the x coordinate of the operand
  79956. * @param y defines the y coordinate of the operand
  79957. * @param z defines the z coordinate of the operand
  79958. * @returns the current updated Vector3
  79959. */
  79960. set(x: number, y: number, z: number): Vector3;
  79961. /**
  79962. * Copies the given float to the current Vector3 coordinates
  79963. * @param v defines the x, y and z coordinates of the operand
  79964. * @returns the current updated Vector3
  79965. */
  79966. setAll(v: number): Vector3;
  79967. /**
  79968. * Get the clip factor between two vectors
  79969. * @param vector0 defines the first operand
  79970. * @param vector1 defines the second operand
  79971. * @param axis defines the axis to use
  79972. * @param size defines the size along the axis
  79973. * @returns the clip factor
  79974. */
  79975. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  79976. /**
  79977. * Get angle between two vectors
  79978. * @param vector0 angle between vector0 and vector1
  79979. * @param vector1 angle between vector0 and vector1
  79980. * @param normal direction of the normal
  79981. * @return the angle between vector0 and vector1
  79982. */
  79983. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  79984. /**
  79985. * Returns a new Vector3 set from the index "offset" of the given array
  79986. * @param array defines the source array
  79987. * @param offset defines the offset in the source array
  79988. * @returns the new Vector3
  79989. */
  79990. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  79991. /**
  79992. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  79993. * @param array defines the source array
  79994. * @param offset defines the offset in the source array
  79995. * @returns the new Vector3
  79996. * @deprecated Please use FromArray instead.
  79997. */
  79998. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  79999. /**
  80000. * Sets the given vector "result" with the element values from the index "offset" of the given array
  80001. * @param array defines the source array
  80002. * @param offset defines the offset in the source array
  80003. * @param result defines the Vector3 where to store the result
  80004. */
  80005. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  80006. /**
  80007. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  80008. * @param array defines the source array
  80009. * @param offset defines the offset in the source array
  80010. * @param result defines the Vector3 where to store the result
  80011. * @deprecated Please use FromArrayToRef instead.
  80012. */
  80013. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  80014. /**
  80015. * Sets the given vector "result" with the given floats.
  80016. * @param x defines the x coordinate of the source
  80017. * @param y defines the y coordinate of the source
  80018. * @param z defines the z coordinate of the source
  80019. * @param result defines the Vector3 where to store the result
  80020. */
  80021. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  80022. /**
  80023. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  80024. * @returns a new empty Vector3
  80025. */
  80026. static Zero(): Vector3;
  80027. /**
  80028. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  80029. * @returns a new unit Vector3
  80030. */
  80031. static One(): Vector3;
  80032. /**
  80033. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  80034. * @returns a new up Vector3
  80035. */
  80036. static Up(): Vector3;
  80037. /**
  80038. * Gets a up Vector3 that must not be updated
  80039. */
  80040. static get UpReadOnly(): DeepImmutable<Vector3>;
  80041. /**
  80042. * Gets a zero Vector3 that must not be updated
  80043. */
  80044. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  80045. /**
  80046. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  80047. * @returns a new down Vector3
  80048. */
  80049. static Down(): Vector3;
  80050. /**
  80051. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  80052. * @param rightHandedSystem is the scene right-handed (negative z)
  80053. * @returns a new forward Vector3
  80054. */
  80055. static Forward(rightHandedSystem?: boolean): Vector3;
  80056. /**
  80057. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  80058. * @param rightHandedSystem is the scene right-handed (negative-z)
  80059. * @returns a new forward Vector3
  80060. */
  80061. static Backward(rightHandedSystem?: boolean): Vector3;
  80062. /**
  80063. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  80064. * @returns a new right Vector3
  80065. */
  80066. static Right(): Vector3;
  80067. /**
  80068. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  80069. * @returns a new left Vector3
  80070. */
  80071. static Left(): Vector3;
  80072. /**
  80073. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  80074. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  80075. * @param vector defines the Vector3 to transform
  80076. * @param transformation defines the transformation matrix
  80077. * @returns the transformed Vector3
  80078. */
  80079. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  80080. /**
  80081. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  80082. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  80083. * @param vector defines the Vector3 to transform
  80084. * @param transformation defines the transformation matrix
  80085. * @param result defines the Vector3 where to store the result
  80086. */
  80087. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  80088. /**
  80089. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  80090. * This method computes tranformed coordinates only, not transformed direction vectors
  80091. * @param x define the x coordinate of the source vector
  80092. * @param y define the y coordinate of the source vector
  80093. * @param z define the z coordinate of the source vector
  80094. * @param transformation defines the transformation matrix
  80095. * @param result defines the Vector3 where to store the result
  80096. */
  80097. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  80098. /**
  80099. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  80100. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  80101. * @param vector defines the Vector3 to transform
  80102. * @param transformation defines the transformation matrix
  80103. * @returns the new Vector3
  80104. */
  80105. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  80106. /**
  80107. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  80108. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  80109. * @param vector defines the Vector3 to transform
  80110. * @param transformation defines the transformation matrix
  80111. * @param result defines the Vector3 where to store the result
  80112. */
  80113. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  80114. /**
  80115. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  80116. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  80117. * @param x define the x coordinate of the source vector
  80118. * @param y define the y coordinate of the source vector
  80119. * @param z define the z coordinate of the source vector
  80120. * @param transformation defines the transformation matrix
  80121. * @param result defines the Vector3 where to store the result
  80122. */
  80123. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  80124. /**
  80125. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  80126. * @param value1 defines the first control point
  80127. * @param value2 defines the second control point
  80128. * @param value3 defines the third control point
  80129. * @param value4 defines the fourth control point
  80130. * @param amount defines the amount on the spline to use
  80131. * @returns the new Vector3
  80132. */
  80133. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  80134. /**
  80135. * 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"
  80136. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  80137. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  80138. * @param value defines the current value
  80139. * @param min defines the lower range value
  80140. * @param max defines the upper range value
  80141. * @returns the new Vector3
  80142. */
  80143. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  80144. /**
  80145. * 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"
  80146. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  80147. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  80148. * @param value defines the current value
  80149. * @param min defines the lower range value
  80150. * @param max defines the upper range value
  80151. * @param result defines the Vector3 where to store the result
  80152. */
  80153. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  80154. /**
  80155. * Checks if a given vector is inside a specific range
  80156. * @param v defines the vector to test
  80157. * @param min defines the minimum range
  80158. * @param max defines the maximum range
  80159. */
  80160. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  80161. /**
  80162. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  80163. * @param value1 defines the first control point
  80164. * @param tangent1 defines the first tangent vector
  80165. * @param value2 defines the second control point
  80166. * @param tangent2 defines the second tangent vector
  80167. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  80168. * @returns the new Vector3
  80169. */
  80170. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  80171. /**
  80172. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  80173. * @param start defines the start value
  80174. * @param end defines the end value
  80175. * @param amount max defines amount between both (between 0 and 1)
  80176. * @returns the new Vector3
  80177. */
  80178. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  80179. /**
  80180. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  80181. * @param start defines the start value
  80182. * @param end defines the end value
  80183. * @param amount max defines amount between both (between 0 and 1)
  80184. * @param result defines the Vector3 where to store the result
  80185. */
  80186. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  80187. /**
  80188. * Returns the dot product (float) between the vectors "left" and "right"
  80189. * @param left defines the left operand
  80190. * @param right defines the right operand
  80191. * @returns the dot product
  80192. */
  80193. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  80194. /**
  80195. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  80196. * The cross product is then orthogonal to both "left" and "right"
  80197. * @param left defines the left operand
  80198. * @param right defines the right operand
  80199. * @returns the cross product
  80200. */
  80201. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  80202. /**
  80203. * Sets the given vector "result" with the cross product of "left" and "right"
  80204. * The cross product is then orthogonal to both "left" and "right"
  80205. * @param left defines the left operand
  80206. * @param right defines the right operand
  80207. * @param result defines the Vector3 where to store the result
  80208. */
  80209. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  80210. /**
  80211. * Returns a new Vector3 as the normalization of the given vector
  80212. * @param vector defines the Vector3 to normalize
  80213. * @returns the new Vector3
  80214. */
  80215. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  80216. /**
  80217. * Sets the given vector "result" with the normalization of the given first vector
  80218. * @param vector defines the Vector3 to normalize
  80219. * @param result defines the Vector3 where to store the result
  80220. */
  80221. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  80222. /**
  80223. * Project a Vector3 onto screen space
  80224. * @param vector defines the Vector3 to project
  80225. * @param world defines the world matrix to use
  80226. * @param transform defines the transform (view x projection) matrix to use
  80227. * @param viewport defines the screen viewport to use
  80228. * @returns the new Vector3
  80229. */
  80230. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  80231. /** @hidden */
  80232. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  80233. /**
  80234. * Unproject from screen space to object space
  80235. * @param source defines the screen space Vector3 to use
  80236. * @param viewportWidth defines the current width of the viewport
  80237. * @param viewportHeight defines the current height of the viewport
  80238. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  80239. * @param transform defines the transform (view x projection) matrix to use
  80240. * @returns the new Vector3
  80241. */
  80242. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  80243. /**
  80244. * Unproject from screen space to object space
  80245. * @param source defines the screen space Vector3 to use
  80246. * @param viewportWidth defines the current width of the viewport
  80247. * @param viewportHeight defines the current height of the viewport
  80248. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  80249. * @param view defines the view matrix to use
  80250. * @param projection defines the projection matrix to use
  80251. * @returns the new Vector3
  80252. */
  80253. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  80254. /**
  80255. * Unproject from screen space to object space
  80256. * @param source defines the screen space Vector3 to use
  80257. * @param viewportWidth defines the current width of the viewport
  80258. * @param viewportHeight defines the current height of the viewport
  80259. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  80260. * @param view defines the view matrix to use
  80261. * @param projection defines the projection matrix to use
  80262. * @param result defines the Vector3 where to store the result
  80263. */
  80264. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  80265. /**
  80266. * Unproject from screen space to object space
  80267. * @param sourceX defines the screen space x coordinate to use
  80268. * @param sourceY defines the screen space y coordinate to use
  80269. * @param sourceZ defines the screen space z coordinate to use
  80270. * @param viewportWidth defines the current width of the viewport
  80271. * @param viewportHeight defines the current height of the viewport
  80272. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  80273. * @param view defines the view matrix to use
  80274. * @param projection defines the projection matrix to use
  80275. * @param result defines the Vector3 where to store the result
  80276. */
  80277. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  80278. /**
  80279. * Gets the minimal coordinate values between two Vector3
  80280. * @param left defines the first operand
  80281. * @param right defines the second operand
  80282. * @returns the new Vector3
  80283. */
  80284. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  80285. /**
  80286. * Gets the maximal coordinate values between two Vector3
  80287. * @param left defines the first operand
  80288. * @param right defines the second operand
  80289. * @returns the new Vector3
  80290. */
  80291. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  80292. /**
  80293. * Returns the distance between the vectors "value1" and "value2"
  80294. * @param value1 defines the first operand
  80295. * @param value2 defines the second operand
  80296. * @returns the distance
  80297. */
  80298. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  80299. /**
  80300. * Returns the squared distance between the vectors "value1" and "value2"
  80301. * @param value1 defines the first operand
  80302. * @param value2 defines the second operand
  80303. * @returns the squared distance
  80304. */
  80305. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  80306. /**
  80307. * Returns a new Vector3 located at the center between "value1" and "value2"
  80308. * @param value1 defines the first operand
  80309. * @param value2 defines the second operand
  80310. * @returns the new Vector3
  80311. */
  80312. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  80313. /**
  80314. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  80315. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  80316. * to something in order to rotate it from its local system to the given target system
  80317. * Note: axis1, axis2 and axis3 are normalized during this operation
  80318. * @param axis1 defines the first axis
  80319. * @param axis2 defines the second axis
  80320. * @param axis3 defines the third axis
  80321. * @returns a new Vector3
  80322. */
  80323. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  80324. /**
  80325. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  80326. * @param axis1 defines the first axis
  80327. * @param axis2 defines the second axis
  80328. * @param axis3 defines the third axis
  80329. * @param ref defines the Vector3 where to store the result
  80330. */
  80331. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  80332. }
  80333. /**
  80334. * Vector4 class created for EulerAngle class conversion to Quaternion
  80335. */
  80336. export class Vector4 {
  80337. /** x value of the vector */
  80338. x: number;
  80339. /** y value of the vector */
  80340. y: number;
  80341. /** z value of the vector */
  80342. z: number;
  80343. /** w value of the vector */
  80344. w: number;
  80345. /**
  80346. * Creates a Vector4 object from the given floats.
  80347. * @param x x value of the vector
  80348. * @param y y value of the vector
  80349. * @param z z value of the vector
  80350. * @param w w value of the vector
  80351. */
  80352. constructor(
  80353. /** x value of the vector */
  80354. x: number,
  80355. /** y value of the vector */
  80356. y: number,
  80357. /** z value of the vector */
  80358. z: number,
  80359. /** w value of the vector */
  80360. w: number);
  80361. /**
  80362. * Returns the string with the Vector4 coordinates.
  80363. * @returns a string containing all the vector values
  80364. */
  80365. toString(): string;
  80366. /**
  80367. * Returns the string "Vector4".
  80368. * @returns "Vector4"
  80369. */
  80370. getClassName(): string;
  80371. /**
  80372. * Returns the Vector4 hash code.
  80373. * @returns a unique hash code
  80374. */
  80375. getHashCode(): number;
  80376. /**
  80377. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  80378. * @returns the resulting array
  80379. */
  80380. asArray(): number[];
  80381. /**
  80382. * Populates the given array from the given index with the Vector4 coordinates.
  80383. * @param array array to populate
  80384. * @param index index of the array to start at (default: 0)
  80385. * @returns the Vector4.
  80386. */
  80387. toArray(array: FloatArray, index?: number): Vector4;
  80388. /**
  80389. * Adds the given vector to the current Vector4.
  80390. * @param otherVector the vector to add
  80391. * @returns the updated Vector4.
  80392. */
  80393. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  80394. /**
  80395. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  80396. * @param otherVector the vector to add
  80397. * @returns the resulting vector
  80398. */
  80399. add(otherVector: DeepImmutable<Vector4>): Vector4;
  80400. /**
  80401. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  80402. * @param otherVector the vector to add
  80403. * @param result the vector to store the result
  80404. * @returns the current Vector4.
  80405. */
  80406. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  80407. /**
  80408. * Subtract in place the given vector from the current Vector4.
  80409. * @param otherVector the vector to subtract
  80410. * @returns the updated Vector4.
  80411. */
  80412. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  80413. /**
  80414. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  80415. * @param otherVector the vector to add
  80416. * @returns the new vector with the result
  80417. */
  80418. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  80419. /**
  80420. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  80421. * @param otherVector the vector to subtract
  80422. * @param result the vector to store the result
  80423. * @returns the current Vector4.
  80424. */
  80425. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  80426. /**
  80427. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  80428. */
  80429. /**
  80430. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  80431. * @param x value to subtract
  80432. * @param y value to subtract
  80433. * @param z value to subtract
  80434. * @param w value to subtract
  80435. * @returns new vector containing the result
  80436. */
  80437. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  80438. /**
  80439. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  80440. * @param x value to subtract
  80441. * @param y value to subtract
  80442. * @param z value to subtract
  80443. * @param w value to subtract
  80444. * @param result the vector to store the result in
  80445. * @returns the current Vector4.
  80446. */
  80447. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  80448. /**
  80449. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  80450. * @returns a new vector with the negated values
  80451. */
  80452. negate(): Vector4;
  80453. /**
  80454. * Negate this vector in place
  80455. * @returns this
  80456. */
  80457. negateInPlace(): Vector4;
  80458. /**
  80459. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  80460. * @param result defines the Vector3 object where to store the result
  80461. * @returns the current Vector4
  80462. */
  80463. negateToRef(result: Vector4): Vector4;
  80464. /**
  80465. * Multiplies the current Vector4 coordinates by scale (float).
  80466. * @param scale the number to scale with
  80467. * @returns the updated Vector4.
  80468. */
  80469. scaleInPlace(scale: number): Vector4;
  80470. /**
  80471. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  80472. * @param scale the number to scale with
  80473. * @returns a new vector with the result
  80474. */
  80475. scale(scale: number): Vector4;
  80476. /**
  80477. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  80478. * @param scale the number to scale with
  80479. * @param result a vector to store the result in
  80480. * @returns the current Vector4.
  80481. */
  80482. scaleToRef(scale: number, result: Vector4): Vector4;
  80483. /**
  80484. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  80485. * @param scale defines the scale factor
  80486. * @param result defines the Vector4 object where to store the result
  80487. * @returns the unmodified current Vector4
  80488. */
  80489. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  80490. /**
  80491. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  80492. * @param otherVector the vector to compare against
  80493. * @returns true if they are equal
  80494. */
  80495. equals(otherVector: DeepImmutable<Vector4>): boolean;
  80496. /**
  80497. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  80498. * @param otherVector vector to compare against
  80499. * @param epsilon (Default: very small number)
  80500. * @returns true if they are equal
  80501. */
  80502. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  80503. /**
  80504. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  80505. * @param x x value to compare against
  80506. * @param y y value to compare against
  80507. * @param z z value to compare against
  80508. * @param w w value to compare against
  80509. * @returns true if equal
  80510. */
  80511. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  80512. /**
  80513. * Multiplies in place the current Vector4 by the given one.
  80514. * @param otherVector vector to multiple with
  80515. * @returns the updated Vector4.
  80516. */
  80517. multiplyInPlace(otherVector: Vector4): Vector4;
  80518. /**
  80519. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  80520. * @param otherVector vector to multiple with
  80521. * @returns resulting new vector
  80522. */
  80523. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  80524. /**
  80525. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  80526. * @param otherVector vector to multiple with
  80527. * @param result vector to store the result
  80528. * @returns the current Vector4.
  80529. */
  80530. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  80531. /**
  80532. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  80533. * @param x x value multiply with
  80534. * @param y y value multiply with
  80535. * @param z z value multiply with
  80536. * @param w w value multiply with
  80537. * @returns resulting new vector
  80538. */
  80539. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  80540. /**
  80541. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  80542. * @param otherVector vector to devide with
  80543. * @returns resulting new vector
  80544. */
  80545. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  80546. /**
  80547. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  80548. * @param otherVector vector to devide with
  80549. * @param result vector to store the result
  80550. * @returns the current Vector4.
  80551. */
  80552. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  80553. /**
  80554. * Divides the current Vector3 coordinates by the given ones.
  80555. * @param otherVector vector to devide with
  80556. * @returns the updated Vector3.
  80557. */
  80558. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  80559. /**
  80560. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  80561. * @param other defines the second operand
  80562. * @returns the current updated Vector4
  80563. */
  80564. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  80565. /**
  80566. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  80567. * @param other defines the second operand
  80568. * @returns the current updated Vector4
  80569. */
  80570. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  80571. /**
  80572. * Gets a new Vector4 from current Vector4 floored values
  80573. * @returns a new Vector4
  80574. */
  80575. floor(): Vector4;
  80576. /**
  80577. * Gets a new Vector4 from current Vector3 floored values
  80578. * @returns a new Vector4
  80579. */
  80580. fract(): Vector4;
  80581. /**
  80582. * Returns the Vector4 length (float).
  80583. * @returns the length
  80584. */
  80585. length(): number;
  80586. /**
  80587. * Returns the Vector4 squared length (float).
  80588. * @returns the length squared
  80589. */
  80590. lengthSquared(): number;
  80591. /**
  80592. * Normalizes in place the Vector4.
  80593. * @returns the updated Vector4.
  80594. */
  80595. normalize(): Vector4;
  80596. /**
  80597. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  80598. * @returns this converted to a new vector3
  80599. */
  80600. toVector3(): Vector3;
  80601. /**
  80602. * Returns a new Vector4 copied from the current one.
  80603. * @returns the new cloned vector
  80604. */
  80605. clone(): Vector4;
  80606. /**
  80607. * Updates the current Vector4 with the given one coordinates.
  80608. * @param source the source vector to copy from
  80609. * @returns the updated Vector4.
  80610. */
  80611. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  80612. /**
  80613. * Updates the current Vector4 coordinates with the given floats.
  80614. * @param x float to copy from
  80615. * @param y float to copy from
  80616. * @param z float to copy from
  80617. * @param w float to copy from
  80618. * @returns the updated Vector4.
  80619. */
  80620. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  80621. /**
  80622. * Updates the current Vector4 coordinates with the given floats.
  80623. * @param x float to set from
  80624. * @param y float to set from
  80625. * @param z float to set from
  80626. * @param w float to set from
  80627. * @returns the updated Vector4.
  80628. */
  80629. set(x: number, y: number, z: number, w: number): Vector4;
  80630. /**
  80631. * Copies the given float to the current Vector3 coordinates
  80632. * @param v defines the x, y, z and w coordinates of the operand
  80633. * @returns the current updated Vector3
  80634. */
  80635. setAll(v: number): Vector4;
  80636. /**
  80637. * Returns a new Vector4 set from the starting index of the given array.
  80638. * @param array the array to pull values from
  80639. * @param offset the offset into the array to start at
  80640. * @returns the new vector
  80641. */
  80642. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  80643. /**
  80644. * Updates the given vector "result" from the starting index of the given array.
  80645. * @param array the array to pull values from
  80646. * @param offset the offset into the array to start at
  80647. * @param result the vector to store the result in
  80648. */
  80649. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  80650. /**
  80651. * Updates the given vector "result" from the starting index of the given Float32Array.
  80652. * @param array the array to pull values from
  80653. * @param offset the offset into the array to start at
  80654. * @param result the vector to store the result in
  80655. */
  80656. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  80657. /**
  80658. * Updates the given vector "result" coordinates from the given floats.
  80659. * @param x float to set from
  80660. * @param y float to set from
  80661. * @param z float to set from
  80662. * @param w float to set from
  80663. * @param result the vector to the floats in
  80664. */
  80665. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  80666. /**
  80667. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  80668. * @returns the new vector
  80669. */
  80670. static Zero(): Vector4;
  80671. /**
  80672. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  80673. * @returns the new vector
  80674. */
  80675. static One(): Vector4;
  80676. /**
  80677. * Returns a new normalized Vector4 from the given one.
  80678. * @param vector the vector to normalize
  80679. * @returns the vector
  80680. */
  80681. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  80682. /**
  80683. * Updates the given vector "result" from the normalization of the given one.
  80684. * @param vector the vector to normalize
  80685. * @param result the vector to store the result in
  80686. */
  80687. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  80688. /**
  80689. * Returns a vector with the minimum values from the left and right vectors
  80690. * @param left left vector to minimize
  80691. * @param right right vector to minimize
  80692. * @returns a new vector with the minimum of the left and right vector values
  80693. */
  80694. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  80695. /**
  80696. * Returns a vector with the maximum values from the left and right vectors
  80697. * @param left left vector to maximize
  80698. * @param right right vector to maximize
  80699. * @returns a new vector with the maximum of the left and right vector values
  80700. */
  80701. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  80702. /**
  80703. * Returns the distance (float) between the vectors "value1" and "value2".
  80704. * @param value1 value to calulate the distance between
  80705. * @param value2 value to calulate the distance between
  80706. * @return the distance between the two vectors
  80707. */
  80708. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  80709. /**
  80710. * Returns the squared distance (float) between the vectors "value1" and "value2".
  80711. * @param value1 value to calulate the distance between
  80712. * @param value2 value to calulate the distance between
  80713. * @return the distance between the two vectors squared
  80714. */
  80715. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  80716. /**
  80717. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  80718. * @param value1 value to calulate the center between
  80719. * @param value2 value to calulate the center between
  80720. * @return the center between the two vectors
  80721. */
  80722. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  80723. /**
  80724. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  80725. * This methods computes transformed normalized direction vectors only.
  80726. * @param vector the vector to transform
  80727. * @param transformation the transformation matrix to apply
  80728. * @returns the new vector
  80729. */
  80730. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  80731. /**
  80732. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  80733. * This methods computes transformed normalized direction vectors only.
  80734. * @param vector the vector to transform
  80735. * @param transformation the transformation matrix to apply
  80736. * @param result the vector to store the result in
  80737. */
  80738. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  80739. /**
  80740. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  80741. * This methods computes transformed normalized direction vectors only.
  80742. * @param x value to transform
  80743. * @param y value to transform
  80744. * @param z value to transform
  80745. * @param w value to transform
  80746. * @param transformation the transformation matrix to apply
  80747. * @param result the vector to store the results in
  80748. */
  80749. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  80750. /**
  80751. * Creates a new Vector4 from a Vector3
  80752. * @param source defines the source data
  80753. * @param w defines the 4th component (default is 0)
  80754. * @returns a new Vector4
  80755. */
  80756. static FromVector3(source: Vector3, w?: number): Vector4;
  80757. }
  80758. /**
  80759. * Class used to store quaternion data
  80760. * @see https://en.wikipedia.org/wiki/Quaternion
  80761. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  80762. */
  80763. export class Quaternion {
  80764. /** defines the first component (0 by default) */
  80765. x: number;
  80766. /** defines the second component (0 by default) */
  80767. y: number;
  80768. /** defines the third component (0 by default) */
  80769. z: number;
  80770. /** defines the fourth component (1.0 by default) */
  80771. w: number;
  80772. /**
  80773. * Creates a new Quaternion from the given floats
  80774. * @param x defines the first component (0 by default)
  80775. * @param y defines the second component (0 by default)
  80776. * @param z defines the third component (0 by default)
  80777. * @param w defines the fourth component (1.0 by default)
  80778. */
  80779. constructor(
  80780. /** defines the first component (0 by default) */
  80781. x?: number,
  80782. /** defines the second component (0 by default) */
  80783. y?: number,
  80784. /** defines the third component (0 by default) */
  80785. z?: number,
  80786. /** defines the fourth component (1.0 by default) */
  80787. w?: number);
  80788. /**
  80789. * Gets a string representation for the current quaternion
  80790. * @returns a string with the Quaternion coordinates
  80791. */
  80792. toString(): string;
  80793. /**
  80794. * Gets the class name of the quaternion
  80795. * @returns the string "Quaternion"
  80796. */
  80797. getClassName(): string;
  80798. /**
  80799. * Gets a hash code for this quaternion
  80800. * @returns the quaternion hash code
  80801. */
  80802. getHashCode(): number;
  80803. /**
  80804. * Copy the quaternion to an array
  80805. * @returns a new array populated with 4 elements from the quaternion coordinates
  80806. */
  80807. asArray(): number[];
  80808. /**
  80809. * Check if two quaternions are equals
  80810. * @param otherQuaternion defines the second operand
  80811. * @return true if the current quaternion and the given one coordinates are strictly equals
  80812. */
  80813. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  80814. /**
  80815. * Gets a boolean if two quaternions are equals (using an epsilon value)
  80816. * @param otherQuaternion defines the other quaternion
  80817. * @param epsilon defines the minimal distance to consider equality
  80818. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  80819. */
  80820. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  80821. /**
  80822. * Clone the current quaternion
  80823. * @returns a new quaternion copied from the current one
  80824. */
  80825. clone(): Quaternion;
  80826. /**
  80827. * Copy a quaternion to the current one
  80828. * @param other defines the other quaternion
  80829. * @returns the updated current quaternion
  80830. */
  80831. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  80832. /**
  80833. * Updates the current quaternion with the given float coordinates
  80834. * @param x defines the x coordinate
  80835. * @param y defines the y coordinate
  80836. * @param z defines the z coordinate
  80837. * @param w defines the w coordinate
  80838. * @returns the updated current quaternion
  80839. */
  80840. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  80841. /**
  80842. * Updates the current quaternion from the given float coordinates
  80843. * @param x defines the x coordinate
  80844. * @param y defines the y coordinate
  80845. * @param z defines the z coordinate
  80846. * @param w defines the w coordinate
  80847. * @returns the updated current quaternion
  80848. */
  80849. set(x: number, y: number, z: number, w: number): Quaternion;
  80850. /**
  80851. * Adds two quaternions
  80852. * @param other defines the second operand
  80853. * @returns a new quaternion as the addition result of the given one and the current quaternion
  80854. */
  80855. add(other: DeepImmutable<Quaternion>): Quaternion;
  80856. /**
  80857. * Add a quaternion to the current one
  80858. * @param other defines the quaternion to add
  80859. * @returns the current quaternion
  80860. */
  80861. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  80862. /**
  80863. * Subtract two quaternions
  80864. * @param other defines the second operand
  80865. * @returns a new quaternion as the subtraction result of the given one from the current one
  80866. */
  80867. subtract(other: Quaternion): Quaternion;
  80868. /**
  80869. * Multiplies the current quaternion by a scale factor
  80870. * @param value defines the scale factor
  80871. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  80872. */
  80873. scale(value: number): Quaternion;
  80874. /**
  80875. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  80876. * @param scale defines the scale factor
  80877. * @param result defines the Quaternion object where to store the result
  80878. * @returns the unmodified current quaternion
  80879. */
  80880. scaleToRef(scale: number, result: Quaternion): Quaternion;
  80881. /**
  80882. * Multiplies in place the current quaternion by a scale factor
  80883. * @param value defines the scale factor
  80884. * @returns the current modified quaternion
  80885. */
  80886. scaleInPlace(value: number): Quaternion;
  80887. /**
  80888. * Scale the current quaternion values by a factor and add the result to a given quaternion
  80889. * @param scale defines the scale factor
  80890. * @param result defines the Quaternion object where to store the result
  80891. * @returns the unmodified current quaternion
  80892. */
  80893. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  80894. /**
  80895. * Multiplies two quaternions
  80896. * @param q1 defines the second operand
  80897. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  80898. */
  80899. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  80900. /**
  80901. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  80902. * @param q1 defines the second operand
  80903. * @param result defines the target quaternion
  80904. * @returns the current quaternion
  80905. */
  80906. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  80907. /**
  80908. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  80909. * @param q1 defines the second operand
  80910. * @returns the currentupdated quaternion
  80911. */
  80912. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  80913. /**
  80914. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  80915. * @param ref defines the target quaternion
  80916. * @returns the current quaternion
  80917. */
  80918. conjugateToRef(ref: Quaternion): Quaternion;
  80919. /**
  80920. * Conjugates in place (1-q) the current quaternion
  80921. * @returns the current updated quaternion
  80922. */
  80923. conjugateInPlace(): Quaternion;
  80924. /**
  80925. * Conjugates in place (1-q) the current quaternion
  80926. * @returns a new quaternion
  80927. */
  80928. conjugate(): Quaternion;
  80929. /**
  80930. * Gets length of current quaternion
  80931. * @returns the quaternion length (float)
  80932. */
  80933. length(): number;
  80934. /**
  80935. * Normalize in place the current quaternion
  80936. * @returns the current updated quaternion
  80937. */
  80938. normalize(): Quaternion;
  80939. /**
  80940. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  80941. * @param order is a reserved parameter and is ignore for now
  80942. * @returns a new Vector3 containing the Euler angles
  80943. */
  80944. toEulerAngles(order?: string): Vector3;
  80945. /**
  80946. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  80947. * @param result defines the vector which will be filled with the Euler angles
  80948. * @param order is a reserved parameter and is ignore for now
  80949. * @returns the current unchanged quaternion
  80950. */
  80951. toEulerAnglesToRef(result: Vector3): Quaternion;
  80952. /**
  80953. * Updates the given rotation matrix with the current quaternion values
  80954. * @param result defines the target matrix
  80955. * @returns the current unchanged quaternion
  80956. */
  80957. toRotationMatrix(result: Matrix): Quaternion;
  80958. /**
  80959. * Updates the current quaternion from the given rotation matrix values
  80960. * @param matrix defines the source matrix
  80961. * @returns the current updated quaternion
  80962. */
  80963. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  80964. /**
  80965. * Creates a new quaternion from a rotation matrix
  80966. * @param matrix defines the source matrix
  80967. * @returns a new quaternion created from the given rotation matrix values
  80968. */
  80969. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  80970. /**
  80971. * Updates the given quaternion with the given rotation matrix values
  80972. * @param matrix defines the source matrix
  80973. * @param result defines the target quaternion
  80974. */
  80975. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  80976. /**
  80977. * Returns the dot product (float) between the quaternions "left" and "right"
  80978. * @param left defines the left operand
  80979. * @param right defines the right operand
  80980. * @returns the dot product
  80981. */
  80982. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  80983. /**
  80984. * Checks if the two quaternions are close to each other
  80985. * @param quat0 defines the first quaternion to check
  80986. * @param quat1 defines the second quaternion to check
  80987. * @returns true if the two quaternions are close to each other
  80988. */
  80989. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  80990. /**
  80991. * Creates an empty quaternion
  80992. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  80993. */
  80994. static Zero(): Quaternion;
  80995. /**
  80996. * Inverse a given quaternion
  80997. * @param q defines the source quaternion
  80998. * @returns a new quaternion as the inverted current quaternion
  80999. */
  81000. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  81001. /**
  81002. * Inverse a given quaternion
  81003. * @param q defines the source quaternion
  81004. * @param result the quaternion the result will be stored in
  81005. * @returns the result quaternion
  81006. */
  81007. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  81008. /**
  81009. * Creates an identity quaternion
  81010. * @returns the identity quaternion
  81011. */
  81012. static Identity(): Quaternion;
  81013. /**
  81014. * Gets a boolean indicating if the given quaternion is identity
  81015. * @param quaternion defines the quaternion to check
  81016. * @returns true if the quaternion is identity
  81017. */
  81018. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  81019. /**
  81020. * Creates a quaternion from a rotation around an axis
  81021. * @param axis defines the axis to use
  81022. * @param angle defines the angle to use
  81023. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  81024. */
  81025. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  81026. /**
  81027. * Creates a rotation around an axis and stores it into the given quaternion
  81028. * @param axis defines the axis to use
  81029. * @param angle defines the angle to use
  81030. * @param result defines the target quaternion
  81031. * @returns the target quaternion
  81032. */
  81033. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  81034. /**
  81035. * Creates a new quaternion from data stored into an array
  81036. * @param array defines the data source
  81037. * @param offset defines the offset in the source array where the data starts
  81038. * @returns a new quaternion
  81039. */
  81040. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  81041. /**
  81042. * Updates the given quaternion "result" from the starting index of the given array.
  81043. * @param array the array to pull values from
  81044. * @param offset the offset into the array to start at
  81045. * @param result the quaternion to store the result in
  81046. */
  81047. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  81048. /**
  81049. * Create a quaternion from Euler rotation angles
  81050. * @param x Pitch
  81051. * @param y Yaw
  81052. * @param z Roll
  81053. * @returns the new Quaternion
  81054. */
  81055. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  81056. /**
  81057. * Updates a quaternion from Euler rotation angles
  81058. * @param x Pitch
  81059. * @param y Yaw
  81060. * @param z Roll
  81061. * @param result the quaternion to store the result
  81062. * @returns the updated quaternion
  81063. */
  81064. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  81065. /**
  81066. * Create a quaternion from Euler rotation vector
  81067. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  81068. * @returns the new Quaternion
  81069. */
  81070. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  81071. /**
  81072. * Updates a quaternion from Euler rotation vector
  81073. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  81074. * @param result the quaternion to store the result
  81075. * @returns the updated quaternion
  81076. */
  81077. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  81078. /**
  81079. * Creates a new quaternion from the given Euler float angles (y, x, z)
  81080. * @param yaw defines the rotation around Y axis
  81081. * @param pitch defines the rotation around X axis
  81082. * @param roll defines the rotation around Z axis
  81083. * @returns the new quaternion
  81084. */
  81085. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  81086. /**
  81087. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  81088. * @param yaw defines the rotation around Y axis
  81089. * @param pitch defines the rotation around X axis
  81090. * @param roll defines the rotation around Z axis
  81091. * @param result defines the target quaternion
  81092. */
  81093. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  81094. /**
  81095. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  81096. * @param alpha defines the rotation around first axis
  81097. * @param beta defines the rotation around second axis
  81098. * @param gamma defines the rotation around third axis
  81099. * @returns the new quaternion
  81100. */
  81101. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  81102. /**
  81103. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  81104. * @param alpha defines the rotation around first axis
  81105. * @param beta defines the rotation around second axis
  81106. * @param gamma defines the rotation around third axis
  81107. * @param result defines the target quaternion
  81108. */
  81109. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  81110. /**
  81111. * 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)
  81112. * @param axis1 defines the first axis
  81113. * @param axis2 defines the second axis
  81114. * @param axis3 defines the third axis
  81115. * @returns the new quaternion
  81116. */
  81117. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  81118. /**
  81119. * 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
  81120. * @param axis1 defines the first axis
  81121. * @param axis2 defines the second axis
  81122. * @param axis3 defines the third axis
  81123. * @param ref defines the target quaternion
  81124. */
  81125. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  81126. /**
  81127. * Interpolates between two quaternions
  81128. * @param left defines first quaternion
  81129. * @param right defines second quaternion
  81130. * @param amount defines the gradient to use
  81131. * @returns the new interpolated quaternion
  81132. */
  81133. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  81134. /**
  81135. * Interpolates between two quaternions and stores it into a target quaternion
  81136. * @param left defines first quaternion
  81137. * @param right defines second quaternion
  81138. * @param amount defines the gradient to use
  81139. * @param result defines the target quaternion
  81140. */
  81141. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  81142. /**
  81143. * Interpolate between two quaternions using Hermite interpolation
  81144. * @param value1 defines first quaternion
  81145. * @param tangent1 defines the incoming tangent
  81146. * @param value2 defines second quaternion
  81147. * @param tangent2 defines the outgoing tangent
  81148. * @param amount defines the target quaternion
  81149. * @returns the new interpolated quaternion
  81150. */
  81151. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  81152. }
  81153. /**
  81154. * Class used to store matrix data (4x4)
  81155. */
  81156. export class Matrix {
  81157. private static _updateFlagSeed;
  81158. private static _identityReadOnly;
  81159. private _isIdentity;
  81160. private _isIdentityDirty;
  81161. private _isIdentity3x2;
  81162. private _isIdentity3x2Dirty;
  81163. /**
  81164. * Gets the update flag of the matrix which is an unique number for the matrix.
  81165. * It will be incremented every time the matrix data change.
  81166. * You can use it to speed the comparison between two versions of the same matrix.
  81167. */
  81168. updateFlag: number;
  81169. private readonly _m;
  81170. /**
  81171. * Gets the internal data of the matrix
  81172. */
  81173. get m(): DeepImmutable<Float32Array>;
  81174. /** @hidden */
  81175. _markAsUpdated(): void;
  81176. /** @hidden */
  81177. private _updateIdentityStatus;
  81178. /**
  81179. * Creates an empty matrix (filled with zeros)
  81180. */
  81181. constructor();
  81182. /**
  81183. * Check if the current matrix is identity
  81184. * @returns true is the matrix is the identity matrix
  81185. */
  81186. isIdentity(): boolean;
  81187. /**
  81188. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  81189. * @returns true is the matrix is the identity matrix
  81190. */
  81191. isIdentityAs3x2(): boolean;
  81192. /**
  81193. * Gets the determinant of the matrix
  81194. * @returns the matrix determinant
  81195. */
  81196. determinant(): number;
  81197. /**
  81198. * Returns the matrix as a Float32Array
  81199. * @returns the matrix underlying array
  81200. */
  81201. toArray(): DeepImmutable<Float32Array>;
  81202. /**
  81203. * Returns the matrix as a Float32Array
  81204. * @returns the matrix underlying array.
  81205. */
  81206. asArray(): DeepImmutable<Float32Array>;
  81207. /**
  81208. * Inverts the current matrix in place
  81209. * @returns the current inverted matrix
  81210. */
  81211. invert(): Matrix;
  81212. /**
  81213. * Sets all the matrix elements to zero
  81214. * @returns the current matrix
  81215. */
  81216. reset(): Matrix;
  81217. /**
  81218. * Adds the current matrix with a second one
  81219. * @param other defines the matrix to add
  81220. * @returns a new matrix as the addition of the current matrix and the given one
  81221. */
  81222. add(other: DeepImmutable<Matrix>): Matrix;
  81223. /**
  81224. * Sets the given matrix "result" to the addition of the current matrix and the given one
  81225. * @param other defines the matrix to add
  81226. * @param result defines the target matrix
  81227. * @returns the current matrix
  81228. */
  81229. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  81230. /**
  81231. * Adds in place the given matrix to the current matrix
  81232. * @param other defines the second operand
  81233. * @returns the current updated matrix
  81234. */
  81235. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  81236. /**
  81237. * Sets the given matrix to the current inverted Matrix
  81238. * @param other defines the target matrix
  81239. * @returns the unmodified current matrix
  81240. */
  81241. invertToRef(other: Matrix): Matrix;
  81242. /**
  81243. * add a value at the specified position in the current Matrix
  81244. * @param index the index of the value within the matrix. between 0 and 15.
  81245. * @param value the value to be added
  81246. * @returns the current updated matrix
  81247. */
  81248. addAtIndex(index: number, value: number): Matrix;
  81249. /**
  81250. * mutiply the specified position in the current Matrix by a value
  81251. * @param index the index of the value within the matrix. between 0 and 15.
  81252. * @param value the value to be added
  81253. * @returns the current updated matrix
  81254. */
  81255. multiplyAtIndex(index: number, value: number): Matrix;
  81256. /**
  81257. * Inserts the translation vector (using 3 floats) in the current matrix
  81258. * @param x defines the 1st component of the translation
  81259. * @param y defines the 2nd component of the translation
  81260. * @param z defines the 3rd component of the translation
  81261. * @returns the current updated matrix
  81262. */
  81263. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  81264. /**
  81265. * Adds the translation vector (using 3 floats) in the current matrix
  81266. * @param x defines the 1st component of the translation
  81267. * @param y defines the 2nd component of the translation
  81268. * @param z defines the 3rd component of the translation
  81269. * @returns the current updated matrix
  81270. */
  81271. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  81272. /**
  81273. * Inserts the translation vector in the current matrix
  81274. * @param vector3 defines the translation to insert
  81275. * @returns the current updated matrix
  81276. */
  81277. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  81278. /**
  81279. * Gets the translation value of the current matrix
  81280. * @returns a new Vector3 as the extracted translation from the matrix
  81281. */
  81282. getTranslation(): Vector3;
  81283. /**
  81284. * Fill a Vector3 with the extracted translation from the matrix
  81285. * @param result defines the Vector3 where to store the translation
  81286. * @returns the current matrix
  81287. */
  81288. getTranslationToRef(result: Vector3): Matrix;
  81289. /**
  81290. * Remove rotation and scaling part from the matrix
  81291. * @returns the updated matrix
  81292. */
  81293. removeRotationAndScaling(): Matrix;
  81294. /**
  81295. * Multiply two matrices
  81296. * @param other defines the second operand
  81297. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  81298. */
  81299. multiply(other: DeepImmutable<Matrix>): Matrix;
  81300. /**
  81301. * Copy the current matrix from the given one
  81302. * @param other defines the source matrix
  81303. * @returns the current updated matrix
  81304. */
  81305. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  81306. /**
  81307. * Populates the given array from the starting index with the current matrix values
  81308. * @param array defines the target array
  81309. * @param offset defines the offset in the target array where to start storing values
  81310. * @returns the current matrix
  81311. */
  81312. copyToArray(array: Float32Array, offset?: number): Matrix;
  81313. /**
  81314. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  81315. * @param other defines the second operand
  81316. * @param result defines the matrix where to store the multiplication
  81317. * @returns the current matrix
  81318. */
  81319. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  81320. /**
  81321. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  81322. * @param other defines the second operand
  81323. * @param result defines the array where to store the multiplication
  81324. * @param offset defines the offset in the target array where to start storing values
  81325. * @returns the current matrix
  81326. */
  81327. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  81328. /**
  81329. * Check equality between this matrix and a second one
  81330. * @param value defines the second matrix to compare
  81331. * @returns true is the current matrix and the given one values are strictly equal
  81332. */
  81333. equals(value: DeepImmutable<Matrix>): boolean;
  81334. /**
  81335. * Clone the current matrix
  81336. * @returns a new matrix from the current matrix
  81337. */
  81338. clone(): Matrix;
  81339. /**
  81340. * Returns the name of the current matrix class
  81341. * @returns the string "Matrix"
  81342. */
  81343. getClassName(): string;
  81344. /**
  81345. * Gets the hash code of the current matrix
  81346. * @returns the hash code
  81347. */
  81348. getHashCode(): number;
  81349. /**
  81350. * Decomposes the current Matrix into a translation, rotation and scaling components
  81351. * @param scale defines the scale vector3 given as a reference to update
  81352. * @param rotation defines the rotation quaternion given as a reference to update
  81353. * @param translation defines the translation vector3 given as a reference to update
  81354. * @returns true if operation was successful
  81355. */
  81356. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  81357. /**
  81358. * Gets specific row of the matrix
  81359. * @param index defines the number of the row to get
  81360. * @returns the index-th row of the current matrix as a new Vector4
  81361. */
  81362. getRow(index: number): Nullable<Vector4>;
  81363. /**
  81364. * Sets the index-th row of the current matrix to the vector4 values
  81365. * @param index defines the number of the row to set
  81366. * @param row defines the target vector4
  81367. * @returns the updated current matrix
  81368. */
  81369. setRow(index: number, row: Vector4): Matrix;
  81370. /**
  81371. * Compute the transpose of the matrix
  81372. * @returns the new transposed matrix
  81373. */
  81374. transpose(): Matrix;
  81375. /**
  81376. * Compute the transpose of the matrix and store it in a given matrix
  81377. * @param result defines the target matrix
  81378. * @returns the current matrix
  81379. */
  81380. transposeToRef(result: Matrix): Matrix;
  81381. /**
  81382. * Sets the index-th row of the current matrix with the given 4 x float values
  81383. * @param index defines the row index
  81384. * @param x defines the x component to set
  81385. * @param y defines the y component to set
  81386. * @param z defines the z component to set
  81387. * @param w defines the w component to set
  81388. * @returns the updated current matrix
  81389. */
  81390. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  81391. /**
  81392. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  81393. * @param scale defines the scale factor
  81394. * @returns a new matrix
  81395. */
  81396. scale(scale: number): Matrix;
  81397. /**
  81398. * Scale the current matrix values by a factor to a given result matrix
  81399. * @param scale defines the scale factor
  81400. * @param result defines the matrix to store the result
  81401. * @returns the current matrix
  81402. */
  81403. scaleToRef(scale: number, result: Matrix): Matrix;
  81404. /**
  81405. * Scale the current matrix values by a factor and add the result to a given matrix
  81406. * @param scale defines the scale factor
  81407. * @param result defines the Matrix to store the result
  81408. * @returns the current matrix
  81409. */
  81410. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  81411. /**
  81412. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  81413. * @param ref matrix to store the result
  81414. */
  81415. toNormalMatrix(ref: Matrix): void;
  81416. /**
  81417. * Gets only rotation part of the current matrix
  81418. * @returns a new matrix sets to the extracted rotation matrix from the current one
  81419. */
  81420. getRotationMatrix(): Matrix;
  81421. /**
  81422. * Extracts the rotation matrix from the current one and sets it as the given "result"
  81423. * @param result defines the target matrix to store data to
  81424. * @returns the current matrix
  81425. */
  81426. getRotationMatrixToRef(result: Matrix): Matrix;
  81427. /**
  81428. * Toggles model matrix from being right handed to left handed in place and vice versa
  81429. */
  81430. toggleModelMatrixHandInPlace(): void;
  81431. /**
  81432. * Toggles projection matrix from being right handed to left handed in place and vice versa
  81433. */
  81434. toggleProjectionMatrixHandInPlace(): void;
  81435. /**
  81436. * Creates a matrix from an array
  81437. * @param array defines the source array
  81438. * @param offset defines an offset in the source array
  81439. * @returns a new Matrix set from the starting index of the given array
  81440. */
  81441. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  81442. /**
  81443. * Copy the content of an array into a given matrix
  81444. * @param array defines the source array
  81445. * @param offset defines an offset in the source array
  81446. * @param result defines the target matrix
  81447. */
  81448. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  81449. /**
  81450. * Stores an array into a matrix after having multiplied each component by a given factor
  81451. * @param array defines the source array
  81452. * @param offset defines the offset in the source array
  81453. * @param scale defines the scaling factor
  81454. * @param result defines the target matrix
  81455. */
  81456. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  81457. /**
  81458. * Gets an identity matrix that must not be updated
  81459. */
  81460. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  81461. /**
  81462. * Stores a list of values (16) inside a given matrix
  81463. * @param initialM11 defines 1st value of 1st row
  81464. * @param initialM12 defines 2nd value of 1st row
  81465. * @param initialM13 defines 3rd value of 1st row
  81466. * @param initialM14 defines 4th value of 1st row
  81467. * @param initialM21 defines 1st value of 2nd row
  81468. * @param initialM22 defines 2nd value of 2nd row
  81469. * @param initialM23 defines 3rd value of 2nd row
  81470. * @param initialM24 defines 4th value of 2nd row
  81471. * @param initialM31 defines 1st value of 3rd row
  81472. * @param initialM32 defines 2nd value of 3rd row
  81473. * @param initialM33 defines 3rd value of 3rd row
  81474. * @param initialM34 defines 4th value of 3rd row
  81475. * @param initialM41 defines 1st value of 4th row
  81476. * @param initialM42 defines 2nd value of 4th row
  81477. * @param initialM43 defines 3rd value of 4th row
  81478. * @param initialM44 defines 4th value of 4th row
  81479. * @param result defines the target matrix
  81480. */
  81481. 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;
  81482. /**
  81483. * Creates new matrix from a list of values (16)
  81484. * @param initialM11 defines 1st value of 1st row
  81485. * @param initialM12 defines 2nd value of 1st row
  81486. * @param initialM13 defines 3rd value of 1st row
  81487. * @param initialM14 defines 4th value of 1st row
  81488. * @param initialM21 defines 1st value of 2nd row
  81489. * @param initialM22 defines 2nd value of 2nd row
  81490. * @param initialM23 defines 3rd value of 2nd row
  81491. * @param initialM24 defines 4th value of 2nd row
  81492. * @param initialM31 defines 1st value of 3rd row
  81493. * @param initialM32 defines 2nd value of 3rd row
  81494. * @param initialM33 defines 3rd value of 3rd row
  81495. * @param initialM34 defines 4th value of 3rd row
  81496. * @param initialM41 defines 1st value of 4th row
  81497. * @param initialM42 defines 2nd value of 4th row
  81498. * @param initialM43 defines 3rd value of 4th row
  81499. * @param initialM44 defines 4th value of 4th row
  81500. * @returns the new matrix
  81501. */
  81502. 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;
  81503. /**
  81504. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  81505. * @param scale defines the scale vector3
  81506. * @param rotation defines the rotation quaternion
  81507. * @param translation defines the translation vector3
  81508. * @returns a new matrix
  81509. */
  81510. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  81511. /**
  81512. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  81513. * @param scale defines the scale vector3
  81514. * @param rotation defines the rotation quaternion
  81515. * @param translation defines the translation vector3
  81516. * @param result defines the target matrix
  81517. */
  81518. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  81519. /**
  81520. * Creates a new identity matrix
  81521. * @returns a new identity matrix
  81522. */
  81523. static Identity(): Matrix;
  81524. /**
  81525. * Creates a new identity matrix and stores the result in a given matrix
  81526. * @param result defines the target matrix
  81527. */
  81528. static IdentityToRef(result: Matrix): void;
  81529. /**
  81530. * Creates a new zero matrix
  81531. * @returns a new zero matrix
  81532. */
  81533. static Zero(): Matrix;
  81534. /**
  81535. * Creates a new rotation matrix for "angle" radians around the X axis
  81536. * @param angle defines the angle (in radians) to use
  81537. * @return the new matrix
  81538. */
  81539. static RotationX(angle: number): Matrix;
  81540. /**
  81541. * Creates a new matrix as the invert of a given matrix
  81542. * @param source defines the source matrix
  81543. * @returns the new matrix
  81544. */
  81545. static Invert(source: DeepImmutable<Matrix>): Matrix;
  81546. /**
  81547. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  81548. * @param angle defines the angle (in radians) to use
  81549. * @param result defines the target matrix
  81550. */
  81551. static RotationXToRef(angle: number, result: Matrix): void;
  81552. /**
  81553. * Creates a new rotation matrix for "angle" radians around the Y axis
  81554. * @param angle defines the angle (in radians) to use
  81555. * @return the new matrix
  81556. */
  81557. static RotationY(angle: number): Matrix;
  81558. /**
  81559. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  81560. * @param angle defines the angle (in radians) to use
  81561. * @param result defines the target matrix
  81562. */
  81563. static RotationYToRef(angle: number, result: Matrix): void;
  81564. /**
  81565. * Creates a new rotation matrix for "angle" radians around the Z axis
  81566. * @param angle defines the angle (in radians) to use
  81567. * @return the new matrix
  81568. */
  81569. static RotationZ(angle: number): Matrix;
  81570. /**
  81571. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  81572. * @param angle defines the angle (in radians) to use
  81573. * @param result defines the target matrix
  81574. */
  81575. static RotationZToRef(angle: number, result: Matrix): void;
  81576. /**
  81577. * Creates a new rotation matrix for "angle" radians around the given axis
  81578. * @param axis defines the axis to use
  81579. * @param angle defines the angle (in radians) to use
  81580. * @return the new matrix
  81581. */
  81582. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  81583. /**
  81584. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  81585. * @param axis defines the axis to use
  81586. * @param angle defines the angle (in radians) to use
  81587. * @param result defines the target matrix
  81588. */
  81589. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  81590. /**
  81591. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  81592. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  81593. * @param from defines the vector to align
  81594. * @param to defines the vector to align to
  81595. * @param result defines the target matrix
  81596. */
  81597. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  81598. /**
  81599. * Creates a rotation matrix
  81600. * @param yaw defines the yaw angle in radians (Y axis)
  81601. * @param pitch defines the pitch angle in radians (X axis)
  81602. * @param roll defines the roll angle in radians (X axis)
  81603. * @returns the new rotation matrix
  81604. */
  81605. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  81606. /**
  81607. * Creates a rotation matrix and stores it in a given matrix
  81608. * @param yaw defines the yaw angle in radians (Y axis)
  81609. * @param pitch defines the pitch angle in radians (X axis)
  81610. * @param roll defines the roll angle in radians (X axis)
  81611. * @param result defines the target matrix
  81612. */
  81613. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  81614. /**
  81615. * Creates a scaling matrix
  81616. * @param x defines the scale factor on X axis
  81617. * @param y defines the scale factor on Y axis
  81618. * @param z defines the scale factor on Z axis
  81619. * @returns the new matrix
  81620. */
  81621. static Scaling(x: number, y: number, z: number): Matrix;
  81622. /**
  81623. * Creates a scaling matrix and stores it in a given matrix
  81624. * @param x defines the scale factor on X axis
  81625. * @param y defines the scale factor on Y axis
  81626. * @param z defines the scale factor on Z axis
  81627. * @param result defines the target matrix
  81628. */
  81629. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  81630. /**
  81631. * Creates a translation matrix
  81632. * @param x defines the translation on X axis
  81633. * @param y defines the translation on Y axis
  81634. * @param z defines the translationon Z axis
  81635. * @returns the new matrix
  81636. */
  81637. static Translation(x: number, y: number, z: number): Matrix;
  81638. /**
  81639. * Creates a translation matrix and stores it in a given matrix
  81640. * @param x defines the translation on X axis
  81641. * @param y defines the translation on Y axis
  81642. * @param z defines the translationon Z axis
  81643. * @param result defines the target matrix
  81644. */
  81645. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  81646. /**
  81647. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  81648. * @param startValue defines the start value
  81649. * @param endValue defines the end value
  81650. * @param gradient defines the gradient factor
  81651. * @returns the new matrix
  81652. */
  81653. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  81654. /**
  81655. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  81656. * @param startValue defines the start value
  81657. * @param endValue defines the end value
  81658. * @param gradient defines the gradient factor
  81659. * @param result defines the Matrix object where to store data
  81660. */
  81661. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  81662. /**
  81663. * Builds a new matrix whose values are computed by:
  81664. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  81665. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  81666. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  81667. * @param startValue defines the first matrix
  81668. * @param endValue defines the second matrix
  81669. * @param gradient defines the gradient between the two matrices
  81670. * @returns the new matrix
  81671. */
  81672. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  81673. /**
  81674. * Update a matrix to values which are computed by:
  81675. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  81676. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  81677. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  81678. * @param startValue defines the first matrix
  81679. * @param endValue defines the second matrix
  81680. * @param gradient defines the gradient between the two matrices
  81681. * @param result defines the target matrix
  81682. */
  81683. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  81684. /**
  81685. * 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"
  81686. * This function works in left handed mode
  81687. * @param eye defines the final position of the entity
  81688. * @param target defines where the entity should look at
  81689. * @param up defines the up vector for the entity
  81690. * @returns the new matrix
  81691. */
  81692. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  81693. /**
  81694. * 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".
  81695. * This function works in left handed mode
  81696. * @param eye defines the final position of the entity
  81697. * @param target defines where the entity should look at
  81698. * @param up defines the up vector for the entity
  81699. * @param result defines the target matrix
  81700. */
  81701. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  81702. /**
  81703. * 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"
  81704. * This function works in right handed mode
  81705. * @param eye defines the final position of the entity
  81706. * @param target defines where the entity should look at
  81707. * @param up defines the up vector for the entity
  81708. * @returns the new matrix
  81709. */
  81710. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  81711. /**
  81712. * 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".
  81713. * This function works in right handed mode
  81714. * @param eye defines the final position of the entity
  81715. * @param target defines where the entity should look at
  81716. * @param up defines the up vector for the entity
  81717. * @param result defines the target matrix
  81718. */
  81719. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  81720. /**
  81721. * Create a left-handed orthographic projection matrix
  81722. * @param width defines the viewport width
  81723. * @param height defines the viewport height
  81724. * @param znear defines the near clip plane
  81725. * @param zfar defines the far clip plane
  81726. * @returns a new matrix as a left-handed orthographic projection matrix
  81727. */
  81728. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  81729. /**
  81730. * Store a left-handed orthographic projection to a given matrix
  81731. * @param width defines the viewport width
  81732. * @param height defines the viewport height
  81733. * @param znear defines the near clip plane
  81734. * @param zfar defines the far clip plane
  81735. * @param result defines the target matrix
  81736. */
  81737. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  81738. /**
  81739. * Create a left-handed orthographic projection matrix
  81740. * @param left defines the viewport left coordinate
  81741. * @param right defines the viewport right coordinate
  81742. * @param bottom defines the viewport bottom coordinate
  81743. * @param top defines the viewport top coordinate
  81744. * @param znear defines the near clip plane
  81745. * @param zfar defines the far clip plane
  81746. * @returns a new matrix as a left-handed orthographic projection matrix
  81747. */
  81748. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  81749. /**
  81750. * Stores a left-handed orthographic projection into a given matrix
  81751. * @param left defines the viewport left coordinate
  81752. * @param right defines the viewport right coordinate
  81753. * @param bottom defines the viewport bottom coordinate
  81754. * @param top defines the viewport top coordinate
  81755. * @param znear defines the near clip plane
  81756. * @param zfar defines the far clip plane
  81757. * @param result defines the target matrix
  81758. */
  81759. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  81760. /**
  81761. * Creates a right-handed orthographic projection matrix
  81762. * @param left defines the viewport left coordinate
  81763. * @param right defines the viewport right coordinate
  81764. * @param bottom defines the viewport bottom coordinate
  81765. * @param top defines the viewport top coordinate
  81766. * @param znear defines the near clip plane
  81767. * @param zfar defines the far clip plane
  81768. * @returns a new matrix as a right-handed orthographic projection matrix
  81769. */
  81770. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  81771. /**
  81772. * Stores a right-handed orthographic projection into a given matrix
  81773. * @param left defines the viewport left coordinate
  81774. * @param right defines the viewport right coordinate
  81775. * @param bottom defines the viewport bottom coordinate
  81776. * @param top defines the viewport top coordinate
  81777. * @param znear defines the near clip plane
  81778. * @param zfar defines the far clip plane
  81779. * @param result defines the target matrix
  81780. */
  81781. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  81782. /**
  81783. * Creates a left-handed perspective projection matrix
  81784. * @param width defines the viewport width
  81785. * @param height defines the viewport height
  81786. * @param znear defines the near clip plane
  81787. * @param zfar defines the far clip plane
  81788. * @returns a new matrix as a left-handed perspective projection matrix
  81789. */
  81790. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  81791. /**
  81792. * Creates a left-handed perspective projection matrix
  81793. * @param fov defines the horizontal field of view
  81794. * @param aspect defines the aspect ratio
  81795. * @param znear defines the near clip plane
  81796. * @param zfar defines the far clip plane
  81797. * @returns a new matrix as a left-handed perspective projection matrix
  81798. */
  81799. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  81800. /**
  81801. * Stores a left-handed perspective projection into a given matrix
  81802. * @param fov defines the horizontal field of view
  81803. * @param aspect defines the aspect ratio
  81804. * @param znear defines the near clip plane
  81805. * @param zfar defines the far clip plane
  81806. * @param result defines the target matrix
  81807. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  81808. */
  81809. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  81810. /**
  81811. * Stores a left-handed perspective projection into a given matrix with depth reversed
  81812. * @param fov defines the horizontal field of view
  81813. * @param aspect defines the aspect ratio
  81814. * @param znear defines the near clip plane
  81815. * @param zfar not used as infinity is used as far clip
  81816. * @param result defines the target matrix
  81817. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  81818. */
  81819. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  81820. /**
  81821. * Creates a right-handed perspective projection matrix
  81822. * @param fov defines the horizontal field of view
  81823. * @param aspect defines the aspect ratio
  81824. * @param znear defines the near clip plane
  81825. * @param zfar defines the far clip plane
  81826. * @returns a new matrix as a right-handed perspective projection matrix
  81827. */
  81828. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  81829. /**
  81830. * Stores a right-handed perspective projection into a given matrix
  81831. * @param fov defines the horizontal field of view
  81832. * @param aspect defines the aspect ratio
  81833. * @param znear defines the near clip plane
  81834. * @param zfar defines the far clip plane
  81835. * @param result defines the target matrix
  81836. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  81837. */
  81838. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  81839. /**
  81840. * Stores a right-handed perspective projection into a given matrix
  81841. * @param fov defines the horizontal field of view
  81842. * @param aspect defines the aspect ratio
  81843. * @param znear defines the near clip plane
  81844. * @param zfar not used as infinity is used as far clip
  81845. * @param result defines the target matrix
  81846. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  81847. */
  81848. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  81849. /**
  81850. * Stores a perspective projection for WebVR info a given matrix
  81851. * @param fov defines the field of view
  81852. * @param znear defines the near clip plane
  81853. * @param zfar defines the far clip plane
  81854. * @param result defines the target matrix
  81855. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  81856. */
  81857. static PerspectiveFovWebVRToRef(fov: {
  81858. upDegrees: number;
  81859. downDegrees: number;
  81860. leftDegrees: number;
  81861. rightDegrees: number;
  81862. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  81863. /**
  81864. * Computes a complete transformation matrix
  81865. * @param viewport defines the viewport to use
  81866. * @param world defines the world matrix
  81867. * @param view defines the view matrix
  81868. * @param projection defines the projection matrix
  81869. * @param zmin defines the near clip plane
  81870. * @param zmax defines the far clip plane
  81871. * @returns the transformation matrix
  81872. */
  81873. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  81874. /**
  81875. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  81876. * @param matrix defines the matrix to use
  81877. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  81878. */
  81879. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  81880. /**
  81881. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  81882. * @param matrix defines the matrix to use
  81883. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  81884. */
  81885. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  81886. /**
  81887. * Compute the transpose of a given matrix
  81888. * @param matrix defines the matrix to transpose
  81889. * @returns the new matrix
  81890. */
  81891. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  81892. /**
  81893. * Compute the transpose of a matrix and store it in a target matrix
  81894. * @param matrix defines the matrix to transpose
  81895. * @param result defines the target matrix
  81896. */
  81897. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  81898. /**
  81899. * Computes a reflection matrix from a plane
  81900. * @param plane defines the reflection plane
  81901. * @returns a new matrix
  81902. */
  81903. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  81904. /**
  81905. * Computes a reflection matrix from a plane
  81906. * @param plane defines the reflection plane
  81907. * @param result defines the target matrix
  81908. */
  81909. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  81910. /**
  81911. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  81912. * @param xaxis defines the value of the 1st axis
  81913. * @param yaxis defines the value of the 2nd axis
  81914. * @param zaxis defines the value of the 3rd axis
  81915. * @param result defines the target matrix
  81916. */
  81917. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  81918. /**
  81919. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  81920. * @param quat defines the quaternion to use
  81921. * @param result defines the target matrix
  81922. */
  81923. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  81924. }
  81925. /**
  81926. * @hidden
  81927. */
  81928. export class TmpVectors {
  81929. static Vector2: Vector2[];
  81930. static Vector3: Vector3[];
  81931. static Vector4: Vector4[];
  81932. static Quaternion: Quaternion[];
  81933. static Matrix: Matrix[];
  81934. }
  81935. }
  81936. declare module BABYLON {
  81937. /**
  81938. * Defines potential orientation for back face culling
  81939. */
  81940. export enum Orientation {
  81941. /**
  81942. * Clockwise
  81943. */
  81944. CW = 0,
  81945. /** Counter clockwise */
  81946. CCW = 1
  81947. }
  81948. /** Class used to represent a Bezier curve */
  81949. export class BezierCurve {
  81950. /**
  81951. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  81952. * @param t defines the time
  81953. * @param x1 defines the left coordinate on X axis
  81954. * @param y1 defines the left coordinate on Y axis
  81955. * @param x2 defines the right coordinate on X axis
  81956. * @param y2 defines the right coordinate on Y axis
  81957. * @returns the interpolated value
  81958. */
  81959. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  81960. }
  81961. /**
  81962. * Defines angle representation
  81963. */
  81964. export class Angle {
  81965. private _radians;
  81966. /**
  81967. * Creates an Angle object of "radians" radians (float).
  81968. * @param radians the angle in radians
  81969. */
  81970. constructor(radians: number);
  81971. /**
  81972. * Get value in degrees
  81973. * @returns the Angle value in degrees (float)
  81974. */
  81975. degrees(): number;
  81976. /**
  81977. * Get value in radians
  81978. * @returns the Angle value in radians (float)
  81979. */
  81980. radians(): number;
  81981. /**
  81982. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  81983. * @param a defines first vector
  81984. * @param b defines second vector
  81985. * @returns a new Angle
  81986. */
  81987. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  81988. /**
  81989. * Gets a new Angle object from the given float in radians
  81990. * @param radians defines the angle value in radians
  81991. * @returns a new Angle
  81992. */
  81993. static FromRadians(radians: number): Angle;
  81994. /**
  81995. * Gets a new Angle object from the given float in degrees
  81996. * @param degrees defines the angle value in degrees
  81997. * @returns a new Angle
  81998. */
  81999. static FromDegrees(degrees: number): Angle;
  82000. }
  82001. /**
  82002. * This represents an arc in a 2d space.
  82003. */
  82004. export class Arc2 {
  82005. /** Defines the start point of the arc */
  82006. startPoint: Vector2;
  82007. /** Defines the mid point of the arc */
  82008. midPoint: Vector2;
  82009. /** Defines the end point of the arc */
  82010. endPoint: Vector2;
  82011. /**
  82012. * Defines the center point of the arc.
  82013. */
  82014. centerPoint: Vector2;
  82015. /**
  82016. * Defines the radius of the arc.
  82017. */
  82018. radius: number;
  82019. /**
  82020. * Defines the angle of the arc (from mid point to end point).
  82021. */
  82022. angle: Angle;
  82023. /**
  82024. * Defines the start angle of the arc (from start point to middle point).
  82025. */
  82026. startAngle: Angle;
  82027. /**
  82028. * Defines the orientation of the arc (clock wise/counter clock wise).
  82029. */
  82030. orientation: Orientation;
  82031. /**
  82032. * Creates an Arc object from the three given points : start, middle and end.
  82033. * @param startPoint Defines the start point of the arc
  82034. * @param midPoint Defines the midlle point of the arc
  82035. * @param endPoint Defines the end point of the arc
  82036. */
  82037. constructor(
  82038. /** Defines the start point of the arc */
  82039. startPoint: Vector2,
  82040. /** Defines the mid point of the arc */
  82041. midPoint: Vector2,
  82042. /** Defines the end point of the arc */
  82043. endPoint: Vector2);
  82044. }
  82045. /**
  82046. * Represents a 2D path made up of multiple 2D points
  82047. */
  82048. export class Path2 {
  82049. private _points;
  82050. private _length;
  82051. /**
  82052. * If the path start and end point are the same
  82053. */
  82054. closed: boolean;
  82055. /**
  82056. * Creates a Path2 object from the starting 2D coordinates x and y.
  82057. * @param x the starting points x value
  82058. * @param y the starting points y value
  82059. */
  82060. constructor(x: number, y: number);
  82061. /**
  82062. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  82063. * @param x the added points x value
  82064. * @param y the added points y value
  82065. * @returns the updated Path2.
  82066. */
  82067. addLineTo(x: number, y: number): Path2;
  82068. /**
  82069. * 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.
  82070. * @param midX middle point x value
  82071. * @param midY middle point y value
  82072. * @param endX end point x value
  82073. * @param endY end point y value
  82074. * @param numberOfSegments (default: 36)
  82075. * @returns the updated Path2.
  82076. */
  82077. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  82078. /**
  82079. * Closes the Path2.
  82080. * @returns the Path2.
  82081. */
  82082. close(): Path2;
  82083. /**
  82084. * Gets the sum of the distance between each sequential point in the path
  82085. * @returns the Path2 total length (float).
  82086. */
  82087. length(): number;
  82088. /**
  82089. * Gets the points which construct the path
  82090. * @returns the Path2 internal array of points.
  82091. */
  82092. getPoints(): Vector2[];
  82093. /**
  82094. * Retreives the point at the distance aways from the starting point
  82095. * @param normalizedLengthPosition the length along the path to retreive the point from
  82096. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  82097. */
  82098. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  82099. /**
  82100. * Creates a new path starting from an x and y position
  82101. * @param x starting x value
  82102. * @param y starting y value
  82103. * @returns a new Path2 starting at the coordinates (x, y).
  82104. */
  82105. static StartingAt(x: number, y: number): Path2;
  82106. }
  82107. /**
  82108. * Represents a 3D path made up of multiple 3D points
  82109. */
  82110. export class Path3D {
  82111. /**
  82112. * an array of Vector3, the curve axis of the Path3D
  82113. */
  82114. path: Vector3[];
  82115. private _curve;
  82116. private _distances;
  82117. private _tangents;
  82118. private _normals;
  82119. private _binormals;
  82120. private _raw;
  82121. private _alignTangentsWithPath;
  82122. private readonly _pointAtData;
  82123. /**
  82124. * new Path3D(path, normal, raw)
  82125. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  82126. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  82127. * @param path an array of Vector3, the curve axis of the Path3D
  82128. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  82129. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  82130. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  82131. */
  82132. constructor(
  82133. /**
  82134. * an array of Vector3, the curve axis of the Path3D
  82135. */
  82136. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  82137. /**
  82138. * Returns the Path3D array of successive Vector3 designing its curve.
  82139. * @returns the Path3D array of successive Vector3 designing its curve.
  82140. */
  82141. getCurve(): Vector3[];
  82142. /**
  82143. * Returns the Path3D array of successive Vector3 designing its curve.
  82144. * @returns the Path3D array of successive Vector3 designing its curve.
  82145. */
  82146. getPoints(): Vector3[];
  82147. /**
  82148. * @returns the computed length (float) of the path.
  82149. */
  82150. length(): number;
  82151. /**
  82152. * Returns an array populated with tangent vectors on each Path3D curve point.
  82153. * @returns an array populated with tangent vectors on each Path3D curve point.
  82154. */
  82155. getTangents(): Vector3[];
  82156. /**
  82157. * Returns an array populated with normal vectors on each Path3D curve point.
  82158. * @returns an array populated with normal vectors on each Path3D curve point.
  82159. */
  82160. getNormals(): Vector3[];
  82161. /**
  82162. * Returns an array populated with binormal vectors on each Path3D curve point.
  82163. * @returns an array populated with binormal vectors on each Path3D curve point.
  82164. */
  82165. getBinormals(): Vector3[];
  82166. /**
  82167. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  82168. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  82169. */
  82170. getDistances(): number[];
  82171. /**
  82172. * Returns an interpolated point along this path
  82173. * @param position the position of the point along this path, from 0.0 to 1.0
  82174. * @returns a new Vector3 as the point
  82175. */
  82176. getPointAt(position: number): Vector3;
  82177. /**
  82178. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  82179. * @param position the position of the point along this path, from 0.0 to 1.0
  82180. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  82181. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  82182. */
  82183. getTangentAt(position: number, interpolated?: boolean): Vector3;
  82184. /**
  82185. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  82186. * @param position the position of the point along this path, from 0.0 to 1.0
  82187. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  82188. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  82189. */
  82190. getNormalAt(position: number, interpolated?: boolean): Vector3;
  82191. /**
  82192. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  82193. * @param position the position of the point along this path, from 0.0 to 1.0
  82194. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  82195. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  82196. */
  82197. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  82198. /**
  82199. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  82200. * @param position the position of the point along this path, from 0.0 to 1.0
  82201. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  82202. */
  82203. getDistanceAt(position: number): number;
  82204. /**
  82205. * Returns the array index of the previous point of an interpolated point along this path
  82206. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  82207. * @returns the array index
  82208. */
  82209. getPreviousPointIndexAt(position: number): number;
  82210. /**
  82211. * 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)
  82212. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  82213. * @returns the sub position
  82214. */
  82215. getSubPositionAt(position: number): number;
  82216. /**
  82217. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  82218. * @param target the vector of which to get the closest position to
  82219. * @returns the position of the closest virtual point on this path to the target vector
  82220. */
  82221. getClosestPositionTo(target: Vector3): number;
  82222. /**
  82223. * Returns a sub path (slice) of this path
  82224. * @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
  82225. * @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
  82226. * @returns a sub path (slice) of this path
  82227. */
  82228. slice(start?: number, end?: number): Path3D;
  82229. /**
  82230. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  82231. * @param path path which all values are copied into the curves points
  82232. * @param firstNormal which should be projected onto the curve
  82233. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  82234. * @returns the same object updated.
  82235. */
  82236. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  82237. private _compute;
  82238. private _getFirstNonNullVector;
  82239. private _getLastNonNullVector;
  82240. private _normalVector;
  82241. /**
  82242. * Updates the point at data for an interpolated point along this curve
  82243. * @param position the position of the point along this curve, from 0.0 to 1.0
  82244. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  82245. * @returns the (updated) point at data
  82246. */
  82247. private _updatePointAtData;
  82248. /**
  82249. * Updates the point at data from the specified parameters
  82250. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  82251. * @param point the interpolated point
  82252. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  82253. */
  82254. private _setPointAtData;
  82255. /**
  82256. * Updates the point at interpolation matrix for the tangents, normals and binormals
  82257. */
  82258. private _updateInterpolationMatrix;
  82259. }
  82260. /**
  82261. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  82262. * A Curve3 is designed from a series of successive Vector3.
  82263. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  82264. */
  82265. export class Curve3 {
  82266. private _points;
  82267. private _length;
  82268. /**
  82269. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  82270. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  82271. * @param v1 (Vector3) the control point
  82272. * @param v2 (Vector3) the end point of the Quadratic Bezier
  82273. * @param nbPoints (integer) the wanted number of points in the curve
  82274. * @returns the created Curve3
  82275. */
  82276. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  82277. /**
  82278. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  82279. * @param v0 (Vector3) the origin point of the Cubic Bezier
  82280. * @param v1 (Vector3) the first control point
  82281. * @param v2 (Vector3) the second control point
  82282. * @param v3 (Vector3) the end point of the Cubic Bezier
  82283. * @param nbPoints (integer) the wanted number of points in the curve
  82284. * @returns the created Curve3
  82285. */
  82286. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  82287. /**
  82288. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  82289. * @param p1 (Vector3) the origin point of the Hermite Spline
  82290. * @param t1 (Vector3) the tangent vector at the origin point
  82291. * @param p2 (Vector3) the end point of the Hermite Spline
  82292. * @param t2 (Vector3) the tangent vector at the end point
  82293. * @param nbPoints (integer) the wanted number of points in the curve
  82294. * @returns the created Curve3
  82295. */
  82296. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  82297. /**
  82298. * Returns a Curve3 object along a CatmullRom Spline curve :
  82299. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  82300. * @param nbPoints (integer) the wanted number of points between each curve control points
  82301. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  82302. * @returns the created Curve3
  82303. */
  82304. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  82305. /**
  82306. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  82307. * A Curve3 is designed from a series of successive Vector3.
  82308. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  82309. * @param points points which make up the curve
  82310. */
  82311. constructor(points: Vector3[]);
  82312. /**
  82313. * @returns the Curve3 stored array of successive Vector3
  82314. */
  82315. getPoints(): Vector3[];
  82316. /**
  82317. * @returns the computed length (float) of the curve.
  82318. */
  82319. length(): number;
  82320. /**
  82321. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  82322. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  82323. * curveA and curveB keep unchanged.
  82324. * @param curve the curve to continue from this curve
  82325. * @returns the newly constructed curve
  82326. */
  82327. continue(curve: DeepImmutable<Curve3>): Curve3;
  82328. private _computeLength;
  82329. }
  82330. }
  82331. declare module BABYLON {
  82332. /**
  82333. * This represents the main contract an easing function should follow.
  82334. * Easing functions are used throughout the animation system.
  82335. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82336. */
  82337. export interface IEasingFunction {
  82338. /**
  82339. * Given an input gradient between 0 and 1, this returns the corrseponding value
  82340. * of the easing function.
  82341. * The link below provides some of the most common examples of easing functions.
  82342. * @see https://easings.net/
  82343. * @param gradient Defines the value between 0 and 1 we want the easing value for
  82344. * @returns the corresponding value on the curve defined by the easing function
  82345. */
  82346. ease(gradient: number): number;
  82347. }
  82348. /**
  82349. * Base class used for every default easing function.
  82350. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82351. */
  82352. export class EasingFunction implements IEasingFunction {
  82353. /**
  82354. * Interpolation follows the mathematical formula associated with the easing function.
  82355. */
  82356. static readonly EASINGMODE_EASEIN: number;
  82357. /**
  82358. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  82359. */
  82360. static readonly EASINGMODE_EASEOUT: number;
  82361. /**
  82362. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  82363. */
  82364. static readonly EASINGMODE_EASEINOUT: number;
  82365. private _easingMode;
  82366. /**
  82367. * Sets the easing mode of the current function.
  82368. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  82369. */
  82370. setEasingMode(easingMode: number): void;
  82371. /**
  82372. * Gets the current easing mode.
  82373. * @returns the easing mode
  82374. */
  82375. getEasingMode(): number;
  82376. /**
  82377. * @hidden
  82378. */
  82379. easeInCore(gradient: number): number;
  82380. /**
  82381. * Given an input gradient between 0 and 1, this returns the corresponding value
  82382. * of the easing function.
  82383. * @param gradient Defines the value between 0 and 1 we want the easing value for
  82384. * @returns the corresponding value on the curve defined by the easing function
  82385. */
  82386. ease(gradient: number): number;
  82387. }
  82388. /**
  82389. * Easing function with a circle shape (see link below).
  82390. * @see https://easings.net/#easeInCirc
  82391. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82392. */
  82393. export class CircleEase extends EasingFunction implements IEasingFunction {
  82394. /** @hidden */
  82395. easeInCore(gradient: number): number;
  82396. }
  82397. /**
  82398. * Easing function with a ease back shape (see link below).
  82399. * @see https://easings.net/#easeInBack
  82400. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82401. */
  82402. export class BackEase extends EasingFunction implements IEasingFunction {
  82403. /** Defines the amplitude of the function */
  82404. amplitude: number;
  82405. /**
  82406. * Instantiates a back ease easing
  82407. * @see https://easings.net/#easeInBack
  82408. * @param amplitude Defines the amplitude of the function
  82409. */
  82410. constructor(
  82411. /** Defines the amplitude of the function */
  82412. amplitude?: number);
  82413. /** @hidden */
  82414. easeInCore(gradient: number): number;
  82415. }
  82416. /**
  82417. * Easing function with a bouncing shape (see link below).
  82418. * @see https://easings.net/#easeInBounce
  82419. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82420. */
  82421. export class BounceEase extends EasingFunction implements IEasingFunction {
  82422. /** Defines the number of bounces */
  82423. bounces: number;
  82424. /** Defines the amplitude of the bounce */
  82425. bounciness: number;
  82426. /**
  82427. * Instantiates a bounce easing
  82428. * @see https://easings.net/#easeInBounce
  82429. * @param bounces Defines the number of bounces
  82430. * @param bounciness Defines the amplitude of the bounce
  82431. */
  82432. constructor(
  82433. /** Defines the number of bounces */
  82434. bounces?: number,
  82435. /** Defines the amplitude of the bounce */
  82436. bounciness?: number);
  82437. /** @hidden */
  82438. easeInCore(gradient: number): number;
  82439. }
  82440. /**
  82441. * Easing function with a power of 3 shape (see link below).
  82442. * @see https://easings.net/#easeInCubic
  82443. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82444. */
  82445. export class CubicEase extends EasingFunction implements IEasingFunction {
  82446. /** @hidden */
  82447. easeInCore(gradient: number): number;
  82448. }
  82449. /**
  82450. * Easing function with an elastic shape (see link below).
  82451. * @see https://easings.net/#easeInElastic
  82452. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82453. */
  82454. export class ElasticEase extends EasingFunction implements IEasingFunction {
  82455. /** Defines the number of oscillations*/
  82456. oscillations: number;
  82457. /** Defines the amplitude of the oscillations*/
  82458. springiness: number;
  82459. /**
  82460. * Instantiates an elastic easing function
  82461. * @see https://easings.net/#easeInElastic
  82462. * @param oscillations Defines the number of oscillations
  82463. * @param springiness Defines the amplitude of the oscillations
  82464. */
  82465. constructor(
  82466. /** Defines the number of oscillations*/
  82467. oscillations?: number,
  82468. /** Defines the amplitude of the oscillations*/
  82469. springiness?: number);
  82470. /** @hidden */
  82471. easeInCore(gradient: number): number;
  82472. }
  82473. /**
  82474. * Easing function with an exponential shape (see link below).
  82475. * @see https://easings.net/#easeInExpo
  82476. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82477. */
  82478. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  82479. /** Defines the exponent of the function */
  82480. exponent: number;
  82481. /**
  82482. * Instantiates an exponential easing function
  82483. * @see https://easings.net/#easeInExpo
  82484. * @param exponent Defines the exponent of the function
  82485. */
  82486. constructor(
  82487. /** Defines the exponent of the function */
  82488. exponent?: number);
  82489. /** @hidden */
  82490. easeInCore(gradient: number): number;
  82491. }
  82492. /**
  82493. * Easing function with a power shape (see link below).
  82494. * @see https://easings.net/#easeInQuad
  82495. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82496. */
  82497. export class PowerEase extends EasingFunction implements IEasingFunction {
  82498. /** Defines the power of the function */
  82499. power: number;
  82500. /**
  82501. * Instantiates an power base easing function
  82502. * @see https://easings.net/#easeInQuad
  82503. * @param power Defines the power of the function
  82504. */
  82505. constructor(
  82506. /** Defines the power of the function */
  82507. power?: number);
  82508. /** @hidden */
  82509. easeInCore(gradient: number): number;
  82510. }
  82511. /**
  82512. * Easing function with a power of 2 shape (see link below).
  82513. * @see https://easings.net/#easeInQuad
  82514. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82515. */
  82516. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  82517. /** @hidden */
  82518. easeInCore(gradient: number): number;
  82519. }
  82520. /**
  82521. * Easing function with a power of 4 shape (see link below).
  82522. * @see https://easings.net/#easeInQuart
  82523. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82524. */
  82525. export class QuarticEase extends EasingFunction implements IEasingFunction {
  82526. /** @hidden */
  82527. easeInCore(gradient: number): number;
  82528. }
  82529. /**
  82530. * Easing function with a power of 5 shape (see link below).
  82531. * @see https://easings.net/#easeInQuint
  82532. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82533. */
  82534. export class QuinticEase extends EasingFunction implements IEasingFunction {
  82535. /** @hidden */
  82536. easeInCore(gradient: number): number;
  82537. }
  82538. /**
  82539. * Easing function with a sin shape (see link below).
  82540. * @see https://easings.net/#easeInSine
  82541. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82542. */
  82543. export class SineEase extends EasingFunction implements IEasingFunction {
  82544. /** @hidden */
  82545. easeInCore(gradient: number): number;
  82546. }
  82547. /**
  82548. * Easing function with a bezier shape (see link below).
  82549. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  82550. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82551. */
  82552. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  82553. /** Defines the x component of the start tangent in the bezier curve */
  82554. x1: number;
  82555. /** Defines the y component of the start tangent in the bezier curve */
  82556. y1: number;
  82557. /** Defines the x component of the end tangent in the bezier curve */
  82558. x2: number;
  82559. /** Defines the y component of the end tangent in the bezier curve */
  82560. y2: number;
  82561. /**
  82562. * Instantiates a bezier function
  82563. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  82564. * @param x1 Defines the x component of the start tangent in the bezier curve
  82565. * @param y1 Defines the y component of the start tangent in the bezier curve
  82566. * @param x2 Defines the x component of the end tangent in the bezier curve
  82567. * @param y2 Defines the y component of the end tangent in the bezier curve
  82568. */
  82569. constructor(
  82570. /** Defines the x component of the start tangent in the bezier curve */
  82571. x1?: number,
  82572. /** Defines the y component of the start tangent in the bezier curve */
  82573. y1?: number,
  82574. /** Defines the x component of the end tangent in the bezier curve */
  82575. x2?: number,
  82576. /** Defines the y component of the end tangent in the bezier curve */
  82577. y2?: number);
  82578. /** @hidden */
  82579. easeInCore(gradient: number): number;
  82580. }
  82581. }
  82582. declare module BABYLON {
  82583. /**
  82584. * Class used to hold a RBG color
  82585. */
  82586. export class Color3 {
  82587. /**
  82588. * Defines the red component (between 0 and 1, default is 0)
  82589. */
  82590. r: number;
  82591. /**
  82592. * Defines the green component (between 0 and 1, default is 0)
  82593. */
  82594. g: number;
  82595. /**
  82596. * Defines the blue component (between 0 and 1, default is 0)
  82597. */
  82598. b: number;
  82599. /**
  82600. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  82601. * @param r defines the red component (between 0 and 1, default is 0)
  82602. * @param g defines the green component (between 0 and 1, default is 0)
  82603. * @param b defines the blue component (between 0 and 1, default is 0)
  82604. */
  82605. constructor(
  82606. /**
  82607. * Defines the red component (between 0 and 1, default is 0)
  82608. */
  82609. r?: number,
  82610. /**
  82611. * Defines the green component (between 0 and 1, default is 0)
  82612. */
  82613. g?: number,
  82614. /**
  82615. * Defines the blue component (between 0 and 1, default is 0)
  82616. */
  82617. b?: number);
  82618. /**
  82619. * Creates a string with the Color3 current values
  82620. * @returns the string representation of the Color3 object
  82621. */
  82622. toString(): string;
  82623. /**
  82624. * Returns the string "Color3"
  82625. * @returns "Color3"
  82626. */
  82627. getClassName(): string;
  82628. /**
  82629. * Compute the Color3 hash code
  82630. * @returns an unique number that can be used to hash Color3 objects
  82631. */
  82632. getHashCode(): number;
  82633. /**
  82634. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  82635. * @param array defines the array where to store the r,g,b components
  82636. * @param index defines an optional index in the target array to define where to start storing values
  82637. * @returns the current Color3 object
  82638. */
  82639. toArray(array: FloatArray, index?: number): Color3;
  82640. /**
  82641. * Returns a new Color4 object from the current Color3 and the given alpha
  82642. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  82643. * @returns a new Color4 object
  82644. */
  82645. toColor4(alpha?: number): Color4;
  82646. /**
  82647. * Returns a new array populated with 3 numeric elements : red, green and blue values
  82648. * @returns the new array
  82649. */
  82650. asArray(): number[];
  82651. /**
  82652. * Returns the luminance value
  82653. * @returns a float value
  82654. */
  82655. toLuminance(): number;
  82656. /**
  82657. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  82658. * @param otherColor defines the second operand
  82659. * @returns the new Color3 object
  82660. */
  82661. multiply(otherColor: DeepImmutable<Color3>): Color3;
  82662. /**
  82663. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  82664. * @param otherColor defines the second operand
  82665. * @param result defines the Color3 object where to store the result
  82666. * @returns the current Color3
  82667. */
  82668. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  82669. /**
  82670. * Determines equality between Color3 objects
  82671. * @param otherColor defines the second operand
  82672. * @returns true if the rgb values are equal to the given ones
  82673. */
  82674. equals(otherColor: DeepImmutable<Color3>): boolean;
  82675. /**
  82676. * Determines equality between the current Color3 object and a set of r,b,g values
  82677. * @param r defines the red component to check
  82678. * @param g defines the green component to check
  82679. * @param b defines the blue component to check
  82680. * @returns true if the rgb values are equal to the given ones
  82681. */
  82682. equalsFloats(r: number, g: number, b: number): boolean;
  82683. /**
  82684. * Multiplies in place each rgb value by scale
  82685. * @param scale defines the scaling factor
  82686. * @returns the updated Color3
  82687. */
  82688. scale(scale: number): Color3;
  82689. /**
  82690. * Multiplies the rgb values by scale and stores the result into "result"
  82691. * @param scale defines the scaling factor
  82692. * @param result defines the Color3 object where to store the result
  82693. * @returns the unmodified current Color3
  82694. */
  82695. scaleToRef(scale: number, result: Color3): Color3;
  82696. /**
  82697. * Scale the current Color3 values by a factor and add the result to a given Color3
  82698. * @param scale defines the scale factor
  82699. * @param result defines color to store the result into
  82700. * @returns the unmodified current Color3
  82701. */
  82702. scaleAndAddToRef(scale: number, result: Color3): Color3;
  82703. /**
  82704. * Clamps the rgb values by the min and max values and stores the result into "result"
  82705. * @param min defines minimum clamping value (default is 0)
  82706. * @param max defines maximum clamping value (default is 1)
  82707. * @param result defines color to store the result into
  82708. * @returns the original Color3
  82709. */
  82710. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  82711. /**
  82712. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  82713. * @param otherColor defines the second operand
  82714. * @returns the new Color3
  82715. */
  82716. add(otherColor: DeepImmutable<Color3>): Color3;
  82717. /**
  82718. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  82719. * @param otherColor defines the second operand
  82720. * @param result defines Color3 object to store the result into
  82721. * @returns the unmodified current Color3
  82722. */
  82723. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  82724. /**
  82725. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  82726. * @param otherColor defines the second operand
  82727. * @returns the new Color3
  82728. */
  82729. subtract(otherColor: DeepImmutable<Color3>): Color3;
  82730. /**
  82731. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  82732. * @param otherColor defines the second operand
  82733. * @param result defines Color3 object to store the result into
  82734. * @returns the unmodified current Color3
  82735. */
  82736. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  82737. /**
  82738. * Copy the current object
  82739. * @returns a new Color3 copied the current one
  82740. */
  82741. clone(): Color3;
  82742. /**
  82743. * Copies the rgb values from the source in the current Color3
  82744. * @param source defines the source Color3 object
  82745. * @returns the updated Color3 object
  82746. */
  82747. copyFrom(source: DeepImmutable<Color3>): Color3;
  82748. /**
  82749. * Updates the Color3 rgb values from the given floats
  82750. * @param r defines the red component to read from
  82751. * @param g defines the green component to read from
  82752. * @param b defines the blue component to read from
  82753. * @returns the current Color3 object
  82754. */
  82755. copyFromFloats(r: number, g: number, b: number): Color3;
  82756. /**
  82757. * Updates the Color3 rgb values from the given floats
  82758. * @param r defines the red component to read from
  82759. * @param g defines the green component to read from
  82760. * @param b defines the blue component to read from
  82761. * @returns the current Color3 object
  82762. */
  82763. set(r: number, g: number, b: number): Color3;
  82764. /**
  82765. * Compute the Color3 hexadecimal code as a string
  82766. * @returns a string containing the hexadecimal representation of the Color3 object
  82767. */
  82768. toHexString(): string;
  82769. /**
  82770. * Computes a new Color3 converted from the current one to linear space
  82771. * @returns a new Color3 object
  82772. */
  82773. toLinearSpace(): Color3;
  82774. /**
  82775. * Converts current color in rgb space to HSV values
  82776. * @returns a new color3 representing the HSV values
  82777. */
  82778. toHSV(): Color3;
  82779. /**
  82780. * Converts current color in rgb space to HSV values
  82781. * @param result defines the Color3 where to store the HSV values
  82782. */
  82783. toHSVToRef(result: Color3): void;
  82784. /**
  82785. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  82786. * @param convertedColor defines the Color3 object where to store the linear space version
  82787. * @returns the unmodified Color3
  82788. */
  82789. toLinearSpaceToRef(convertedColor: Color3): Color3;
  82790. /**
  82791. * Computes a new Color3 converted from the current one to gamma space
  82792. * @returns a new Color3 object
  82793. */
  82794. toGammaSpace(): Color3;
  82795. /**
  82796. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  82797. * @param convertedColor defines the Color3 object where to store the gamma space version
  82798. * @returns the unmodified Color3
  82799. */
  82800. toGammaSpaceToRef(convertedColor: Color3): Color3;
  82801. private static _BlackReadOnly;
  82802. /**
  82803. * Convert Hue, saturation and value to a Color3 (RGB)
  82804. * @param hue defines the hue
  82805. * @param saturation defines the saturation
  82806. * @param value defines the value
  82807. * @param result defines the Color3 where to store the RGB values
  82808. */
  82809. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  82810. /**
  82811. * Creates a new Color3 from the string containing valid hexadecimal values
  82812. * @param hex defines a string containing valid hexadecimal values
  82813. * @returns a new Color3 object
  82814. */
  82815. static FromHexString(hex: string): Color3;
  82816. /**
  82817. * Creates a new Color3 from the starting index of the given array
  82818. * @param array defines the source array
  82819. * @param offset defines an offset in the source array
  82820. * @returns a new Color3 object
  82821. */
  82822. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  82823. /**
  82824. * Creates a new Color3 from integer values (< 256)
  82825. * @param r defines the red component to read from (value between 0 and 255)
  82826. * @param g defines the green component to read from (value between 0 and 255)
  82827. * @param b defines the blue component to read from (value between 0 and 255)
  82828. * @returns a new Color3 object
  82829. */
  82830. static FromInts(r: number, g: number, b: number): Color3;
  82831. /**
  82832. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  82833. * @param start defines the start Color3 value
  82834. * @param end defines the end Color3 value
  82835. * @param amount defines the gradient value between start and end
  82836. * @returns a new Color3 object
  82837. */
  82838. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  82839. /**
  82840. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  82841. * @param left defines the start value
  82842. * @param right defines the end value
  82843. * @param amount defines the gradient factor
  82844. * @param result defines the Color3 object where to store the result
  82845. */
  82846. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  82847. /**
  82848. * Returns a Color3 value containing a red color
  82849. * @returns a new Color3 object
  82850. */
  82851. static Red(): Color3;
  82852. /**
  82853. * Returns a Color3 value containing a green color
  82854. * @returns a new Color3 object
  82855. */
  82856. static Green(): Color3;
  82857. /**
  82858. * Returns a Color3 value containing a blue color
  82859. * @returns a new Color3 object
  82860. */
  82861. static Blue(): Color3;
  82862. /**
  82863. * Returns a Color3 value containing a black color
  82864. * @returns a new Color3 object
  82865. */
  82866. static Black(): Color3;
  82867. /**
  82868. * Gets a Color3 value containing a black color that must not be updated
  82869. */
  82870. static get BlackReadOnly(): DeepImmutable<Color3>;
  82871. /**
  82872. * Returns a Color3 value containing a white color
  82873. * @returns a new Color3 object
  82874. */
  82875. static White(): Color3;
  82876. /**
  82877. * Returns a Color3 value containing a purple color
  82878. * @returns a new Color3 object
  82879. */
  82880. static Purple(): Color3;
  82881. /**
  82882. * Returns a Color3 value containing a magenta color
  82883. * @returns a new Color3 object
  82884. */
  82885. static Magenta(): Color3;
  82886. /**
  82887. * Returns a Color3 value containing a yellow color
  82888. * @returns a new Color3 object
  82889. */
  82890. static Yellow(): Color3;
  82891. /**
  82892. * Returns a Color3 value containing a gray color
  82893. * @returns a new Color3 object
  82894. */
  82895. static Gray(): Color3;
  82896. /**
  82897. * Returns a Color3 value containing a teal color
  82898. * @returns a new Color3 object
  82899. */
  82900. static Teal(): Color3;
  82901. /**
  82902. * Returns a Color3 value containing a random color
  82903. * @returns a new Color3 object
  82904. */
  82905. static Random(): Color3;
  82906. }
  82907. /**
  82908. * Class used to hold a RBGA color
  82909. */
  82910. export class Color4 {
  82911. /**
  82912. * Defines the red component (between 0 and 1, default is 0)
  82913. */
  82914. r: number;
  82915. /**
  82916. * Defines the green component (between 0 and 1, default is 0)
  82917. */
  82918. g: number;
  82919. /**
  82920. * Defines the blue component (between 0 and 1, default is 0)
  82921. */
  82922. b: number;
  82923. /**
  82924. * Defines the alpha component (between 0 and 1, default is 1)
  82925. */
  82926. a: number;
  82927. /**
  82928. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  82929. * @param r defines the red component (between 0 and 1, default is 0)
  82930. * @param g defines the green component (between 0 and 1, default is 0)
  82931. * @param b defines the blue component (between 0 and 1, default is 0)
  82932. * @param a defines the alpha component (between 0 and 1, default is 1)
  82933. */
  82934. constructor(
  82935. /**
  82936. * Defines the red component (between 0 and 1, default is 0)
  82937. */
  82938. r?: number,
  82939. /**
  82940. * Defines the green component (between 0 and 1, default is 0)
  82941. */
  82942. g?: number,
  82943. /**
  82944. * Defines the blue component (between 0 and 1, default is 0)
  82945. */
  82946. b?: number,
  82947. /**
  82948. * Defines the alpha component (between 0 and 1, default is 1)
  82949. */
  82950. a?: number);
  82951. /**
  82952. * Adds in place the given Color4 values to the current Color4 object
  82953. * @param right defines the second operand
  82954. * @returns the current updated Color4 object
  82955. */
  82956. addInPlace(right: DeepImmutable<Color4>): Color4;
  82957. /**
  82958. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  82959. * @returns the new array
  82960. */
  82961. asArray(): number[];
  82962. /**
  82963. * Stores from the starting index in the given array the Color4 successive values
  82964. * @param array defines the array where to store the r,g,b components
  82965. * @param index defines an optional index in the target array to define where to start storing values
  82966. * @returns the current Color4 object
  82967. */
  82968. toArray(array: number[], index?: number): Color4;
  82969. /**
  82970. * Determines equality between Color4 objects
  82971. * @param otherColor defines the second operand
  82972. * @returns true if the rgba values are equal to the given ones
  82973. */
  82974. equals(otherColor: DeepImmutable<Color4>): boolean;
  82975. /**
  82976. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  82977. * @param right defines the second operand
  82978. * @returns a new Color4 object
  82979. */
  82980. add(right: DeepImmutable<Color4>): Color4;
  82981. /**
  82982. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  82983. * @param right defines the second operand
  82984. * @returns a new Color4 object
  82985. */
  82986. subtract(right: DeepImmutable<Color4>): Color4;
  82987. /**
  82988. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  82989. * @param right defines the second operand
  82990. * @param result defines the Color4 object where to store the result
  82991. * @returns the current Color4 object
  82992. */
  82993. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  82994. /**
  82995. * Creates a new Color4 with the current Color4 values multiplied by scale
  82996. * @param scale defines the scaling factor to apply
  82997. * @returns a new Color4 object
  82998. */
  82999. scale(scale: number): Color4;
  83000. /**
  83001. * Multiplies the current Color4 values by scale and stores the result in "result"
  83002. * @param scale defines the scaling factor to apply
  83003. * @param result defines the Color4 object where to store the result
  83004. * @returns the current unmodified Color4
  83005. */
  83006. scaleToRef(scale: number, result: Color4): Color4;
  83007. /**
  83008. * Scale the current Color4 values by a factor and add the result to a given Color4
  83009. * @param scale defines the scale factor
  83010. * @param result defines the Color4 object where to store the result
  83011. * @returns the unmodified current Color4
  83012. */
  83013. scaleAndAddToRef(scale: number, result: Color4): Color4;
  83014. /**
  83015. * Clamps the rgb values by the min and max values and stores the result into "result"
  83016. * @param min defines minimum clamping value (default is 0)
  83017. * @param max defines maximum clamping value (default is 1)
  83018. * @param result defines color to store the result into.
  83019. * @returns the cuurent Color4
  83020. */
  83021. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  83022. /**
  83023. * Multipy an Color4 value by another and return a new Color4 object
  83024. * @param color defines the Color4 value to multiply by
  83025. * @returns a new Color4 object
  83026. */
  83027. multiply(color: Color4): Color4;
  83028. /**
  83029. * Multipy a Color4 value by another and push the result in a reference value
  83030. * @param color defines the Color4 value to multiply by
  83031. * @param result defines the Color4 to fill the result in
  83032. * @returns the result Color4
  83033. */
  83034. multiplyToRef(color: Color4, result: Color4): Color4;
  83035. /**
  83036. * Creates a string with the Color4 current values
  83037. * @returns the string representation of the Color4 object
  83038. */
  83039. toString(): string;
  83040. /**
  83041. * Returns the string "Color4"
  83042. * @returns "Color4"
  83043. */
  83044. getClassName(): string;
  83045. /**
  83046. * Compute the Color4 hash code
  83047. * @returns an unique number that can be used to hash Color4 objects
  83048. */
  83049. getHashCode(): number;
  83050. /**
  83051. * Creates a new Color4 copied from the current one
  83052. * @returns a new Color4 object
  83053. */
  83054. clone(): Color4;
  83055. /**
  83056. * Copies the given Color4 values into the current one
  83057. * @param source defines the source Color4 object
  83058. * @returns the current updated Color4 object
  83059. */
  83060. copyFrom(source: Color4): Color4;
  83061. /**
  83062. * Copies the given float values into the current one
  83063. * @param r defines the red component to read from
  83064. * @param g defines the green component to read from
  83065. * @param b defines the blue component to read from
  83066. * @param a defines the alpha component to read from
  83067. * @returns the current updated Color4 object
  83068. */
  83069. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  83070. /**
  83071. * Copies the given float values into the current one
  83072. * @param r defines the red component to read from
  83073. * @param g defines the green component to read from
  83074. * @param b defines the blue component to read from
  83075. * @param a defines the alpha component to read from
  83076. * @returns the current updated Color4 object
  83077. */
  83078. set(r: number, g: number, b: number, a: number): Color4;
  83079. /**
  83080. * Compute the Color4 hexadecimal code as a string
  83081. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  83082. * @returns a string containing the hexadecimal representation of the Color4 object
  83083. */
  83084. toHexString(returnAsColor3?: boolean): string;
  83085. /**
  83086. * Computes a new Color4 converted from the current one to linear space
  83087. * @returns a new Color4 object
  83088. */
  83089. toLinearSpace(): Color4;
  83090. /**
  83091. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  83092. * @param convertedColor defines the Color4 object where to store the linear space version
  83093. * @returns the unmodified Color4
  83094. */
  83095. toLinearSpaceToRef(convertedColor: Color4): Color4;
  83096. /**
  83097. * Computes a new Color4 converted from the current one to gamma space
  83098. * @returns a new Color4 object
  83099. */
  83100. toGammaSpace(): Color4;
  83101. /**
  83102. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  83103. * @param convertedColor defines the Color4 object where to store the gamma space version
  83104. * @returns the unmodified Color4
  83105. */
  83106. toGammaSpaceToRef(convertedColor: Color4): Color4;
  83107. /**
  83108. * Creates a new Color4 from the string containing valid hexadecimal values
  83109. * @param hex defines a string containing valid hexadecimal values
  83110. * @returns a new Color4 object
  83111. */
  83112. static FromHexString(hex: string): Color4;
  83113. /**
  83114. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  83115. * @param left defines the start value
  83116. * @param right defines the end value
  83117. * @param amount defines the gradient factor
  83118. * @returns a new Color4 object
  83119. */
  83120. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  83121. /**
  83122. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  83123. * @param left defines the start value
  83124. * @param right defines the end value
  83125. * @param amount defines the gradient factor
  83126. * @param result defines the Color4 object where to store data
  83127. */
  83128. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  83129. /**
  83130. * Creates a new Color4 from a Color3 and an alpha value
  83131. * @param color3 defines the source Color3 to read from
  83132. * @param alpha defines the alpha component (1.0 by default)
  83133. * @returns a new Color4 object
  83134. */
  83135. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  83136. /**
  83137. * Creates a new Color4 from the starting index element of the given array
  83138. * @param array defines the source array to read from
  83139. * @param offset defines the offset in the source array
  83140. * @returns a new Color4 object
  83141. */
  83142. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  83143. /**
  83144. * Creates a new Color3 from integer values (< 256)
  83145. * @param r defines the red component to read from (value between 0 and 255)
  83146. * @param g defines the green component to read from (value between 0 and 255)
  83147. * @param b defines the blue component to read from (value between 0 and 255)
  83148. * @param a defines the alpha component to read from (value between 0 and 255)
  83149. * @returns a new Color3 object
  83150. */
  83151. static FromInts(r: number, g: number, b: number, a: number): Color4;
  83152. /**
  83153. * Check the content of a given array and convert it to an array containing RGBA data
  83154. * If the original array was already containing count * 4 values then it is returned directly
  83155. * @param colors defines the array to check
  83156. * @param count defines the number of RGBA data to expect
  83157. * @returns an array containing count * 4 values (RGBA)
  83158. */
  83159. static CheckColors4(colors: number[], count: number): number[];
  83160. }
  83161. /**
  83162. * @hidden
  83163. */
  83164. export class TmpColors {
  83165. static Color3: Color3[];
  83166. static Color4: Color4[];
  83167. }
  83168. }
  83169. declare module BABYLON {
  83170. /**
  83171. * Defines an interface which represents an animation key frame
  83172. */
  83173. export interface IAnimationKey {
  83174. /**
  83175. * Frame of the key frame
  83176. */
  83177. frame: number;
  83178. /**
  83179. * Value at the specifies key frame
  83180. */
  83181. value: any;
  83182. /**
  83183. * The input tangent for the cubic hermite spline
  83184. */
  83185. inTangent?: any;
  83186. /**
  83187. * The output tangent for the cubic hermite spline
  83188. */
  83189. outTangent?: any;
  83190. /**
  83191. * The animation interpolation type
  83192. */
  83193. interpolation?: AnimationKeyInterpolation;
  83194. }
  83195. /**
  83196. * Enum for the animation key frame interpolation type
  83197. */
  83198. export enum AnimationKeyInterpolation {
  83199. /**
  83200. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  83201. */
  83202. STEP = 1
  83203. }
  83204. }
  83205. declare module BABYLON {
  83206. /**
  83207. * Represents the range of an animation
  83208. */
  83209. export class AnimationRange {
  83210. /**The name of the animation range**/
  83211. name: string;
  83212. /**The starting frame of the animation */
  83213. from: number;
  83214. /**The ending frame of the animation*/
  83215. to: number;
  83216. /**
  83217. * Initializes the range of an animation
  83218. * @param name The name of the animation range
  83219. * @param from The starting frame of the animation
  83220. * @param to The ending frame of the animation
  83221. */
  83222. constructor(
  83223. /**The name of the animation range**/
  83224. name: string,
  83225. /**The starting frame of the animation */
  83226. from: number,
  83227. /**The ending frame of the animation*/
  83228. to: number);
  83229. /**
  83230. * Makes a copy of the animation range
  83231. * @returns A copy of the animation range
  83232. */
  83233. clone(): AnimationRange;
  83234. }
  83235. }
  83236. declare module BABYLON {
  83237. /**
  83238. * Composed of a frame, and an action function
  83239. */
  83240. export class AnimationEvent {
  83241. /** The frame for which the event is triggered **/
  83242. frame: number;
  83243. /** The event to perform when triggered **/
  83244. action: (currentFrame: number) => void;
  83245. /** Specifies if the event should be triggered only once**/
  83246. onlyOnce?: boolean | undefined;
  83247. /**
  83248. * Specifies if the animation event is done
  83249. */
  83250. isDone: boolean;
  83251. /**
  83252. * Initializes the animation event
  83253. * @param frame The frame for which the event is triggered
  83254. * @param action The event to perform when triggered
  83255. * @param onlyOnce Specifies if the event should be triggered only once
  83256. */
  83257. constructor(
  83258. /** The frame for which the event is triggered **/
  83259. frame: number,
  83260. /** The event to perform when triggered **/
  83261. action: (currentFrame: number) => void,
  83262. /** Specifies if the event should be triggered only once**/
  83263. onlyOnce?: boolean | undefined);
  83264. /** @hidden */
  83265. _clone(): AnimationEvent;
  83266. }
  83267. }
  83268. declare module BABYLON {
  83269. /**
  83270. * Interface used to define a behavior
  83271. */
  83272. export interface Behavior<T> {
  83273. /** gets or sets behavior's name */
  83274. name: string;
  83275. /**
  83276. * Function called when the behavior needs to be initialized (after attaching it to a target)
  83277. */
  83278. init(): void;
  83279. /**
  83280. * Called when the behavior is attached to a target
  83281. * @param target defines the target where the behavior is attached to
  83282. */
  83283. attach(target: T): void;
  83284. /**
  83285. * Called when the behavior is detached from its target
  83286. */
  83287. detach(): void;
  83288. }
  83289. /**
  83290. * Interface implemented by classes supporting behaviors
  83291. */
  83292. export interface IBehaviorAware<T> {
  83293. /**
  83294. * Attach a behavior
  83295. * @param behavior defines the behavior to attach
  83296. * @returns the current host
  83297. */
  83298. addBehavior(behavior: Behavior<T>): T;
  83299. /**
  83300. * Remove a behavior from the current object
  83301. * @param behavior defines the behavior to detach
  83302. * @returns the current host
  83303. */
  83304. removeBehavior(behavior: Behavior<T>): T;
  83305. /**
  83306. * Gets a behavior using its name to search
  83307. * @param name defines the name to search
  83308. * @returns the behavior or null if not found
  83309. */
  83310. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  83311. }
  83312. }
  83313. declare module BABYLON {
  83314. /**
  83315. * Defines an array and its length.
  83316. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  83317. */
  83318. export interface ISmartArrayLike<T> {
  83319. /**
  83320. * The data of the array.
  83321. */
  83322. data: Array<T>;
  83323. /**
  83324. * The active length of the array.
  83325. */
  83326. length: number;
  83327. }
  83328. /**
  83329. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  83330. */
  83331. export class SmartArray<T> implements ISmartArrayLike<T> {
  83332. /**
  83333. * The full set of data from the array.
  83334. */
  83335. data: Array<T>;
  83336. /**
  83337. * The active length of the array.
  83338. */
  83339. length: number;
  83340. protected _id: number;
  83341. /**
  83342. * Instantiates a Smart Array.
  83343. * @param capacity defines the default capacity of the array.
  83344. */
  83345. constructor(capacity: number);
  83346. /**
  83347. * Pushes a value at the end of the active data.
  83348. * @param value defines the object to push in the array.
  83349. */
  83350. push(value: T): void;
  83351. /**
  83352. * Iterates over the active data and apply the lambda to them.
  83353. * @param func defines the action to apply on each value.
  83354. */
  83355. forEach(func: (content: T) => void): void;
  83356. /**
  83357. * Sorts the full sets of data.
  83358. * @param compareFn defines the comparison function to apply.
  83359. */
  83360. sort(compareFn: (a: T, b: T) => number): void;
  83361. /**
  83362. * Resets the active data to an empty array.
  83363. */
  83364. reset(): void;
  83365. /**
  83366. * Releases all the data from the array as well as the array.
  83367. */
  83368. dispose(): void;
  83369. /**
  83370. * Concats the active data with a given array.
  83371. * @param array defines the data to concatenate with.
  83372. */
  83373. concat(array: any): void;
  83374. /**
  83375. * Returns the position of a value in the active data.
  83376. * @param value defines the value to find the index for
  83377. * @returns the index if found in the active data otherwise -1
  83378. */
  83379. indexOf(value: T): number;
  83380. /**
  83381. * Returns whether an element is part of the active data.
  83382. * @param value defines the value to look for
  83383. * @returns true if found in the active data otherwise false
  83384. */
  83385. contains(value: T): boolean;
  83386. private static _GlobalId;
  83387. }
  83388. /**
  83389. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  83390. * The data in this array can only be present once
  83391. */
  83392. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  83393. private _duplicateId;
  83394. /**
  83395. * Pushes a value at the end of the active data.
  83396. * THIS DOES NOT PREVENT DUPPLICATE DATA
  83397. * @param value defines the object to push in the array.
  83398. */
  83399. push(value: T): void;
  83400. /**
  83401. * Pushes a value at the end of the active data.
  83402. * If the data is already present, it won t be added again
  83403. * @param value defines the object to push in the array.
  83404. * @returns true if added false if it was already present
  83405. */
  83406. pushNoDuplicate(value: T): boolean;
  83407. /**
  83408. * Resets the active data to an empty array.
  83409. */
  83410. reset(): void;
  83411. /**
  83412. * Concats the active data with a given array.
  83413. * This ensures no dupplicate will be present in the result.
  83414. * @param array defines the data to concatenate with.
  83415. */
  83416. concatWithNoDuplicate(array: any): void;
  83417. }
  83418. }
  83419. declare module BABYLON {
  83420. /**
  83421. * @ignore
  83422. * This is a list of all the different input types that are available in the application.
  83423. * Fo instance: ArcRotateCameraGamepadInput...
  83424. */
  83425. export var CameraInputTypes: {};
  83426. /**
  83427. * This is the contract to implement in order to create a new input class.
  83428. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  83429. */
  83430. export interface ICameraInput<TCamera extends Camera> {
  83431. /**
  83432. * Defines the camera the input is attached to.
  83433. */
  83434. camera: Nullable<TCamera>;
  83435. /**
  83436. * Gets the class name of the current intput.
  83437. * @returns the class name
  83438. */
  83439. getClassName(): string;
  83440. /**
  83441. * Get the friendly name associated with the input class.
  83442. * @returns the input friendly name
  83443. */
  83444. getSimpleName(): string;
  83445. /**
  83446. * Attach the input controls to a specific dom element to get the input from.
  83447. * @param element Defines the element the controls should be listened from
  83448. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  83449. */
  83450. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  83451. /**
  83452. * Detach the current controls from the specified dom element.
  83453. * @param element Defines the element to stop listening the inputs from
  83454. */
  83455. detachControl(element: Nullable<HTMLElement>): void;
  83456. /**
  83457. * Update the current camera state depending on the inputs that have been used this frame.
  83458. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  83459. */
  83460. checkInputs?: () => void;
  83461. }
  83462. /**
  83463. * Represents a map of input types to input instance or input index to input instance.
  83464. */
  83465. export interface CameraInputsMap<TCamera extends Camera> {
  83466. /**
  83467. * Accessor to the input by input type.
  83468. */
  83469. [name: string]: ICameraInput<TCamera>;
  83470. /**
  83471. * Accessor to the input by input index.
  83472. */
  83473. [idx: number]: ICameraInput<TCamera>;
  83474. }
  83475. /**
  83476. * This represents the input manager used within a camera.
  83477. * It helps dealing with all the different kind of input attached to a camera.
  83478. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  83479. */
  83480. export class CameraInputsManager<TCamera extends Camera> {
  83481. /**
  83482. * Defines the list of inputs attahed to the camera.
  83483. */
  83484. attached: CameraInputsMap<TCamera>;
  83485. /**
  83486. * Defines the dom element the camera is collecting inputs from.
  83487. * This is null if the controls have not been attached.
  83488. */
  83489. attachedElement: Nullable<HTMLElement>;
  83490. /**
  83491. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  83492. */
  83493. noPreventDefault: boolean;
  83494. /**
  83495. * Defined the camera the input manager belongs to.
  83496. */
  83497. camera: TCamera;
  83498. /**
  83499. * Update the current camera state depending on the inputs that have been used this frame.
  83500. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  83501. */
  83502. checkInputs: () => void;
  83503. /**
  83504. * Instantiate a new Camera Input Manager.
  83505. * @param camera Defines the camera the input manager blongs to
  83506. */
  83507. constructor(camera: TCamera);
  83508. /**
  83509. * Add an input method to a camera
  83510. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  83511. * @param input camera input method
  83512. */
  83513. add(input: ICameraInput<TCamera>): void;
  83514. /**
  83515. * Remove a specific input method from a camera
  83516. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  83517. * @param inputToRemove camera input method
  83518. */
  83519. remove(inputToRemove: ICameraInput<TCamera>): void;
  83520. /**
  83521. * Remove a specific input type from a camera
  83522. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  83523. * @param inputType the type of the input to remove
  83524. */
  83525. removeByType(inputType: string): void;
  83526. private _addCheckInputs;
  83527. /**
  83528. * Attach the input controls to the currently attached dom element to listen the events from.
  83529. * @param input Defines the input to attach
  83530. */
  83531. attachInput(input: ICameraInput<TCamera>): void;
  83532. /**
  83533. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  83534. * @param element Defines the dom element to collect the events from
  83535. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  83536. */
  83537. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  83538. /**
  83539. * Detach the current manager inputs controls from a specific dom element.
  83540. * @param element Defines the dom element to collect the events from
  83541. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  83542. */
  83543. detachElement(element: HTMLElement, disconnect?: boolean): void;
  83544. /**
  83545. * Rebuild the dynamic inputCheck function from the current list of
  83546. * defined inputs in the manager.
  83547. */
  83548. rebuildInputCheck(): void;
  83549. /**
  83550. * Remove all attached input methods from a camera
  83551. */
  83552. clear(): void;
  83553. /**
  83554. * Serialize the current input manager attached to a camera.
  83555. * This ensures than once parsed,
  83556. * the input associated to the camera will be identical to the current ones
  83557. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  83558. */
  83559. serialize(serializedCamera: any): void;
  83560. /**
  83561. * Parses an input manager serialized JSON to restore the previous list of inputs
  83562. * and states associated to a camera.
  83563. * @param parsedCamera Defines the JSON to parse
  83564. */
  83565. parse(parsedCamera: any): void;
  83566. }
  83567. }
  83568. declare module BABYLON {
  83569. /**
  83570. * Class used to store data that will be store in GPU memory
  83571. */
  83572. export class Buffer {
  83573. private _engine;
  83574. private _buffer;
  83575. /** @hidden */
  83576. _data: Nullable<DataArray>;
  83577. private _updatable;
  83578. private _instanced;
  83579. private _divisor;
  83580. /**
  83581. * Gets the byte stride.
  83582. */
  83583. readonly byteStride: number;
  83584. /**
  83585. * Constructor
  83586. * @param engine the engine
  83587. * @param data the data to use for this buffer
  83588. * @param updatable whether the data is updatable
  83589. * @param stride the stride (optional)
  83590. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  83591. * @param instanced whether the buffer is instanced (optional)
  83592. * @param useBytes set to true if the stride in in bytes (optional)
  83593. * @param divisor sets an optional divisor for instances (1 by default)
  83594. */
  83595. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  83596. /**
  83597. * Create a new VertexBuffer based on the current buffer
  83598. * @param kind defines the vertex buffer kind (position, normal, etc.)
  83599. * @param offset defines offset in the buffer (0 by default)
  83600. * @param size defines the size in floats of attributes (position is 3 for instance)
  83601. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  83602. * @param instanced defines if the vertex buffer contains indexed data
  83603. * @param useBytes defines if the offset and stride are in bytes *
  83604. * @param divisor sets an optional divisor for instances (1 by default)
  83605. * @returns the new vertex buffer
  83606. */
  83607. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  83608. /**
  83609. * Gets a boolean indicating if the Buffer is updatable?
  83610. * @returns true if the buffer is updatable
  83611. */
  83612. isUpdatable(): boolean;
  83613. /**
  83614. * Gets current buffer's data
  83615. * @returns a DataArray or null
  83616. */
  83617. getData(): Nullable<DataArray>;
  83618. /**
  83619. * Gets underlying native buffer
  83620. * @returns underlying native buffer
  83621. */
  83622. getBuffer(): Nullable<DataBuffer>;
  83623. /**
  83624. * Gets the stride in float32 units (i.e. byte stride / 4).
  83625. * May not be an integer if the byte stride is not divisible by 4.
  83626. * @returns the stride in float32 units
  83627. * @deprecated Please use byteStride instead.
  83628. */
  83629. getStrideSize(): number;
  83630. /**
  83631. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  83632. * @param data defines the data to store
  83633. */
  83634. create(data?: Nullable<DataArray>): void;
  83635. /** @hidden */
  83636. _rebuild(): void;
  83637. /**
  83638. * Update current buffer data
  83639. * @param data defines the data to store
  83640. */
  83641. update(data: DataArray): void;
  83642. /**
  83643. * Updates the data directly.
  83644. * @param data the new data
  83645. * @param offset the new offset
  83646. * @param vertexCount the vertex count (optional)
  83647. * @param useBytes set to true if the offset is in bytes
  83648. */
  83649. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  83650. /**
  83651. * Release all resources
  83652. */
  83653. dispose(): void;
  83654. }
  83655. /**
  83656. * Specialized buffer used to store vertex data
  83657. */
  83658. export class VertexBuffer {
  83659. /** @hidden */
  83660. _buffer: Buffer;
  83661. private _kind;
  83662. private _size;
  83663. private _ownsBuffer;
  83664. private _instanced;
  83665. private _instanceDivisor;
  83666. /**
  83667. * The byte type.
  83668. */
  83669. static readonly BYTE: number;
  83670. /**
  83671. * The unsigned byte type.
  83672. */
  83673. static readonly UNSIGNED_BYTE: number;
  83674. /**
  83675. * The short type.
  83676. */
  83677. static readonly SHORT: number;
  83678. /**
  83679. * The unsigned short type.
  83680. */
  83681. static readonly UNSIGNED_SHORT: number;
  83682. /**
  83683. * The integer type.
  83684. */
  83685. static readonly INT: number;
  83686. /**
  83687. * The unsigned integer type.
  83688. */
  83689. static readonly UNSIGNED_INT: number;
  83690. /**
  83691. * The float type.
  83692. */
  83693. static readonly FLOAT: number;
  83694. /**
  83695. * Gets or sets the instance divisor when in instanced mode
  83696. */
  83697. get instanceDivisor(): number;
  83698. set instanceDivisor(value: number);
  83699. /**
  83700. * Gets the byte stride.
  83701. */
  83702. readonly byteStride: number;
  83703. /**
  83704. * Gets the byte offset.
  83705. */
  83706. readonly byteOffset: number;
  83707. /**
  83708. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  83709. */
  83710. readonly normalized: boolean;
  83711. /**
  83712. * Gets the data type of each component in the array.
  83713. */
  83714. readonly type: number;
  83715. /**
  83716. * Constructor
  83717. * @param engine the engine
  83718. * @param data the data to use for this vertex buffer
  83719. * @param kind the vertex buffer kind
  83720. * @param updatable whether the data is updatable
  83721. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  83722. * @param stride the stride (optional)
  83723. * @param instanced whether the buffer is instanced (optional)
  83724. * @param offset the offset of the data (optional)
  83725. * @param size the number of components (optional)
  83726. * @param type the type of the component (optional)
  83727. * @param normalized whether the data contains normalized data (optional)
  83728. * @param useBytes set to true if stride and offset are in bytes (optional)
  83729. * @param divisor defines the instance divisor to use (1 by default)
  83730. */
  83731. 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);
  83732. /** @hidden */
  83733. _rebuild(): void;
  83734. /**
  83735. * Returns the kind of the VertexBuffer (string)
  83736. * @returns a string
  83737. */
  83738. getKind(): string;
  83739. /**
  83740. * Gets a boolean indicating if the VertexBuffer is updatable?
  83741. * @returns true if the buffer is updatable
  83742. */
  83743. isUpdatable(): boolean;
  83744. /**
  83745. * Gets current buffer's data
  83746. * @returns a DataArray or null
  83747. */
  83748. getData(): Nullable<DataArray>;
  83749. /**
  83750. * Gets underlying native buffer
  83751. * @returns underlying native buffer
  83752. */
  83753. getBuffer(): Nullable<DataBuffer>;
  83754. /**
  83755. * Gets the stride in float32 units (i.e. byte stride / 4).
  83756. * May not be an integer if the byte stride is not divisible by 4.
  83757. * @returns the stride in float32 units
  83758. * @deprecated Please use byteStride instead.
  83759. */
  83760. getStrideSize(): number;
  83761. /**
  83762. * Returns the offset as a multiple of the type byte length.
  83763. * @returns the offset in bytes
  83764. * @deprecated Please use byteOffset instead.
  83765. */
  83766. getOffset(): number;
  83767. /**
  83768. * Returns the number of components per vertex attribute (integer)
  83769. * @returns the size in float
  83770. */
  83771. getSize(): number;
  83772. /**
  83773. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  83774. * @returns true if this buffer is instanced
  83775. */
  83776. getIsInstanced(): boolean;
  83777. /**
  83778. * Returns the instancing divisor, zero for non-instanced (integer).
  83779. * @returns a number
  83780. */
  83781. getInstanceDivisor(): number;
  83782. /**
  83783. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  83784. * @param data defines the data to store
  83785. */
  83786. create(data?: DataArray): void;
  83787. /**
  83788. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  83789. * This function will create a new buffer if the current one is not updatable
  83790. * @param data defines the data to store
  83791. */
  83792. update(data: DataArray): void;
  83793. /**
  83794. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  83795. * Returns the directly updated WebGLBuffer.
  83796. * @param data the new data
  83797. * @param offset the new offset
  83798. * @param useBytes set to true if the offset is in bytes
  83799. */
  83800. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  83801. /**
  83802. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  83803. */
  83804. dispose(): void;
  83805. /**
  83806. * Enumerates each value of this vertex buffer as numbers.
  83807. * @param count the number of values to enumerate
  83808. * @param callback the callback function called for each value
  83809. */
  83810. forEach(count: number, callback: (value: number, index: number) => void): void;
  83811. /**
  83812. * Positions
  83813. */
  83814. static readonly PositionKind: string;
  83815. /**
  83816. * Normals
  83817. */
  83818. static readonly NormalKind: string;
  83819. /**
  83820. * Tangents
  83821. */
  83822. static readonly TangentKind: string;
  83823. /**
  83824. * Texture coordinates
  83825. */
  83826. static readonly UVKind: string;
  83827. /**
  83828. * Texture coordinates 2
  83829. */
  83830. static readonly UV2Kind: string;
  83831. /**
  83832. * Texture coordinates 3
  83833. */
  83834. static readonly UV3Kind: string;
  83835. /**
  83836. * Texture coordinates 4
  83837. */
  83838. static readonly UV4Kind: string;
  83839. /**
  83840. * Texture coordinates 5
  83841. */
  83842. static readonly UV5Kind: string;
  83843. /**
  83844. * Texture coordinates 6
  83845. */
  83846. static readonly UV6Kind: string;
  83847. /**
  83848. * Colors
  83849. */
  83850. static readonly ColorKind: string;
  83851. /**
  83852. * Matrix indices (for bones)
  83853. */
  83854. static readonly MatricesIndicesKind: string;
  83855. /**
  83856. * Matrix weights (for bones)
  83857. */
  83858. static readonly MatricesWeightsKind: string;
  83859. /**
  83860. * Additional matrix indices (for bones)
  83861. */
  83862. static readonly MatricesIndicesExtraKind: string;
  83863. /**
  83864. * Additional matrix weights (for bones)
  83865. */
  83866. static readonly MatricesWeightsExtraKind: string;
  83867. /**
  83868. * Deduces the stride given a kind.
  83869. * @param kind The kind string to deduce
  83870. * @returns The deduced stride
  83871. */
  83872. static DeduceStride(kind: string): number;
  83873. /**
  83874. * Gets the byte length of the given type.
  83875. * @param type the type
  83876. * @returns the number of bytes
  83877. */
  83878. static GetTypeByteLength(type: number): number;
  83879. /**
  83880. * Enumerates each value of the given parameters as numbers.
  83881. * @param data the data to enumerate
  83882. * @param byteOffset the byte offset of the data
  83883. * @param byteStride the byte stride of the data
  83884. * @param componentCount the number of components per element
  83885. * @param componentType the type of the component
  83886. * @param count the number of values to enumerate
  83887. * @param normalized whether the data is normalized
  83888. * @param callback the callback function called for each value
  83889. */
  83890. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  83891. private static _GetFloatValue;
  83892. }
  83893. }
  83894. declare module BABYLON {
  83895. /**
  83896. * @hidden
  83897. */
  83898. export class IntersectionInfo {
  83899. bu: Nullable<number>;
  83900. bv: Nullable<number>;
  83901. distance: number;
  83902. faceId: number;
  83903. subMeshId: number;
  83904. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  83905. }
  83906. }
  83907. declare module BABYLON {
  83908. /**
  83909. * Class used to store bounding sphere information
  83910. */
  83911. export class BoundingSphere {
  83912. /**
  83913. * Gets the center of the bounding sphere in local space
  83914. */
  83915. readonly center: Vector3;
  83916. /**
  83917. * Radius of the bounding sphere in local space
  83918. */
  83919. radius: number;
  83920. /**
  83921. * Gets the center of the bounding sphere in world space
  83922. */
  83923. readonly centerWorld: Vector3;
  83924. /**
  83925. * Radius of the bounding sphere in world space
  83926. */
  83927. radiusWorld: number;
  83928. /**
  83929. * Gets the minimum vector in local space
  83930. */
  83931. readonly minimum: Vector3;
  83932. /**
  83933. * Gets the maximum vector in local space
  83934. */
  83935. readonly maximum: Vector3;
  83936. private _worldMatrix;
  83937. private static readonly TmpVector3;
  83938. /**
  83939. * Creates a new bounding sphere
  83940. * @param min defines the minimum vector (in local space)
  83941. * @param max defines the maximum vector (in local space)
  83942. * @param worldMatrix defines the new world matrix
  83943. */
  83944. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  83945. /**
  83946. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  83947. * @param min defines the new minimum vector (in local space)
  83948. * @param max defines the new maximum vector (in local space)
  83949. * @param worldMatrix defines the new world matrix
  83950. */
  83951. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  83952. /**
  83953. * Scale the current bounding sphere by applying a scale factor
  83954. * @param factor defines the scale factor to apply
  83955. * @returns the current bounding box
  83956. */
  83957. scale(factor: number): BoundingSphere;
  83958. /**
  83959. * Gets the world matrix of the bounding box
  83960. * @returns a matrix
  83961. */
  83962. getWorldMatrix(): DeepImmutable<Matrix>;
  83963. /** @hidden */
  83964. _update(worldMatrix: DeepImmutable<Matrix>): void;
  83965. /**
  83966. * Tests if the bounding sphere is intersecting the frustum planes
  83967. * @param frustumPlanes defines the frustum planes to test
  83968. * @returns true if there is an intersection
  83969. */
  83970. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  83971. /**
  83972. * Tests if the bounding sphere center is in between the frustum planes.
  83973. * Used for optimistic fast inclusion.
  83974. * @param frustumPlanes defines the frustum planes to test
  83975. * @returns true if the sphere center is in between the frustum planes
  83976. */
  83977. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  83978. /**
  83979. * Tests if a point is inside the bounding sphere
  83980. * @param point defines the point to test
  83981. * @returns true if the point is inside the bounding sphere
  83982. */
  83983. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  83984. /**
  83985. * Checks if two sphere intersct
  83986. * @param sphere0 sphere 0
  83987. * @param sphere1 sphere 1
  83988. * @returns true if the speres intersect
  83989. */
  83990. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  83991. }
  83992. }
  83993. declare module BABYLON {
  83994. /**
  83995. * Class used to store bounding box information
  83996. */
  83997. export class BoundingBox implements ICullable {
  83998. /**
  83999. * Gets the 8 vectors representing the bounding box in local space
  84000. */
  84001. readonly vectors: Vector3[];
  84002. /**
  84003. * Gets the center of the bounding box in local space
  84004. */
  84005. readonly center: Vector3;
  84006. /**
  84007. * Gets the center of the bounding box in world space
  84008. */
  84009. readonly centerWorld: Vector3;
  84010. /**
  84011. * Gets the extend size in local space
  84012. */
  84013. readonly extendSize: Vector3;
  84014. /**
  84015. * Gets the extend size in world space
  84016. */
  84017. readonly extendSizeWorld: Vector3;
  84018. /**
  84019. * Gets the OBB (object bounding box) directions
  84020. */
  84021. readonly directions: Vector3[];
  84022. /**
  84023. * Gets the 8 vectors representing the bounding box in world space
  84024. */
  84025. readonly vectorsWorld: Vector3[];
  84026. /**
  84027. * Gets the minimum vector in world space
  84028. */
  84029. readonly minimumWorld: Vector3;
  84030. /**
  84031. * Gets the maximum vector in world space
  84032. */
  84033. readonly maximumWorld: Vector3;
  84034. /**
  84035. * Gets the minimum vector in local space
  84036. */
  84037. readonly minimum: Vector3;
  84038. /**
  84039. * Gets the maximum vector in local space
  84040. */
  84041. readonly maximum: Vector3;
  84042. private _worldMatrix;
  84043. private static readonly TmpVector3;
  84044. /**
  84045. * @hidden
  84046. */
  84047. _tag: number;
  84048. /**
  84049. * Creates a new bounding box
  84050. * @param min defines the minimum vector (in local space)
  84051. * @param max defines the maximum vector (in local space)
  84052. * @param worldMatrix defines the new world matrix
  84053. */
  84054. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  84055. /**
  84056. * Recreates the entire bounding box from scratch as if we call the constructor in place
  84057. * @param min defines the new minimum vector (in local space)
  84058. * @param max defines the new maximum vector (in local space)
  84059. * @param worldMatrix defines the new world matrix
  84060. */
  84061. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  84062. /**
  84063. * Scale the current bounding box by applying a scale factor
  84064. * @param factor defines the scale factor to apply
  84065. * @returns the current bounding box
  84066. */
  84067. scale(factor: number): BoundingBox;
  84068. /**
  84069. * Gets the world matrix of the bounding box
  84070. * @returns a matrix
  84071. */
  84072. getWorldMatrix(): DeepImmutable<Matrix>;
  84073. /** @hidden */
  84074. _update(world: DeepImmutable<Matrix>): void;
  84075. /**
  84076. * Tests if the bounding box is intersecting the frustum planes
  84077. * @param frustumPlanes defines the frustum planes to test
  84078. * @returns true if there is an intersection
  84079. */
  84080. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  84081. /**
  84082. * Tests if the bounding box is entirely inside the frustum planes
  84083. * @param frustumPlanes defines the frustum planes to test
  84084. * @returns true if there is an inclusion
  84085. */
  84086. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  84087. /**
  84088. * Tests if a point is inside the bounding box
  84089. * @param point defines the point to test
  84090. * @returns true if the point is inside the bounding box
  84091. */
  84092. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  84093. /**
  84094. * Tests if the bounding box intersects with a bounding sphere
  84095. * @param sphere defines the sphere to test
  84096. * @returns true if there is an intersection
  84097. */
  84098. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  84099. /**
  84100. * Tests if the bounding box intersects with a box defined by a min and max vectors
  84101. * @param min defines the min vector to use
  84102. * @param max defines the max vector to use
  84103. * @returns true if there is an intersection
  84104. */
  84105. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  84106. /**
  84107. * Tests if two bounding boxes are intersections
  84108. * @param box0 defines the first box to test
  84109. * @param box1 defines the second box to test
  84110. * @returns true if there is an intersection
  84111. */
  84112. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  84113. /**
  84114. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  84115. * @param minPoint defines the minimum vector of the bounding box
  84116. * @param maxPoint defines the maximum vector of the bounding box
  84117. * @param sphereCenter defines the sphere center
  84118. * @param sphereRadius defines the sphere radius
  84119. * @returns true if there is an intersection
  84120. */
  84121. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  84122. /**
  84123. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  84124. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  84125. * @param frustumPlanes defines the frustum planes to test
  84126. * @return true if there is an inclusion
  84127. */
  84128. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  84129. /**
  84130. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  84131. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  84132. * @param frustumPlanes defines the frustum planes to test
  84133. * @return true if there is an intersection
  84134. */
  84135. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  84136. }
  84137. }
  84138. declare module BABYLON {
  84139. /** @hidden */
  84140. export class Collider {
  84141. /** Define if a collision was found */
  84142. collisionFound: boolean;
  84143. /**
  84144. * Define last intersection point in local space
  84145. */
  84146. intersectionPoint: Vector3;
  84147. /**
  84148. * Define last collided mesh
  84149. */
  84150. collidedMesh: Nullable<AbstractMesh>;
  84151. private _collisionPoint;
  84152. private _planeIntersectionPoint;
  84153. private _tempVector;
  84154. private _tempVector2;
  84155. private _tempVector3;
  84156. private _tempVector4;
  84157. private _edge;
  84158. private _baseToVertex;
  84159. private _destinationPoint;
  84160. private _slidePlaneNormal;
  84161. private _displacementVector;
  84162. /** @hidden */
  84163. _radius: Vector3;
  84164. /** @hidden */
  84165. _retry: number;
  84166. private _velocity;
  84167. private _basePoint;
  84168. private _epsilon;
  84169. /** @hidden */
  84170. _velocityWorldLength: number;
  84171. /** @hidden */
  84172. _basePointWorld: Vector3;
  84173. private _velocityWorld;
  84174. private _normalizedVelocity;
  84175. /** @hidden */
  84176. _initialVelocity: Vector3;
  84177. /** @hidden */
  84178. _initialPosition: Vector3;
  84179. private _nearestDistance;
  84180. private _collisionMask;
  84181. get collisionMask(): number;
  84182. set collisionMask(mask: number);
  84183. /**
  84184. * Gets the plane normal used to compute the sliding response (in local space)
  84185. */
  84186. get slidePlaneNormal(): Vector3;
  84187. /** @hidden */
  84188. _initialize(source: Vector3, dir: Vector3, e: number): void;
  84189. /** @hidden */
  84190. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  84191. /** @hidden */
  84192. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  84193. /** @hidden */
  84194. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  84195. /** @hidden */
  84196. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  84197. /** @hidden */
  84198. _getResponse(pos: Vector3, vel: Vector3): void;
  84199. }
  84200. }
  84201. declare module BABYLON {
  84202. /**
  84203. * Interface for cullable objects
  84204. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  84205. */
  84206. export interface ICullable {
  84207. /**
  84208. * Checks if the object or part of the object is in the frustum
  84209. * @param frustumPlanes Camera near/planes
  84210. * @returns true if the object is in frustum otherwise false
  84211. */
  84212. isInFrustum(frustumPlanes: Plane[]): boolean;
  84213. /**
  84214. * Checks if a cullable object (mesh...) is in the camera frustum
  84215. * Unlike isInFrustum this cheks the full bounding box
  84216. * @param frustumPlanes Camera near/planes
  84217. * @returns true if the object is in frustum otherwise false
  84218. */
  84219. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  84220. }
  84221. /**
  84222. * Info for a bounding data of a mesh
  84223. */
  84224. export class BoundingInfo implements ICullable {
  84225. /**
  84226. * Bounding box for the mesh
  84227. */
  84228. readonly boundingBox: BoundingBox;
  84229. /**
  84230. * Bounding sphere for the mesh
  84231. */
  84232. readonly boundingSphere: BoundingSphere;
  84233. private _isLocked;
  84234. private static readonly TmpVector3;
  84235. /**
  84236. * Constructs bounding info
  84237. * @param minimum min vector of the bounding box/sphere
  84238. * @param maximum max vector of the bounding box/sphere
  84239. * @param worldMatrix defines the new world matrix
  84240. */
  84241. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  84242. /**
  84243. * Recreates the entire bounding info from scratch as if we call the constructor in place
  84244. * @param min defines the new minimum vector (in local space)
  84245. * @param max defines the new maximum vector (in local space)
  84246. * @param worldMatrix defines the new world matrix
  84247. */
  84248. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  84249. /**
  84250. * min vector of the bounding box/sphere
  84251. */
  84252. get minimum(): Vector3;
  84253. /**
  84254. * max vector of the bounding box/sphere
  84255. */
  84256. get maximum(): Vector3;
  84257. /**
  84258. * If the info is locked and won't be updated to avoid perf overhead
  84259. */
  84260. get isLocked(): boolean;
  84261. set isLocked(value: boolean);
  84262. /**
  84263. * Updates the bounding sphere and box
  84264. * @param world world matrix to be used to update
  84265. */
  84266. update(world: DeepImmutable<Matrix>): void;
  84267. /**
  84268. * Recreate the bounding info to be centered around a specific point given a specific extend.
  84269. * @param center New center of the bounding info
  84270. * @param extend New extend of the bounding info
  84271. * @returns the current bounding info
  84272. */
  84273. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  84274. /**
  84275. * Scale the current bounding info by applying a scale factor
  84276. * @param factor defines the scale factor to apply
  84277. * @returns the current bounding info
  84278. */
  84279. scale(factor: number): BoundingInfo;
  84280. /**
  84281. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  84282. * @param frustumPlanes defines the frustum to test
  84283. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  84284. * @returns true if the bounding info is in the frustum planes
  84285. */
  84286. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  84287. /**
  84288. * Gets the world distance between the min and max points of the bounding box
  84289. */
  84290. get diagonalLength(): number;
  84291. /**
  84292. * Checks if a cullable object (mesh...) is in the camera frustum
  84293. * Unlike isInFrustum this cheks the full bounding box
  84294. * @param frustumPlanes Camera near/planes
  84295. * @returns true if the object is in frustum otherwise false
  84296. */
  84297. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  84298. /** @hidden */
  84299. _checkCollision(collider: Collider): boolean;
  84300. /**
  84301. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  84302. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  84303. * @param point the point to check intersection with
  84304. * @returns if the point intersects
  84305. */
  84306. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  84307. /**
  84308. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  84309. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  84310. * @param boundingInfo the bounding info to check intersection with
  84311. * @param precise if the intersection should be done using OBB
  84312. * @returns if the bounding info intersects
  84313. */
  84314. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  84315. }
  84316. }
  84317. declare module BABYLON {
  84318. /**
  84319. * Extracts minimum and maximum values from a list of indexed positions
  84320. * @param positions defines the positions to use
  84321. * @param indices defines the indices to the positions
  84322. * @param indexStart defines the start index
  84323. * @param indexCount defines the end index
  84324. * @param bias defines bias value to add to the result
  84325. * @return minimum and maximum values
  84326. */
  84327. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  84328. minimum: Vector3;
  84329. maximum: Vector3;
  84330. };
  84331. /**
  84332. * Extracts minimum and maximum values from a list of positions
  84333. * @param positions defines the positions to use
  84334. * @param start defines the start index in the positions array
  84335. * @param count defines the number of positions to handle
  84336. * @param bias defines bias value to add to the result
  84337. * @param stride defines the stride size to use (distance between two positions in the positions array)
  84338. * @return minimum and maximum values
  84339. */
  84340. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  84341. minimum: Vector3;
  84342. maximum: Vector3;
  84343. };
  84344. }
  84345. declare module BABYLON {
  84346. /** @hidden */
  84347. export class WebGLDataBuffer extends DataBuffer {
  84348. private _buffer;
  84349. constructor(resource: WebGLBuffer);
  84350. get underlyingResource(): any;
  84351. }
  84352. }
  84353. declare module BABYLON {
  84354. /** @hidden */
  84355. export class WebGLPipelineContext implements IPipelineContext {
  84356. engine: ThinEngine;
  84357. program: Nullable<WebGLProgram>;
  84358. context?: WebGLRenderingContext;
  84359. vertexShader?: WebGLShader;
  84360. fragmentShader?: WebGLShader;
  84361. isParallelCompiled: boolean;
  84362. onCompiled?: () => void;
  84363. transformFeedback?: WebGLTransformFeedback | null;
  84364. vertexCompilationError: Nullable<string>;
  84365. fragmentCompilationError: Nullable<string>;
  84366. programLinkError: Nullable<string>;
  84367. programValidationError: Nullable<string>;
  84368. get isAsync(): boolean;
  84369. get isReady(): boolean;
  84370. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  84371. _getVertexShaderCode(): string | null;
  84372. _getFragmentShaderCode(): string | null;
  84373. }
  84374. }
  84375. declare module BABYLON {
  84376. interface ThinEngine {
  84377. /**
  84378. * Create an uniform buffer
  84379. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  84380. * @param elements defines the content of the uniform buffer
  84381. * @returns the webGL uniform buffer
  84382. */
  84383. createUniformBuffer(elements: FloatArray): DataBuffer;
  84384. /**
  84385. * Create a dynamic uniform buffer
  84386. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  84387. * @param elements defines the content of the uniform buffer
  84388. * @returns the webGL uniform buffer
  84389. */
  84390. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  84391. /**
  84392. * Update an existing uniform buffer
  84393. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  84394. * @param uniformBuffer defines the target uniform buffer
  84395. * @param elements defines the content to update
  84396. * @param offset defines the offset in the uniform buffer where update should start
  84397. * @param count defines the size of the data to update
  84398. */
  84399. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  84400. /**
  84401. * Bind an uniform buffer to the current webGL context
  84402. * @param buffer defines the buffer to bind
  84403. */
  84404. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  84405. /**
  84406. * Bind a buffer to the current webGL context at a given location
  84407. * @param buffer defines the buffer to bind
  84408. * @param location defines the index where to bind the buffer
  84409. */
  84410. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  84411. /**
  84412. * Bind a specific block at a given index in a specific shader program
  84413. * @param pipelineContext defines the pipeline context to use
  84414. * @param blockName defines the block name
  84415. * @param index defines the index where to bind the block
  84416. */
  84417. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  84418. }
  84419. }
  84420. declare module BABYLON {
  84421. /**
  84422. * Uniform buffer objects.
  84423. *
  84424. * Handles blocks of uniform on the GPU.
  84425. *
  84426. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  84427. *
  84428. * For more information, please refer to :
  84429. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  84430. */
  84431. export class UniformBuffer {
  84432. private _engine;
  84433. private _buffer;
  84434. private _data;
  84435. private _bufferData;
  84436. private _dynamic?;
  84437. private _uniformLocations;
  84438. private _uniformSizes;
  84439. private _uniformLocationPointer;
  84440. private _needSync;
  84441. private _noUBO;
  84442. private _currentEffect;
  84443. /** @hidden */
  84444. _alreadyBound: boolean;
  84445. private static _MAX_UNIFORM_SIZE;
  84446. private static _tempBuffer;
  84447. /**
  84448. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  84449. * This is dynamic to allow compat with webgl 1 and 2.
  84450. * You will need to pass the name of the uniform as well as the value.
  84451. */
  84452. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  84453. /**
  84454. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  84455. * This is dynamic to allow compat with webgl 1 and 2.
  84456. * You will need to pass the name of the uniform as well as the value.
  84457. */
  84458. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  84459. /**
  84460. * Lambda to Update a single float in a uniform buffer.
  84461. * This is dynamic to allow compat with webgl 1 and 2.
  84462. * You will need to pass the name of the uniform as well as the value.
  84463. */
  84464. updateFloat: (name: string, x: number) => void;
  84465. /**
  84466. * Lambda to Update a vec2 of float in a uniform buffer.
  84467. * This is dynamic to allow compat with webgl 1 and 2.
  84468. * You will need to pass the name of the uniform as well as the value.
  84469. */
  84470. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  84471. /**
  84472. * Lambda to Update a vec3 of float in a uniform buffer.
  84473. * This is dynamic to allow compat with webgl 1 and 2.
  84474. * You will need to pass the name of the uniform as well as the value.
  84475. */
  84476. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  84477. /**
  84478. * Lambda to Update a vec4 of float in a uniform buffer.
  84479. * This is dynamic to allow compat with webgl 1 and 2.
  84480. * You will need to pass the name of the uniform as well as the value.
  84481. */
  84482. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  84483. /**
  84484. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  84485. * This is dynamic to allow compat with webgl 1 and 2.
  84486. * You will need to pass the name of the uniform as well as the value.
  84487. */
  84488. updateMatrix: (name: string, mat: Matrix) => void;
  84489. /**
  84490. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  84491. * This is dynamic to allow compat with webgl 1 and 2.
  84492. * You will need to pass the name of the uniform as well as the value.
  84493. */
  84494. updateVector3: (name: string, vector: Vector3) => void;
  84495. /**
  84496. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  84497. * This is dynamic to allow compat with webgl 1 and 2.
  84498. * You will need to pass the name of the uniform as well as the value.
  84499. */
  84500. updateVector4: (name: string, vector: Vector4) => void;
  84501. /**
  84502. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  84503. * This is dynamic to allow compat with webgl 1 and 2.
  84504. * You will need to pass the name of the uniform as well as the value.
  84505. */
  84506. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  84507. /**
  84508. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  84509. * This is dynamic to allow compat with webgl 1 and 2.
  84510. * You will need to pass the name of the uniform as well as the value.
  84511. */
  84512. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  84513. /**
  84514. * Instantiates a new Uniform buffer objects.
  84515. *
  84516. * Handles blocks of uniform on the GPU.
  84517. *
  84518. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  84519. *
  84520. * For more information, please refer to :
  84521. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  84522. * @param engine Define the engine the buffer is associated with
  84523. * @param data Define the data contained in the buffer
  84524. * @param dynamic Define if the buffer is updatable
  84525. */
  84526. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  84527. /**
  84528. * Indicates if the buffer is using the WebGL2 UBO implementation,
  84529. * or just falling back on setUniformXXX calls.
  84530. */
  84531. get useUbo(): boolean;
  84532. /**
  84533. * Indicates if the WebGL underlying uniform buffer is in sync
  84534. * with the javascript cache data.
  84535. */
  84536. get isSync(): boolean;
  84537. /**
  84538. * Indicates if the WebGL underlying uniform buffer is dynamic.
  84539. * Also, a dynamic UniformBuffer will disable cache verification and always
  84540. * update the underlying WebGL uniform buffer to the GPU.
  84541. * @returns if Dynamic, otherwise false
  84542. */
  84543. isDynamic(): boolean;
  84544. /**
  84545. * The data cache on JS side.
  84546. * @returns the underlying data as a float array
  84547. */
  84548. getData(): Float32Array;
  84549. /**
  84550. * The underlying WebGL Uniform buffer.
  84551. * @returns the webgl buffer
  84552. */
  84553. getBuffer(): Nullable<DataBuffer>;
  84554. /**
  84555. * std140 layout specifies how to align data within an UBO structure.
  84556. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  84557. * for specs.
  84558. */
  84559. private _fillAlignment;
  84560. /**
  84561. * Adds an uniform in the buffer.
  84562. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  84563. * for the layout to be correct !
  84564. * @param name Name of the uniform, as used in the uniform block in the shader.
  84565. * @param size Data size, or data directly.
  84566. */
  84567. addUniform(name: string, size: number | number[]): void;
  84568. /**
  84569. * Adds a Matrix 4x4 to the uniform buffer.
  84570. * @param name Name of the uniform, as used in the uniform block in the shader.
  84571. * @param mat A 4x4 matrix.
  84572. */
  84573. addMatrix(name: string, mat: Matrix): void;
  84574. /**
  84575. * Adds a vec2 to the uniform buffer.
  84576. * @param name Name of the uniform, as used in the uniform block in the shader.
  84577. * @param x Define the x component value of the vec2
  84578. * @param y Define the y component value of the vec2
  84579. */
  84580. addFloat2(name: string, x: number, y: number): void;
  84581. /**
  84582. * Adds a vec3 to the uniform buffer.
  84583. * @param name Name of the uniform, as used in the uniform block in the shader.
  84584. * @param x Define the x component value of the vec3
  84585. * @param y Define the y component value of the vec3
  84586. * @param z Define the z component value of the vec3
  84587. */
  84588. addFloat3(name: string, x: number, y: number, z: number): void;
  84589. /**
  84590. * Adds a vec3 to the uniform buffer.
  84591. * @param name Name of the uniform, as used in the uniform block in the shader.
  84592. * @param color Define the vec3 from a Color
  84593. */
  84594. addColor3(name: string, color: Color3): void;
  84595. /**
  84596. * Adds a vec4 to the uniform buffer.
  84597. * @param name Name of the uniform, as used in the uniform block in the shader.
  84598. * @param color Define the rgb components from a Color
  84599. * @param alpha Define the a component of the vec4
  84600. */
  84601. addColor4(name: string, color: Color3, alpha: number): void;
  84602. /**
  84603. * Adds a vec3 to the uniform buffer.
  84604. * @param name Name of the uniform, as used in the uniform block in the shader.
  84605. * @param vector Define the vec3 components from a Vector
  84606. */
  84607. addVector3(name: string, vector: Vector3): void;
  84608. /**
  84609. * Adds a Matrix 3x3 to the uniform buffer.
  84610. * @param name Name of the uniform, as used in the uniform block in the shader.
  84611. */
  84612. addMatrix3x3(name: string): void;
  84613. /**
  84614. * Adds a Matrix 2x2 to the uniform buffer.
  84615. * @param name Name of the uniform, as used in the uniform block in the shader.
  84616. */
  84617. addMatrix2x2(name: string): void;
  84618. /**
  84619. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  84620. */
  84621. create(): void;
  84622. /** @hidden */
  84623. _rebuild(): void;
  84624. /**
  84625. * Updates the WebGL Uniform Buffer on the GPU.
  84626. * If the `dynamic` flag is set to true, no cache comparison is done.
  84627. * Otherwise, the buffer will be updated only if the cache differs.
  84628. */
  84629. update(): void;
  84630. /**
  84631. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  84632. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  84633. * @param data Define the flattened data
  84634. * @param size Define the size of the data.
  84635. */
  84636. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  84637. private _valueCache;
  84638. private _cacheMatrix;
  84639. private _updateMatrix3x3ForUniform;
  84640. private _updateMatrix3x3ForEffect;
  84641. private _updateMatrix2x2ForEffect;
  84642. private _updateMatrix2x2ForUniform;
  84643. private _updateFloatForEffect;
  84644. private _updateFloatForUniform;
  84645. private _updateFloat2ForEffect;
  84646. private _updateFloat2ForUniform;
  84647. private _updateFloat3ForEffect;
  84648. private _updateFloat3ForUniform;
  84649. private _updateFloat4ForEffect;
  84650. private _updateFloat4ForUniform;
  84651. private _updateMatrixForEffect;
  84652. private _updateMatrixForUniform;
  84653. private _updateVector3ForEffect;
  84654. private _updateVector3ForUniform;
  84655. private _updateVector4ForEffect;
  84656. private _updateVector4ForUniform;
  84657. private _updateColor3ForEffect;
  84658. private _updateColor3ForUniform;
  84659. private _updateColor4ForEffect;
  84660. private _updateColor4ForUniform;
  84661. /**
  84662. * Sets a sampler uniform on the effect.
  84663. * @param name Define the name of the sampler.
  84664. * @param texture Define the texture to set in the sampler
  84665. */
  84666. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  84667. /**
  84668. * Directly updates the value of the uniform in the cache AND on the GPU.
  84669. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  84670. * @param data Define the flattened data
  84671. */
  84672. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  84673. /**
  84674. * Binds this uniform buffer to an effect.
  84675. * @param effect Define the effect to bind the buffer to
  84676. * @param name Name of the uniform block in the shader.
  84677. */
  84678. bindToEffect(effect: Effect, name: string): void;
  84679. /**
  84680. * Disposes the uniform buffer.
  84681. */
  84682. dispose(): void;
  84683. }
  84684. }
  84685. declare module BABYLON {
  84686. /**
  84687. * Enum that determines the text-wrapping mode to use.
  84688. */
  84689. export enum InspectableType {
  84690. /**
  84691. * Checkbox for booleans
  84692. */
  84693. Checkbox = 0,
  84694. /**
  84695. * Sliders for numbers
  84696. */
  84697. Slider = 1,
  84698. /**
  84699. * Vector3
  84700. */
  84701. Vector3 = 2,
  84702. /**
  84703. * Quaternions
  84704. */
  84705. Quaternion = 3,
  84706. /**
  84707. * Color3
  84708. */
  84709. Color3 = 4,
  84710. /**
  84711. * String
  84712. */
  84713. String = 5
  84714. }
  84715. /**
  84716. * Interface used to define custom inspectable properties.
  84717. * This interface is used by the inspector to display custom property grids
  84718. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  84719. */
  84720. export interface IInspectable {
  84721. /**
  84722. * Gets the label to display
  84723. */
  84724. label: string;
  84725. /**
  84726. * Gets the name of the property to edit
  84727. */
  84728. propertyName: string;
  84729. /**
  84730. * Gets the type of the editor to use
  84731. */
  84732. type: InspectableType;
  84733. /**
  84734. * Gets the minimum value of the property when using in "slider" mode
  84735. */
  84736. min?: number;
  84737. /**
  84738. * Gets the maximum value of the property when using in "slider" mode
  84739. */
  84740. max?: number;
  84741. /**
  84742. * Gets the setp to use when using in "slider" mode
  84743. */
  84744. step?: number;
  84745. }
  84746. }
  84747. declare module BABYLON {
  84748. /**
  84749. * Class used to provide helper for timing
  84750. */
  84751. export class TimingTools {
  84752. /**
  84753. * Polyfill for setImmediate
  84754. * @param action defines the action to execute after the current execution block
  84755. */
  84756. static SetImmediate(action: () => void): void;
  84757. }
  84758. }
  84759. declare module BABYLON {
  84760. /**
  84761. * Class used to enable instatition of objects by class name
  84762. */
  84763. export class InstantiationTools {
  84764. /**
  84765. * Use this object to register external classes like custom textures or material
  84766. * to allow the laoders to instantiate them
  84767. */
  84768. static RegisteredExternalClasses: {
  84769. [key: string]: Object;
  84770. };
  84771. /**
  84772. * Tries to instantiate a new object from a given class name
  84773. * @param className defines the class name to instantiate
  84774. * @returns the new object or null if the system was not able to do the instantiation
  84775. */
  84776. static Instantiate(className: string): any;
  84777. }
  84778. }
  84779. declare module BABYLON {
  84780. /**
  84781. * Define options used to create a depth texture
  84782. */
  84783. export class DepthTextureCreationOptions {
  84784. /** Specifies whether or not a stencil should be allocated in the texture */
  84785. generateStencil?: boolean;
  84786. /** Specifies whether or not bilinear filtering is enable on the texture */
  84787. bilinearFiltering?: boolean;
  84788. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  84789. comparisonFunction?: number;
  84790. /** Specifies if the created texture is a cube texture */
  84791. isCube?: boolean;
  84792. }
  84793. }
  84794. declare module BABYLON {
  84795. interface ThinEngine {
  84796. /**
  84797. * Creates a depth stencil cube texture.
  84798. * This is only available in WebGL 2.
  84799. * @param size The size of face edge in the cube texture.
  84800. * @param options The options defining the cube texture.
  84801. * @returns The cube texture
  84802. */
  84803. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  84804. /**
  84805. * Creates a cube texture
  84806. * @param rootUrl defines the url where the files to load is located
  84807. * @param scene defines the current scene
  84808. * @param files defines the list of files to load (1 per face)
  84809. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  84810. * @param onLoad defines an optional callback raised when the texture is loaded
  84811. * @param onError defines an optional callback raised if there is an issue to load the texture
  84812. * @param format defines the format of the data
  84813. * @param forcedExtension defines the extension to use to pick the right loader
  84814. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  84815. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  84816. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  84817. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  84818. * @returns the cube texture as an InternalTexture
  84819. */
  84820. 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;
  84821. /**
  84822. * Creates a cube texture
  84823. * @param rootUrl defines the url where the files to load is located
  84824. * @param scene defines the current scene
  84825. * @param files defines the list of files to load (1 per face)
  84826. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  84827. * @param onLoad defines an optional callback raised when the texture is loaded
  84828. * @param onError defines an optional callback raised if there is an issue to load the texture
  84829. * @param format defines the format of the data
  84830. * @param forcedExtension defines the extension to use to pick the right loader
  84831. * @returns the cube texture as an InternalTexture
  84832. */
  84833. 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;
  84834. /**
  84835. * Creates a cube texture
  84836. * @param rootUrl defines the url where the files to load is located
  84837. * @param scene defines the current scene
  84838. * @param files defines the list of files to load (1 per face)
  84839. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  84840. * @param onLoad defines an optional callback raised when the texture is loaded
  84841. * @param onError defines an optional callback raised if there is an issue to load the texture
  84842. * @param format defines the format of the data
  84843. * @param forcedExtension defines the extension to use to pick the right loader
  84844. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  84845. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  84846. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  84847. * @returns the cube texture as an InternalTexture
  84848. */
  84849. 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;
  84850. /** @hidden */
  84851. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  84852. /** @hidden */
  84853. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  84854. /** @hidden */
  84855. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  84856. /** @hidden */
  84857. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  84858. /**
  84859. * @hidden
  84860. */
  84861. _setCubeMapTextureParams(loadMipmap: boolean): void;
  84862. }
  84863. }
  84864. declare module BABYLON {
  84865. /**
  84866. * Class for creating a cube texture
  84867. */
  84868. export class CubeTexture extends BaseTexture {
  84869. private _delayedOnLoad;
  84870. /**
  84871. * Observable triggered once the texture has been loaded.
  84872. */
  84873. onLoadObservable: Observable<CubeTexture>;
  84874. /**
  84875. * The url of the texture
  84876. */
  84877. url: string;
  84878. /**
  84879. * Gets or sets the center of the bounding box associated with the cube texture.
  84880. * It must define where the camera used to render the texture was set
  84881. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  84882. */
  84883. boundingBoxPosition: Vector3;
  84884. private _boundingBoxSize;
  84885. /**
  84886. * Gets or sets the size of the bounding box associated with the cube texture
  84887. * When defined, the cubemap will switch to local mode
  84888. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  84889. * @example https://www.babylonjs-playground.com/#RNASML
  84890. */
  84891. set boundingBoxSize(value: Vector3);
  84892. /**
  84893. * Returns the bounding box size
  84894. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  84895. */
  84896. get boundingBoxSize(): Vector3;
  84897. protected _rotationY: number;
  84898. /**
  84899. * Sets texture matrix rotation angle around Y axis in radians.
  84900. */
  84901. set rotationY(value: number);
  84902. /**
  84903. * Gets texture matrix rotation angle around Y axis radians.
  84904. */
  84905. get rotationY(): number;
  84906. /**
  84907. * Are mip maps generated for this texture or not.
  84908. */
  84909. get noMipmap(): boolean;
  84910. private _noMipmap;
  84911. private _files;
  84912. protected _forcedExtension: Nullable<string>;
  84913. private _extensions;
  84914. private _textureMatrix;
  84915. private _format;
  84916. private _createPolynomials;
  84917. /**
  84918. * Creates a cube texture from an array of image urls
  84919. * @param files defines an array of image urls
  84920. * @param scene defines the hosting scene
  84921. * @param noMipmap specifies if mip maps are not used
  84922. * @returns a cube texture
  84923. */
  84924. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  84925. /**
  84926. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  84927. * @param url defines the url of the prefiltered texture
  84928. * @param scene defines the scene the texture is attached to
  84929. * @param forcedExtension defines the extension of the file if different from the url
  84930. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  84931. * @return the prefiltered texture
  84932. */
  84933. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  84934. /**
  84935. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  84936. * as prefiltered data.
  84937. * @param rootUrl defines the url of the texture or the root name of the six images
  84938. * @param null defines the scene or engine the texture is attached to
  84939. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  84940. * @param noMipmap defines if mipmaps should be created or not
  84941. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  84942. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  84943. * @param onError defines a callback triggered in case of error during load
  84944. * @param format defines the internal format to use for the texture once loaded
  84945. * @param prefiltered defines whether or not the texture is created from prefiltered data
  84946. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  84947. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  84948. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  84949. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  84950. * @return the cube texture
  84951. */
  84952. 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);
  84953. /**
  84954. * Get the current class name of the texture useful for serialization or dynamic coding.
  84955. * @returns "CubeTexture"
  84956. */
  84957. getClassName(): string;
  84958. /**
  84959. * Update the url (and optional buffer) of this texture if url was null during construction.
  84960. * @param url the url of the texture
  84961. * @param forcedExtension defines the extension to use
  84962. * @param onLoad callback called when the texture is loaded (defaults to null)
  84963. * @param prefiltered Defines whether the updated texture is prefiltered or not
  84964. */
  84965. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  84966. /**
  84967. * Delays loading of the cube texture
  84968. * @param forcedExtension defines the extension to use
  84969. */
  84970. delayLoad(forcedExtension?: string): void;
  84971. /**
  84972. * Returns the reflection texture matrix
  84973. * @returns the reflection texture matrix
  84974. */
  84975. getReflectionTextureMatrix(): Matrix;
  84976. /**
  84977. * Sets the reflection texture matrix
  84978. * @param value Reflection texture matrix
  84979. */
  84980. setReflectionTextureMatrix(value: Matrix): void;
  84981. /**
  84982. * Parses text to create a cube texture
  84983. * @param parsedTexture define the serialized text to read from
  84984. * @param scene defines the hosting scene
  84985. * @param rootUrl defines the root url of the cube texture
  84986. * @returns a cube texture
  84987. */
  84988. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  84989. /**
  84990. * Makes a clone, or deep copy, of the cube texture
  84991. * @returns a new cube texture
  84992. */
  84993. clone(): CubeTexture;
  84994. }
  84995. }
  84996. declare module BABYLON {
  84997. /**
  84998. * Manages the defines for the Material
  84999. */
  85000. export class MaterialDefines {
  85001. /** @hidden */
  85002. protected _keys: string[];
  85003. private _isDirty;
  85004. /** @hidden */
  85005. _renderId: number;
  85006. /** @hidden */
  85007. _areLightsDirty: boolean;
  85008. /** @hidden */
  85009. _areLightsDisposed: boolean;
  85010. /** @hidden */
  85011. _areAttributesDirty: boolean;
  85012. /** @hidden */
  85013. _areTexturesDirty: boolean;
  85014. /** @hidden */
  85015. _areFresnelDirty: boolean;
  85016. /** @hidden */
  85017. _areMiscDirty: boolean;
  85018. /** @hidden */
  85019. _areImageProcessingDirty: boolean;
  85020. /** @hidden */
  85021. _normals: boolean;
  85022. /** @hidden */
  85023. _uvs: boolean;
  85024. /** @hidden */
  85025. _needNormals: boolean;
  85026. /** @hidden */
  85027. _needUVs: boolean;
  85028. [id: string]: any;
  85029. /**
  85030. * Specifies if the material needs to be re-calculated
  85031. */
  85032. get isDirty(): boolean;
  85033. /**
  85034. * Marks the material to indicate that it has been re-calculated
  85035. */
  85036. markAsProcessed(): void;
  85037. /**
  85038. * Marks the material to indicate that it needs to be re-calculated
  85039. */
  85040. markAsUnprocessed(): void;
  85041. /**
  85042. * Marks the material to indicate all of its defines need to be re-calculated
  85043. */
  85044. markAllAsDirty(): void;
  85045. /**
  85046. * Marks the material to indicate that image processing needs to be re-calculated
  85047. */
  85048. markAsImageProcessingDirty(): void;
  85049. /**
  85050. * Marks the material to indicate the lights need to be re-calculated
  85051. * @param disposed Defines whether the light is dirty due to dispose or not
  85052. */
  85053. markAsLightDirty(disposed?: boolean): void;
  85054. /**
  85055. * Marks the attribute state as changed
  85056. */
  85057. markAsAttributesDirty(): void;
  85058. /**
  85059. * Marks the texture state as changed
  85060. */
  85061. markAsTexturesDirty(): void;
  85062. /**
  85063. * Marks the fresnel state as changed
  85064. */
  85065. markAsFresnelDirty(): void;
  85066. /**
  85067. * Marks the misc state as changed
  85068. */
  85069. markAsMiscDirty(): void;
  85070. /**
  85071. * Rebuilds the material defines
  85072. */
  85073. rebuild(): void;
  85074. /**
  85075. * Specifies if two material defines are equal
  85076. * @param other - A material define instance to compare to
  85077. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  85078. */
  85079. isEqual(other: MaterialDefines): boolean;
  85080. /**
  85081. * Clones this instance's defines to another instance
  85082. * @param other - material defines to clone values to
  85083. */
  85084. cloneTo(other: MaterialDefines): void;
  85085. /**
  85086. * Resets the material define values
  85087. */
  85088. reset(): void;
  85089. /**
  85090. * Converts the material define values to a string
  85091. * @returns - String of material define information
  85092. */
  85093. toString(): string;
  85094. }
  85095. }
  85096. declare module BABYLON {
  85097. /**
  85098. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  85099. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  85100. * 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;
  85101. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  85102. */
  85103. export class ColorCurves {
  85104. private _dirty;
  85105. private _tempColor;
  85106. private _globalCurve;
  85107. private _highlightsCurve;
  85108. private _midtonesCurve;
  85109. private _shadowsCurve;
  85110. private _positiveCurve;
  85111. private _negativeCurve;
  85112. private _globalHue;
  85113. private _globalDensity;
  85114. private _globalSaturation;
  85115. private _globalExposure;
  85116. /**
  85117. * Gets the global Hue value.
  85118. * 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).
  85119. */
  85120. get globalHue(): number;
  85121. /**
  85122. * Sets the global Hue value.
  85123. * 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).
  85124. */
  85125. set globalHue(value: number);
  85126. /**
  85127. * Gets the global Density value.
  85128. * 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.
  85129. * Values less than zero provide a filter of opposite hue.
  85130. */
  85131. get globalDensity(): number;
  85132. /**
  85133. * Sets the global Density value.
  85134. * 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.
  85135. * Values less than zero provide a filter of opposite hue.
  85136. */
  85137. set globalDensity(value: number);
  85138. /**
  85139. * Gets the global Saturation value.
  85140. * 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.
  85141. */
  85142. get globalSaturation(): number;
  85143. /**
  85144. * Sets the global Saturation value.
  85145. * 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.
  85146. */
  85147. set globalSaturation(value: number);
  85148. /**
  85149. * Gets the global Exposure value.
  85150. * 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.
  85151. */
  85152. get globalExposure(): number;
  85153. /**
  85154. * Sets the global Exposure value.
  85155. * 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.
  85156. */
  85157. set globalExposure(value: number);
  85158. private _highlightsHue;
  85159. private _highlightsDensity;
  85160. private _highlightsSaturation;
  85161. private _highlightsExposure;
  85162. /**
  85163. * Gets the highlights Hue value.
  85164. * 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).
  85165. */
  85166. get highlightsHue(): number;
  85167. /**
  85168. * Sets the highlights Hue value.
  85169. * 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).
  85170. */
  85171. set highlightsHue(value: number);
  85172. /**
  85173. * Gets the highlights Density value.
  85174. * 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.
  85175. * Values less than zero provide a filter of opposite hue.
  85176. */
  85177. get highlightsDensity(): number;
  85178. /**
  85179. * Sets the highlights Density value.
  85180. * 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.
  85181. * Values less than zero provide a filter of opposite hue.
  85182. */
  85183. set highlightsDensity(value: number);
  85184. /**
  85185. * Gets the highlights Saturation value.
  85186. * 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.
  85187. */
  85188. get highlightsSaturation(): number;
  85189. /**
  85190. * Sets the highlights Saturation value.
  85191. * 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.
  85192. */
  85193. set highlightsSaturation(value: number);
  85194. /**
  85195. * Gets the highlights Exposure value.
  85196. * 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.
  85197. */
  85198. get highlightsExposure(): number;
  85199. /**
  85200. * Sets the highlights Exposure value.
  85201. * 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.
  85202. */
  85203. set highlightsExposure(value: number);
  85204. private _midtonesHue;
  85205. private _midtonesDensity;
  85206. private _midtonesSaturation;
  85207. private _midtonesExposure;
  85208. /**
  85209. * Gets the midtones Hue value.
  85210. * 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).
  85211. */
  85212. get midtonesHue(): number;
  85213. /**
  85214. * Sets the midtones Hue value.
  85215. * 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).
  85216. */
  85217. set midtonesHue(value: number);
  85218. /**
  85219. * Gets the midtones Density value.
  85220. * 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.
  85221. * Values less than zero provide a filter of opposite hue.
  85222. */
  85223. get midtonesDensity(): number;
  85224. /**
  85225. * Sets the midtones Density value.
  85226. * 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.
  85227. * Values less than zero provide a filter of opposite hue.
  85228. */
  85229. set midtonesDensity(value: number);
  85230. /**
  85231. * Gets the midtones Saturation value.
  85232. * 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.
  85233. */
  85234. get midtonesSaturation(): number;
  85235. /**
  85236. * Sets the midtones Saturation value.
  85237. * 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.
  85238. */
  85239. set midtonesSaturation(value: number);
  85240. /**
  85241. * Gets the midtones Exposure value.
  85242. * 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.
  85243. */
  85244. get midtonesExposure(): number;
  85245. /**
  85246. * Sets the midtones Exposure value.
  85247. * 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.
  85248. */
  85249. set midtonesExposure(value: number);
  85250. private _shadowsHue;
  85251. private _shadowsDensity;
  85252. private _shadowsSaturation;
  85253. private _shadowsExposure;
  85254. /**
  85255. * Gets the shadows Hue value.
  85256. * 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).
  85257. */
  85258. get shadowsHue(): number;
  85259. /**
  85260. * Sets the shadows Hue value.
  85261. * 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).
  85262. */
  85263. set shadowsHue(value: number);
  85264. /**
  85265. * Gets the shadows Density value.
  85266. * 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.
  85267. * Values less than zero provide a filter of opposite hue.
  85268. */
  85269. get shadowsDensity(): number;
  85270. /**
  85271. * Sets the shadows Density value.
  85272. * 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.
  85273. * Values less than zero provide a filter of opposite hue.
  85274. */
  85275. set shadowsDensity(value: number);
  85276. /**
  85277. * Gets the shadows Saturation value.
  85278. * 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.
  85279. */
  85280. get shadowsSaturation(): number;
  85281. /**
  85282. * Sets the shadows Saturation value.
  85283. * 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.
  85284. */
  85285. set shadowsSaturation(value: number);
  85286. /**
  85287. * Gets the shadows Exposure value.
  85288. * 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.
  85289. */
  85290. get shadowsExposure(): number;
  85291. /**
  85292. * Sets the shadows Exposure value.
  85293. * 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.
  85294. */
  85295. set shadowsExposure(value: number);
  85296. /**
  85297. * Returns the class name
  85298. * @returns The class name
  85299. */
  85300. getClassName(): string;
  85301. /**
  85302. * Binds the color curves to the shader.
  85303. * @param colorCurves The color curve to bind
  85304. * @param effect The effect to bind to
  85305. * @param positiveUniform The positive uniform shader parameter
  85306. * @param neutralUniform The neutral uniform shader parameter
  85307. * @param negativeUniform The negative uniform shader parameter
  85308. */
  85309. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  85310. /**
  85311. * Prepare the list of uniforms associated with the ColorCurves effects.
  85312. * @param uniformsList The list of uniforms used in the effect
  85313. */
  85314. static PrepareUniforms(uniformsList: string[]): void;
  85315. /**
  85316. * Returns color grading data based on a hue, density, saturation and exposure value.
  85317. * @param filterHue The hue of the color filter.
  85318. * @param filterDensity The density of the color filter.
  85319. * @param saturation The saturation.
  85320. * @param exposure The exposure.
  85321. * @param result The result data container.
  85322. */
  85323. private getColorGradingDataToRef;
  85324. /**
  85325. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  85326. * @param value The input slider value in range [-100,100].
  85327. * @returns Adjusted value.
  85328. */
  85329. private static applyColorGradingSliderNonlinear;
  85330. /**
  85331. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  85332. * @param hue The hue (H) input.
  85333. * @param saturation The saturation (S) input.
  85334. * @param brightness The brightness (B) input.
  85335. * @result An RGBA color represented as Vector4.
  85336. */
  85337. private static fromHSBToRef;
  85338. /**
  85339. * Returns a value clamped between min and max
  85340. * @param value The value to clamp
  85341. * @param min The minimum of value
  85342. * @param max The maximum of value
  85343. * @returns The clamped value.
  85344. */
  85345. private static clamp;
  85346. /**
  85347. * Clones the current color curve instance.
  85348. * @return The cloned curves
  85349. */
  85350. clone(): ColorCurves;
  85351. /**
  85352. * Serializes the current color curve instance to a json representation.
  85353. * @return a JSON representation
  85354. */
  85355. serialize(): any;
  85356. /**
  85357. * Parses the color curve from a json representation.
  85358. * @param source the JSON source to parse
  85359. * @return The parsed curves
  85360. */
  85361. static Parse(source: any): ColorCurves;
  85362. }
  85363. }
  85364. declare module BABYLON {
  85365. /**
  85366. * Interface to follow in your material defines to integrate easily the
  85367. * Image proccessing functions.
  85368. * @hidden
  85369. */
  85370. export interface IImageProcessingConfigurationDefines {
  85371. IMAGEPROCESSING: boolean;
  85372. VIGNETTE: boolean;
  85373. VIGNETTEBLENDMODEMULTIPLY: boolean;
  85374. VIGNETTEBLENDMODEOPAQUE: boolean;
  85375. TONEMAPPING: boolean;
  85376. TONEMAPPING_ACES: boolean;
  85377. CONTRAST: boolean;
  85378. EXPOSURE: boolean;
  85379. COLORCURVES: boolean;
  85380. COLORGRADING: boolean;
  85381. COLORGRADING3D: boolean;
  85382. SAMPLER3DGREENDEPTH: boolean;
  85383. SAMPLER3DBGRMAP: boolean;
  85384. IMAGEPROCESSINGPOSTPROCESS: boolean;
  85385. }
  85386. /**
  85387. * @hidden
  85388. */
  85389. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  85390. IMAGEPROCESSING: boolean;
  85391. VIGNETTE: boolean;
  85392. VIGNETTEBLENDMODEMULTIPLY: boolean;
  85393. VIGNETTEBLENDMODEOPAQUE: boolean;
  85394. TONEMAPPING: boolean;
  85395. TONEMAPPING_ACES: boolean;
  85396. CONTRAST: boolean;
  85397. COLORCURVES: boolean;
  85398. COLORGRADING: boolean;
  85399. COLORGRADING3D: boolean;
  85400. SAMPLER3DGREENDEPTH: boolean;
  85401. SAMPLER3DBGRMAP: boolean;
  85402. IMAGEPROCESSINGPOSTPROCESS: boolean;
  85403. EXPOSURE: boolean;
  85404. constructor();
  85405. }
  85406. /**
  85407. * This groups together the common properties used for image processing either in direct forward pass
  85408. * or through post processing effect depending on the use of the image processing pipeline in your scene
  85409. * or not.
  85410. */
  85411. export class ImageProcessingConfiguration {
  85412. /**
  85413. * Default tone mapping applied in BabylonJS.
  85414. */
  85415. static readonly TONEMAPPING_STANDARD: number;
  85416. /**
  85417. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  85418. * to other engines rendering to increase portability.
  85419. */
  85420. static readonly TONEMAPPING_ACES: number;
  85421. /**
  85422. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  85423. */
  85424. colorCurves: Nullable<ColorCurves>;
  85425. private _colorCurvesEnabled;
  85426. /**
  85427. * Gets wether the color curves effect is enabled.
  85428. */
  85429. get colorCurvesEnabled(): boolean;
  85430. /**
  85431. * Sets wether the color curves effect is enabled.
  85432. */
  85433. set colorCurvesEnabled(value: boolean);
  85434. private _colorGradingTexture;
  85435. /**
  85436. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  85437. */
  85438. get colorGradingTexture(): Nullable<BaseTexture>;
  85439. /**
  85440. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  85441. */
  85442. set colorGradingTexture(value: Nullable<BaseTexture>);
  85443. private _colorGradingEnabled;
  85444. /**
  85445. * Gets wether the color grading effect is enabled.
  85446. */
  85447. get colorGradingEnabled(): boolean;
  85448. /**
  85449. * Sets wether the color grading effect is enabled.
  85450. */
  85451. set colorGradingEnabled(value: boolean);
  85452. private _colorGradingWithGreenDepth;
  85453. /**
  85454. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  85455. */
  85456. get colorGradingWithGreenDepth(): boolean;
  85457. /**
  85458. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  85459. */
  85460. set colorGradingWithGreenDepth(value: boolean);
  85461. private _colorGradingBGR;
  85462. /**
  85463. * Gets wether the color grading texture contains BGR values.
  85464. */
  85465. get colorGradingBGR(): boolean;
  85466. /**
  85467. * Sets wether the color grading texture contains BGR values.
  85468. */
  85469. set colorGradingBGR(value: boolean);
  85470. /** @hidden */
  85471. _exposure: number;
  85472. /**
  85473. * Gets the Exposure used in the effect.
  85474. */
  85475. get exposure(): number;
  85476. /**
  85477. * Sets the Exposure used in the effect.
  85478. */
  85479. set exposure(value: number);
  85480. private _toneMappingEnabled;
  85481. /**
  85482. * Gets wether the tone mapping effect is enabled.
  85483. */
  85484. get toneMappingEnabled(): boolean;
  85485. /**
  85486. * Sets wether the tone mapping effect is enabled.
  85487. */
  85488. set toneMappingEnabled(value: boolean);
  85489. private _toneMappingType;
  85490. /**
  85491. * Gets the type of tone mapping effect.
  85492. */
  85493. get toneMappingType(): number;
  85494. /**
  85495. * Sets the type of tone mapping effect used in BabylonJS.
  85496. */
  85497. set toneMappingType(value: number);
  85498. protected _contrast: number;
  85499. /**
  85500. * Gets the contrast used in the effect.
  85501. */
  85502. get contrast(): number;
  85503. /**
  85504. * Sets the contrast used in the effect.
  85505. */
  85506. set contrast(value: number);
  85507. /**
  85508. * Vignette stretch size.
  85509. */
  85510. vignetteStretch: number;
  85511. /**
  85512. * Vignette centre X Offset.
  85513. */
  85514. vignetteCentreX: number;
  85515. /**
  85516. * Vignette centre Y Offset.
  85517. */
  85518. vignetteCentreY: number;
  85519. /**
  85520. * Vignette weight or intensity of the vignette effect.
  85521. */
  85522. vignetteWeight: number;
  85523. /**
  85524. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  85525. * if vignetteEnabled is set to true.
  85526. */
  85527. vignetteColor: Color4;
  85528. /**
  85529. * Camera field of view used by the Vignette effect.
  85530. */
  85531. vignetteCameraFov: number;
  85532. private _vignetteBlendMode;
  85533. /**
  85534. * Gets the vignette blend mode allowing different kind of effect.
  85535. */
  85536. get vignetteBlendMode(): number;
  85537. /**
  85538. * Sets the vignette blend mode allowing different kind of effect.
  85539. */
  85540. set vignetteBlendMode(value: number);
  85541. private _vignetteEnabled;
  85542. /**
  85543. * Gets wether the vignette effect is enabled.
  85544. */
  85545. get vignetteEnabled(): boolean;
  85546. /**
  85547. * Sets wether the vignette effect is enabled.
  85548. */
  85549. set vignetteEnabled(value: boolean);
  85550. private _applyByPostProcess;
  85551. /**
  85552. * Gets wether the image processing is applied through a post process or not.
  85553. */
  85554. get applyByPostProcess(): boolean;
  85555. /**
  85556. * Sets wether the image processing is applied through a post process or not.
  85557. */
  85558. set applyByPostProcess(value: boolean);
  85559. private _isEnabled;
  85560. /**
  85561. * Gets wether the image processing is enabled or not.
  85562. */
  85563. get isEnabled(): boolean;
  85564. /**
  85565. * Sets wether the image processing is enabled or not.
  85566. */
  85567. set isEnabled(value: boolean);
  85568. /**
  85569. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  85570. */
  85571. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  85572. /**
  85573. * Method called each time the image processing information changes requires to recompile the effect.
  85574. */
  85575. protected _updateParameters(): void;
  85576. /**
  85577. * Gets the current class name.
  85578. * @return "ImageProcessingConfiguration"
  85579. */
  85580. getClassName(): string;
  85581. /**
  85582. * Prepare the list of uniforms associated with the Image Processing effects.
  85583. * @param uniforms The list of uniforms used in the effect
  85584. * @param defines the list of defines currently in use
  85585. */
  85586. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  85587. /**
  85588. * Prepare the list of samplers associated with the Image Processing effects.
  85589. * @param samplersList The list of uniforms used in the effect
  85590. * @param defines the list of defines currently in use
  85591. */
  85592. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  85593. /**
  85594. * Prepare the list of defines associated to the shader.
  85595. * @param defines the list of defines to complete
  85596. * @param forPostProcess Define if we are currently in post process mode or not
  85597. */
  85598. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  85599. /**
  85600. * Returns true if all the image processing information are ready.
  85601. * @returns True if ready, otherwise, false
  85602. */
  85603. isReady(): boolean;
  85604. /**
  85605. * Binds the image processing to the shader.
  85606. * @param effect The effect to bind to
  85607. * @param overrideAspectRatio Override the aspect ratio of the effect
  85608. */
  85609. bind(effect: Effect, overrideAspectRatio?: number): void;
  85610. /**
  85611. * Clones the current image processing instance.
  85612. * @return The cloned image processing
  85613. */
  85614. clone(): ImageProcessingConfiguration;
  85615. /**
  85616. * Serializes the current image processing instance to a json representation.
  85617. * @return a JSON representation
  85618. */
  85619. serialize(): any;
  85620. /**
  85621. * Parses the image processing from a json representation.
  85622. * @param source the JSON source to parse
  85623. * @return The parsed image processing
  85624. */
  85625. static Parse(source: any): ImageProcessingConfiguration;
  85626. private static _VIGNETTEMODE_MULTIPLY;
  85627. private static _VIGNETTEMODE_OPAQUE;
  85628. /**
  85629. * Used to apply the vignette as a mix with the pixel color.
  85630. */
  85631. static get VIGNETTEMODE_MULTIPLY(): number;
  85632. /**
  85633. * Used to apply the vignette as a replacement of the pixel color.
  85634. */
  85635. static get VIGNETTEMODE_OPAQUE(): number;
  85636. }
  85637. }
  85638. declare module BABYLON {
  85639. /** @hidden */
  85640. export var postprocessVertexShader: {
  85641. name: string;
  85642. shader: string;
  85643. };
  85644. }
  85645. declare module BABYLON {
  85646. interface ThinEngine {
  85647. /**
  85648. * Creates a new render target texture
  85649. * @param size defines the size of the texture
  85650. * @param options defines the options used to create the texture
  85651. * @returns a new render target texture stored in an InternalTexture
  85652. */
  85653. createRenderTargetTexture(size: number | {
  85654. width: number;
  85655. height: number;
  85656. layers?: number;
  85657. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  85658. /**
  85659. * Creates a depth stencil texture.
  85660. * This is only available in WebGL 2 or with the depth texture extension available.
  85661. * @param size The size of face edge in the texture.
  85662. * @param options The options defining the texture.
  85663. * @returns The texture
  85664. */
  85665. createDepthStencilTexture(size: number | {
  85666. width: number;
  85667. height: number;
  85668. layers?: number;
  85669. }, options: DepthTextureCreationOptions): InternalTexture;
  85670. /** @hidden */
  85671. _createDepthStencilTexture(size: number | {
  85672. width: number;
  85673. height: number;
  85674. layers?: number;
  85675. }, options: DepthTextureCreationOptions): InternalTexture;
  85676. }
  85677. }
  85678. declare module BABYLON {
  85679. /**
  85680. * Defines the kind of connection point for node based material
  85681. */
  85682. export enum NodeMaterialBlockConnectionPointTypes {
  85683. /** Float */
  85684. Float = 1,
  85685. /** Int */
  85686. Int = 2,
  85687. /** Vector2 */
  85688. Vector2 = 4,
  85689. /** Vector3 */
  85690. Vector3 = 8,
  85691. /** Vector4 */
  85692. Vector4 = 16,
  85693. /** Color3 */
  85694. Color3 = 32,
  85695. /** Color4 */
  85696. Color4 = 64,
  85697. /** Matrix */
  85698. Matrix = 128,
  85699. /** Custom object */
  85700. Object = 256,
  85701. /** Detect type based on connection */
  85702. AutoDetect = 1024,
  85703. /** Output type that will be defined by input type */
  85704. BasedOnInput = 2048
  85705. }
  85706. }
  85707. declare module BABYLON {
  85708. /**
  85709. * Enum used to define the target of a block
  85710. */
  85711. export enum NodeMaterialBlockTargets {
  85712. /** Vertex shader */
  85713. Vertex = 1,
  85714. /** Fragment shader */
  85715. Fragment = 2,
  85716. /** Neutral */
  85717. Neutral = 4,
  85718. /** Vertex and Fragment */
  85719. VertexAndFragment = 3
  85720. }
  85721. }
  85722. declare module BABYLON {
  85723. /**
  85724. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  85725. */
  85726. export enum NodeMaterialBlockConnectionPointMode {
  85727. /** Value is an uniform */
  85728. Uniform = 0,
  85729. /** Value is a mesh attribute */
  85730. Attribute = 1,
  85731. /** Value is a varying between vertex and fragment shaders */
  85732. Varying = 2,
  85733. /** Mode is undefined */
  85734. Undefined = 3
  85735. }
  85736. }
  85737. declare module BABYLON {
  85738. /**
  85739. * Enum used to define system values e.g. values automatically provided by the system
  85740. */
  85741. export enum NodeMaterialSystemValues {
  85742. /** World */
  85743. World = 1,
  85744. /** View */
  85745. View = 2,
  85746. /** Projection */
  85747. Projection = 3,
  85748. /** ViewProjection */
  85749. ViewProjection = 4,
  85750. /** WorldView */
  85751. WorldView = 5,
  85752. /** WorldViewProjection */
  85753. WorldViewProjection = 6,
  85754. /** CameraPosition */
  85755. CameraPosition = 7,
  85756. /** Fog Color */
  85757. FogColor = 8,
  85758. /** Delta time */
  85759. DeltaTime = 9
  85760. }
  85761. }
  85762. declare module BABYLON {
  85763. /** Defines supported spaces */
  85764. export enum Space {
  85765. /** Local (object) space */
  85766. LOCAL = 0,
  85767. /** World space */
  85768. WORLD = 1,
  85769. /** Bone space */
  85770. BONE = 2
  85771. }
  85772. /** Defines the 3 main axes */
  85773. export class Axis {
  85774. /** X axis */
  85775. static X: Vector3;
  85776. /** Y axis */
  85777. static Y: Vector3;
  85778. /** Z axis */
  85779. static Z: Vector3;
  85780. }
  85781. }
  85782. declare module BABYLON {
  85783. /**
  85784. * Represents a camera frustum
  85785. */
  85786. export class Frustum {
  85787. /**
  85788. * Gets the planes representing the frustum
  85789. * @param transform matrix to be applied to the returned planes
  85790. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  85791. */
  85792. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  85793. /**
  85794. * Gets the near frustum plane transformed by the transform matrix
  85795. * @param transform transformation matrix to be applied to the resulting frustum plane
  85796. * @param frustumPlane the resuling frustum plane
  85797. */
  85798. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  85799. /**
  85800. * Gets the far frustum plane transformed by the transform matrix
  85801. * @param transform transformation matrix to be applied to the resulting frustum plane
  85802. * @param frustumPlane the resuling frustum plane
  85803. */
  85804. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  85805. /**
  85806. * Gets the left frustum plane transformed by the transform matrix
  85807. * @param transform transformation matrix to be applied to the resulting frustum plane
  85808. * @param frustumPlane the resuling frustum plane
  85809. */
  85810. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  85811. /**
  85812. * Gets the right frustum plane transformed by the transform matrix
  85813. * @param transform transformation matrix to be applied to the resulting frustum plane
  85814. * @param frustumPlane the resuling frustum plane
  85815. */
  85816. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  85817. /**
  85818. * Gets the top frustum plane transformed by the transform matrix
  85819. * @param transform transformation matrix to be applied to the resulting frustum plane
  85820. * @param frustumPlane the resuling frustum plane
  85821. */
  85822. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  85823. /**
  85824. * Gets the bottom frustum plane transformed by the transform matrix
  85825. * @param transform transformation matrix to be applied to the resulting frustum plane
  85826. * @param frustumPlane the resuling frustum plane
  85827. */
  85828. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  85829. /**
  85830. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  85831. * @param transform transformation matrix to be applied to the resulting frustum planes
  85832. * @param frustumPlanes the resuling frustum planes
  85833. */
  85834. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  85835. }
  85836. }
  85837. declare module BABYLON {
  85838. /**
  85839. * Interface for the size containing width and height
  85840. */
  85841. export interface ISize {
  85842. /**
  85843. * Width
  85844. */
  85845. width: number;
  85846. /**
  85847. * Heighht
  85848. */
  85849. height: number;
  85850. }
  85851. /**
  85852. * Size containing widht and height
  85853. */
  85854. export class Size implements ISize {
  85855. /**
  85856. * Width
  85857. */
  85858. width: number;
  85859. /**
  85860. * Height
  85861. */
  85862. height: number;
  85863. /**
  85864. * Creates a Size object from the given width and height (floats).
  85865. * @param width width of the new size
  85866. * @param height height of the new size
  85867. */
  85868. constructor(width: number, height: number);
  85869. /**
  85870. * Returns a string with the Size width and height
  85871. * @returns a string with the Size width and height
  85872. */
  85873. toString(): string;
  85874. /**
  85875. * "Size"
  85876. * @returns the string "Size"
  85877. */
  85878. getClassName(): string;
  85879. /**
  85880. * Returns the Size hash code.
  85881. * @returns a hash code for a unique width and height
  85882. */
  85883. getHashCode(): number;
  85884. /**
  85885. * Updates the current size from the given one.
  85886. * @param src the given size
  85887. */
  85888. copyFrom(src: Size): void;
  85889. /**
  85890. * Updates in place the current Size from the given floats.
  85891. * @param width width of the new size
  85892. * @param height height of the new size
  85893. * @returns the updated Size.
  85894. */
  85895. copyFromFloats(width: number, height: number): Size;
  85896. /**
  85897. * Updates in place the current Size from the given floats.
  85898. * @param width width to set
  85899. * @param height height to set
  85900. * @returns the updated Size.
  85901. */
  85902. set(width: number, height: number): Size;
  85903. /**
  85904. * Multiplies the width and height by numbers
  85905. * @param w factor to multiple the width by
  85906. * @param h factor to multiple the height by
  85907. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  85908. */
  85909. multiplyByFloats(w: number, h: number): Size;
  85910. /**
  85911. * Clones the size
  85912. * @returns a new Size copied from the given one.
  85913. */
  85914. clone(): Size;
  85915. /**
  85916. * True if the current Size and the given one width and height are strictly equal.
  85917. * @param other the other size to compare against
  85918. * @returns True if the current Size and the given one width and height are strictly equal.
  85919. */
  85920. equals(other: Size): boolean;
  85921. /**
  85922. * The surface of the Size : width * height (float).
  85923. */
  85924. get surface(): number;
  85925. /**
  85926. * Create a new size of zero
  85927. * @returns a new Size set to (0.0, 0.0)
  85928. */
  85929. static Zero(): Size;
  85930. /**
  85931. * Sums the width and height of two sizes
  85932. * @param otherSize size to add to this size
  85933. * @returns a new Size set as the addition result of the current Size and the given one.
  85934. */
  85935. add(otherSize: Size): Size;
  85936. /**
  85937. * Subtracts the width and height of two
  85938. * @param otherSize size to subtract to this size
  85939. * @returns a new Size set as the subtraction result of the given one from the current Size.
  85940. */
  85941. subtract(otherSize: Size): Size;
  85942. /**
  85943. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  85944. * @param start starting size to lerp between
  85945. * @param end end size to lerp between
  85946. * @param amount amount to lerp between the start and end values
  85947. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  85948. */
  85949. static Lerp(start: Size, end: Size, amount: number): Size;
  85950. }
  85951. }
  85952. declare module BABYLON {
  85953. /**
  85954. * Contains position and normal vectors for a vertex
  85955. */
  85956. export class PositionNormalVertex {
  85957. /** the position of the vertex (defaut: 0,0,0) */
  85958. position: Vector3;
  85959. /** the normal of the vertex (defaut: 0,1,0) */
  85960. normal: Vector3;
  85961. /**
  85962. * Creates a PositionNormalVertex
  85963. * @param position the position of the vertex (defaut: 0,0,0)
  85964. * @param normal the normal of the vertex (defaut: 0,1,0)
  85965. */
  85966. constructor(
  85967. /** the position of the vertex (defaut: 0,0,0) */
  85968. position?: Vector3,
  85969. /** the normal of the vertex (defaut: 0,1,0) */
  85970. normal?: Vector3);
  85971. /**
  85972. * Clones the PositionNormalVertex
  85973. * @returns the cloned PositionNormalVertex
  85974. */
  85975. clone(): PositionNormalVertex;
  85976. }
  85977. /**
  85978. * Contains position, normal and uv vectors for a vertex
  85979. */
  85980. export class PositionNormalTextureVertex {
  85981. /** the position of the vertex (defaut: 0,0,0) */
  85982. position: Vector3;
  85983. /** the normal of the vertex (defaut: 0,1,0) */
  85984. normal: Vector3;
  85985. /** the uv of the vertex (default: 0,0) */
  85986. uv: Vector2;
  85987. /**
  85988. * Creates a PositionNormalTextureVertex
  85989. * @param position the position of the vertex (defaut: 0,0,0)
  85990. * @param normal the normal of the vertex (defaut: 0,1,0)
  85991. * @param uv the uv of the vertex (default: 0,0)
  85992. */
  85993. constructor(
  85994. /** the position of the vertex (defaut: 0,0,0) */
  85995. position?: Vector3,
  85996. /** the normal of the vertex (defaut: 0,1,0) */
  85997. normal?: Vector3,
  85998. /** the uv of the vertex (default: 0,0) */
  85999. uv?: Vector2);
  86000. /**
  86001. * Clones the PositionNormalTextureVertex
  86002. * @returns the cloned PositionNormalTextureVertex
  86003. */
  86004. clone(): PositionNormalTextureVertex;
  86005. }
  86006. }
  86007. declare module BABYLON {
  86008. /**
  86009. * Enum defining the type of animations supported by InputBlock
  86010. */
  86011. export enum AnimatedInputBlockTypes {
  86012. /** No animation */
  86013. None = 0,
  86014. /** Time based animation. Will only work for floats */
  86015. Time = 1
  86016. }
  86017. }
  86018. declare module BABYLON {
  86019. /**
  86020. * Interface describing all the common properties and methods a shadow light needs to implement.
  86021. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  86022. * as well as binding the different shadow properties to the effects.
  86023. */
  86024. export interface IShadowLight extends Light {
  86025. /**
  86026. * The light id in the scene (used in scene.findLighById for instance)
  86027. */
  86028. id: string;
  86029. /**
  86030. * The position the shdow will be casted from.
  86031. */
  86032. position: Vector3;
  86033. /**
  86034. * In 2d mode (needCube being false), the direction used to cast the shadow.
  86035. */
  86036. direction: Vector3;
  86037. /**
  86038. * The transformed position. Position of the light in world space taking parenting in account.
  86039. */
  86040. transformedPosition: Vector3;
  86041. /**
  86042. * The transformed direction. Direction of the light in world space taking parenting in account.
  86043. */
  86044. transformedDirection: Vector3;
  86045. /**
  86046. * The friendly name of the light in the scene.
  86047. */
  86048. name: string;
  86049. /**
  86050. * Defines the shadow projection clipping minimum z value.
  86051. */
  86052. shadowMinZ: number;
  86053. /**
  86054. * Defines the shadow projection clipping maximum z value.
  86055. */
  86056. shadowMaxZ: number;
  86057. /**
  86058. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  86059. * @returns true if the information has been computed, false if it does not need to (no parenting)
  86060. */
  86061. computeTransformedInformation(): boolean;
  86062. /**
  86063. * Gets the scene the light belongs to.
  86064. * @returns The scene
  86065. */
  86066. getScene(): Scene;
  86067. /**
  86068. * Callback defining a custom Projection Matrix Builder.
  86069. * This can be used to override the default projection matrix computation.
  86070. */
  86071. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  86072. /**
  86073. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  86074. * @param matrix The materix to updated with the projection information
  86075. * @param viewMatrix The transform matrix of the light
  86076. * @param renderList The list of mesh to render in the map
  86077. * @returns The current light
  86078. */
  86079. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  86080. /**
  86081. * Gets the current depth scale used in ESM.
  86082. * @returns The scale
  86083. */
  86084. getDepthScale(): number;
  86085. /**
  86086. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  86087. * @returns true if a cube texture needs to be use
  86088. */
  86089. needCube(): boolean;
  86090. /**
  86091. * Detects if the projection matrix requires to be recomputed this frame.
  86092. * @returns true if it requires to be recomputed otherwise, false.
  86093. */
  86094. needProjectionMatrixCompute(): boolean;
  86095. /**
  86096. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  86097. */
  86098. forceProjectionMatrixCompute(): void;
  86099. /**
  86100. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  86101. * @param faceIndex The index of the face we are computed the direction to generate shadow
  86102. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  86103. */
  86104. getShadowDirection(faceIndex?: number): Vector3;
  86105. /**
  86106. * Gets the minZ used for shadow according to both the scene and the light.
  86107. * @param activeCamera The camera we are returning the min for
  86108. * @returns the depth min z
  86109. */
  86110. getDepthMinZ(activeCamera: Camera): number;
  86111. /**
  86112. * Gets the maxZ used for shadow according to both the scene and the light.
  86113. * @param activeCamera The camera we are returning the max for
  86114. * @returns the depth max z
  86115. */
  86116. getDepthMaxZ(activeCamera: Camera): number;
  86117. }
  86118. /**
  86119. * Base implementation IShadowLight
  86120. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  86121. */
  86122. export abstract class ShadowLight extends Light implements IShadowLight {
  86123. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  86124. protected _position: Vector3;
  86125. protected _setPosition(value: Vector3): void;
  86126. /**
  86127. * Sets the position the shadow will be casted from. Also use as the light position for both
  86128. * point and spot lights.
  86129. */
  86130. get position(): Vector3;
  86131. /**
  86132. * Sets the position the shadow will be casted from. Also use as the light position for both
  86133. * point and spot lights.
  86134. */
  86135. set position(value: Vector3);
  86136. protected _direction: Vector3;
  86137. protected _setDirection(value: Vector3): void;
  86138. /**
  86139. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  86140. * Also use as the light direction on spot and directional lights.
  86141. */
  86142. get direction(): Vector3;
  86143. /**
  86144. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  86145. * Also use as the light direction on spot and directional lights.
  86146. */
  86147. set direction(value: Vector3);
  86148. protected _shadowMinZ: number;
  86149. /**
  86150. * Gets the shadow projection clipping minimum z value.
  86151. */
  86152. get shadowMinZ(): number;
  86153. /**
  86154. * Sets the shadow projection clipping minimum z value.
  86155. */
  86156. set shadowMinZ(value: number);
  86157. protected _shadowMaxZ: number;
  86158. /**
  86159. * Sets the shadow projection clipping maximum z value.
  86160. */
  86161. get shadowMaxZ(): number;
  86162. /**
  86163. * Gets the shadow projection clipping maximum z value.
  86164. */
  86165. set shadowMaxZ(value: number);
  86166. /**
  86167. * Callback defining a custom Projection Matrix Builder.
  86168. * This can be used to override the default projection matrix computation.
  86169. */
  86170. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  86171. /**
  86172. * The transformed position. Position of the light in world space taking parenting in account.
  86173. */
  86174. transformedPosition: Vector3;
  86175. /**
  86176. * The transformed direction. Direction of the light in world space taking parenting in account.
  86177. */
  86178. transformedDirection: Vector3;
  86179. private _needProjectionMatrixCompute;
  86180. /**
  86181. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  86182. * @returns true if the information has been computed, false if it does not need to (no parenting)
  86183. */
  86184. computeTransformedInformation(): boolean;
  86185. /**
  86186. * Return the depth scale used for the shadow map.
  86187. * @returns the depth scale.
  86188. */
  86189. getDepthScale(): number;
  86190. /**
  86191. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  86192. * @param faceIndex The index of the face we are computed the direction to generate shadow
  86193. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  86194. */
  86195. getShadowDirection(faceIndex?: number): Vector3;
  86196. /**
  86197. * Returns the ShadowLight absolute position in the World.
  86198. * @returns the position vector in world space
  86199. */
  86200. getAbsolutePosition(): Vector3;
  86201. /**
  86202. * Sets the ShadowLight direction toward the passed target.
  86203. * @param target The point to target in local space
  86204. * @returns the updated ShadowLight direction
  86205. */
  86206. setDirectionToTarget(target: Vector3): Vector3;
  86207. /**
  86208. * Returns the light rotation in euler definition.
  86209. * @returns the x y z rotation in local space.
  86210. */
  86211. getRotation(): Vector3;
  86212. /**
  86213. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  86214. * @returns true if a cube texture needs to be use
  86215. */
  86216. needCube(): boolean;
  86217. /**
  86218. * Detects if the projection matrix requires to be recomputed this frame.
  86219. * @returns true if it requires to be recomputed otherwise, false.
  86220. */
  86221. needProjectionMatrixCompute(): boolean;
  86222. /**
  86223. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  86224. */
  86225. forceProjectionMatrixCompute(): void;
  86226. /** @hidden */
  86227. _initCache(): void;
  86228. /** @hidden */
  86229. _isSynchronized(): boolean;
  86230. /**
  86231. * Computes the world matrix of the node
  86232. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  86233. * @returns the world matrix
  86234. */
  86235. computeWorldMatrix(force?: boolean): Matrix;
  86236. /**
  86237. * Gets the minZ used for shadow according to both the scene and the light.
  86238. * @param activeCamera The camera we are returning the min for
  86239. * @returns the depth min z
  86240. */
  86241. getDepthMinZ(activeCamera: Camera): number;
  86242. /**
  86243. * Gets the maxZ used for shadow according to both the scene and the light.
  86244. * @param activeCamera The camera we are returning the max for
  86245. * @returns the depth max z
  86246. */
  86247. getDepthMaxZ(activeCamera: Camera): number;
  86248. /**
  86249. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  86250. * @param matrix The materix to updated with the projection information
  86251. * @param viewMatrix The transform matrix of the light
  86252. * @param renderList The list of mesh to render in the map
  86253. * @returns The current light
  86254. */
  86255. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  86256. }
  86257. }
  86258. declare module BABYLON {
  86259. /** @hidden */
  86260. export var packingFunctions: {
  86261. name: string;
  86262. shader: string;
  86263. };
  86264. }
  86265. declare module BABYLON {
  86266. /** @hidden */
  86267. export var bayerDitherFunctions: {
  86268. name: string;
  86269. shader: string;
  86270. };
  86271. }
  86272. declare module BABYLON {
  86273. /** @hidden */
  86274. export var shadowMapFragmentDeclaration: {
  86275. name: string;
  86276. shader: string;
  86277. };
  86278. }
  86279. declare module BABYLON {
  86280. /** @hidden */
  86281. export var clipPlaneFragmentDeclaration: {
  86282. name: string;
  86283. shader: string;
  86284. };
  86285. }
  86286. declare module BABYLON {
  86287. /** @hidden */
  86288. export var clipPlaneFragment: {
  86289. name: string;
  86290. shader: string;
  86291. };
  86292. }
  86293. declare module BABYLON {
  86294. /** @hidden */
  86295. export var shadowMapFragment: {
  86296. name: string;
  86297. shader: string;
  86298. };
  86299. }
  86300. declare module BABYLON {
  86301. /** @hidden */
  86302. export var shadowMapPixelShader: {
  86303. name: string;
  86304. shader: string;
  86305. };
  86306. }
  86307. declare module BABYLON {
  86308. /** @hidden */
  86309. export var bonesDeclaration: {
  86310. name: string;
  86311. shader: string;
  86312. };
  86313. }
  86314. declare module BABYLON {
  86315. /** @hidden */
  86316. export var morphTargetsVertexGlobalDeclaration: {
  86317. name: string;
  86318. shader: string;
  86319. };
  86320. }
  86321. declare module BABYLON {
  86322. /** @hidden */
  86323. export var morphTargetsVertexDeclaration: {
  86324. name: string;
  86325. shader: string;
  86326. };
  86327. }
  86328. declare module BABYLON {
  86329. /** @hidden */
  86330. export var instancesDeclaration: {
  86331. name: string;
  86332. shader: string;
  86333. };
  86334. }
  86335. declare module BABYLON {
  86336. /** @hidden */
  86337. export var helperFunctions: {
  86338. name: string;
  86339. shader: string;
  86340. };
  86341. }
  86342. declare module BABYLON {
  86343. /** @hidden */
  86344. export var shadowMapVertexDeclaration: {
  86345. name: string;
  86346. shader: string;
  86347. };
  86348. }
  86349. declare module BABYLON {
  86350. /** @hidden */
  86351. export var clipPlaneVertexDeclaration: {
  86352. name: string;
  86353. shader: string;
  86354. };
  86355. }
  86356. declare module BABYLON {
  86357. /** @hidden */
  86358. export var morphTargetsVertex: {
  86359. name: string;
  86360. shader: string;
  86361. };
  86362. }
  86363. declare module BABYLON {
  86364. /** @hidden */
  86365. export var instancesVertex: {
  86366. name: string;
  86367. shader: string;
  86368. };
  86369. }
  86370. declare module BABYLON {
  86371. /** @hidden */
  86372. export var bonesVertex: {
  86373. name: string;
  86374. shader: string;
  86375. };
  86376. }
  86377. declare module BABYLON {
  86378. /** @hidden */
  86379. export var shadowMapVertexNormalBias: {
  86380. name: string;
  86381. shader: string;
  86382. };
  86383. }
  86384. declare module BABYLON {
  86385. /** @hidden */
  86386. export var shadowMapVertexMetric: {
  86387. name: string;
  86388. shader: string;
  86389. };
  86390. }
  86391. declare module BABYLON {
  86392. /** @hidden */
  86393. export var clipPlaneVertex: {
  86394. name: string;
  86395. shader: string;
  86396. };
  86397. }
  86398. declare module BABYLON {
  86399. /** @hidden */
  86400. export var shadowMapVertexShader: {
  86401. name: string;
  86402. shader: string;
  86403. };
  86404. }
  86405. declare module BABYLON {
  86406. /** @hidden */
  86407. export var depthBoxBlurPixelShader: {
  86408. name: string;
  86409. shader: string;
  86410. };
  86411. }
  86412. declare module BABYLON {
  86413. /** @hidden */
  86414. export var shadowMapFragmentSoftTransparentShadow: {
  86415. name: string;
  86416. shader: string;
  86417. };
  86418. }
  86419. declare module BABYLON {
  86420. /**
  86421. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  86422. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  86423. */
  86424. export class EffectFallbacks implements IEffectFallbacks {
  86425. private _defines;
  86426. private _currentRank;
  86427. private _maxRank;
  86428. private _mesh;
  86429. /**
  86430. * Removes the fallback from the bound mesh.
  86431. */
  86432. unBindMesh(): void;
  86433. /**
  86434. * Adds a fallback on the specified property.
  86435. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  86436. * @param define The name of the define in the shader
  86437. */
  86438. addFallback(rank: number, define: string): void;
  86439. /**
  86440. * Sets the mesh to use CPU skinning when needing to fallback.
  86441. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  86442. * @param mesh The mesh to use the fallbacks.
  86443. */
  86444. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  86445. /**
  86446. * Checks to see if more fallbacks are still availible.
  86447. */
  86448. get hasMoreFallbacks(): boolean;
  86449. /**
  86450. * Removes the defines that should be removed when falling back.
  86451. * @param currentDefines defines the current define statements for the shader.
  86452. * @param effect defines the current effect we try to compile
  86453. * @returns The resulting defines with defines of the current rank removed.
  86454. */
  86455. reduce(currentDefines: string, effect: Effect): string;
  86456. }
  86457. }
  86458. declare module BABYLON {
  86459. /**
  86460. * Interface used to define Action
  86461. */
  86462. export interface IAction {
  86463. /**
  86464. * Trigger for the action
  86465. */
  86466. trigger: number;
  86467. /** Options of the trigger */
  86468. triggerOptions: any;
  86469. /**
  86470. * Gets the trigger parameters
  86471. * @returns the trigger parameters
  86472. */
  86473. getTriggerParameter(): any;
  86474. /**
  86475. * Internal only - executes current action event
  86476. * @hidden
  86477. */
  86478. _executeCurrent(evt?: ActionEvent): void;
  86479. /**
  86480. * Serialize placeholder for child classes
  86481. * @param parent of child
  86482. * @returns the serialized object
  86483. */
  86484. serialize(parent: any): any;
  86485. /**
  86486. * Internal only
  86487. * @hidden
  86488. */
  86489. _prepare(): void;
  86490. /**
  86491. * Internal only - manager for action
  86492. * @hidden
  86493. */
  86494. _actionManager: AbstractActionManager;
  86495. /**
  86496. * Adds action to chain of actions, may be a DoNothingAction
  86497. * @param action defines the next action to execute
  86498. * @returns The action passed in
  86499. * @see https://www.babylonjs-playground.com/#1T30HR#0
  86500. */
  86501. then(action: IAction): IAction;
  86502. }
  86503. /**
  86504. * The action to be carried out following a trigger
  86505. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  86506. */
  86507. export class Action implements IAction {
  86508. /** the trigger, with or without parameters, for the action */
  86509. triggerOptions: any;
  86510. /**
  86511. * Trigger for the action
  86512. */
  86513. trigger: number;
  86514. /**
  86515. * Internal only - manager for action
  86516. * @hidden
  86517. */
  86518. _actionManager: ActionManager;
  86519. private _nextActiveAction;
  86520. private _child;
  86521. private _condition?;
  86522. private _triggerParameter;
  86523. /**
  86524. * An event triggered prior to action being executed.
  86525. */
  86526. onBeforeExecuteObservable: Observable<Action>;
  86527. /**
  86528. * Creates a new Action
  86529. * @param triggerOptions the trigger, with or without parameters, for the action
  86530. * @param condition an optional determinant of action
  86531. */
  86532. constructor(
  86533. /** the trigger, with or without parameters, for the action */
  86534. triggerOptions: any, condition?: Condition);
  86535. /**
  86536. * Internal only
  86537. * @hidden
  86538. */
  86539. _prepare(): void;
  86540. /**
  86541. * Gets the trigger parameters
  86542. * @returns the trigger parameters
  86543. */
  86544. getTriggerParameter(): any;
  86545. /**
  86546. * Internal only - executes current action event
  86547. * @hidden
  86548. */
  86549. _executeCurrent(evt?: ActionEvent): void;
  86550. /**
  86551. * Execute placeholder for child classes
  86552. * @param evt optional action event
  86553. */
  86554. execute(evt?: ActionEvent): void;
  86555. /**
  86556. * Skips to next active action
  86557. */
  86558. skipToNextActiveAction(): void;
  86559. /**
  86560. * Adds action to chain of actions, may be a DoNothingAction
  86561. * @param action defines the next action to execute
  86562. * @returns The action passed in
  86563. * @see https://www.babylonjs-playground.com/#1T30HR#0
  86564. */
  86565. then(action: Action): Action;
  86566. /**
  86567. * Internal only
  86568. * @hidden
  86569. */
  86570. _getProperty(propertyPath: string): string;
  86571. /**
  86572. * Internal only
  86573. * @hidden
  86574. */
  86575. _getEffectiveTarget(target: any, propertyPath: string): any;
  86576. /**
  86577. * Serialize placeholder for child classes
  86578. * @param parent of child
  86579. * @returns the serialized object
  86580. */
  86581. serialize(parent: any): any;
  86582. /**
  86583. * Internal only called by serialize
  86584. * @hidden
  86585. */
  86586. protected _serialize(serializedAction: any, parent?: any): any;
  86587. /**
  86588. * Internal only
  86589. * @hidden
  86590. */
  86591. static _SerializeValueAsString: (value: any) => string;
  86592. /**
  86593. * Internal only
  86594. * @hidden
  86595. */
  86596. static _GetTargetProperty: (target: Node | Scene) => {
  86597. name: string;
  86598. targetType: string;
  86599. value: string;
  86600. };
  86601. }
  86602. }
  86603. declare module BABYLON {
  86604. /**
  86605. * A Condition applied to an Action
  86606. */
  86607. export class Condition {
  86608. /**
  86609. * Internal only - manager for action
  86610. * @hidden
  86611. */
  86612. _actionManager: ActionManager;
  86613. /**
  86614. * Internal only
  86615. * @hidden
  86616. */
  86617. _evaluationId: number;
  86618. /**
  86619. * Internal only
  86620. * @hidden
  86621. */
  86622. _currentResult: boolean;
  86623. /**
  86624. * Creates a new Condition
  86625. * @param actionManager the manager of the action the condition is applied to
  86626. */
  86627. constructor(actionManager: ActionManager);
  86628. /**
  86629. * Check if the current condition is valid
  86630. * @returns a boolean
  86631. */
  86632. isValid(): boolean;
  86633. /**
  86634. * Internal only
  86635. * @hidden
  86636. */
  86637. _getProperty(propertyPath: string): string;
  86638. /**
  86639. * Internal only
  86640. * @hidden
  86641. */
  86642. _getEffectiveTarget(target: any, propertyPath: string): any;
  86643. /**
  86644. * Serialize placeholder for child classes
  86645. * @returns the serialized object
  86646. */
  86647. serialize(): any;
  86648. /**
  86649. * Internal only
  86650. * @hidden
  86651. */
  86652. protected _serialize(serializedCondition: any): any;
  86653. }
  86654. /**
  86655. * Defines specific conditional operators as extensions of Condition
  86656. */
  86657. export class ValueCondition extends Condition {
  86658. /** path to specify the property of the target the conditional operator uses */
  86659. propertyPath: string;
  86660. /** the value compared by the conditional operator against the current value of the property */
  86661. value: any;
  86662. /** the conditional operator, default ValueCondition.IsEqual */
  86663. operator: number;
  86664. /**
  86665. * Internal only
  86666. * @hidden
  86667. */
  86668. private static _IsEqual;
  86669. /**
  86670. * Internal only
  86671. * @hidden
  86672. */
  86673. private static _IsDifferent;
  86674. /**
  86675. * Internal only
  86676. * @hidden
  86677. */
  86678. private static _IsGreater;
  86679. /**
  86680. * Internal only
  86681. * @hidden
  86682. */
  86683. private static _IsLesser;
  86684. /**
  86685. * returns the number for IsEqual
  86686. */
  86687. static get IsEqual(): number;
  86688. /**
  86689. * Returns the number for IsDifferent
  86690. */
  86691. static get IsDifferent(): number;
  86692. /**
  86693. * Returns the number for IsGreater
  86694. */
  86695. static get IsGreater(): number;
  86696. /**
  86697. * Returns the number for IsLesser
  86698. */
  86699. static get IsLesser(): number;
  86700. /**
  86701. * Internal only The action manager for the condition
  86702. * @hidden
  86703. */
  86704. _actionManager: ActionManager;
  86705. /**
  86706. * Internal only
  86707. * @hidden
  86708. */
  86709. private _target;
  86710. /**
  86711. * Internal only
  86712. * @hidden
  86713. */
  86714. private _effectiveTarget;
  86715. /**
  86716. * Internal only
  86717. * @hidden
  86718. */
  86719. private _property;
  86720. /**
  86721. * Creates a new ValueCondition
  86722. * @param actionManager manager for the action the condition applies to
  86723. * @param target for the action
  86724. * @param propertyPath path to specify the property of the target the conditional operator uses
  86725. * @param value the value compared by the conditional operator against the current value of the property
  86726. * @param operator the conditional operator, default ValueCondition.IsEqual
  86727. */
  86728. constructor(actionManager: ActionManager, target: any,
  86729. /** path to specify the property of the target the conditional operator uses */
  86730. propertyPath: string,
  86731. /** the value compared by the conditional operator against the current value of the property */
  86732. value: any,
  86733. /** the conditional operator, default ValueCondition.IsEqual */
  86734. operator?: number);
  86735. /**
  86736. * Compares the given value with the property value for the specified conditional operator
  86737. * @returns the result of the comparison
  86738. */
  86739. isValid(): boolean;
  86740. /**
  86741. * Serialize the ValueCondition into a JSON compatible object
  86742. * @returns serialization object
  86743. */
  86744. serialize(): any;
  86745. /**
  86746. * Gets the name of the conditional operator for the ValueCondition
  86747. * @param operator the conditional operator
  86748. * @returns the name
  86749. */
  86750. static GetOperatorName(operator: number): string;
  86751. }
  86752. /**
  86753. * Defines a predicate condition as an extension of Condition
  86754. */
  86755. export class PredicateCondition extends Condition {
  86756. /** defines the predicate function used to validate the condition */
  86757. predicate: () => boolean;
  86758. /**
  86759. * Internal only - manager for action
  86760. * @hidden
  86761. */
  86762. _actionManager: ActionManager;
  86763. /**
  86764. * Creates a new PredicateCondition
  86765. * @param actionManager manager for the action the condition applies to
  86766. * @param predicate defines the predicate function used to validate the condition
  86767. */
  86768. constructor(actionManager: ActionManager,
  86769. /** defines the predicate function used to validate the condition */
  86770. predicate: () => boolean);
  86771. /**
  86772. * @returns the validity of the predicate condition
  86773. */
  86774. isValid(): boolean;
  86775. }
  86776. /**
  86777. * Defines a state condition as an extension of Condition
  86778. */
  86779. export class StateCondition extends Condition {
  86780. /** Value to compare with target state */
  86781. value: string;
  86782. /**
  86783. * Internal only - manager for action
  86784. * @hidden
  86785. */
  86786. _actionManager: ActionManager;
  86787. /**
  86788. * Internal only
  86789. * @hidden
  86790. */
  86791. private _target;
  86792. /**
  86793. * Creates a new StateCondition
  86794. * @param actionManager manager for the action the condition applies to
  86795. * @param target of the condition
  86796. * @param value to compare with target state
  86797. */
  86798. constructor(actionManager: ActionManager, target: any,
  86799. /** Value to compare with target state */
  86800. value: string);
  86801. /**
  86802. * Gets a boolean indicating if the current condition is met
  86803. * @returns the validity of the state
  86804. */
  86805. isValid(): boolean;
  86806. /**
  86807. * Serialize the StateCondition into a JSON compatible object
  86808. * @returns serialization object
  86809. */
  86810. serialize(): any;
  86811. }
  86812. }
  86813. declare module BABYLON {
  86814. /**
  86815. * This defines an action responsible to toggle a boolean once triggered.
  86816. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  86817. */
  86818. export class SwitchBooleanAction extends Action {
  86819. /**
  86820. * The path to the boolean property in the target object
  86821. */
  86822. propertyPath: string;
  86823. private _target;
  86824. private _effectiveTarget;
  86825. private _property;
  86826. /**
  86827. * Instantiate the action
  86828. * @param triggerOptions defines the trigger options
  86829. * @param target defines the object containing the boolean
  86830. * @param propertyPath defines the path to the boolean property in the target object
  86831. * @param condition defines the trigger related conditions
  86832. */
  86833. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  86834. /** @hidden */
  86835. _prepare(): void;
  86836. /**
  86837. * Execute the action toggle the boolean value.
  86838. */
  86839. execute(): void;
  86840. /**
  86841. * Serializes the actions and its related information.
  86842. * @param parent defines the object to serialize in
  86843. * @returns the serialized object
  86844. */
  86845. serialize(parent: any): any;
  86846. }
  86847. /**
  86848. * This defines an action responsible to set a the state field of the target
  86849. * to a desired value once triggered.
  86850. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  86851. */
  86852. export class SetStateAction extends Action {
  86853. /**
  86854. * The value to store in the state field.
  86855. */
  86856. value: string;
  86857. private _target;
  86858. /**
  86859. * Instantiate the action
  86860. * @param triggerOptions defines the trigger options
  86861. * @param target defines the object containing the state property
  86862. * @param value defines the value to store in the state field
  86863. * @param condition defines the trigger related conditions
  86864. */
  86865. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  86866. /**
  86867. * Execute the action and store the value on the target state property.
  86868. */
  86869. execute(): void;
  86870. /**
  86871. * Serializes the actions and its related information.
  86872. * @param parent defines the object to serialize in
  86873. * @returns the serialized object
  86874. */
  86875. serialize(parent: any): any;
  86876. }
  86877. /**
  86878. * This defines an action responsible to set a property of the target
  86879. * to a desired value once triggered.
  86880. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  86881. */
  86882. export class SetValueAction extends Action {
  86883. /**
  86884. * The path of the property to set in the target.
  86885. */
  86886. propertyPath: string;
  86887. /**
  86888. * The value to set in the property
  86889. */
  86890. value: any;
  86891. private _target;
  86892. private _effectiveTarget;
  86893. private _property;
  86894. /**
  86895. * Instantiate the action
  86896. * @param triggerOptions defines the trigger options
  86897. * @param target defines the object containing the property
  86898. * @param propertyPath defines the path of the property to set in the target
  86899. * @param value defines the value to set in the property
  86900. * @param condition defines the trigger related conditions
  86901. */
  86902. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  86903. /** @hidden */
  86904. _prepare(): void;
  86905. /**
  86906. * Execute the action and set the targetted property to the desired value.
  86907. */
  86908. execute(): void;
  86909. /**
  86910. * Serializes the actions and its related information.
  86911. * @param parent defines the object to serialize in
  86912. * @returns the serialized object
  86913. */
  86914. serialize(parent: any): any;
  86915. }
  86916. /**
  86917. * This defines an action responsible to increment the target value
  86918. * to a desired value once triggered.
  86919. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  86920. */
  86921. export class IncrementValueAction extends Action {
  86922. /**
  86923. * The path of the property to increment in the target.
  86924. */
  86925. propertyPath: string;
  86926. /**
  86927. * The value we should increment the property by.
  86928. */
  86929. value: any;
  86930. private _target;
  86931. private _effectiveTarget;
  86932. private _property;
  86933. /**
  86934. * Instantiate the action
  86935. * @param triggerOptions defines the trigger options
  86936. * @param target defines the object containing the property
  86937. * @param propertyPath defines the path of the property to increment in the target
  86938. * @param value defines the value value we should increment the property by
  86939. * @param condition defines the trigger related conditions
  86940. */
  86941. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  86942. /** @hidden */
  86943. _prepare(): void;
  86944. /**
  86945. * Execute the action and increment the target of the value amount.
  86946. */
  86947. execute(): void;
  86948. /**
  86949. * Serializes the actions and its related information.
  86950. * @param parent defines the object to serialize in
  86951. * @returns the serialized object
  86952. */
  86953. serialize(parent: any): any;
  86954. }
  86955. /**
  86956. * This defines an action responsible to start an animation once triggered.
  86957. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  86958. */
  86959. export class PlayAnimationAction extends Action {
  86960. /**
  86961. * Where the animation should start (animation frame)
  86962. */
  86963. from: number;
  86964. /**
  86965. * Where the animation should stop (animation frame)
  86966. */
  86967. to: number;
  86968. /**
  86969. * Define if the animation should loop or stop after the first play.
  86970. */
  86971. loop?: boolean;
  86972. private _target;
  86973. /**
  86974. * Instantiate the action
  86975. * @param triggerOptions defines the trigger options
  86976. * @param target defines the target animation or animation name
  86977. * @param from defines from where the animation should start (animation frame)
  86978. * @param end defines where the animation should stop (animation frame)
  86979. * @param loop defines if the animation should loop or stop after the first play
  86980. * @param condition defines the trigger related conditions
  86981. */
  86982. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  86983. /** @hidden */
  86984. _prepare(): void;
  86985. /**
  86986. * Execute the action and play the animation.
  86987. */
  86988. execute(): void;
  86989. /**
  86990. * Serializes the actions and its related information.
  86991. * @param parent defines the object to serialize in
  86992. * @returns the serialized object
  86993. */
  86994. serialize(parent: any): any;
  86995. }
  86996. /**
  86997. * This defines an action responsible to stop an animation once triggered.
  86998. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  86999. */
  87000. export class StopAnimationAction extends Action {
  87001. private _target;
  87002. /**
  87003. * Instantiate the action
  87004. * @param triggerOptions defines the trigger options
  87005. * @param target defines the target animation or animation name
  87006. * @param condition defines the trigger related conditions
  87007. */
  87008. constructor(triggerOptions: any, target: any, condition?: Condition);
  87009. /** @hidden */
  87010. _prepare(): void;
  87011. /**
  87012. * Execute the action and stop the animation.
  87013. */
  87014. execute(): void;
  87015. /**
  87016. * Serializes the actions and its related information.
  87017. * @param parent defines the object to serialize in
  87018. * @returns the serialized object
  87019. */
  87020. serialize(parent: any): any;
  87021. }
  87022. /**
  87023. * This defines an action responsible that does nothing once triggered.
  87024. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87025. */
  87026. export class DoNothingAction extends Action {
  87027. /**
  87028. * Instantiate the action
  87029. * @param triggerOptions defines the trigger options
  87030. * @param condition defines the trigger related conditions
  87031. */
  87032. constructor(triggerOptions?: any, condition?: Condition);
  87033. /**
  87034. * Execute the action and do nothing.
  87035. */
  87036. execute(): void;
  87037. /**
  87038. * Serializes the actions and its related information.
  87039. * @param parent defines the object to serialize in
  87040. * @returns the serialized object
  87041. */
  87042. serialize(parent: any): any;
  87043. }
  87044. /**
  87045. * This defines an action responsible to trigger several actions once triggered.
  87046. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87047. */
  87048. export class CombineAction extends Action {
  87049. /**
  87050. * The list of aggregated animations to run.
  87051. */
  87052. children: Action[];
  87053. /**
  87054. * Instantiate the action
  87055. * @param triggerOptions defines the trigger options
  87056. * @param children defines the list of aggregated animations to run
  87057. * @param condition defines the trigger related conditions
  87058. */
  87059. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  87060. /** @hidden */
  87061. _prepare(): void;
  87062. /**
  87063. * Execute the action and executes all the aggregated actions.
  87064. */
  87065. execute(evt: ActionEvent): void;
  87066. /**
  87067. * Serializes the actions and its related information.
  87068. * @param parent defines the object to serialize in
  87069. * @returns the serialized object
  87070. */
  87071. serialize(parent: any): any;
  87072. }
  87073. /**
  87074. * This defines an action responsible to run code (external event) once triggered.
  87075. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87076. */
  87077. export class ExecuteCodeAction extends Action {
  87078. /**
  87079. * The callback function to run.
  87080. */
  87081. func: (evt: ActionEvent) => void;
  87082. /**
  87083. * Instantiate the action
  87084. * @param triggerOptions defines the trigger options
  87085. * @param func defines the callback function to run
  87086. * @param condition defines the trigger related conditions
  87087. */
  87088. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  87089. /**
  87090. * Execute the action and run the attached code.
  87091. */
  87092. execute(evt: ActionEvent): void;
  87093. }
  87094. /**
  87095. * This defines an action responsible to set the parent property of the target once triggered.
  87096. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87097. */
  87098. export class SetParentAction extends Action {
  87099. private _parent;
  87100. private _target;
  87101. /**
  87102. * Instantiate the action
  87103. * @param triggerOptions defines the trigger options
  87104. * @param target defines the target containing the parent property
  87105. * @param parent defines from where the animation should start (animation frame)
  87106. * @param condition defines the trigger related conditions
  87107. */
  87108. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  87109. /** @hidden */
  87110. _prepare(): void;
  87111. /**
  87112. * Execute the action and set the parent property.
  87113. */
  87114. execute(): void;
  87115. /**
  87116. * Serializes the actions and its related information.
  87117. * @param parent defines the object to serialize in
  87118. * @returns the serialized object
  87119. */
  87120. serialize(parent: any): any;
  87121. }
  87122. }
  87123. declare module BABYLON {
  87124. /**
  87125. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  87126. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  87127. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87128. */
  87129. export class ActionManager extends AbstractActionManager {
  87130. /**
  87131. * Nothing
  87132. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87133. */
  87134. static readonly NothingTrigger: number;
  87135. /**
  87136. * On pick
  87137. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87138. */
  87139. static readonly OnPickTrigger: number;
  87140. /**
  87141. * On left pick
  87142. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87143. */
  87144. static readonly OnLeftPickTrigger: number;
  87145. /**
  87146. * On right pick
  87147. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87148. */
  87149. static readonly OnRightPickTrigger: number;
  87150. /**
  87151. * On center pick
  87152. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87153. */
  87154. static readonly OnCenterPickTrigger: number;
  87155. /**
  87156. * On pick down
  87157. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87158. */
  87159. static readonly OnPickDownTrigger: number;
  87160. /**
  87161. * On double pick
  87162. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87163. */
  87164. static readonly OnDoublePickTrigger: number;
  87165. /**
  87166. * On pick up
  87167. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87168. */
  87169. static readonly OnPickUpTrigger: number;
  87170. /**
  87171. * On pick out.
  87172. * This trigger will only be raised if you also declared a OnPickDown
  87173. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87174. */
  87175. static readonly OnPickOutTrigger: number;
  87176. /**
  87177. * On long press
  87178. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87179. */
  87180. static readonly OnLongPressTrigger: number;
  87181. /**
  87182. * On pointer over
  87183. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87184. */
  87185. static readonly OnPointerOverTrigger: number;
  87186. /**
  87187. * On pointer out
  87188. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87189. */
  87190. static readonly OnPointerOutTrigger: number;
  87191. /**
  87192. * On every frame
  87193. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87194. */
  87195. static readonly OnEveryFrameTrigger: number;
  87196. /**
  87197. * On intersection enter
  87198. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87199. */
  87200. static readonly OnIntersectionEnterTrigger: number;
  87201. /**
  87202. * On intersection exit
  87203. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87204. */
  87205. static readonly OnIntersectionExitTrigger: number;
  87206. /**
  87207. * On key down
  87208. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87209. */
  87210. static readonly OnKeyDownTrigger: number;
  87211. /**
  87212. * On key up
  87213. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87214. */
  87215. static readonly OnKeyUpTrigger: number;
  87216. private _scene;
  87217. /**
  87218. * Creates a new action manager
  87219. * @param scene defines the hosting scene
  87220. */
  87221. constructor(scene: Scene);
  87222. /**
  87223. * Releases all associated resources
  87224. */
  87225. dispose(): void;
  87226. /**
  87227. * Gets hosting scene
  87228. * @returns the hosting scene
  87229. */
  87230. getScene(): Scene;
  87231. /**
  87232. * Does this action manager handles actions of any of the given triggers
  87233. * @param triggers defines the triggers to be tested
  87234. * @return a boolean indicating whether one (or more) of the triggers is handled
  87235. */
  87236. hasSpecificTriggers(triggers: number[]): boolean;
  87237. /**
  87238. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  87239. * speed.
  87240. * @param triggerA defines the trigger to be tested
  87241. * @param triggerB defines the trigger to be tested
  87242. * @return a boolean indicating whether one (or more) of the triggers is handled
  87243. */
  87244. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  87245. /**
  87246. * Does this action manager handles actions of a given trigger
  87247. * @param trigger defines the trigger to be tested
  87248. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  87249. * @return whether the trigger is handled
  87250. */
  87251. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  87252. /**
  87253. * Does this action manager has pointer triggers
  87254. */
  87255. get hasPointerTriggers(): boolean;
  87256. /**
  87257. * Does this action manager has pick triggers
  87258. */
  87259. get hasPickTriggers(): boolean;
  87260. /**
  87261. * Registers an action to this action manager
  87262. * @param action defines the action to be registered
  87263. * @return the action amended (prepared) after registration
  87264. */
  87265. registerAction(action: IAction): Nullable<IAction>;
  87266. /**
  87267. * Unregisters an action to this action manager
  87268. * @param action defines the action to be unregistered
  87269. * @return a boolean indicating whether the action has been unregistered
  87270. */
  87271. unregisterAction(action: IAction): Boolean;
  87272. /**
  87273. * Process a specific trigger
  87274. * @param trigger defines the trigger to process
  87275. * @param evt defines the event details to be processed
  87276. */
  87277. processTrigger(trigger: number, evt?: IActionEvent): void;
  87278. /** @hidden */
  87279. _getEffectiveTarget(target: any, propertyPath: string): any;
  87280. /** @hidden */
  87281. _getProperty(propertyPath: string): string;
  87282. /**
  87283. * Serialize this manager to a JSON object
  87284. * @param name defines the property name to store this manager
  87285. * @returns a JSON representation of this manager
  87286. */
  87287. serialize(name: string): any;
  87288. /**
  87289. * Creates a new ActionManager from a JSON data
  87290. * @param parsedActions defines the JSON data to read from
  87291. * @param object defines the hosting mesh
  87292. * @param scene defines the hosting scene
  87293. */
  87294. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  87295. /**
  87296. * Get a trigger name by index
  87297. * @param trigger defines the trigger index
  87298. * @returns a trigger name
  87299. */
  87300. static GetTriggerName(trigger: number): string;
  87301. }
  87302. }
  87303. declare module BABYLON {
  87304. /**
  87305. * Class used to represent a sprite
  87306. * @see http://doc.babylonjs.com/babylon101/sprites
  87307. */
  87308. export class Sprite implements IAnimatable {
  87309. /** defines the name */
  87310. name: string;
  87311. /** Gets or sets the current world position */
  87312. position: Vector3;
  87313. /** Gets or sets the main color */
  87314. color: Color4;
  87315. /** Gets or sets the width */
  87316. width: number;
  87317. /** Gets or sets the height */
  87318. height: number;
  87319. /** Gets or sets rotation angle */
  87320. angle: number;
  87321. /** Gets or sets the cell index in the sprite sheet */
  87322. cellIndex: number;
  87323. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  87324. cellRef: string;
  87325. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  87326. invertU: boolean;
  87327. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  87328. invertV: boolean;
  87329. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  87330. disposeWhenFinishedAnimating: boolean;
  87331. /** Gets the list of attached animations */
  87332. animations: Nullable<Array<Animation>>;
  87333. /** Gets or sets a boolean indicating if the sprite can be picked */
  87334. isPickable: boolean;
  87335. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  87336. useAlphaForPicking: boolean;
  87337. /** @hidden */
  87338. _xOffset: number;
  87339. /** @hidden */
  87340. _yOffset: number;
  87341. /** @hidden */
  87342. _xSize: number;
  87343. /** @hidden */
  87344. _ySize: number;
  87345. /**
  87346. * Gets or sets the associated action manager
  87347. */
  87348. actionManager: Nullable<ActionManager>;
  87349. /**
  87350. * An event triggered when the control has been disposed
  87351. */
  87352. onDisposeObservable: Observable<Sprite>;
  87353. private _animationStarted;
  87354. private _loopAnimation;
  87355. private _fromIndex;
  87356. private _toIndex;
  87357. private _delay;
  87358. private _direction;
  87359. private _manager;
  87360. private _time;
  87361. private _onAnimationEnd;
  87362. /**
  87363. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  87364. */
  87365. isVisible: boolean;
  87366. /**
  87367. * Gets or sets the sprite size
  87368. */
  87369. get size(): number;
  87370. set size(value: number);
  87371. /**
  87372. * Returns a boolean indicating if the animation is started
  87373. */
  87374. get animationStarted(): boolean;
  87375. /**
  87376. * Gets or sets the unique id of the sprite
  87377. */
  87378. uniqueId: number;
  87379. /**
  87380. * Gets the manager of this sprite
  87381. */
  87382. get manager(): ISpriteManager;
  87383. /**
  87384. * Creates a new Sprite
  87385. * @param name defines the name
  87386. * @param manager defines the manager
  87387. */
  87388. constructor(
  87389. /** defines the name */
  87390. name: string, manager: ISpriteManager);
  87391. /**
  87392. * Returns the string "Sprite"
  87393. * @returns "Sprite"
  87394. */
  87395. getClassName(): string;
  87396. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  87397. get fromIndex(): number;
  87398. set fromIndex(value: number);
  87399. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  87400. get toIndex(): number;
  87401. set toIndex(value: number);
  87402. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  87403. get loopAnimation(): boolean;
  87404. set loopAnimation(value: boolean);
  87405. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  87406. get delay(): number;
  87407. set delay(value: number);
  87408. /**
  87409. * Starts an animation
  87410. * @param from defines the initial key
  87411. * @param to defines the end key
  87412. * @param loop defines if the animation must loop
  87413. * @param delay defines the start delay (in ms)
  87414. * @param onAnimationEnd defines a callback to call when animation ends
  87415. */
  87416. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  87417. /** Stops current animation (if any) */
  87418. stopAnimation(): void;
  87419. /** @hidden */
  87420. _animate(deltaTime: number): void;
  87421. /** Release associated resources */
  87422. dispose(): void;
  87423. /**
  87424. * Serializes the sprite to a JSON object
  87425. * @returns the JSON object
  87426. */
  87427. serialize(): any;
  87428. /**
  87429. * Parses a JSON object to create a new sprite
  87430. * @param parsedSprite The JSON object to parse
  87431. * @param manager defines the hosting manager
  87432. * @returns the new sprite
  87433. */
  87434. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  87435. }
  87436. }
  87437. declare module BABYLON {
  87438. /**
  87439. * Information about the result of picking within a scene
  87440. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  87441. */
  87442. export class PickingInfo {
  87443. /** @hidden */
  87444. _pickingUnavailable: boolean;
  87445. /**
  87446. * If the pick collided with an object
  87447. */
  87448. hit: boolean;
  87449. /**
  87450. * Distance away where the pick collided
  87451. */
  87452. distance: number;
  87453. /**
  87454. * The location of pick collision
  87455. */
  87456. pickedPoint: Nullable<Vector3>;
  87457. /**
  87458. * The mesh corresponding the the pick collision
  87459. */
  87460. pickedMesh: Nullable<AbstractMesh>;
  87461. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  87462. bu: number;
  87463. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  87464. bv: number;
  87465. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  87466. faceId: number;
  87467. /** Id of the the submesh that was picked */
  87468. subMeshId: number;
  87469. /** If a sprite was picked, this will be the sprite the pick collided with */
  87470. pickedSprite: Nullable<Sprite>;
  87471. /**
  87472. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  87473. */
  87474. originMesh: Nullable<AbstractMesh>;
  87475. /**
  87476. * The ray that was used to perform the picking.
  87477. */
  87478. ray: Nullable<Ray>;
  87479. /**
  87480. * Gets the normal correspodning to the face the pick collided with
  87481. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  87482. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  87483. * @returns The normal correspodning to the face the pick collided with
  87484. */
  87485. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  87486. /**
  87487. * Gets the texture coordinates of where the pick occured
  87488. * @returns the vector containing the coordnates of the texture
  87489. */
  87490. getTextureCoordinates(): Nullable<Vector2>;
  87491. }
  87492. }
  87493. declare module BABYLON {
  87494. /**
  87495. * Class representing a ray with position and direction
  87496. */
  87497. export class Ray {
  87498. /** origin point */
  87499. origin: Vector3;
  87500. /** direction */
  87501. direction: Vector3;
  87502. /** length of the ray */
  87503. length: number;
  87504. private static readonly TmpVector3;
  87505. private _tmpRay;
  87506. /**
  87507. * Creates a new ray
  87508. * @param origin origin point
  87509. * @param direction direction
  87510. * @param length length of the ray
  87511. */
  87512. constructor(
  87513. /** origin point */
  87514. origin: Vector3,
  87515. /** direction */
  87516. direction: Vector3,
  87517. /** length of the ray */
  87518. length?: number);
  87519. /**
  87520. * Checks if the ray intersects a box
  87521. * This does not account for the ray lenght by design to improve perfs.
  87522. * @param minimum bound of the box
  87523. * @param maximum bound of the box
  87524. * @param intersectionTreshold extra extend to be added to the box in all direction
  87525. * @returns if the box was hit
  87526. */
  87527. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  87528. /**
  87529. * Checks if the ray intersects a box
  87530. * This does not account for the ray lenght by design to improve perfs.
  87531. * @param box the bounding box to check
  87532. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  87533. * @returns if the box was hit
  87534. */
  87535. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  87536. /**
  87537. * If the ray hits a sphere
  87538. * @param sphere the bounding sphere to check
  87539. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  87540. * @returns true if it hits the sphere
  87541. */
  87542. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  87543. /**
  87544. * If the ray hits a triange
  87545. * @param vertex0 triangle vertex
  87546. * @param vertex1 triangle vertex
  87547. * @param vertex2 triangle vertex
  87548. * @returns intersection information if hit
  87549. */
  87550. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  87551. /**
  87552. * Checks if ray intersects a plane
  87553. * @param plane the plane to check
  87554. * @returns the distance away it was hit
  87555. */
  87556. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  87557. /**
  87558. * Calculate the intercept of a ray on a given axis
  87559. * @param axis to check 'x' | 'y' | 'z'
  87560. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  87561. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  87562. */
  87563. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  87564. /**
  87565. * Checks if ray intersects a mesh
  87566. * @param mesh the mesh to check
  87567. * @param fastCheck defines if the first intersection will be used (and not the closest)
  87568. * @returns picking info of the intersecton
  87569. */
  87570. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  87571. /**
  87572. * Checks if ray intersects a mesh
  87573. * @param meshes the meshes to check
  87574. * @param fastCheck defines if the first intersection will be used (and not the closest)
  87575. * @param results array to store result in
  87576. * @returns Array of picking infos
  87577. */
  87578. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  87579. private _comparePickingInfo;
  87580. private static smallnum;
  87581. private static rayl;
  87582. /**
  87583. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  87584. * @param sega the first point of the segment to test the intersection against
  87585. * @param segb the second point of the segment to test the intersection against
  87586. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  87587. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  87588. */
  87589. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  87590. /**
  87591. * Update the ray from viewport position
  87592. * @param x position
  87593. * @param y y position
  87594. * @param viewportWidth viewport width
  87595. * @param viewportHeight viewport height
  87596. * @param world world matrix
  87597. * @param view view matrix
  87598. * @param projection projection matrix
  87599. * @returns this ray updated
  87600. */
  87601. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  87602. /**
  87603. * Creates a ray with origin and direction of 0,0,0
  87604. * @returns the new ray
  87605. */
  87606. static Zero(): Ray;
  87607. /**
  87608. * Creates a new ray from screen space and viewport
  87609. * @param x position
  87610. * @param y y position
  87611. * @param viewportWidth viewport width
  87612. * @param viewportHeight viewport height
  87613. * @param world world matrix
  87614. * @param view view matrix
  87615. * @param projection projection matrix
  87616. * @returns new ray
  87617. */
  87618. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  87619. /**
  87620. * 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
  87621. * transformed to the given world matrix.
  87622. * @param origin The origin point
  87623. * @param end The end point
  87624. * @param world a matrix to transform the ray to. Default is the identity matrix.
  87625. * @returns the new ray
  87626. */
  87627. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  87628. /**
  87629. * Transforms a ray by a matrix
  87630. * @param ray ray to transform
  87631. * @param matrix matrix to apply
  87632. * @returns the resulting new ray
  87633. */
  87634. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  87635. /**
  87636. * Transforms a ray by a matrix
  87637. * @param ray ray to transform
  87638. * @param matrix matrix to apply
  87639. * @param result ray to store result in
  87640. */
  87641. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  87642. /**
  87643. * Unproject a ray from screen space to object space
  87644. * @param sourceX defines the screen space x coordinate to use
  87645. * @param sourceY defines the screen space y coordinate to use
  87646. * @param viewportWidth defines the current width of the viewport
  87647. * @param viewportHeight defines the current height of the viewport
  87648. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  87649. * @param view defines the view matrix to use
  87650. * @param projection defines the projection matrix to use
  87651. */
  87652. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  87653. }
  87654. /**
  87655. * Type used to define predicate used to select faces when a mesh intersection is detected
  87656. */
  87657. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  87658. interface Scene {
  87659. /** @hidden */
  87660. _tempPickingRay: Nullable<Ray>;
  87661. /** @hidden */
  87662. _cachedRayForTransform: Ray;
  87663. /** @hidden */
  87664. _pickWithRayInverseMatrix: Matrix;
  87665. /** @hidden */
  87666. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  87667. /** @hidden */
  87668. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  87669. }
  87670. }
  87671. declare module BABYLON {
  87672. /**
  87673. * Groups all the scene component constants in one place to ease maintenance.
  87674. * @hidden
  87675. */
  87676. export class SceneComponentConstants {
  87677. static readonly NAME_EFFECTLAYER: string;
  87678. static readonly NAME_LAYER: string;
  87679. static readonly NAME_LENSFLARESYSTEM: string;
  87680. static readonly NAME_BOUNDINGBOXRENDERER: string;
  87681. static readonly NAME_PARTICLESYSTEM: string;
  87682. static readonly NAME_GAMEPAD: string;
  87683. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  87684. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  87685. static readonly NAME_DEPTHRENDERER: string;
  87686. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  87687. static readonly NAME_SPRITE: string;
  87688. static readonly NAME_OUTLINERENDERER: string;
  87689. static readonly NAME_PROCEDURALTEXTURE: string;
  87690. static readonly NAME_SHADOWGENERATOR: string;
  87691. static readonly NAME_OCTREE: string;
  87692. static readonly NAME_PHYSICSENGINE: string;
  87693. static readonly NAME_AUDIO: string;
  87694. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  87695. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  87696. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  87697. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  87698. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  87699. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  87700. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  87701. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  87702. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  87703. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  87704. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  87705. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  87706. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  87707. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  87708. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  87709. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  87710. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  87711. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  87712. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  87713. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  87714. static readonly STEP_AFTERRENDER_AUDIO: number;
  87715. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  87716. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  87717. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  87718. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  87719. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  87720. static readonly STEP_POINTERMOVE_SPRITE: number;
  87721. static readonly STEP_POINTERDOWN_SPRITE: number;
  87722. static readonly STEP_POINTERUP_SPRITE: number;
  87723. }
  87724. /**
  87725. * This represents a scene component.
  87726. *
  87727. * This is used to decouple the dependency the scene is having on the different workloads like
  87728. * layers, post processes...
  87729. */
  87730. export interface ISceneComponent {
  87731. /**
  87732. * The name of the component. Each component must have a unique name.
  87733. */
  87734. name: string;
  87735. /**
  87736. * The scene the component belongs to.
  87737. */
  87738. scene: Scene;
  87739. /**
  87740. * Register the component to one instance of a scene.
  87741. */
  87742. register(): void;
  87743. /**
  87744. * Rebuilds the elements related to this component in case of
  87745. * context lost for instance.
  87746. */
  87747. rebuild(): void;
  87748. /**
  87749. * Disposes the component and the associated ressources.
  87750. */
  87751. dispose(): void;
  87752. }
  87753. /**
  87754. * This represents a SERIALIZABLE scene component.
  87755. *
  87756. * This extends Scene Component to add Serialization methods on top.
  87757. */
  87758. export interface ISceneSerializableComponent extends ISceneComponent {
  87759. /**
  87760. * Adds all the elements from the container to the scene
  87761. * @param container the container holding the elements
  87762. */
  87763. addFromContainer(container: AbstractScene): void;
  87764. /**
  87765. * Removes all the elements in the container from the scene
  87766. * @param container contains the elements to remove
  87767. * @param dispose if the removed element should be disposed (default: false)
  87768. */
  87769. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  87770. /**
  87771. * Serializes the component data to the specified json object
  87772. * @param serializationObject The object to serialize to
  87773. */
  87774. serialize(serializationObject: any): void;
  87775. }
  87776. /**
  87777. * Strong typing of a Mesh related stage step action
  87778. */
  87779. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  87780. /**
  87781. * Strong typing of a Evaluate Sub Mesh related stage step action
  87782. */
  87783. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  87784. /**
  87785. * Strong typing of a Active Mesh related stage step action
  87786. */
  87787. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  87788. /**
  87789. * Strong typing of a Camera related stage step action
  87790. */
  87791. export type CameraStageAction = (camera: Camera) => void;
  87792. /**
  87793. * Strong typing of a Camera Frame buffer related stage step action
  87794. */
  87795. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  87796. /**
  87797. * Strong typing of a Render Target related stage step action
  87798. */
  87799. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  87800. /**
  87801. * Strong typing of a RenderingGroup related stage step action
  87802. */
  87803. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  87804. /**
  87805. * Strong typing of a Mesh Render related stage step action
  87806. */
  87807. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  87808. /**
  87809. * Strong typing of a simple stage step action
  87810. */
  87811. export type SimpleStageAction = () => void;
  87812. /**
  87813. * Strong typing of a render target action.
  87814. */
  87815. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  87816. /**
  87817. * Strong typing of a pointer move action.
  87818. */
  87819. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  87820. /**
  87821. * Strong typing of a pointer up/down action.
  87822. */
  87823. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  87824. /**
  87825. * Representation of a stage in the scene (Basically a list of ordered steps)
  87826. * @hidden
  87827. */
  87828. export class Stage<T extends Function> extends Array<{
  87829. index: number;
  87830. component: ISceneComponent;
  87831. action: T;
  87832. }> {
  87833. /**
  87834. * Hide ctor from the rest of the world.
  87835. * @param items The items to add.
  87836. */
  87837. private constructor();
  87838. /**
  87839. * Creates a new Stage.
  87840. * @returns A new instance of a Stage
  87841. */
  87842. static Create<T extends Function>(): Stage<T>;
  87843. /**
  87844. * Registers a step in an ordered way in the targeted stage.
  87845. * @param index Defines the position to register the step in
  87846. * @param component Defines the component attached to the step
  87847. * @param action Defines the action to launch during the step
  87848. */
  87849. registerStep(index: number, component: ISceneComponent, action: T): void;
  87850. /**
  87851. * Clears all the steps from the stage.
  87852. */
  87853. clear(): void;
  87854. }
  87855. }
  87856. declare module BABYLON {
  87857. interface Scene {
  87858. /** @hidden */
  87859. _pointerOverSprite: Nullable<Sprite>;
  87860. /** @hidden */
  87861. _pickedDownSprite: Nullable<Sprite>;
  87862. /** @hidden */
  87863. _tempSpritePickingRay: Nullable<Ray>;
  87864. /**
  87865. * All of the sprite managers added to this scene
  87866. * @see http://doc.babylonjs.com/babylon101/sprites
  87867. */
  87868. spriteManagers: Array<ISpriteManager>;
  87869. /**
  87870. * An event triggered when sprites rendering is about to start
  87871. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  87872. */
  87873. onBeforeSpritesRenderingObservable: Observable<Scene>;
  87874. /**
  87875. * An event triggered when sprites rendering is done
  87876. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  87877. */
  87878. onAfterSpritesRenderingObservable: Observable<Scene>;
  87879. /** @hidden */
  87880. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  87881. /** Launch a ray to try to pick a sprite in the scene
  87882. * @param x position on screen
  87883. * @param y position on screen
  87884. * @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
  87885. * @param fastCheck defines if the first intersection will be used (and not the closest)
  87886. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  87887. * @returns a PickingInfo
  87888. */
  87889. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  87890. /** Use the given ray to pick a sprite in the scene
  87891. * @param ray The ray (in world space) to use to pick meshes
  87892. * @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
  87893. * @param fastCheck defines if the first intersection will be used (and not the closest)
  87894. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  87895. * @returns a PickingInfo
  87896. */
  87897. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  87898. /** @hidden */
  87899. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  87900. /** Launch a ray to try to pick sprites in the scene
  87901. * @param x position on screen
  87902. * @param y position on screen
  87903. * @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
  87904. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  87905. * @returns a PickingInfo array
  87906. */
  87907. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  87908. /** Use the given ray to pick sprites in the scene
  87909. * @param ray The ray (in world space) to use to pick meshes
  87910. * @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
  87911. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  87912. * @returns a PickingInfo array
  87913. */
  87914. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  87915. /**
  87916. * Force the sprite under the pointer
  87917. * @param sprite defines the sprite to use
  87918. */
  87919. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  87920. /**
  87921. * Gets the sprite under the pointer
  87922. * @returns a Sprite or null if no sprite is under the pointer
  87923. */
  87924. getPointerOverSprite(): Nullable<Sprite>;
  87925. }
  87926. /**
  87927. * Defines the sprite scene component responsible to manage sprites
  87928. * in a given scene.
  87929. */
  87930. export class SpriteSceneComponent implements ISceneComponent {
  87931. /**
  87932. * The component name helpfull to identify the component in the list of scene components.
  87933. */
  87934. readonly name: string;
  87935. /**
  87936. * The scene the component belongs to.
  87937. */
  87938. scene: Scene;
  87939. /** @hidden */
  87940. private _spritePredicate;
  87941. /**
  87942. * Creates a new instance of the component for the given scene
  87943. * @param scene Defines the scene to register the component in
  87944. */
  87945. constructor(scene: Scene);
  87946. /**
  87947. * Registers the component in a given scene
  87948. */
  87949. register(): void;
  87950. /**
  87951. * Rebuilds the elements related to this component in case of
  87952. * context lost for instance.
  87953. */
  87954. rebuild(): void;
  87955. /**
  87956. * Disposes the component and the associated ressources.
  87957. */
  87958. dispose(): void;
  87959. private _pickSpriteButKeepRay;
  87960. private _pointerMove;
  87961. private _pointerDown;
  87962. private _pointerUp;
  87963. }
  87964. }
  87965. declare module BABYLON {
  87966. /** @hidden */
  87967. export var fogFragmentDeclaration: {
  87968. name: string;
  87969. shader: string;
  87970. };
  87971. }
  87972. declare module BABYLON {
  87973. /** @hidden */
  87974. export var fogFragment: {
  87975. name: string;
  87976. shader: string;
  87977. };
  87978. }
  87979. declare module BABYLON {
  87980. /** @hidden */
  87981. export var spritesPixelShader: {
  87982. name: string;
  87983. shader: string;
  87984. };
  87985. }
  87986. declare module BABYLON {
  87987. /** @hidden */
  87988. export var fogVertexDeclaration: {
  87989. name: string;
  87990. shader: string;
  87991. };
  87992. }
  87993. declare module BABYLON {
  87994. /** @hidden */
  87995. export var spritesVertexShader: {
  87996. name: string;
  87997. shader: string;
  87998. };
  87999. }
  88000. declare module BABYLON {
  88001. /**
  88002. * Defines the minimum interface to fullfil in order to be a sprite manager.
  88003. */
  88004. export interface ISpriteManager extends IDisposable {
  88005. /**
  88006. * Gets manager's name
  88007. */
  88008. name: string;
  88009. /**
  88010. * Restricts the camera to viewing objects with the same layerMask.
  88011. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  88012. */
  88013. layerMask: number;
  88014. /**
  88015. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  88016. */
  88017. isPickable: boolean;
  88018. /**
  88019. * Gets the hosting scene
  88020. */
  88021. scene: Scene;
  88022. /**
  88023. * Specifies the rendering group id for this mesh (0 by default)
  88024. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  88025. */
  88026. renderingGroupId: number;
  88027. /**
  88028. * Defines the list of sprites managed by the manager.
  88029. */
  88030. sprites: Array<Sprite>;
  88031. /**
  88032. * Gets or sets the spritesheet texture
  88033. */
  88034. texture: Texture;
  88035. /** Defines the default width of a cell in the spritesheet */
  88036. cellWidth: number;
  88037. /** Defines the default height of a cell in the spritesheet */
  88038. cellHeight: number;
  88039. /**
  88040. * Tests the intersection of a sprite with a specific ray.
  88041. * @param ray The ray we are sending to test the collision
  88042. * @param camera The camera space we are sending rays in
  88043. * @param predicate A predicate allowing excluding sprites from the list of object to test
  88044. * @param fastCheck defines if the first intersection will be used (and not the closest)
  88045. * @returns picking info or null.
  88046. */
  88047. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  88048. /**
  88049. * Intersects the sprites with a ray
  88050. * @param ray defines the ray to intersect with
  88051. * @param camera defines the current active camera
  88052. * @param predicate defines a predicate used to select candidate sprites
  88053. * @returns null if no hit or a PickingInfo array
  88054. */
  88055. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  88056. /**
  88057. * Renders the list of sprites on screen.
  88058. */
  88059. render(): void;
  88060. }
  88061. /**
  88062. * Class used to manage multiple sprites on the same spritesheet
  88063. * @see http://doc.babylonjs.com/babylon101/sprites
  88064. */
  88065. export class SpriteManager implements ISpriteManager {
  88066. /** defines the manager's name */
  88067. name: string;
  88068. /** Define the Url to load snippets */
  88069. static SnippetUrl: string;
  88070. /** Snippet ID if the manager was created from the snippet server */
  88071. snippetId: string;
  88072. /** Gets the list of sprites */
  88073. sprites: Sprite[];
  88074. /** Gets or sets the rendering group id (0 by default) */
  88075. renderingGroupId: number;
  88076. /** Gets or sets camera layer mask */
  88077. layerMask: number;
  88078. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  88079. fogEnabled: boolean;
  88080. /** Gets or sets a boolean indicating if the sprites are pickable */
  88081. isPickable: boolean;
  88082. /** Defines the default width of a cell in the spritesheet */
  88083. cellWidth: number;
  88084. /** Defines the default height of a cell in the spritesheet */
  88085. cellHeight: number;
  88086. /** Associative array from JSON sprite data file */
  88087. private _cellData;
  88088. /** Array of sprite names from JSON sprite data file */
  88089. private _spriteMap;
  88090. /** True when packed cell data from JSON file is ready*/
  88091. private _packedAndReady;
  88092. private _textureContent;
  88093. /**
  88094. * An event triggered when the manager is disposed.
  88095. */
  88096. onDisposeObservable: Observable<SpriteManager>;
  88097. private _onDisposeObserver;
  88098. /**
  88099. * Callback called when the manager is disposed
  88100. */
  88101. set onDispose(callback: () => void);
  88102. private _capacity;
  88103. private _fromPacked;
  88104. private _spriteTexture;
  88105. private _epsilon;
  88106. private _scene;
  88107. private _vertexData;
  88108. private _buffer;
  88109. private _vertexBuffers;
  88110. private _indexBuffer;
  88111. private _effectBase;
  88112. private _effectFog;
  88113. /**
  88114. * Gets or sets the unique id of the sprite
  88115. */
  88116. uniqueId: number;
  88117. /**
  88118. * Gets the array of sprites
  88119. */
  88120. get children(): Sprite[];
  88121. /**
  88122. * Gets the hosting scene
  88123. */
  88124. get scene(): Scene;
  88125. /**
  88126. * Gets the capacity of the manager
  88127. */
  88128. get capacity(): number;
  88129. /**
  88130. * Gets or sets the spritesheet texture
  88131. */
  88132. get texture(): Texture;
  88133. set texture(value: Texture);
  88134. private _blendMode;
  88135. /**
  88136. * Blend mode use to render the particle, it can be any of
  88137. * the static Constants.ALPHA_x properties provided in this class.
  88138. * Default value is Constants.ALPHA_COMBINE
  88139. */
  88140. get blendMode(): number;
  88141. set blendMode(blendMode: number);
  88142. /** Disables writing to the depth buffer when rendering the sprites.
  88143. * It can be handy to disable depth writing when using textures without alpha channel
  88144. * and setting some specific blend modes.
  88145. */
  88146. disableDepthWrite: boolean;
  88147. /**
  88148. * Creates a new sprite manager
  88149. * @param name defines the manager's name
  88150. * @param imgUrl defines the sprite sheet url
  88151. * @param capacity defines the maximum allowed number of sprites
  88152. * @param cellSize defines the size of a sprite cell
  88153. * @param scene defines the hosting scene
  88154. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  88155. * @param samplingMode defines the smapling mode to use with spritesheet
  88156. * @param fromPacked set to false; do not alter
  88157. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  88158. */
  88159. constructor(
  88160. /** defines the manager's name */
  88161. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  88162. /**
  88163. * Returns the string "SpriteManager"
  88164. * @returns "SpriteManager"
  88165. */
  88166. getClassName(): string;
  88167. private _makePacked;
  88168. private _appendSpriteVertex;
  88169. private _checkTextureAlpha;
  88170. /**
  88171. * Intersects the sprites with a ray
  88172. * @param ray defines the ray to intersect with
  88173. * @param camera defines the current active camera
  88174. * @param predicate defines a predicate used to select candidate sprites
  88175. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  88176. * @returns null if no hit or a PickingInfo
  88177. */
  88178. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  88179. /**
  88180. * Intersects the sprites with a ray
  88181. * @param ray defines the ray to intersect with
  88182. * @param camera defines the current active camera
  88183. * @param predicate defines a predicate used to select candidate sprites
  88184. * @returns null if no hit or a PickingInfo array
  88185. */
  88186. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  88187. /**
  88188. * Render all child sprites
  88189. */
  88190. render(): void;
  88191. /**
  88192. * Release associated resources
  88193. */
  88194. dispose(): void;
  88195. /**
  88196. * Serializes the sprite manager to a JSON object
  88197. * @param serializeTexture defines if the texture must be serialized as well
  88198. * @returns the JSON object
  88199. */
  88200. serialize(serializeTexture?: boolean): any;
  88201. /**
  88202. * Parses a JSON object to create a new sprite manager.
  88203. * @param parsedManager The JSON object to parse
  88204. * @param scene The scene to create the sprite managerin
  88205. * @param rootUrl The root url to use to load external dependencies like texture
  88206. * @returns the new sprite manager
  88207. */
  88208. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  88209. /**
  88210. * Creates a sprite manager from a snippet saved in a remote file
  88211. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  88212. * @param url defines the url to load from
  88213. * @param scene defines the hosting scene
  88214. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  88215. * @returns a promise that will resolve to the new sprite manager
  88216. */
  88217. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  88218. /**
  88219. * Creates a sprite manager from a snippet saved by the sprite editor
  88220. * @param snippetId defines the snippet to load
  88221. * @param scene defines the hosting scene
  88222. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  88223. * @returns a promise that will resolve to the new sprite manager
  88224. */
  88225. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  88226. }
  88227. }
  88228. declare module BABYLON {
  88229. /** Interface used by value gradients (color, factor, ...) */
  88230. export interface IValueGradient {
  88231. /**
  88232. * Gets or sets the gradient value (between 0 and 1)
  88233. */
  88234. gradient: number;
  88235. }
  88236. /** Class used to store color4 gradient */
  88237. export class ColorGradient implements IValueGradient {
  88238. /**
  88239. * Gets or sets the gradient value (between 0 and 1)
  88240. */
  88241. gradient: number;
  88242. /**
  88243. * Gets or sets first associated color
  88244. */
  88245. color1: Color4;
  88246. /**
  88247. * Gets or sets second associated color
  88248. */
  88249. color2?: Color4 | undefined;
  88250. /**
  88251. * Creates a new color4 gradient
  88252. * @param gradient gets or sets the gradient value (between 0 and 1)
  88253. * @param color1 gets or sets first associated color
  88254. * @param color2 gets or sets first second color
  88255. */
  88256. constructor(
  88257. /**
  88258. * Gets or sets the gradient value (between 0 and 1)
  88259. */
  88260. gradient: number,
  88261. /**
  88262. * Gets or sets first associated color
  88263. */
  88264. color1: Color4,
  88265. /**
  88266. * Gets or sets second associated color
  88267. */
  88268. color2?: Color4 | undefined);
  88269. /**
  88270. * Will get a color picked randomly between color1 and color2.
  88271. * If color2 is undefined then color1 will be used
  88272. * @param result defines the target Color4 to store the result in
  88273. */
  88274. getColorToRef(result: Color4): void;
  88275. }
  88276. /** Class used to store color 3 gradient */
  88277. export class Color3Gradient implements IValueGradient {
  88278. /**
  88279. * Gets or sets the gradient value (between 0 and 1)
  88280. */
  88281. gradient: number;
  88282. /**
  88283. * Gets or sets the associated color
  88284. */
  88285. color: Color3;
  88286. /**
  88287. * Creates a new color3 gradient
  88288. * @param gradient gets or sets the gradient value (between 0 and 1)
  88289. * @param color gets or sets associated color
  88290. */
  88291. constructor(
  88292. /**
  88293. * Gets or sets the gradient value (between 0 and 1)
  88294. */
  88295. gradient: number,
  88296. /**
  88297. * Gets or sets the associated color
  88298. */
  88299. color: Color3);
  88300. }
  88301. /** Class used to store factor gradient */
  88302. export class FactorGradient implements IValueGradient {
  88303. /**
  88304. * Gets or sets the gradient value (between 0 and 1)
  88305. */
  88306. gradient: number;
  88307. /**
  88308. * Gets or sets first associated factor
  88309. */
  88310. factor1: number;
  88311. /**
  88312. * Gets or sets second associated factor
  88313. */
  88314. factor2?: number | undefined;
  88315. /**
  88316. * Creates a new factor gradient
  88317. * @param gradient gets or sets the gradient value (between 0 and 1)
  88318. * @param factor1 gets or sets first associated factor
  88319. * @param factor2 gets or sets second associated factor
  88320. */
  88321. constructor(
  88322. /**
  88323. * Gets or sets the gradient value (between 0 and 1)
  88324. */
  88325. gradient: number,
  88326. /**
  88327. * Gets or sets first associated factor
  88328. */
  88329. factor1: number,
  88330. /**
  88331. * Gets or sets second associated factor
  88332. */
  88333. factor2?: number | undefined);
  88334. /**
  88335. * Will get a number picked randomly between factor1 and factor2.
  88336. * If factor2 is undefined then factor1 will be used
  88337. * @returns the picked number
  88338. */
  88339. getFactor(): number;
  88340. }
  88341. /**
  88342. * Helper used to simplify some generic gradient tasks
  88343. */
  88344. export class GradientHelper {
  88345. /**
  88346. * Gets the current gradient from an array of IValueGradient
  88347. * @param ratio defines the current ratio to get
  88348. * @param gradients defines the array of IValueGradient
  88349. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  88350. */
  88351. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  88352. }
  88353. }
  88354. declare module BABYLON {
  88355. interface ThinEngine {
  88356. /**
  88357. * Creates a dynamic texture
  88358. * @param width defines the width of the texture
  88359. * @param height defines the height of the texture
  88360. * @param generateMipMaps defines if the engine should generate the mip levels
  88361. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  88362. * @returns the dynamic texture inside an InternalTexture
  88363. */
  88364. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  88365. /**
  88366. * Update the content of a dynamic texture
  88367. * @param texture defines the texture to update
  88368. * @param canvas defines the canvas containing the source
  88369. * @param invertY defines if data must be stored with Y axis inverted
  88370. * @param premulAlpha defines if alpha is stored as premultiplied
  88371. * @param format defines the format of the data
  88372. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  88373. */
  88374. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  88375. }
  88376. }
  88377. declare module BABYLON {
  88378. /**
  88379. * Helper class used to generate a canvas to manipulate images
  88380. */
  88381. export class CanvasGenerator {
  88382. /**
  88383. * Create a new canvas (or offscreen canvas depending on the context)
  88384. * @param width defines the expected width
  88385. * @param height defines the expected height
  88386. * @return a new canvas or offscreen canvas
  88387. */
  88388. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  88389. }
  88390. }
  88391. declare module BABYLON {
  88392. /**
  88393. * A class extending Texture allowing drawing on a texture
  88394. * @see http://doc.babylonjs.com/how_to/dynamictexture
  88395. */
  88396. export class DynamicTexture extends Texture {
  88397. private _generateMipMaps;
  88398. private _canvas;
  88399. private _context;
  88400. /**
  88401. * Creates a DynamicTexture
  88402. * @param name defines the name of the texture
  88403. * @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
  88404. * @param scene defines the scene where you want the texture
  88405. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  88406. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  88407. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  88408. */
  88409. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  88410. /**
  88411. * Get the current class name of the texture useful for serialization or dynamic coding.
  88412. * @returns "DynamicTexture"
  88413. */
  88414. getClassName(): string;
  88415. /**
  88416. * Gets the current state of canRescale
  88417. */
  88418. get canRescale(): boolean;
  88419. private _recreate;
  88420. /**
  88421. * Scales the texture
  88422. * @param ratio the scale factor to apply to both width and height
  88423. */
  88424. scale(ratio: number): void;
  88425. /**
  88426. * Resizes the texture
  88427. * @param width the new width
  88428. * @param height the new height
  88429. */
  88430. scaleTo(width: number, height: number): void;
  88431. /**
  88432. * Gets the context of the canvas used by the texture
  88433. * @returns the canvas context of the dynamic texture
  88434. */
  88435. getContext(): CanvasRenderingContext2D;
  88436. /**
  88437. * Clears the texture
  88438. */
  88439. clear(): void;
  88440. /**
  88441. * Updates the texture
  88442. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  88443. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  88444. */
  88445. update(invertY?: boolean, premulAlpha?: boolean): void;
  88446. /**
  88447. * Draws text onto the texture
  88448. * @param text defines the text to be drawn
  88449. * @param x defines the placement of the text from the left
  88450. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  88451. * @param font defines the font to be used with font-style, font-size, font-name
  88452. * @param color defines the color used for the text
  88453. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  88454. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  88455. * @param update defines whether texture is immediately update (default is true)
  88456. */
  88457. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  88458. /**
  88459. * Clones the texture
  88460. * @returns the clone of the texture.
  88461. */
  88462. clone(): DynamicTexture;
  88463. /**
  88464. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  88465. * @returns a serialized dynamic texture object
  88466. */
  88467. serialize(): any;
  88468. /** @hidden */
  88469. _rebuild(): void;
  88470. }
  88471. }
  88472. declare module BABYLON {
  88473. interface ThinEngine {
  88474. /**
  88475. * Creates a raw texture
  88476. * @param data defines the data to store in the texture
  88477. * @param width defines the width of the texture
  88478. * @param height defines the height of the texture
  88479. * @param format defines the format of the data
  88480. * @param generateMipMaps defines if the engine should generate the mip levels
  88481. * @param invertY defines if data must be stored with Y axis inverted
  88482. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  88483. * @param compression defines the compression used (null by default)
  88484. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  88485. * @returns the raw texture inside an InternalTexture
  88486. */
  88487. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  88488. /**
  88489. * Update a raw texture
  88490. * @param texture defines the texture to update
  88491. * @param data defines the data to store in the texture
  88492. * @param format defines the format of the data
  88493. * @param invertY defines if data must be stored with Y axis inverted
  88494. */
  88495. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  88496. /**
  88497. * Update a raw texture
  88498. * @param texture defines the texture to update
  88499. * @param data defines the data to store in the texture
  88500. * @param format defines the format of the data
  88501. * @param invertY defines if data must be stored with Y axis inverted
  88502. * @param compression defines the compression used (null by default)
  88503. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  88504. */
  88505. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  88506. /**
  88507. * Creates a new raw cube texture
  88508. * @param data defines the array of data to use to create each face
  88509. * @param size defines the size of the textures
  88510. * @param format defines the format of the data
  88511. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  88512. * @param generateMipMaps defines if the engine should generate the mip levels
  88513. * @param invertY defines if data must be stored with Y axis inverted
  88514. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  88515. * @param compression defines the compression used (null by default)
  88516. * @returns the cube texture as an InternalTexture
  88517. */
  88518. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  88519. /**
  88520. * Update a raw cube texture
  88521. * @param texture defines the texture to udpdate
  88522. * @param data defines the data to store
  88523. * @param format defines the data format
  88524. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  88525. * @param invertY defines if data must be stored with Y axis inverted
  88526. */
  88527. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  88528. /**
  88529. * Update a raw cube texture
  88530. * @param texture defines the texture to udpdate
  88531. * @param data defines the data to store
  88532. * @param format defines the data format
  88533. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  88534. * @param invertY defines if data must be stored with Y axis inverted
  88535. * @param compression defines the compression used (null by default)
  88536. */
  88537. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  88538. /**
  88539. * Update a raw cube texture
  88540. * @param texture defines the texture to udpdate
  88541. * @param data defines the data to store
  88542. * @param format defines the data format
  88543. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  88544. * @param invertY defines if data must be stored with Y axis inverted
  88545. * @param compression defines the compression used (null by default)
  88546. * @param level defines which level of the texture to update
  88547. */
  88548. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  88549. /**
  88550. * Creates a new raw cube texture from a specified url
  88551. * @param url defines the url where the data is located
  88552. * @param scene defines the current scene
  88553. * @param size defines the size of the textures
  88554. * @param format defines the format of the data
  88555. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  88556. * @param noMipmap defines if the engine should avoid generating the mip levels
  88557. * @param callback defines a callback used to extract texture data from loaded data
  88558. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  88559. * @param onLoad defines a callback called when texture is loaded
  88560. * @param onError defines a callback called if there is an error
  88561. * @returns the cube texture as an InternalTexture
  88562. */
  88563. 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;
  88564. /**
  88565. * Creates a new raw cube texture from a specified url
  88566. * @param url defines the url where the data is located
  88567. * @param scene defines the current scene
  88568. * @param size defines the size of the textures
  88569. * @param format defines the format of the data
  88570. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  88571. * @param noMipmap defines if the engine should avoid generating the mip levels
  88572. * @param callback defines a callback used to extract texture data from loaded data
  88573. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  88574. * @param onLoad defines a callback called when texture is loaded
  88575. * @param onError defines a callback called if there is an error
  88576. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  88577. * @param invertY defines if data must be stored with Y axis inverted
  88578. * @returns the cube texture as an InternalTexture
  88579. */
  88580. 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;
  88581. /**
  88582. * Creates a new raw 3D texture
  88583. * @param data defines the data used to create the texture
  88584. * @param width defines the width of the texture
  88585. * @param height defines the height of the texture
  88586. * @param depth defines the depth of the texture
  88587. * @param format defines the format of the texture
  88588. * @param generateMipMaps defines if the engine must generate mip levels
  88589. * @param invertY defines if data must be stored with Y axis inverted
  88590. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  88591. * @param compression defines the compressed used (can be null)
  88592. * @param textureType defines the compressed used (can be null)
  88593. * @returns a new raw 3D texture (stored in an InternalTexture)
  88594. */
  88595. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  88596. /**
  88597. * Update a raw 3D texture
  88598. * @param texture defines the texture to update
  88599. * @param data defines the data to store
  88600. * @param format defines the data format
  88601. * @param invertY defines if data must be stored with Y axis inverted
  88602. */
  88603. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  88604. /**
  88605. * Update a raw 3D texture
  88606. * @param texture defines the texture to update
  88607. * @param data defines the data to store
  88608. * @param format defines the data format
  88609. * @param invertY defines if data must be stored with Y axis inverted
  88610. * @param compression defines the used compression (can be null)
  88611. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  88612. */
  88613. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  88614. /**
  88615. * Creates a new raw 2D array texture
  88616. * @param data defines the data used to create the texture
  88617. * @param width defines the width of the texture
  88618. * @param height defines the height of the texture
  88619. * @param depth defines the number of layers of the texture
  88620. * @param format defines the format of the texture
  88621. * @param generateMipMaps defines if the engine must generate mip levels
  88622. * @param invertY defines if data must be stored with Y axis inverted
  88623. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  88624. * @param compression defines the compressed used (can be null)
  88625. * @param textureType defines the compressed used (can be null)
  88626. * @returns a new raw 2D array texture (stored in an InternalTexture)
  88627. */
  88628. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  88629. /**
  88630. * Update a raw 2D array texture
  88631. * @param texture defines the texture to update
  88632. * @param data defines the data to store
  88633. * @param format defines the data format
  88634. * @param invertY defines if data must be stored with Y axis inverted
  88635. */
  88636. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  88637. /**
  88638. * Update a raw 2D array texture
  88639. * @param texture defines the texture to update
  88640. * @param data defines the data to store
  88641. * @param format defines the data format
  88642. * @param invertY defines if data must be stored with Y axis inverted
  88643. * @param compression defines the used compression (can be null)
  88644. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  88645. */
  88646. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  88647. }
  88648. }
  88649. declare module BABYLON {
  88650. /**
  88651. * Raw texture can help creating a texture directly from an array of data.
  88652. * This can be super useful if you either get the data from an uncompressed source or
  88653. * if you wish to create your texture pixel by pixel.
  88654. */
  88655. export class RawTexture extends Texture {
  88656. /**
  88657. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  88658. */
  88659. format: number;
  88660. /**
  88661. * Instantiates a new RawTexture.
  88662. * Raw texture can help creating a texture directly from an array of data.
  88663. * This can be super useful if you either get the data from an uncompressed source or
  88664. * if you wish to create your texture pixel by pixel.
  88665. * @param data define the array of data to use to create the texture
  88666. * @param width define the width of the texture
  88667. * @param height define the height of the texture
  88668. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  88669. * @param scene define the scene the texture belongs to
  88670. * @param generateMipMaps define whether mip maps should be generated or not
  88671. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  88672. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  88673. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  88674. */
  88675. constructor(data: ArrayBufferView, width: number, height: number,
  88676. /**
  88677. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  88678. */
  88679. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  88680. /**
  88681. * Updates the texture underlying data.
  88682. * @param data Define the new data of the texture
  88683. */
  88684. update(data: ArrayBufferView): void;
  88685. /**
  88686. * Creates a luminance texture from some data.
  88687. * @param data Define the texture data
  88688. * @param width Define the width of the texture
  88689. * @param height Define the height of the texture
  88690. * @param scene Define the scene the texture belongs to
  88691. * @param generateMipMaps Define whether or not to create mip maps for the texture
  88692. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  88693. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  88694. * @returns the luminance texture
  88695. */
  88696. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  88697. /**
  88698. * Creates a luminance alpha texture from some data.
  88699. * @param data Define the texture data
  88700. * @param width Define the width of the texture
  88701. * @param height Define the height of the texture
  88702. * @param scene Define the scene the texture belongs to
  88703. * @param generateMipMaps Define whether or not to create mip maps for the texture
  88704. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  88705. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  88706. * @returns the luminance alpha texture
  88707. */
  88708. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  88709. /**
  88710. * Creates an alpha texture from some data.
  88711. * @param data Define the texture data
  88712. * @param width Define the width of the texture
  88713. * @param height Define the height of the texture
  88714. * @param scene Define the scene the texture belongs to
  88715. * @param generateMipMaps Define whether or not to create mip maps for the texture
  88716. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  88717. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  88718. * @returns the alpha texture
  88719. */
  88720. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  88721. /**
  88722. * Creates a RGB texture from some data.
  88723. * @param data Define the texture data
  88724. * @param width Define the width of the texture
  88725. * @param height Define the height of the texture
  88726. * @param scene Define the scene the texture belongs to
  88727. * @param generateMipMaps Define whether or not to create mip maps for the texture
  88728. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  88729. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  88730. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  88731. * @returns the RGB alpha texture
  88732. */
  88733. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  88734. /**
  88735. * Creates a RGBA texture from some data.
  88736. * @param data Define the texture data
  88737. * @param width Define the width of the texture
  88738. * @param height Define the height of the texture
  88739. * @param scene Define the scene the texture belongs to
  88740. * @param generateMipMaps Define whether or not to create mip maps for the texture
  88741. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  88742. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  88743. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  88744. * @returns the RGBA texture
  88745. */
  88746. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  88747. /**
  88748. * Creates a R texture from some data.
  88749. * @param data Define the texture data
  88750. * @param width Define the width of the texture
  88751. * @param height Define the height of the texture
  88752. * @param scene Define the scene the texture belongs to
  88753. * @param generateMipMaps Define whether or not to create mip maps for the texture
  88754. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  88755. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  88756. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  88757. * @returns the R texture
  88758. */
  88759. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  88760. }
  88761. }
  88762. declare module BABYLON {
  88763. interface AbstractScene {
  88764. /**
  88765. * The list of procedural textures added to the scene
  88766. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  88767. */
  88768. proceduralTextures: Array<ProceduralTexture>;
  88769. }
  88770. /**
  88771. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  88772. * in a given scene.
  88773. */
  88774. export class ProceduralTextureSceneComponent implements ISceneComponent {
  88775. /**
  88776. * The component name helpfull to identify the component in the list of scene components.
  88777. */
  88778. readonly name: string;
  88779. /**
  88780. * The scene the component belongs to.
  88781. */
  88782. scene: Scene;
  88783. /**
  88784. * Creates a new instance of the component for the given scene
  88785. * @param scene Defines the scene to register the component in
  88786. */
  88787. constructor(scene: Scene);
  88788. /**
  88789. * Registers the component in a given scene
  88790. */
  88791. register(): void;
  88792. /**
  88793. * Rebuilds the elements related to this component in case of
  88794. * context lost for instance.
  88795. */
  88796. rebuild(): void;
  88797. /**
  88798. * Disposes the component and the associated ressources.
  88799. */
  88800. dispose(): void;
  88801. private _beforeClear;
  88802. }
  88803. }
  88804. declare module BABYLON {
  88805. interface ThinEngine {
  88806. /**
  88807. * Creates a new render target cube texture
  88808. * @param size defines the size of the texture
  88809. * @param options defines the options used to create the texture
  88810. * @returns a new render target cube texture stored in an InternalTexture
  88811. */
  88812. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  88813. }
  88814. }
  88815. declare module BABYLON {
  88816. /** @hidden */
  88817. export var proceduralVertexShader: {
  88818. name: string;
  88819. shader: string;
  88820. };
  88821. }
  88822. declare module BABYLON {
  88823. /**
  88824. * 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.
  88825. * This is the base class of any Procedural texture and contains most of the shareable code.
  88826. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  88827. */
  88828. export class ProceduralTexture extends Texture {
  88829. isCube: boolean;
  88830. /**
  88831. * Define if the texture is enabled or not (disabled texture will not render)
  88832. */
  88833. isEnabled: boolean;
  88834. /**
  88835. * Define if the texture must be cleared before rendering (default is true)
  88836. */
  88837. autoClear: boolean;
  88838. /**
  88839. * Callback called when the texture is generated
  88840. */
  88841. onGenerated: () => void;
  88842. /**
  88843. * Event raised when the texture is generated
  88844. */
  88845. onGeneratedObservable: Observable<ProceduralTexture>;
  88846. /** @hidden */
  88847. _generateMipMaps: boolean;
  88848. /** @hidden **/
  88849. _effect: Effect;
  88850. /** @hidden */
  88851. _textures: {
  88852. [key: string]: Texture;
  88853. };
  88854. /** @hidden */
  88855. protected _fallbackTexture: Nullable<Texture>;
  88856. private _size;
  88857. private _currentRefreshId;
  88858. private _frameId;
  88859. private _refreshRate;
  88860. private _vertexBuffers;
  88861. private _indexBuffer;
  88862. private _uniforms;
  88863. private _samplers;
  88864. private _fragment;
  88865. private _floats;
  88866. private _ints;
  88867. private _floatsArrays;
  88868. private _colors3;
  88869. private _colors4;
  88870. private _vectors2;
  88871. private _vectors3;
  88872. private _matrices;
  88873. private _fallbackTextureUsed;
  88874. private _fullEngine;
  88875. private _cachedDefines;
  88876. private _contentUpdateId;
  88877. private _contentData;
  88878. /**
  88879. * Instantiates a new procedural texture.
  88880. * 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.
  88881. * This is the base class of any Procedural texture and contains most of the shareable code.
  88882. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  88883. * @param name Define the name of the texture
  88884. * @param size Define the size of the texture to create
  88885. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  88886. * @param scene Define the scene the texture belongs to
  88887. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  88888. * @param generateMipMaps Define if the texture should creates mip maps or not
  88889. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  88890. */
  88891. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  88892. /**
  88893. * The effect that is created when initializing the post process.
  88894. * @returns The created effect corresponding the the postprocess.
  88895. */
  88896. getEffect(): Effect;
  88897. /**
  88898. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  88899. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  88900. */
  88901. getContent(): Nullable<ArrayBufferView>;
  88902. private _createIndexBuffer;
  88903. /** @hidden */
  88904. _rebuild(): void;
  88905. /**
  88906. * Resets the texture in order to recreate its associated resources.
  88907. * This can be called in case of context loss
  88908. */
  88909. reset(): void;
  88910. protected _getDefines(): string;
  88911. /**
  88912. * Is the texture ready to be used ? (rendered at least once)
  88913. * @returns true if ready, otherwise, false.
  88914. */
  88915. isReady(): boolean;
  88916. /**
  88917. * Resets the refresh counter of the texture and start bak from scratch.
  88918. * Could be useful to regenerate the texture if it is setup to render only once.
  88919. */
  88920. resetRefreshCounter(): void;
  88921. /**
  88922. * Set the fragment shader to use in order to render the texture.
  88923. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  88924. */
  88925. setFragment(fragment: any): void;
  88926. /**
  88927. * Define the refresh rate of the texture or the rendering frequency.
  88928. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  88929. */
  88930. get refreshRate(): number;
  88931. set refreshRate(value: number);
  88932. /** @hidden */
  88933. _shouldRender(): boolean;
  88934. /**
  88935. * Get the size the texture is rendering at.
  88936. * @returns the size (texture is always squared)
  88937. */
  88938. getRenderSize(): number;
  88939. /**
  88940. * Resize the texture to new value.
  88941. * @param size Define the new size the texture should have
  88942. * @param generateMipMaps Define whether the new texture should create mip maps
  88943. */
  88944. resize(size: number, generateMipMaps: boolean): void;
  88945. private _checkUniform;
  88946. /**
  88947. * Set a texture in the shader program used to render.
  88948. * @param name Define the name of the uniform samplers as defined in the shader
  88949. * @param texture Define the texture to bind to this sampler
  88950. * @return the texture itself allowing "fluent" like uniform updates
  88951. */
  88952. setTexture(name: string, texture: Texture): ProceduralTexture;
  88953. /**
  88954. * Set a float in the shader.
  88955. * @param name Define the name of the uniform as defined in the shader
  88956. * @param value Define the value to give to the uniform
  88957. * @return the texture itself allowing "fluent" like uniform updates
  88958. */
  88959. setFloat(name: string, value: number): ProceduralTexture;
  88960. /**
  88961. * Set a int in the shader.
  88962. * @param name Define the name of the uniform as defined in the shader
  88963. * @param value Define the value to give to the uniform
  88964. * @return the texture itself allowing "fluent" like uniform updates
  88965. */
  88966. setInt(name: string, value: number): ProceduralTexture;
  88967. /**
  88968. * Set an array of floats in the shader.
  88969. * @param name Define the name of the uniform as defined in the shader
  88970. * @param value Define the value to give to the uniform
  88971. * @return the texture itself allowing "fluent" like uniform updates
  88972. */
  88973. setFloats(name: string, value: number[]): ProceduralTexture;
  88974. /**
  88975. * Set a vec3 in the shader from a Color3.
  88976. * @param name Define the name of the uniform as defined in the shader
  88977. * @param value Define the value to give to the uniform
  88978. * @return the texture itself allowing "fluent" like uniform updates
  88979. */
  88980. setColor3(name: string, value: Color3): ProceduralTexture;
  88981. /**
  88982. * Set a vec4 in the shader from a Color4.
  88983. * @param name Define the name of the uniform as defined in the shader
  88984. * @param value Define the value to give to the uniform
  88985. * @return the texture itself allowing "fluent" like uniform updates
  88986. */
  88987. setColor4(name: string, value: Color4): ProceduralTexture;
  88988. /**
  88989. * Set a vec2 in the shader from a Vector2.
  88990. * @param name Define the name of the uniform as defined in the shader
  88991. * @param value Define the value to give to the uniform
  88992. * @return the texture itself allowing "fluent" like uniform updates
  88993. */
  88994. setVector2(name: string, value: Vector2): ProceduralTexture;
  88995. /**
  88996. * Set a vec3 in the shader from a Vector3.
  88997. * @param name Define the name of the uniform as defined in the shader
  88998. * @param value Define the value to give to the uniform
  88999. * @return the texture itself allowing "fluent" like uniform updates
  89000. */
  89001. setVector3(name: string, value: Vector3): ProceduralTexture;
  89002. /**
  89003. * Set a mat4 in the shader from a MAtrix.
  89004. * @param name Define the name of the uniform as defined in the shader
  89005. * @param value Define the value to give to the uniform
  89006. * @return the texture itself allowing "fluent" like uniform updates
  89007. */
  89008. setMatrix(name: string, value: Matrix): ProceduralTexture;
  89009. /**
  89010. * Render the texture to its associated render target.
  89011. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  89012. */
  89013. render(useCameraPostProcess?: boolean): void;
  89014. /**
  89015. * Clone the texture.
  89016. * @returns the cloned texture
  89017. */
  89018. clone(): ProceduralTexture;
  89019. /**
  89020. * Dispose the texture and release its asoociated resources.
  89021. */
  89022. dispose(): void;
  89023. }
  89024. }
  89025. declare module BABYLON {
  89026. /**
  89027. * This represents the base class for particle system in Babylon.
  89028. * 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.
  89029. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  89030. * @example https://doc.babylonjs.com/babylon101/particles
  89031. */
  89032. export class BaseParticleSystem {
  89033. /**
  89034. * Source color is added to the destination color without alpha affecting the result
  89035. */
  89036. static BLENDMODE_ONEONE: number;
  89037. /**
  89038. * Blend current color and particle color using particle’s alpha
  89039. */
  89040. static BLENDMODE_STANDARD: number;
  89041. /**
  89042. * Add current color and particle color multiplied by particle’s alpha
  89043. */
  89044. static BLENDMODE_ADD: number;
  89045. /**
  89046. * Multiply current color with particle color
  89047. */
  89048. static BLENDMODE_MULTIPLY: number;
  89049. /**
  89050. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  89051. */
  89052. static BLENDMODE_MULTIPLYADD: number;
  89053. /**
  89054. * List of animations used by the particle system.
  89055. */
  89056. animations: Animation[];
  89057. /**
  89058. * Gets or sets the unique id of the particle system
  89059. */
  89060. uniqueId: number;
  89061. /**
  89062. * The id of the Particle system.
  89063. */
  89064. id: string;
  89065. /**
  89066. * The friendly name of the Particle system.
  89067. */
  89068. name: string;
  89069. /**
  89070. * Snippet ID if the particle system was created from the snippet server
  89071. */
  89072. snippetId: string;
  89073. /**
  89074. * The rendering group used by the Particle system to chose when to render.
  89075. */
  89076. renderingGroupId: number;
  89077. /**
  89078. * The emitter represents the Mesh or position we are attaching the particle system to.
  89079. */
  89080. emitter: Nullable<AbstractMesh | Vector3>;
  89081. /**
  89082. * The maximum number of particles to emit per frame
  89083. */
  89084. emitRate: number;
  89085. /**
  89086. * If you want to launch only a few particles at once, that can be done, as well.
  89087. */
  89088. manualEmitCount: number;
  89089. /**
  89090. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  89091. */
  89092. updateSpeed: number;
  89093. /**
  89094. * The amount of time the particle system is running (depends of the overall update speed).
  89095. */
  89096. targetStopDuration: number;
  89097. /**
  89098. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  89099. */
  89100. disposeOnStop: boolean;
  89101. /**
  89102. * Minimum power of emitting particles.
  89103. */
  89104. minEmitPower: number;
  89105. /**
  89106. * Maximum power of emitting particles.
  89107. */
  89108. maxEmitPower: number;
  89109. /**
  89110. * Minimum life time of emitting particles.
  89111. */
  89112. minLifeTime: number;
  89113. /**
  89114. * Maximum life time of emitting particles.
  89115. */
  89116. maxLifeTime: number;
  89117. /**
  89118. * Minimum Size of emitting particles.
  89119. */
  89120. minSize: number;
  89121. /**
  89122. * Maximum Size of emitting particles.
  89123. */
  89124. maxSize: number;
  89125. /**
  89126. * Minimum scale of emitting particles on X axis.
  89127. */
  89128. minScaleX: number;
  89129. /**
  89130. * Maximum scale of emitting particles on X axis.
  89131. */
  89132. maxScaleX: number;
  89133. /**
  89134. * Minimum scale of emitting particles on Y axis.
  89135. */
  89136. minScaleY: number;
  89137. /**
  89138. * Maximum scale of emitting particles on Y axis.
  89139. */
  89140. maxScaleY: number;
  89141. /**
  89142. * Gets or sets the minimal initial rotation in radians.
  89143. */
  89144. minInitialRotation: number;
  89145. /**
  89146. * Gets or sets the maximal initial rotation in radians.
  89147. */
  89148. maxInitialRotation: number;
  89149. /**
  89150. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  89151. */
  89152. minAngularSpeed: number;
  89153. /**
  89154. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  89155. */
  89156. maxAngularSpeed: number;
  89157. /**
  89158. * The texture used to render each particle. (this can be a spritesheet)
  89159. */
  89160. particleTexture: Nullable<Texture>;
  89161. /**
  89162. * The layer mask we are rendering the particles through.
  89163. */
  89164. layerMask: number;
  89165. /**
  89166. * This can help using your own shader to render the particle system.
  89167. * The according effect will be created
  89168. */
  89169. customShader: any;
  89170. /**
  89171. * By default particle system starts as soon as they are created. This prevents the
  89172. * automatic start to happen and let you decide when to start emitting particles.
  89173. */
  89174. preventAutoStart: boolean;
  89175. private _noiseTexture;
  89176. /**
  89177. * Gets or sets a texture used to add random noise to particle positions
  89178. */
  89179. get noiseTexture(): Nullable<ProceduralTexture>;
  89180. set noiseTexture(value: Nullable<ProceduralTexture>);
  89181. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  89182. noiseStrength: Vector3;
  89183. /**
  89184. * Callback triggered when the particle animation is ending.
  89185. */
  89186. onAnimationEnd: Nullable<() => void>;
  89187. /**
  89188. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  89189. */
  89190. blendMode: number;
  89191. /**
  89192. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  89193. * to override the particles.
  89194. */
  89195. forceDepthWrite: boolean;
  89196. /** 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 */
  89197. preWarmCycles: number;
  89198. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  89199. preWarmStepOffset: number;
  89200. /**
  89201. * 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)
  89202. */
  89203. spriteCellChangeSpeed: number;
  89204. /**
  89205. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  89206. */
  89207. startSpriteCellID: number;
  89208. /**
  89209. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  89210. */
  89211. endSpriteCellID: number;
  89212. /**
  89213. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  89214. */
  89215. spriteCellWidth: number;
  89216. /**
  89217. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  89218. */
  89219. spriteCellHeight: number;
  89220. /**
  89221. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  89222. */
  89223. spriteRandomStartCell: boolean;
  89224. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  89225. translationPivot: Vector2;
  89226. /** @hidden */
  89227. protected _isAnimationSheetEnabled: boolean;
  89228. /**
  89229. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  89230. */
  89231. beginAnimationOnStart: boolean;
  89232. /**
  89233. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  89234. */
  89235. beginAnimationFrom: number;
  89236. /**
  89237. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  89238. */
  89239. beginAnimationTo: number;
  89240. /**
  89241. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  89242. */
  89243. beginAnimationLoop: boolean;
  89244. /**
  89245. * Gets or sets a world offset applied to all particles
  89246. */
  89247. worldOffset: Vector3;
  89248. /**
  89249. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  89250. */
  89251. get isAnimationSheetEnabled(): boolean;
  89252. set isAnimationSheetEnabled(value: boolean);
  89253. /**
  89254. * Get hosting scene
  89255. * @returns the scene
  89256. */
  89257. getScene(): Scene;
  89258. /**
  89259. * You can use gravity if you want to give an orientation to your particles.
  89260. */
  89261. gravity: Vector3;
  89262. protected _colorGradients: Nullable<Array<ColorGradient>>;
  89263. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  89264. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  89265. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  89266. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  89267. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  89268. protected _dragGradients: Nullable<Array<FactorGradient>>;
  89269. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  89270. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  89271. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  89272. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  89273. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  89274. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  89275. /**
  89276. * Defines the delay in milliseconds before starting the system (0 by default)
  89277. */
  89278. startDelay: number;
  89279. /**
  89280. * Gets the current list of drag gradients.
  89281. * You must use addDragGradient and removeDragGradient to udpate this list
  89282. * @returns the list of drag gradients
  89283. */
  89284. getDragGradients(): Nullable<Array<FactorGradient>>;
  89285. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  89286. limitVelocityDamping: number;
  89287. /**
  89288. * Gets the current list of limit velocity gradients.
  89289. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  89290. * @returns the list of limit velocity gradients
  89291. */
  89292. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  89293. /**
  89294. * Gets the current list of color gradients.
  89295. * You must use addColorGradient and removeColorGradient to udpate this list
  89296. * @returns the list of color gradients
  89297. */
  89298. getColorGradients(): Nullable<Array<ColorGradient>>;
  89299. /**
  89300. * Gets the current list of size gradients.
  89301. * You must use addSizeGradient and removeSizeGradient to udpate this list
  89302. * @returns the list of size gradients
  89303. */
  89304. getSizeGradients(): Nullable<Array<FactorGradient>>;
  89305. /**
  89306. * Gets the current list of color remap gradients.
  89307. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  89308. * @returns the list of color remap gradients
  89309. */
  89310. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  89311. /**
  89312. * Gets the current list of alpha remap gradients.
  89313. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  89314. * @returns the list of alpha remap gradients
  89315. */
  89316. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  89317. /**
  89318. * Gets the current list of life time gradients.
  89319. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  89320. * @returns the list of life time gradients
  89321. */
  89322. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  89323. /**
  89324. * Gets the current list of angular speed gradients.
  89325. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  89326. * @returns the list of angular speed gradients
  89327. */
  89328. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  89329. /**
  89330. * Gets the current list of velocity gradients.
  89331. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  89332. * @returns the list of velocity gradients
  89333. */
  89334. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  89335. /**
  89336. * Gets the current list of start size gradients.
  89337. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  89338. * @returns the list of start size gradients
  89339. */
  89340. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  89341. /**
  89342. * Gets the current list of emit rate gradients.
  89343. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  89344. * @returns the list of emit rate gradients
  89345. */
  89346. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  89347. /**
  89348. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  89349. * This only works when particleEmitterTyps is a BoxParticleEmitter
  89350. */
  89351. get direction1(): Vector3;
  89352. set direction1(value: Vector3);
  89353. /**
  89354. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  89355. * This only works when particleEmitterTyps is a BoxParticleEmitter
  89356. */
  89357. get direction2(): Vector3;
  89358. set direction2(value: Vector3);
  89359. /**
  89360. * 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.
  89361. * This only works when particleEmitterTyps is a BoxParticleEmitter
  89362. */
  89363. get minEmitBox(): Vector3;
  89364. set minEmitBox(value: Vector3);
  89365. /**
  89366. * 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.
  89367. * This only works when particleEmitterTyps is a BoxParticleEmitter
  89368. */
  89369. get maxEmitBox(): Vector3;
  89370. set maxEmitBox(value: Vector3);
  89371. /**
  89372. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  89373. */
  89374. color1: Color4;
  89375. /**
  89376. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  89377. */
  89378. color2: Color4;
  89379. /**
  89380. * Color the particle will have at the end of its lifetime
  89381. */
  89382. colorDead: Color4;
  89383. /**
  89384. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  89385. */
  89386. textureMask: Color4;
  89387. /**
  89388. * The particle emitter type defines the emitter used by the particle system.
  89389. * It can be for example box, sphere, or cone...
  89390. */
  89391. particleEmitterType: IParticleEmitterType;
  89392. /** @hidden */
  89393. _isSubEmitter: boolean;
  89394. /**
  89395. * Gets or sets the billboard mode to use when isBillboardBased = true.
  89396. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  89397. */
  89398. billboardMode: number;
  89399. protected _isBillboardBased: boolean;
  89400. /**
  89401. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  89402. */
  89403. get isBillboardBased(): boolean;
  89404. set isBillboardBased(value: boolean);
  89405. /**
  89406. * The scene the particle system belongs to.
  89407. */
  89408. protected _scene: Scene;
  89409. /**
  89410. * Local cache of defines for image processing.
  89411. */
  89412. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  89413. /**
  89414. * Default configuration related to image processing available in the standard Material.
  89415. */
  89416. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  89417. /**
  89418. * Gets the image processing configuration used either in this material.
  89419. */
  89420. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  89421. /**
  89422. * Sets the Default image processing configuration used either in the this material.
  89423. *
  89424. * If sets to null, the scene one is in use.
  89425. */
  89426. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  89427. /**
  89428. * Attaches a new image processing configuration to the Standard Material.
  89429. * @param configuration
  89430. */
  89431. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  89432. /** @hidden */
  89433. protected _reset(): void;
  89434. /** @hidden */
  89435. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  89436. /**
  89437. * Instantiates a particle system.
  89438. * 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.
  89439. * @param name The name of the particle system
  89440. */
  89441. constructor(name: string);
  89442. /**
  89443. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  89444. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  89445. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  89446. * @returns the emitter
  89447. */
  89448. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  89449. /**
  89450. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  89451. * @param radius The radius of the hemisphere to emit from
  89452. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  89453. * @returns the emitter
  89454. */
  89455. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  89456. /**
  89457. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  89458. * @param radius The radius of the sphere to emit from
  89459. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  89460. * @returns the emitter
  89461. */
  89462. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  89463. /**
  89464. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  89465. * @param radius The radius of the sphere to emit from
  89466. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  89467. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  89468. * @returns the emitter
  89469. */
  89470. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  89471. /**
  89472. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  89473. * @param radius The radius of the emission cylinder
  89474. * @param height The height of the emission cylinder
  89475. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  89476. * @param directionRandomizer How much to randomize the particle direction [0-1]
  89477. * @returns the emitter
  89478. */
  89479. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  89480. /**
  89481. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  89482. * @param radius The radius of the cylinder to emit from
  89483. * @param height The height of the emission cylinder
  89484. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  89485. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  89486. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  89487. * @returns the emitter
  89488. */
  89489. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  89490. /**
  89491. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  89492. * @param radius The radius of the cone to emit from
  89493. * @param angle The base angle of the cone
  89494. * @returns the emitter
  89495. */
  89496. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  89497. /**
  89498. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  89499. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  89500. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  89501. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  89502. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  89503. * @returns the emitter
  89504. */
  89505. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  89506. }
  89507. }
  89508. declare module BABYLON {
  89509. /**
  89510. * Type of sub emitter
  89511. */
  89512. export enum SubEmitterType {
  89513. /**
  89514. * Attached to the particle over it's lifetime
  89515. */
  89516. ATTACHED = 0,
  89517. /**
  89518. * Created when the particle dies
  89519. */
  89520. END = 1
  89521. }
  89522. /**
  89523. * Sub emitter class used to emit particles from an existing particle
  89524. */
  89525. export class SubEmitter {
  89526. /**
  89527. * the particle system to be used by the sub emitter
  89528. */
  89529. particleSystem: ParticleSystem;
  89530. /**
  89531. * Type of the submitter (Default: END)
  89532. */
  89533. type: SubEmitterType;
  89534. /**
  89535. * 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)
  89536. * Note: This only is supported when using an emitter of type Mesh
  89537. */
  89538. inheritDirection: boolean;
  89539. /**
  89540. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  89541. */
  89542. inheritedVelocityAmount: number;
  89543. /**
  89544. * Creates a sub emitter
  89545. * @param particleSystem the particle system to be used by the sub emitter
  89546. */
  89547. constructor(
  89548. /**
  89549. * the particle system to be used by the sub emitter
  89550. */
  89551. particleSystem: ParticleSystem);
  89552. /**
  89553. * Clones the sub emitter
  89554. * @returns the cloned sub emitter
  89555. */
  89556. clone(): SubEmitter;
  89557. /**
  89558. * Serialize current object to a JSON object
  89559. * @returns the serialized object
  89560. */
  89561. serialize(): any;
  89562. /** @hidden */
  89563. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  89564. /**
  89565. * Creates a new SubEmitter from a serialized JSON version
  89566. * @param serializationObject defines the JSON object to read from
  89567. * @param scene defines the hosting scene
  89568. * @param rootUrl defines the rootUrl for data loading
  89569. * @returns a new SubEmitter
  89570. */
  89571. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  89572. /** Release associated resources */
  89573. dispose(): void;
  89574. }
  89575. }
  89576. declare module BABYLON {
  89577. /** @hidden */
  89578. export var imageProcessingDeclaration: {
  89579. name: string;
  89580. shader: string;
  89581. };
  89582. }
  89583. declare module BABYLON {
  89584. /** @hidden */
  89585. export var imageProcessingFunctions: {
  89586. name: string;
  89587. shader: string;
  89588. };
  89589. }
  89590. declare module BABYLON {
  89591. /** @hidden */
  89592. export var particlesPixelShader: {
  89593. name: string;
  89594. shader: string;
  89595. };
  89596. }
  89597. declare module BABYLON {
  89598. /** @hidden */
  89599. export var particlesVertexShader: {
  89600. name: string;
  89601. shader: string;
  89602. };
  89603. }
  89604. declare module BABYLON {
  89605. /**
  89606. * This represents a particle system in Babylon.
  89607. * 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.
  89608. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  89609. * @example https://doc.babylonjs.com/babylon101/particles
  89610. */
  89611. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  89612. /**
  89613. * Billboard mode will only apply to Y axis
  89614. */
  89615. static readonly BILLBOARDMODE_Y: number;
  89616. /**
  89617. * Billboard mode will apply to all axes
  89618. */
  89619. static readonly BILLBOARDMODE_ALL: number;
  89620. /**
  89621. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  89622. */
  89623. static readonly BILLBOARDMODE_STRETCHED: number;
  89624. /**
  89625. * This function can be defined to provide custom update for active particles.
  89626. * This function will be called instead of regular update (age, position, color, etc.).
  89627. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  89628. */
  89629. updateFunction: (particles: Particle[]) => void;
  89630. private _emitterWorldMatrix;
  89631. /**
  89632. * This function can be defined to specify initial direction for every new particle.
  89633. * It by default use the emitterType defined function
  89634. */
  89635. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  89636. /**
  89637. * This function can be defined to specify initial position for every new particle.
  89638. * It by default use the emitterType defined function
  89639. */
  89640. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  89641. /**
  89642. * @hidden
  89643. */
  89644. _inheritedVelocityOffset: Vector3;
  89645. /**
  89646. * An event triggered when the system is disposed
  89647. */
  89648. onDisposeObservable: Observable<IParticleSystem>;
  89649. private _onDisposeObserver;
  89650. /**
  89651. * Sets a callback that will be triggered when the system is disposed
  89652. */
  89653. set onDispose(callback: () => void);
  89654. private _particles;
  89655. private _epsilon;
  89656. private _capacity;
  89657. private _stockParticles;
  89658. private _newPartsExcess;
  89659. private _vertexData;
  89660. private _vertexBuffer;
  89661. private _vertexBuffers;
  89662. private _spriteBuffer;
  89663. private _indexBuffer;
  89664. private _effect;
  89665. private _customEffect;
  89666. private _cachedDefines;
  89667. private _scaledColorStep;
  89668. private _colorDiff;
  89669. private _scaledDirection;
  89670. private _scaledGravity;
  89671. private _currentRenderId;
  89672. private _alive;
  89673. private _useInstancing;
  89674. private _started;
  89675. private _stopped;
  89676. private _actualFrame;
  89677. private _scaledUpdateSpeed;
  89678. private _vertexBufferSize;
  89679. /** @hidden */
  89680. _currentEmitRateGradient: Nullable<FactorGradient>;
  89681. /** @hidden */
  89682. _currentEmitRate1: number;
  89683. /** @hidden */
  89684. _currentEmitRate2: number;
  89685. /** @hidden */
  89686. _currentStartSizeGradient: Nullable<FactorGradient>;
  89687. /** @hidden */
  89688. _currentStartSize1: number;
  89689. /** @hidden */
  89690. _currentStartSize2: number;
  89691. private readonly _rawTextureWidth;
  89692. private _rampGradientsTexture;
  89693. private _useRampGradients;
  89694. /** Gets or sets a boolean indicating that ramp gradients must be used
  89695. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  89696. */
  89697. get useRampGradients(): boolean;
  89698. set useRampGradients(value: boolean);
  89699. /**
  89700. * 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.
  89701. * 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: [])
  89702. */
  89703. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  89704. private _subEmitters;
  89705. /**
  89706. * @hidden
  89707. * If the particle systems emitter should be disposed when the particle system is disposed
  89708. */
  89709. _disposeEmitterOnDispose: boolean;
  89710. /**
  89711. * The current active Sub-systems, this property is used by the root particle system only.
  89712. */
  89713. activeSubSystems: Array<ParticleSystem>;
  89714. /**
  89715. * Specifies if the particles are updated in emitter local space or world space
  89716. */
  89717. isLocal: boolean;
  89718. private _rootParticleSystem;
  89719. /**
  89720. * Gets the current list of active particles
  89721. */
  89722. get particles(): Particle[];
  89723. /**
  89724. * Gets the number of particles active at the same time.
  89725. * @returns The number of active particles.
  89726. */
  89727. getActiveCount(): number;
  89728. /**
  89729. * Returns the string "ParticleSystem"
  89730. * @returns a string containing the class name
  89731. */
  89732. getClassName(): string;
  89733. /**
  89734. * Gets a boolean indicating that the system is stopping
  89735. * @returns true if the system is currently stopping
  89736. */
  89737. isStopping(): boolean;
  89738. /**
  89739. * Gets the custom effect used to render the particles
  89740. * @param blendMode Blend mode for which the effect should be retrieved
  89741. * @returns The effect
  89742. */
  89743. getCustomEffect(blendMode?: number): Nullable<Effect>;
  89744. /**
  89745. * Sets the custom effect used to render the particles
  89746. * @param effect The effect to set
  89747. * @param blendMode Blend mode for which the effect should be set
  89748. */
  89749. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  89750. /** @hidden */
  89751. private _onBeforeDrawParticlesObservable;
  89752. /**
  89753. * Observable that will be called just before the particles are drawn
  89754. */
  89755. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  89756. /**
  89757. * Gets the name of the particle vertex shader
  89758. */
  89759. get vertexShaderName(): string;
  89760. /**
  89761. * Instantiates a particle system.
  89762. * 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.
  89763. * @param name The name of the particle system
  89764. * @param capacity The max number of particles alive at the same time
  89765. * @param scene The scene the particle system belongs to
  89766. * @param customEffect a custom effect used to change the way particles are rendered by default
  89767. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  89768. * @param epsilon Offset used to render the particles
  89769. */
  89770. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  89771. private _addFactorGradient;
  89772. private _removeFactorGradient;
  89773. /**
  89774. * Adds a new life time gradient
  89775. * @param gradient defines the gradient to use (between 0 and 1)
  89776. * @param factor defines the life time factor to affect to the specified gradient
  89777. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89778. * @returns the current particle system
  89779. */
  89780. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89781. /**
  89782. * Remove a specific life time gradient
  89783. * @param gradient defines the gradient to remove
  89784. * @returns the current particle system
  89785. */
  89786. removeLifeTimeGradient(gradient: number): IParticleSystem;
  89787. /**
  89788. * Adds a new size gradient
  89789. * @param gradient defines the gradient to use (between 0 and 1)
  89790. * @param factor defines the size factor to affect to the specified gradient
  89791. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89792. * @returns the current particle system
  89793. */
  89794. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89795. /**
  89796. * Remove a specific size gradient
  89797. * @param gradient defines the gradient to remove
  89798. * @returns the current particle system
  89799. */
  89800. removeSizeGradient(gradient: number): IParticleSystem;
  89801. /**
  89802. * Adds a new color remap gradient
  89803. * @param gradient defines the gradient to use (between 0 and 1)
  89804. * @param min defines the color remap minimal range
  89805. * @param max defines the color remap maximal range
  89806. * @returns the current particle system
  89807. */
  89808. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  89809. /**
  89810. * Remove a specific color remap gradient
  89811. * @param gradient defines the gradient to remove
  89812. * @returns the current particle system
  89813. */
  89814. removeColorRemapGradient(gradient: number): IParticleSystem;
  89815. /**
  89816. * Adds a new alpha remap gradient
  89817. * @param gradient defines the gradient to use (between 0 and 1)
  89818. * @param min defines the alpha remap minimal range
  89819. * @param max defines the alpha remap maximal range
  89820. * @returns the current particle system
  89821. */
  89822. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  89823. /**
  89824. * Remove a specific alpha remap gradient
  89825. * @param gradient defines the gradient to remove
  89826. * @returns the current particle system
  89827. */
  89828. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  89829. /**
  89830. * Adds a new angular speed gradient
  89831. * @param gradient defines the gradient to use (between 0 and 1)
  89832. * @param factor defines the angular speed to affect to the specified gradient
  89833. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89834. * @returns the current particle system
  89835. */
  89836. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89837. /**
  89838. * Remove a specific angular speed gradient
  89839. * @param gradient defines the gradient to remove
  89840. * @returns the current particle system
  89841. */
  89842. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  89843. /**
  89844. * Adds a new velocity gradient
  89845. * @param gradient defines the gradient to use (between 0 and 1)
  89846. * @param factor defines the velocity to affect to the specified gradient
  89847. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89848. * @returns the current particle system
  89849. */
  89850. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89851. /**
  89852. * Remove a specific velocity gradient
  89853. * @param gradient defines the gradient to remove
  89854. * @returns the current particle system
  89855. */
  89856. removeVelocityGradient(gradient: number): IParticleSystem;
  89857. /**
  89858. * Adds a new limit velocity gradient
  89859. * @param gradient defines the gradient to use (between 0 and 1)
  89860. * @param factor defines the limit velocity value to affect to the specified gradient
  89861. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89862. * @returns the current particle system
  89863. */
  89864. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89865. /**
  89866. * Remove a specific limit velocity gradient
  89867. * @param gradient defines the gradient to remove
  89868. * @returns the current particle system
  89869. */
  89870. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  89871. /**
  89872. * Adds a new drag gradient
  89873. * @param gradient defines the gradient to use (between 0 and 1)
  89874. * @param factor defines the drag value to affect to the specified gradient
  89875. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89876. * @returns the current particle system
  89877. */
  89878. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89879. /**
  89880. * Remove a specific drag gradient
  89881. * @param gradient defines the gradient to remove
  89882. * @returns the current particle system
  89883. */
  89884. removeDragGradient(gradient: number): IParticleSystem;
  89885. /**
  89886. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  89887. * @param gradient defines the gradient to use (between 0 and 1)
  89888. * @param factor defines the emit rate value to affect to the specified gradient
  89889. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89890. * @returns the current particle system
  89891. */
  89892. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89893. /**
  89894. * Remove a specific emit rate gradient
  89895. * @param gradient defines the gradient to remove
  89896. * @returns the current particle system
  89897. */
  89898. removeEmitRateGradient(gradient: number): IParticleSystem;
  89899. /**
  89900. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  89901. * @param gradient defines the gradient to use (between 0 and 1)
  89902. * @param factor defines the start size value to affect to the specified gradient
  89903. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89904. * @returns the current particle system
  89905. */
  89906. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89907. /**
  89908. * Remove a specific start size gradient
  89909. * @param gradient defines the gradient to remove
  89910. * @returns the current particle system
  89911. */
  89912. removeStartSizeGradient(gradient: number): IParticleSystem;
  89913. private _createRampGradientTexture;
  89914. /**
  89915. * Gets the current list of ramp gradients.
  89916. * You must use addRampGradient and removeRampGradient to udpate this list
  89917. * @returns the list of ramp gradients
  89918. */
  89919. getRampGradients(): Nullable<Array<Color3Gradient>>;
  89920. /** Force the system to rebuild all gradients that need to be resync */
  89921. forceRefreshGradients(): void;
  89922. private _syncRampGradientTexture;
  89923. /**
  89924. * Adds a new ramp gradient used to remap particle colors
  89925. * @param gradient defines the gradient to use (between 0 and 1)
  89926. * @param color defines the color to affect to the specified gradient
  89927. * @returns the current particle system
  89928. */
  89929. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  89930. /**
  89931. * Remove a specific ramp gradient
  89932. * @param gradient defines the gradient to remove
  89933. * @returns the current particle system
  89934. */
  89935. removeRampGradient(gradient: number): ParticleSystem;
  89936. /**
  89937. * Adds a new color gradient
  89938. * @param gradient defines the gradient to use (between 0 and 1)
  89939. * @param color1 defines the color to affect to the specified gradient
  89940. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  89941. * @returns this particle system
  89942. */
  89943. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  89944. /**
  89945. * Remove a specific color gradient
  89946. * @param gradient defines the gradient to remove
  89947. * @returns this particle system
  89948. */
  89949. removeColorGradient(gradient: number): IParticleSystem;
  89950. private _fetchR;
  89951. protected _reset(): void;
  89952. private _resetEffect;
  89953. private _createVertexBuffers;
  89954. private _createIndexBuffer;
  89955. /**
  89956. * Gets the maximum number of particles active at the same time.
  89957. * @returns The max number of active particles.
  89958. */
  89959. getCapacity(): number;
  89960. /**
  89961. * Gets whether there are still active particles in the system.
  89962. * @returns True if it is alive, otherwise false.
  89963. */
  89964. isAlive(): boolean;
  89965. /**
  89966. * Gets if the system has been started. (Note: this will still be true after stop is called)
  89967. * @returns True if it has been started, otherwise false.
  89968. */
  89969. isStarted(): boolean;
  89970. private _prepareSubEmitterInternalArray;
  89971. /**
  89972. * Starts the particle system and begins to emit
  89973. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  89974. */
  89975. start(delay?: number): void;
  89976. /**
  89977. * Stops the particle system.
  89978. * @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.
  89979. */
  89980. stop(stopSubEmitters?: boolean): void;
  89981. /**
  89982. * Remove all active particles
  89983. */
  89984. reset(): void;
  89985. /**
  89986. * @hidden (for internal use only)
  89987. */
  89988. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  89989. /**
  89990. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  89991. * Its lifetime will start back at 0.
  89992. */
  89993. recycleParticle: (particle: Particle) => void;
  89994. private _stopSubEmitters;
  89995. private _createParticle;
  89996. private _removeFromRoot;
  89997. private _emitFromParticle;
  89998. private _update;
  89999. /** @hidden */
  90000. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  90001. /** @hidden */
  90002. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  90003. /**
  90004. * Fill the defines array according to the current settings of the particle system
  90005. * @param defines Array to be updated
  90006. * @param blendMode blend mode to take into account when updating the array
  90007. */
  90008. fillDefines(defines: Array<string>, blendMode: number): void;
  90009. /**
  90010. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  90011. * @param uniforms Uniforms array to fill
  90012. * @param attributes Attributes array to fill
  90013. * @param samplers Samplers array to fill
  90014. */
  90015. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  90016. /** @hidden */
  90017. private _getEffect;
  90018. /**
  90019. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  90020. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  90021. */
  90022. animate(preWarmOnly?: boolean): void;
  90023. private _appendParticleVertices;
  90024. /**
  90025. * Rebuilds the particle system.
  90026. */
  90027. rebuild(): void;
  90028. /**
  90029. * Is this system ready to be used/rendered
  90030. * @return true if the system is ready
  90031. */
  90032. isReady(): boolean;
  90033. private _render;
  90034. /**
  90035. * Renders the particle system in its current state.
  90036. * @returns the current number of particles
  90037. */
  90038. render(): number;
  90039. /**
  90040. * Disposes the particle system and free the associated resources
  90041. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  90042. */
  90043. dispose(disposeTexture?: boolean): void;
  90044. /**
  90045. * Clones the particle system.
  90046. * @param name The name of the cloned object
  90047. * @param newEmitter The new emitter to use
  90048. * @returns the cloned particle system
  90049. */
  90050. clone(name: string, newEmitter: any): ParticleSystem;
  90051. /**
  90052. * Serializes the particle system to a JSON object
  90053. * @param serializeTexture defines if the texture must be serialized as well
  90054. * @returns the JSON object
  90055. */
  90056. serialize(serializeTexture?: boolean): any;
  90057. /** @hidden */
  90058. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  90059. /** @hidden */
  90060. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  90061. /**
  90062. * Parses a JSON object to create a particle system.
  90063. * @param parsedParticleSystem The JSON object to parse
  90064. * @param scene The scene to create the particle system in
  90065. * @param rootUrl The root url to use to load external dependencies like texture
  90066. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  90067. * @returns the Parsed particle system
  90068. */
  90069. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  90070. }
  90071. }
  90072. declare module BABYLON {
  90073. /**
  90074. * A particle represents one of the element emitted by a particle system.
  90075. * This is mainly define by its coordinates, direction, velocity and age.
  90076. */
  90077. export class Particle {
  90078. /**
  90079. * The particle system the particle belongs to.
  90080. */
  90081. particleSystem: ParticleSystem;
  90082. private static _Count;
  90083. /**
  90084. * Unique ID of the particle
  90085. */
  90086. id: number;
  90087. /**
  90088. * The world position of the particle in the scene.
  90089. */
  90090. position: Vector3;
  90091. /**
  90092. * The world direction of the particle in the scene.
  90093. */
  90094. direction: Vector3;
  90095. /**
  90096. * The color of the particle.
  90097. */
  90098. color: Color4;
  90099. /**
  90100. * The color change of the particle per step.
  90101. */
  90102. colorStep: Color4;
  90103. /**
  90104. * Defines how long will the life of the particle be.
  90105. */
  90106. lifeTime: number;
  90107. /**
  90108. * The current age of the particle.
  90109. */
  90110. age: number;
  90111. /**
  90112. * The current size of the particle.
  90113. */
  90114. size: number;
  90115. /**
  90116. * The current scale of the particle.
  90117. */
  90118. scale: Vector2;
  90119. /**
  90120. * The current angle of the particle.
  90121. */
  90122. angle: number;
  90123. /**
  90124. * Defines how fast is the angle changing.
  90125. */
  90126. angularSpeed: number;
  90127. /**
  90128. * Defines the cell index used by the particle to be rendered from a sprite.
  90129. */
  90130. cellIndex: number;
  90131. /**
  90132. * The information required to support color remapping
  90133. */
  90134. remapData: Vector4;
  90135. /** @hidden */
  90136. _randomCellOffset?: number;
  90137. /** @hidden */
  90138. _initialDirection: Nullable<Vector3>;
  90139. /** @hidden */
  90140. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  90141. /** @hidden */
  90142. _initialStartSpriteCellID: number;
  90143. /** @hidden */
  90144. _initialEndSpriteCellID: number;
  90145. /** @hidden */
  90146. _currentColorGradient: Nullable<ColorGradient>;
  90147. /** @hidden */
  90148. _currentColor1: Color4;
  90149. /** @hidden */
  90150. _currentColor2: Color4;
  90151. /** @hidden */
  90152. _currentSizeGradient: Nullable<FactorGradient>;
  90153. /** @hidden */
  90154. _currentSize1: number;
  90155. /** @hidden */
  90156. _currentSize2: number;
  90157. /** @hidden */
  90158. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  90159. /** @hidden */
  90160. _currentAngularSpeed1: number;
  90161. /** @hidden */
  90162. _currentAngularSpeed2: number;
  90163. /** @hidden */
  90164. _currentVelocityGradient: Nullable<FactorGradient>;
  90165. /** @hidden */
  90166. _currentVelocity1: number;
  90167. /** @hidden */
  90168. _currentVelocity2: number;
  90169. /** @hidden */
  90170. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  90171. /** @hidden */
  90172. _currentLimitVelocity1: number;
  90173. /** @hidden */
  90174. _currentLimitVelocity2: number;
  90175. /** @hidden */
  90176. _currentDragGradient: Nullable<FactorGradient>;
  90177. /** @hidden */
  90178. _currentDrag1: number;
  90179. /** @hidden */
  90180. _currentDrag2: number;
  90181. /** @hidden */
  90182. _randomNoiseCoordinates1: Vector3;
  90183. /** @hidden */
  90184. _randomNoiseCoordinates2: Vector3;
  90185. /** @hidden */
  90186. _localPosition?: Vector3;
  90187. /**
  90188. * Creates a new instance Particle
  90189. * @param particleSystem the particle system the particle belongs to
  90190. */
  90191. constructor(
  90192. /**
  90193. * The particle system the particle belongs to.
  90194. */
  90195. particleSystem: ParticleSystem);
  90196. private updateCellInfoFromSystem;
  90197. /**
  90198. * Defines how the sprite cell index is updated for the particle
  90199. */
  90200. updateCellIndex(): void;
  90201. /** @hidden */
  90202. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  90203. /** @hidden */
  90204. _inheritParticleInfoToSubEmitters(): void;
  90205. /** @hidden */
  90206. _reset(): void;
  90207. /**
  90208. * Copy the properties of particle to another one.
  90209. * @param other the particle to copy the information to.
  90210. */
  90211. copyTo(other: Particle): void;
  90212. }
  90213. }
  90214. declare module BABYLON {
  90215. /**
  90216. * Particle emitter represents a volume emitting particles.
  90217. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  90218. */
  90219. export interface IParticleEmitterType {
  90220. /**
  90221. * Called by the particle System when the direction is computed for the created particle.
  90222. * @param worldMatrix is the world matrix of the particle system
  90223. * @param directionToUpdate is the direction vector to update with the result
  90224. * @param particle is the particle we are computed the direction for
  90225. * @param isLocal defines if the direction should be set in local space
  90226. */
  90227. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90228. /**
  90229. * Called by the particle System when the position is computed for the created particle.
  90230. * @param worldMatrix is the world matrix of the particle system
  90231. * @param positionToUpdate is the position vector to update with the result
  90232. * @param particle is the particle we are computed the position for
  90233. * @param isLocal defines if the position should be set in local space
  90234. */
  90235. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90236. /**
  90237. * Clones the current emitter and returns a copy of it
  90238. * @returns the new emitter
  90239. */
  90240. clone(): IParticleEmitterType;
  90241. /**
  90242. * Called by the GPUParticleSystem to setup the update shader
  90243. * @param effect defines the update shader
  90244. */
  90245. applyToShader(effect: Effect): void;
  90246. /**
  90247. * Returns a string to use to update the GPU particles update shader
  90248. * @returns the effect defines string
  90249. */
  90250. getEffectDefines(): string;
  90251. /**
  90252. * Returns a string representing the class name
  90253. * @returns a string containing the class name
  90254. */
  90255. getClassName(): string;
  90256. /**
  90257. * Serializes the particle system to a JSON object.
  90258. * @returns the JSON object
  90259. */
  90260. serialize(): any;
  90261. /**
  90262. * Parse properties from a JSON object
  90263. * @param serializationObject defines the JSON object
  90264. * @param scene defines the hosting scene
  90265. */
  90266. parse(serializationObject: any, scene: Scene): void;
  90267. }
  90268. }
  90269. declare module BABYLON {
  90270. /**
  90271. * Particle emitter emitting particles from the inside of a box.
  90272. * It emits the particles randomly between 2 given directions.
  90273. */
  90274. export class BoxParticleEmitter implements IParticleEmitterType {
  90275. /**
  90276. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  90277. */
  90278. direction1: Vector3;
  90279. /**
  90280. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  90281. */
  90282. direction2: Vector3;
  90283. /**
  90284. * 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.
  90285. */
  90286. minEmitBox: Vector3;
  90287. /**
  90288. * 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.
  90289. */
  90290. maxEmitBox: Vector3;
  90291. /**
  90292. * Creates a new instance BoxParticleEmitter
  90293. */
  90294. constructor();
  90295. /**
  90296. * Called by the particle System when the direction is computed for the created particle.
  90297. * @param worldMatrix is the world matrix of the particle system
  90298. * @param directionToUpdate is the direction vector to update with the result
  90299. * @param particle is the particle we are computed the direction for
  90300. * @param isLocal defines if the direction should be set in local space
  90301. */
  90302. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90303. /**
  90304. * Called by the particle System when the position is computed for the created particle.
  90305. * @param worldMatrix is the world matrix of the particle system
  90306. * @param positionToUpdate is the position vector to update with the result
  90307. * @param particle is the particle we are computed the position for
  90308. * @param isLocal defines if the position should be set in local space
  90309. */
  90310. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90311. /**
  90312. * Clones the current emitter and returns a copy of it
  90313. * @returns the new emitter
  90314. */
  90315. clone(): BoxParticleEmitter;
  90316. /**
  90317. * Called by the GPUParticleSystem to setup the update shader
  90318. * @param effect defines the update shader
  90319. */
  90320. applyToShader(effect: Effect): void;
  90321. /**
  90322. * Returns a string to use to update the GPU particles update shader
  90323. * @returns a string containng the defines string
  90324. */
  90325. getEffectDefines(): string;
  90326. /**
  90327. * Returns the string "BoxParticleEmitter"
  90328. * @returns a string containing the class name
  90329. */
  90330. getClassName(): string;
  90331. /**
  90332. * Serializes the particle system to a JSON object.
  90333. * @returns the JSON object
  90334. */
  90335. serialize(): any;
  90336. /**
  90337. * Parse properties from a JSON object
  90338. * @param serializationObject defines the JSON object
  90339. */
  90340. parse(serializationObject: any): void;
  90341. }
  90342. }
  90343. declare module BABYLON {
  90344. /**
  90345. * Particle emitter emitting particles from the inside of a cone.
  90346. * It emits the particles alongside the cone volume from the base to the particle.
  90347. * The emission direction might be randomized.
  90348. */
  90349. export class ConeParticleEmitter implements IParticleEmitterType {
  90350. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  90351. directionRandomizer: number;
  90352. private _radius;
  90353. private _angle;
  90354. private _height;
  90355. /**
  90356. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  90357. */
  90358. radiusRange: number;
  90359. /**
  90360. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  90361. */
  90362. heightRange: number;
  90363. /**
  90364. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  90365. */
  90366. emitFromSpawnPointOnly: boolean;
  90367. /**
  90368. * Gets or sets the radius of the emission cone
  90369. */
  90370. get radius(): number;
  90371. set radius(value: number);
  90372. /**
  90373. * Gets or sets the angle of the emission cone
  90374. */
  90375. get angle(): number;
  90376. set angle(value: number);
  90377. private _buildHeight;
  90378. /**
  90379. * Creates a new instance ConeParticleEmitter
  90380. * @param radius the radius of the emission cone (1 by default)
  90381. * @param angle the cone base angle (PI by default)
  90382. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  90383. */
  90384. constructor(radius?: number, angle?: number,
  90385. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  90386. directionRandomizer?: number);
  90387. /**
  90388. * Called by the particle System when the direction is computed for the created particle.
  90389. * @param worldMatrix is the world matrix of the particle system
  90390. * @param directionToUpdate is the direction vector to update with the result
  90391. * @param particle is the particle we are computed the direction for
  90392. * @param isLocal defines if the direction should be set in local space
  90393. */
  90394. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90395. /**
  90396. * Called by the particle System when the position is computed for the created particle.
  90397. * @param worldMatrix is the world matrix of the particle system
  90398. * @param positionToUpdate is the position vector to update with the result
  90399. * @param particle is the particle we are computed the position for
  90400. * @param isLocal defines if the position should be set in local space
  90401. */
  90402. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90403. /**
  90404. * Clones the current emitter and returns a copy of it
  90405. * @returns the new emitter
  90406. */
  90407. clone(): ConeParticleEmitter;
  90408. /**
  90409. * Called by the GPUParticleSystem to setup the update shader
  90410. * @param effect defines the update shader
  90411. */
  90412. applyToShader(effect: Effect): void;
  90413. /**
  90414. * Returns a string to use to update the GPU particles update shader
  90415. * @returns a string containng the defines string
  90416. */
  90417. getEffectDefines(): string;
  90418. /**
  90419. * Returns the string "ConeParticleEmitter"
  90420. * @returns a string containing the class name
  90421. */
  90422. getClassName(): string;
  90423. /**
  90424. * Serializes the particle system to a JSON object.
  90425. * @returns the JSON object
  90426. */
  90427. serialize(): any;
  90428. /**
  90429. * Parse properties from a JSON object
  90430. * @param serializationObject defines the JSON object
  90431. */
  90432. parse(serializationObject: any): void;
  90433. }
  90434. }
  90435. declare module BABYLON {
  90436. /**
  90437. * Particle emitter emitting particles from the inside of a cylinder.
  90438. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  90439. */
  90440. export class CylinderParticleEmitter implements IParticleEmitterType {
  90441. /**
  90442. * The radius of the emission cylinder.
  90443. */
  90444. radius: number;
  90445. /**
  90446. * The height of the emission cylinder.
  90447. */
  90448. height: number;
  90449. /**
  90450. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  90451. */
  90452. radiusRange: number;
  90453. /**
  90454. * How much to randomize the particle direction [0-1].
  90455. */
  90456. directionRandomizer: number;
  90457. /**
  90458. * Creates a new instance CylinderParticleEmitter
  90459. * @param radius the radius of the emission cylinder (1 by default)
  90460. * @param height the height of the emission cylinder (1 by default)
  90461. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  90462. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  90463. */
  90464. constructor(
  90465. /**
  90466. * The radius of the emission cylinder.
  90467. */
  90468. radius?: number,
  90469. /**
  90470. * The height of the emission cylinder.
  90471. */
  90472. height?: number,
  90473. /**
  90474. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  90475. */
  90476. radiusRange?: number,
  90477. /**
  90478. * How much to randomize the particle direction [0-1].
  90479. */
  90480. directionRandomizer?: number);
  90481. /**
  90482. * Called by the particle System when the direction is computed for the created particle.
  90483. * @param worldMatrix is the world matrix of the particle system
  90484. * @param directionToUpdate is the direction vector to update with the result
  90485. * @param particle is the particle we are computed the direction for
  90486. * @param isLocal defines if the direction should be set in local space
  90487. */
  90488. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90489. /**
  90490. * Called by the particle System when the position is computed for the created particle.
  90491. * @param worldMatrix is the world matrix of the particle system
  90492. * @param positionToUpdate is the position vector to update with the result
  90493. * @param particle is the particle we are computed the position for
  90494. * @param isLocal defines if the position should be set in local space
  90495. */
  90496. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90497. /**
  90498. * Clones the current emitter and returns a copy of it
  90499. * @returns the new emitter
  90500. */
  90501. clone(): CylinderParticleEmitter;
  90502. /**
  90503. * Called by the GPUParticleSystem to setup the update shader
  90504. * @param effect defines the update shader
  90505. */
  90506. applyToShader(effect: Effect): void;
  90507. /**
  90508. * Returns a string to use to update the GPU particles update shader
  90509. * @returns a string containng the defines string
  90510. */
  90511. getEffectDefines(): string;
  90512. /**
  90513. * Returns the string "CylinderParticleEmitter"
  90514. * @returns a string containing the class name
  90515. */
  90516. getClassName(): string;
  90517. /**
  90518. * Serializes the particle system to a JSON object.
  90519. * @returns the JSON object
  90520. */
  90521. serialize(): any;
  90522. /**
  90523. * Parse properties from a JSON object
  90524. * @param serializationObject defines the JSON object
  90525. */
  90526. parse(serializationObject: any): void;
  90527. }
  90528. /**
  90529. * Particle emitter emitting particles from the inside of a cylinder.
  90530. * It emits the particles randomly between two vectors.
  90531. */
  90532. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  90533. /**
  90534. * The min limit of the emission direction.
  90535. */
  90536. direction1: Vector3;
  90537. /**
  90538. * The max limit of the emission direction.
  90539. */
  90540. direction2: Vector3;
  90541. /**
  90542. * Creates a new instance CylinderDirectedParticleEmitter
  90543. * @param radius the radius of the emission cylinder (1 by default)
  90544. * @param height the height of the emission cylinder (1 by default)
  90545. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  90546. * @param direction1 the min limit of the emission direction (up vector by default)
  90547. * @param direction2 the max limit of the emission direction (up vector by default)
  90548. */
  90549. constructor(radius?: number, height?: number, radiusRange?: number,
  90550. /**
  90551. * The min limit of the emission direction.
  90552. */
  90553. direction1?: Vector3,
  90554. /**
  90555. * The max limit of the emission direction.
  90556. */
  90557. direction2?: Vector3);
  90558. /**
  90559. * Called by the particle System when the direction is computed for the created particle.
  90560. * @param worldMatrix is the world matrix of the particle system
  90561. * @param directionToUpdate is the direction vector to update with the result
  90562. * @param particle is the particle we are computed the direction for
  90563. */
  90564. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  90565. /**
  90566. * Clones the current emitter and returns a copy of it
  90567. * @returns the new emitter
  90568. */
  90569. clone(): CylinderDirectedParticleEmitter;
  90570. /**
  90571. * Called by the GPUParticleSystem to setup the update shader
  90572. * @param effect defines the update shader
  90573. */
  90574. applyToShader(effect: Effect): void;
  90575. /**
  90576. * Returns a string to use to update the GPU particles update shader
  90577. * @returns a string containng the defines string
  90578. */
  90579. getEffectDefines(): string;
  90580. /**
  90581. * Returns the string "CylinderDirectedParticleEmitter"
  90582. * @returns a string containing the class name
  90583. */
  90584. getClassName(): string;
  90585. /**
  90586. * Serializes the particle system to a JSON object.
  90587. * @returns the JSON object
  90588. */
  90589. serialize(): any;
  90590. /**
  90591. * Parse properties from a JSON object
  90592. * @param serializationObject defines the JSON object
  90593. */
  90594. parse(serializationObject: any): void;
  90595. }
  90596. }
  90597. declare module BABYLON {
  90598. /**
  90599. * Particle emitter emitting particles from the inside of a hemisphere.
  90600. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  90601. */
  90602. export class HemisphericParticleEmitter implements IParticleEmitterType {
  90603. /**
  90604. * The radius of the emission hemisphere.
  90605. */
  90606. radius: number;
  90607. /**
  90608. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  90609. */
  90610. radiusRange: number;
  90611. /**
  90612. * How much to randomize the particle direction [0-1].
  90613. */
  90614. directionRandomizer: number;
  90615. /**
  90616. * Creates a new instance HemisphericParticleEmitter
  90617. * @param radius the radius of the emission hemisphere (1 by default)
  90618. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  90619. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  90620. */
  90621. constructor(
  90622. /**
  90623. * The radius of the emission hemisphere.
  90624. */
  90625. radius?: number,
  90626. /**
  90627. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  90628. */
  90629. radiusRange?: number,
  90630. /**
  90631. * How much to randomize the particle direction [0-1].
  90632. */
  90633. directionRandomizer?: number);
  90634. /**
  90635. * Called by the particle System when the direction is computed for the created particle.
  90636. * @param worldMatrix is the world matrix of the particle system
  90637. * @param directionToUpdate is the direction vector to update with the result
  90638. * @param particle is the particle we are computed the direction for
  90639. * @param isLocal defines if the direction should be set in local space
  90640. */
  90641. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90642. /**
  90643. * Called by the particle System when the position is computed for the created particle.
  90644. * @param worldMatrix is the world matrix of the particle system
  90645. * @param positionToUpdate is the position vector to update with the result
  90646. * @param particle is the particle we are computed the position for
  90647. * @param isLocal defines if the position should be set in local space
  90648. */
  90649. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90650. /**
  90651. * Clones the current emitter and returns a copy of it
  90652. * @returns the new emitter
  90653. */
  90654. clone(): HemisphericParticleEmitter;
  90655. /**
  90656. * Called by the GPUParticleSystem to setup the update shader
  90657. * @param effect defines the update shader
  90658. */
  90659. applyToShader(effect: Effect): void;
  90660. /**
  90661. * Returns a string to use to update the GPU particles update shader
  90662. * @returns a string containng the defines string
  90663. */
  90664. getEffectDefines(): string;
  90665. /**
  90666. * Returns the string "HemisphericParticleEmitter"
  90667. * @returns a string containing the class name
  90668. */
  90669. getClassName(): string;
  90670. /**
  90671. * Serializes the particle system to a JSON object.
  90672. * @returns the JSON object
  90673. */
  90674. serialize(): any;
  90675. /**
  90676. * Parse properties from a JSON object
  90677. * @param serializationObject defines the JSON object
  90678. */
  90679. parse(serializationObject: any): void;
  90680. }
  90681. }
  90682. declare module BABYLON {
  90683. /**
  90684. * Particle emitter emitting particles from a point.
  90685. * It emits the particles randomly between 2 given directions.
  90686. */
  90687. export class PointParticleEmitter implements IParticleEmitterType {
  90688. /**
  90689. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  90690. */
  90691. direction1: Vector3;
  90692. /**
  90693. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  90694. */
  90695. direction2: Vector3;
  90696. /**
  90697. * Creates a new instance PointParticleEmitter
  90698. */
  90699. constructor();
  90700. /**
  90701. * Called by the particle System when the direction is computed for the created particle.
  90702. * @param worldMatrix is the world matrix of the particle system
  90703. * @param directionToUpdate is the direction vector to update with the result
  90704. * @param particle is the particle we are computed the direction for
  90705. * @param isLocal defines if the direction should be set in local space
  90706. */
  90707. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90708. /**
  90709. * Called by the particle System when the position is computed for the created particle.
  90710. * @param worldMatrix is the world matrix of the particle system
  90711. * @param positionToUpdate is the position vector to update with the result
  90712. * @param particle is the particle we are computed the position for
  90713. * @param isLocal defines if the position should be set in local space
  90714. */
  90715. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90716. /**
  90717. * Clones the current emitter and returns a copy of it
  90718. * @returns the new emitter
  90719. */
  90720. clone(): PointParticleEmitter;
  90721. /**
  90722. * Called by the GPUParticleSystem to setup the update shader
  90723. * @param effect defines the update shader
  90724. */
  90725. applyToShader(effect: Effect): void;
  90726. /**
  90727. * Returns a string to use to update the GPU particles update shader
  90728. * @returns a string containng the defines string
  90729. */
  90730. getEffectDefines(): string;
  90731. /**
  90732. * Returns the string "PointParticleEmitter"
  90733. * @returns a string containing the class name
  90734. */
  90735. getClassName(): string;
  90736. /**
  90737. * Serializes the particle system to a JSON object.
  90738. * @returns the JSON object
  90739. */
  90740. serialize(): any;
  90741. /**
  90742. * Parse properties from a JSON object
  90743. * @param serializationObject defines the JSON object
  90744. */
  90745. parse(serializationObject: any): void;
  90746. }
  90747. }
  90748. declare module BABYLON {
  90749. /**
  90750. * Particle emitter emitting particles from the inside of a sphere.
  90751. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  90752. */
  90753. export class SphereParticleEmitter implements IParticleEmitterType {
  90754. /**
  90755. * The radius of the emission sphere.
  90756. */
  90757. radius: number;
  90758. /**
  90759. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  90760. */
  90761. radiusRange: number;
  90762. /**
  90763. * How much to randomize the particle direction [0-1].
  90764. */
  90765. directionRandomizer: number;
  90766. /**
  90767. * Creates a new instance SphereParticleEmitter
  90768. * @param radius the radius of the emission sphere (1 by default)
  90769. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  90770. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  90771. */
  90772. constructor(
  90773. /**
  90774. * The radius of the emission sphere.
  90775. */
  90776. radius?: number,
  90777. /**
  90778. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  90779. */
  90780. radiusRange?: number,
  90781. /**
  90782. * How much to randomize the particle direction [0-1].
  90783. */
  90784. directionRandomizer?: number);
  90785. /**
  90786. * Called by the particle System when the direction is computed for the created particle.
  90787. * @param worldMatrix is the world matrix of the particle system
  90788. * @param directionToUpdate is the direction vector to update with the result
  90789. * @param particle is the particle we are computed the direction for
  90790. * @param isLocal defines if the direction should be set in local space
  90791. */
  90792. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90793. /**
  90794. * Called by the particle System when the position is computed for the created particle.
  90795. * @param worldMatrix is the world matrix of the particle system
  90796. * @param positionToUpdate is the position vector to update with the result
  90797. * @param particle is the particle we are computed the position for
  90798. * @param isLocal defines if the position should be set in local space
  90799. */
  90800. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90801. /**
  90802. * Clones the current emitter and returns a copy of it
  90803. * @returns the new emitter
  90804. */
  90805. clone(): SphereParticleEmitter;
  90806. /**
  90807. * Called by the GPUParticleSystem to setup the update shader
  90808. * @param effect defines the update shader
  90809. */
  90810. applyToShader(effect: Effect): void;
  90811. /**
  90812. * Returns a string to use to update the GPU particles update shader
  90813. * @returns a string containng the defines string
  90814. */
  90815. getEffectDefines(): string;
  90816. /**
  90817. * Returns the string "SphereParticleEmitter"
  90818. * @returns a string containing the class name
  90819. */
  90820. getClassName(): string;
  90821. /**
  90822. * Serializes the particle system to a JSON object.
  90823. * @returns the JSON object
  90824. */
  90825. serialize(): any;
  90826. /**
  90827. * Parse properties from a JSON object
  90828. * @param serializationObject defines the JSON object
  90829. */
  90830. parse(serializationObject: any): void;
  90831. }
  90832. /**
  90833. * Particle emitter emitting particles from the inside of a sphere.
  90834. * It emits the particles randomly between two vectors.
  90835. */
  90836. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  90837. /**
  90838. * The min limit of the emission direction.
  90839. */
  90840. direction1: Vector3;
  90841. /**
  90842. * The max limit of the emission direction.
  90843. */
  90844. direction2: Vector3;
  90845. /**
  90846. * Creates a new instance SphereDirectedParticleEmitter
  90847. * @param radius the radius of the emission sphere (1 by default)
  90848. * @param direction1 the min limit of the emission direction (up vector by default)
  90849. * @param direction2 the max limit of the emission direction (up vector by default)
  90850. */
  90851. constructor(radius?: number,
  90852. /**
  90853. * The min limit of the emission direction.
  90854. */
  90855. direction1?: Vector3,
  90856. /**
  90857. * The max limit of the emission direction.
  90858. */
  90859. direction2?: Vector3);
  90860. /**
  90861. * Called by the particle System when the direction is computed for the created particle.
  90862. * @param worldMatrix is the world matrix of the particle system
  90863. * @param directionToUpdate is the direction vector to update with the result
  90864. * @param particle is the particle we are computed the direction for
  90865. */
  90866. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  90867. /**
  90868. * Clones the current emitter and returns a copy of it
  90869. * @returns the new emitter
  90870. */
  90871. clone(): SphereDirectedParticleEmitter;
  90872. /**
  90873. * Called by the GPUParticleSystem to setup the update shader
  90874. * @param effect defines the update shader
  90875. */
  90876. applyToShader(effect: Effect): void;
  90877. /**
  90878. * Returns a string to use to update the GPU particles update shader
  90879. * @returns a string containng the defines string
  90880. */
  90881. getEffectDefines(): string;
  90882. /**
  90883. * Returns the string "SphereDirectedParticleEmitter"
  90884. * @returns a string containing the class name
  90885. */
  90886. getClassName(): string;
  90887. /**
  90888. * Serializes the particle system to a JSON object.
  90889. * @returns the JSON object
  90890. */
  90891. serialize(): any;
  90892. /**
  90893. * Parse properties from a JSON object
  90894. * @param serializationObject defines the JSON object
  90895. */
  90896. parse(serializationObject: any): void;
  90897. }
  90898. }
  90899. declare module BABYLON {
  90900. /**
  90901. * Particle emitter emitting particles from a custom list of positions.
  90902. */
  90903. export class CustomParticleEmitter implements IParticleEmitterType {
  90904. /**
  90905. * Gets or sets the position generator that will create the inital position of each particle.
  90906. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  90907. */
  90908. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  90909. /**
  90910. * Gets or sets the destination generator that will create the final destination of each particle.
  90911. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  90912. */
  90913. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  90914. /**
  90915. * Creates a new instance CustomParticleEmitter
  90916. */
  90917. constructor();
  90918. /**
  90919. * Called by the particle System when the direction is computed for the created particle.
  90920. * @param worldMatrix is the world matrix of the particle system
  90921. * @param directionToUpdate is the direction vector to update with the result
  90922. * @param particle is the particle we are computed the direction for
  90923. * @param isLocal defines if the direction should be set in local space
  90924. */
  90925. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90926. /**
  90927. * Called by the particle System when the position is computed for the created particle.
  90928. * @param worldMatrix is the world matrix of the particle system
  90929. * @param positionToUpdate is the position vector to update with the result
  90930. * @param particle is the particle we are computed the position for
  90931. * @param isLocal defines if the position should be set in local space
  90932. */
  90933. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90934. /**
  90935. * Clones the current emitter and returns a copy of it
  90936. * @returns the new emitter
  90937. */
  90938. clone(): CustomParticleEmitter;
  90939. /**
  90940. * Called by the GPUParticleSystem to setup the update shader
  90941. * @param effect defines the update shader
  90942. */
  90943. applyToShader(effect: Effect): void;
  90944. /**
  90945. * Returns a string to use to update the GPU particles update shader
  90946. * @returns a string containng the defines string
  90947. */
  90948. getEffectDefines(): string;
  90949. /**
  90950. * Returns the string "PointParticleEmitter"
  90951. * @returns a string containing the class name
  90952. */
  90953. getClassName(): string;
  90954. /**
  90955. * Serializes the particle system to a JSON object.
  90956. * @returns the JSON object
  90957. */
  90958. serialize(): any;
  90959. /**
  90960. * Parse properties from a JSON object
  90961. * @param serializationObject defines the JSON object
  90962. */
  90963. parse(serializationObject: any): void;
  90964. }
  90965. }
  90966. declare module BABYLON {
  90967. /**
  90968. * Particle emitter emitting particles from the inside of a box.
  90969. * It emits the particles randomly between 2 given directions.
  90970. */
  90971. export class MeshParticleEmitter implements IParticleEmitterType {
  90972. private _indices;
  90973. private _positions;
  90974. private _normals;
  90975. private _storedNormal;
  90976. private _mesh;
  90977. /**
  90978. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  90979. */
  90980. direction1: Vector3;
  90981. /**
  90982. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  90983. */
  90984. direction2: Vector3;
  90985. /**
  90986. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  90987. */
  90988. useMeshNormalsForDirection: boolean;
  90989. /** Defines the mesh to use as source */
  90990. get mesh(): Nullable<AbstractMesh>;
  90991. set mesh(value: Nullable<AbstractMesh>);
  90992. /**
  90993. * Creates a new instance MeshParticleEmitter
  90994. * @param mesh defines the mesh to use as source
  90995. */
  90996. constructor(mesh?: Nullable<AbstractMesh>);
  90997. /**
  90998. * Called by the particle System when the direction is computed for the created particle.
  90999. * @param worldMatrix is the world matrix of the particle system
  91000. * @param directionToUpdate is the direction vector to update with the result
  91001. * @param particle is the particle we are computed the direction for
  91002. * @param isLocal defines if the direction should be set in local space
  91003. */
  91004. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91005. /**
  91006. * Called by the particle System when the position is computed for the created particle.
  91007. * @param worldMatrix is the world matrix of the particle system
  91008. * @param positionToUpdate is the position vector to update with the result
  91009. * @param particle is the particle we are computed the position for
  91010. * @param isLocal defines if the position should be set in local space
  91011. */
  91012. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91013. /**
  91014. * Clones the current emitter and returns a copy of it
  91015. * @returns the new emitter
  91016. */
  91017. clone(): MeshParticleEmitter;
  91018. /**
  91019. * Called by the GPUParticleSystem to setup the update shader
  91020. * @param effect defines the update shader
  91021. */
  91022. applyToShader(effect: Effect): void;
  91023. /**
  91024. * Returns a string to use to update the GPU particles update shader
  91025. * @returns a string containng the defines string
  91026. */
  91027. getEffectDefines(): string;
  91028. /**
  91029. * Returns the string "BoxParticleEmitter"
  91030. * @returns a string containing the class name
  91031. */
  91032. getClassName(): string;
  91033. /**
  91034. * Serializes the particle system to a JSON object.
  91035. * @returns the JSON object
  91036. */
  91037. serialize(): any;
  91038. /**
  91039. * Parse properties from a JSON object
  91040. * @param serializationObject defines the JSON object
  91041. * @param scene defines the hosting scene
  91042. */
  91043. parse(serializationObject: any, scene: Scene): void;
  91044. }
  91045. }
  91046. declare module BABYLON {
  91047. /**
  91048. * Interface representing a particle system in Babylon.js.
  91049. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  91050. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  91051. */
  91052. export interface IParticleSystem {
  91053. /**
  91054. * List of animations used by the particle system.
  91055. */
  91056. animations: Animation[];
  91057. /**
  91058. * The id of the Particle system.
  91059. */
  91060. id: string;
  91061. /**
  91062. * The name of the Particle system.
  91063. */
  91064. name: string;
  91065. /**
  91066. * The emitter represents the Mesh or position we are attaching the particle system to.
  91067. */
  91068. emitter: Nullable<AbstractMesh | Vector3>;
  91069. /**
  91070. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  91071. */
  91072. isBillboardBased: boolean;
  91073. /**
  91074. * The rendering group used by the Particle system to chose when to render.
  91075. */
  91076. renderingGroupId: number;
  91077. /**
  91078. * The layer mask we are rendering the particles through.
  91079. */
  91080. layerMask: number;
  91081. /**
  91082. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  91083. */
  91084. updateSpeed: number;
  91085. /**
  91086. * The amount of time the particle system is running (depends of the overall update speed).
  91087. */
  91088. targetStopDuration: number;
  91089. /**
  91090. * The texture used to render each particle. (this can be a spritesheet)
  91091. */
  91092. particleTexture: Nullable<Texture>;
  91093. /**
  91094. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  91095. */
  91096. blendMode: number;
  91097. /**
  91098. * Minimum life time of emitting particles.
  91099. */
  91100. minLifeTime: number;
  91101. /**
  91102. * Maximum life time of emitting particles.
  91103. */
  91104. maxLifeTime: number;
  91105. /**
  91106. * Minimum Size of emitting particles.
  91107. */
  91108. minSize: number;
  91109. /**
  91110. * Maximum Size of emitting particles.
  91111. */
  91112. maxSize: number;
  91113. /**
  91114. * Minimum scale of emitting particles on X axis.
  91115. */
  91116. minScaleX: number;
  91117. /**
  91118. * Maximum scale of emitting particles on X axis.
  91119. */
  91120. maxScaleX: number;
  91121. /**
  91122. * Minimum scale of emitting particles on Y axis.
  91123. */
  91124. minScaleY: number;
  91125. /**
  91126. * Maximum scale of emitting particles on Y axis.
  91127. */
  91128. maxScaleY: number;
  91129. /**
  91130. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  91131. */
  91132. color1: Color4;
  91133. /**
  91134. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  91135. */
  91136. color2: Color4;
  91137. /**
  91138. * Color the particle will have at the end of its lifetime.
  91139. */
  91140. colorDead: Color4;
  91141. /**
  91142. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  91143. */
  91144. emitRate: number;
  91145. /**
  91146. * You can use gravity if you want to give an orientation to your particles.
  91147. */
  91148. gravity: Vector3;
  91149. /**
  91150. * Minimum power of emitting particles.
  91151. */
  91152. minEmitPower: number;
  91153. /**
  91154. * Maximum power of emitting particles.
  91155. */
  91156. maxEmitPower: number;
  91157. /**
  91158. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  91159. */
  91160. minAngularSpeed: number;
  91161. /**
  91162. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  91163. */
  91164. maxAngularSpeed: number;
  91165. /**
  91166. * Gets or sets the minimal initial rotation in radians.
  91167. */
  91168. minInitialRotation: number;
  91169. /**
  91170. * Gets or sets the maximal initial rotation in radians.
  91171. */
  91172. maxInitialRotation: number;
  91173. /**
  91174. * The particle emitter type defines the emitter used by the particle system.
  91175. * It can be for example box, sphere, or cone...
  91176. */
  91177. particleEmitterType: Nullable<IParticleEmitterType>;
  91178. /**
  91179. * Defines the delay in milliseconds before starting the system (0 by default)
  91180. */
  91181. startDelay: number;
  91182. /**
  91183. * 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
  91184. */
  91185. preWarmCycles: number;
  91186. /**
  91187. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  91188. */
  91189. preWarmStepOffset: number;
  91190. /**
  91191. * 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)
  91192. */
  91193. spriteCellChangeSpeed: number;
  91194. /**
  91195. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  91196. */
  91197. startSpriteCellID: number;
  91198. /**
  91199. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  91200. */
  91201. endSpriteCellID: number;
  91202. /**
  91203. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  91204. */
  91205. spriteCellWidth: number;
  91206. /**
  91207. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  91208. */
  91209. spriteCellHeight: number;
  91210. /**
  91211. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  91212. */
  91213. spriteRandomStartCell: boolean;
  91214. /**
  91215. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  91216. */
  91217. isAnimationSheetEnabled: boolean;
  91218. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  91219. translationPivot: Vector2;
  91220. /**
  91221. * Gets or sets a texture used to add random noise to particle positions
  91222. */
  91223. noiseTexture: Nullable<BaseTexture>;
  91224. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  91225. noiseStrength: Vector3;
  91226. /**
  91227. * Gets or sets the billboard mode to use when isBillboardBased = true.
  91228. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  91229. */
  91230. billboardMode: number;
  91231. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  91232. limitVelocityDamping: number;
  91233. /**
  91234. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  91235. */
  91236. beginAnimationOnStart: boolean;
  91237. /**
  91238. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  91239. */
  91240. beginAnimationFrom: number;
  91241. /**
  91242. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  91243. */
  91244. beginAnimationTo: number;
  91245. /**
  91246. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  91247. */
  91248. beginAnimationLoop: boolean;
  91249. /**
  91250. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  91251. */
  91252. disposeOnStop: boolean;
  91253. /**
  91254. * Specifies if the particles are updated in emitter local space or world space
  91255. */
  91256. isLocal: boolean;
  91257. /** Snippet ID if the particle system was created from the snippet server */
  91258. snippetId: string;
  91259. /**
  91260. * Gets the maximum number of particles active at the same time.
  91261. * @returns The max number of active particles.
  91262. */
  91263. getCapacity(): number;
  91264. /**
  91265. * Gets the number of particles active at the same time.
  91266. * @returns The number of active particles.
  91267. */
  91268. getActiveCount(): number;
  91269. /**
  91270. * Gets if the system has been started. (Note: this will still be true after stop is called)
  91271. * @returns True if it has been started, otherwise false.
  91272. */
  91273. isStarted(): boolean;
  91274. /**
  91275. * Animates the particle system for this frame.
  91276. */
  91277. animate(): void;
  91278. /**
  91279. * Renders the particle system in its current state.
  91280. * @returns the current number of particles
  91281. */
  91282. render(): number;
  91283. /**
  91284. * Dispose the particle system and frees its associated resources.
  91285. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  91286. */
  91287. dispose(disposeTexture?: boolean): void;
  91288. /**
  91289. * An event triggered when the system is disposed
  91290. */
  91291. onDisposeObservable: Observable<IParticleSystem>;
  91292. /**
  91293. * Clones the particle system.
  91294. * @param name The name of the cloned object
  91295. * @param newEmitter The new emitter to use
  91296. * @returns the cloned particle system
  91297. */
  91298. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  91299. /**
  91300. * Serializes the particle system to a JSON object
  91301. * @param serializeTexture defines if the texture must be serialized as well
  91302. * @returns the JSON object
  91303. */
  91304. serialize(serializeTexture: boolean): any;
  91305. /**
  91306. * Rebuild the particle system
  91307. */
  91308. rebuild(): void;
  91309. /** Force the system to rebuild all gradients that need to be resync */
  91310. forceRefreshGradients(): void;
  91311. /**
  91312. * Starts the particle system and begins to emit
  91313. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  91314. */
  91315. start(delay?: number): void;
  91316. /**
  91317. * Stops the particle system.
  91318. */
  91319. stop(): void;
  91320. /**
  91321. * Remove all active particles
  91322. */
  91323. reset(): void;
  91324. /**
  91325. * Gets a boolean indicating that the system is stopping
  91326. * @returns true if the system is currently stopping
  91327. */
  91328. isStopping(): boolean;
  91329. /**
  91330. * Is this system ready to be used/rendered
  91331. * @return true if the system is ready
  91332. */
  91333. isReady(): boolean;
  91334. /**
  91335. * Returns the string "ParticleSystem"
  91336. * @returns a string containing the class name
  91337. */
  91338. getClassName(): string;
  91339. /**
  91340. * Gets the custom effect used to render the particles
  91341. * @param blendMode Blend mode for which the effect should be retrieved
  91342. * @returns The effect
  91343. */
  91344. getCustomEffect(blendMode: number): Nullable<Effect>;
  91345. /**
  91346. * Sets the custom effect used to render the particles
  91347. * @param effect The effect to set
  91348. * @param blendMode Blend mode for which the effect should be set
  91349. */
  91350. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  91351. /**
  91352. * Fill the defines array according to the current settings of the particle system
  91353. * @param defines Array to be updated
  91354. * @param blendMode blend mode to take into account when updating the array
  91355. */
  91356. fillDefines(defines: Array<string>, blendMode: number): void;
  91357. /**
  91358. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  91359. * @param uniforms Uniforms array to fill
  91360. * @param attributes Attributes array to fill
  91361. * @param samplers Samplers array to fill
  91362. */
  91363. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  91364. /**
  91365. * Observable that will be called just before the particles are drawn
  91366. */
  91367. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  91368. /**
  91369. * Gets the name of the particle vertex shader
  91370. */
  91371. vertexShaderName: string;
  91372. /**
  91373. * Adds a new color gradient
  91374. * @param gradient defines the gradient to use (between 0 and 1)
  91375. * @param color1 defines the color to affect to the specified gradient
  91376. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  91377. * @returns the current particle system
  91378. */
  91379. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  91380. /**
  91381. * Remove a specific color gradient
  91382. * @param gradient defines the gradient to remove
  91383. * @returns the current particle system
  91384. */
  91385. removeColorGradient(gradient: number): IParticleSystem;
  91386. /**
  91387. * Adds a new size gradient
  91388. * @param gradient defines the gradient to use (between 0 and 1)
  91389. * @param factor defines the size factor to affect to the specified gradient
  91390. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91391. * @returns the current particle system
  91392. */
  91393. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91394. /**
  91395. * Remove a specific size gradient
  91396. * @param gradient defines the gradient to remove
  91397. * @returns the current particle system
  91398. */
  91399. removeSizeGradient(gradient: number): IParticleSystem;
  91400. /**
  91401. * Gets the current list of color gradients.
  91402. * You must use addColorGradient and removeColorGradient to udpate this list
  91403. * @returns the list of color gradients
  91404. */
  91405. getColorGradients(): Nullable<Array<ColorGradient>>;
  91406. /**
  91407. * Gets the current list of size gradients.
  91408. * You must use addSizeGradient and removeSizeGradient to udpate this list
  91409. * @returns the list of size gradients
  91410. */
  91411. getSizeGradients(): Nullable<Array<FactorGradient>>;
  91412. /**
  91413. * Gets the current list of angular speed gradients.
  91414. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  91415. * @returns the list of angular speed gradients
  91416. */
  91417. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  91418. /**
  91419. * Adds a new angular speed gradient
  91420. * @param gradient defines the gradient to use (between 0 and 1)
  91421. * @param factor defines the angular speed to affect to the specified gradient
  91422. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91423. * @returns the current particle system
  91424. */
  91425. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91426. /**
  91427. * Remove a specific angular speed gradient
  91428. * @param gradient defines the gradient to remove
  91429. * @returns the current particle system
  91430. */
  91431. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  91432. /**
  91433. * Gets the current list of velocity gradients.
  91434. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  91435. * @returns the list of velocity gradients
  91436. */
  91437. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  91438. /**
  91439. * Adds a new velocity gradient
  91440. * @param gradient defines the gradient to use (between 0 and 1)
  91441. * @param factor defines the velocity to affect to the specified gradient
  91442. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91443. * @returns the current particle system
  91444. */
  91445. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91446. /**
  91447. * Remove a specific velocity gradient
  91448. * @param gradient defines the gradient to remove
  91449. * @returns the current particle system
  91450. */
  91451. removeVelocityGradient(gradient: number): IParticleSystem;
  91452. /**
  91453. * Gets the current list of limit velocity gradients.
  91454. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  91455. * @returns the list of limit velocity gradients
  91456. */
  91457. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  91458. /**
  91459. * Adds a new limit velocity gradient
  91460. * @param gradient defines the gradient to use (between 0 and 1)
  91461. * @param factor defines the limit velocity to affect to the specified gradient
  91462. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91463. * @returns the current particle system
  91464. */
  91465. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91466. /**
  91467. * Remove a specific limit velocity gradient
  91468. * @param gradient defines the gradient to remove
  91469. * @returns the current particle system
  91470. */
  91471. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  91472. /**
  91473. * Adds a new drag gradient
  91474. * @param gradient defines the gradient to use (between 0 and 1)
  91475. * @param factor defines the drag to affect to the specified gradient
  91476. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91477. * @returns the current particle system
  91478. */
  91479. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91480. /**
  91481. * Remove a specific drag gradient
  91482. * @param gradient defines the gradient to remove
  91483. * @returns the current particle system
  91484. */
  91485. removeDragGradient(gradient: number): IParticleSystem;
  91486. /**
  91487. * Gets the current list of drag gradients.
  91488. * You must use addDragGradient and removeDragGradient to udpate this list
  91489. * @returns the list of drag gradients
  91490. */
  91491. getDragGradients(): Nullable<Array<FactorGradient>>;
  91492. /**
  91493. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  91494. * @param gradient defines the gradient to use (between 0 and 1)
  91495. * @param factor defines the emit rate to affect to the specified gradient
  91496. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91497. * @returns the current particle system
  91498. */
  91499. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91500. /**
  91501. * Remove a specific emit rate gradient
  91502. * @param gradient defines the gradient to remove
  91503. * @returns the current particle system
  91504. */
  91505. removeEmitRateGradient(gradient: number): IParticleSystem;
  91506. /**
  91507. * Gets the current list of emit rate gradients.
  91508. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  91509. * @returns the list of emit rate gradients
  91510. */
  91511. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  91512. /**
  91513. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  91514. * @param gradient defines the gradient to use (between 0 and 1)
  91515. * @param factor defines the start size to affect to the specified gradient
  91516. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91517. * @returns the current particle system
  91518. */
  91519. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91520. /**
  91521. * Remove a specific start size gradient
  91522. * @param gradient defines the gradient to remove
  91523. * @returns the current particle system
  91524. */
  91525. removeStartSizeGradient(gradient: number): IParticleSystem;
  91526. /**
  91527. * Gets the current list of start size gradients.
  91528. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  91529. * @returns the list of start size gradients
  91530. */
  91531. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  91532. /**
  91533. * Adds a new life time gradient
  91534. * @param gradient defines the gradient to use (between 0 and 1)
  91535. * @param factor defines the life time factor to affect to the specified gradient
  91536. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91537. * @returns the current particle system
  91538. */
  91539. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91540. /**
  91541. * Remove a specific life time gradient
  91542. * @param gradient defines the gradient to remove
  91543. * @returns the current particle system
  91544. */
  91545. removeLifeTimeGradient(gradient: number): IParticleSystem;
  91546. /**
  91547. * Gets the current list of life time gradients.
  91548. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  91549. * @returns the list of life time gradients
  91550. */
  91551. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  91552. /**
  91553. * Gets the current list of color gradients.
  91554. * You must use addColorGradient and removeColorGradient to udpate this list
  91555. * @returns the list of color gradients
  91556. */
  91557. getColorGradients(): Nullable<Array<ColorGradient>>;
  91558. /**
  91559. * Adds a new ramp gradient used to remap particle colors
  91560. * @param gradient defines the gradient to use (between 0 and 1)
  91561. * @param color defines the color to affect to the specified gradient
  91562. * @returns the current particle system
  91563. */
  91564. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  91565. /**
  91566. * Gets the current list of ramp gradients.
  91567. * You must use addRampGradient and removeRampGradient to udpate this list
  91568. * @returns the list of ramp gradients
  91569. */
  91570. getRampGradients(): Nullable<Array<Color3Gradient>>;
  91571. /** Gets or sets a boolean indicating that ramp gradients must be used
  91572. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  91573. */
  91574. useRampGradients: boolean;
  91575. /**
  91576. * Adds a new color remap gradient
  91577. * @param gradient defines the gradient to use (between 0 and 1)
  91578. * @param min defines the color remap minimal range
  91579. * @param max defines the color remap maximal range
  91580. * @returns the current particle system
  91581. */
  91582. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  91583. /**
  91584. * Gets the current list of color remap gradients.
  91585. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  91586. * @returns the list of color remap gradients
  91587. */
  91588. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  91589. /**
  91590. * Adds a new alpha remap gradient
  91591. * @param gradient defines the gradient to use (between 0 and 1)
  91592. * @param min defines the alpha remap minimal range
  91593. * @param max defines the alpha remap maximal range
  91594. * @returns the current particle system
  91595. */
  91596. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  91597. /**
  91598. * Gets the current list of alpha remap gradients.
  91599. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  91600. * @returns the list of alpha remap gradients
  91601. */
  91602. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  91603. /**
  91604. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  91605. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  91606. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  91607. * @returns the emitter
  91608. */
  91609. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  91610. /**
  91611. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  91612. * @param radius The radius of the hemisphere to emit from
  91613. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  91614. * @returns the emitter
  91615. */
  91616. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  91617. /**
  91618. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  91619. * @param radius The radius of the sphere to emit from
  91620. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  91621. * @returns the emitter
  91622. */
  91623. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  91624. /**
  91625. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  91626. * @param radius The radius of the sphere to emit from
  91627. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  91628. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  91629. * @returns the emitter
  91630. */
  91631. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  91632. /**
  91633. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  91634. * @param radius The radius of the emission cylinder
  91635. * @param height The height of the emission cylinder
  91636. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  91637. * @param directionRandomizer How much to randomize the particle direction [0-1]
  91638. * @returns the emitter
  91639. */
  91640. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  91641. /**
  91642. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  91643. * @param radius The radius of the cylinder to emit from
  91644. * @param height The height of the emission cylinder
  91645. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  91646. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  91647. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  91648. * @returns the emitter
  91649. */
  91650. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  91651. /**
  91652. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  91653. * @param radius The radius of the cone to emit from
  91654. * @param angle The base angle of the cone
  91655. * @returns the emitter
  91656. */
  91657. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  91658. /**
  91659. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  91660. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  91661. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  91662. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  91663. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  91664. * @returns the emitter
  91665. */
  91666. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  91667. /**
  91668. * Get hosting scene
  91669. * @returns the scene
  91670. */
  91671. getScene(): Scene;
  91672. }
  91673. }
  91674. declare module BABYLON {
  91675. /**
  91676. * 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.
  91677. * @see https://doc.babylonjs.com/how_to/transformnode
  91678. */
  91679. export class TransformNode extends Node {
  91680. /**
  91681. * Object will not rotate to face the camera
  91682. */
  91683. static BILLBOARDMODE_NONE: number;
  91684. /**
  91685. * Object will rotate to face the camera but only on the x axis
  91686. */
  91687. static BILLBOARDMODE_X: number;
  91688. /**
  91689. * Object will rotate to face the camera but only on the y axis
  91690. */
  91691. static BILLBOARDMODE_Y: number;
  91692. /**
  91693. * Object will rotate to face the camera but only on the z axis
  91694. */
  91695. static BILLBOARDMODE_Z: number;
  91696. /**
  91697. * Object will rotate to face the camera
  91698. */
  91699. static BILLBOARDMODE_ALL: number;
  91700. /**
  91701. * Object will rotate to face the camera's position instead of orientation
  91702. */
  91703. static BILLBOARDMODE_USE_POSITION: number;
  91704. private _forward;
  91705. private _forwardInverted;
  91706. private _up;
  91707. private _right;
  91708. private _rightInverted;
  91709. private _position;
  91710. private _rotation;
  91711. private _rotationQuaternion;
  91712. protected _scaling: Vector3;
  91713. protected _isDirty: boolean;
  91714. private _transformToBoneReferal;
  91715. private _isAbsoluteSynced;
  91716. private _billboardMode;
  91717. /**
  91718. * Gets or sets the billboard mode. Default is 0.
  91719. *
  91720. * | Value | Type | Description |
  91721. * | --- | --- | --- |
  91722. * | 0 | BILLBOARDMODE_NONE | |
  91723. * | 1 | BILLBOARDMODE_X | |
  91724. * | 2 | BILLBOARDMODE_Y | |
  91725. * | 4 | BILLBOARDMODE_Z | |
  91726. * | 7 | BILLBOARDMODE_ALL | |
  91727. *
  91728. */
  91729. get billboardMode(): number;
  91730. set billboardMode(value: number);
  91731. private _preserveParentRotationForBillboard;
  91732. /**
  91733. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  91734. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  91735. */
  91736. get preserveParentRotationForBillboard(): boolean;
  91737. set preserveParentRotationForBillboard(value: boolean);
  91738. /**
  91739. * 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
  91740. */
  91741. scalingDeterminant: number;
  91742. private _infiniteDistance;
  91743. /**
  91744. * Gets or sets the distance of the object to max, often used by skybox
  91745. */
  91746. get infiniteDistance(): boolean;
  91747. set infiniteDistance(value: boolean);
  91748. /**
  91749. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  91750. * By default the system will update normals to compensate
  91751. */
  91752. ignoreNonUniformScaling: boolean;
  91753. /**
  91754. * 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
  91755. */
  91756. reIntegrateRotationIntoRotationQuaternion: boolean;
  91757. /** @hidden */
  91758. _poseMatrix: Nullable<Matrix>;
  91759. /** @hidden */
  91760. _localMatrix: Matrix;
  91761. private _usePivotMatrix;
  91762. private _absolutePosition;
  91763. private _absoluteScaling;
  91764. private _absoluteRotationQuaternion;
  91765. private _pivotMatrix;
  91766. private _pivotMatrixInverse;
  91767. protected _postMultiplyPivotMatrix: boolean;
  91768. protected _isWorldMatrixFrozen: boolean;
  91769. /** @hidden */
  91770. _indexInSceneTransformNodesArray: number;
  91771. /**
  91772. * An event triggered after the world matrix is updated
  91773. */
  91774. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  91775. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  91776. /**
  91777. * Gets a string identifying the name of the class
  91778. * @returns "TransformNode" string
  91779. */
  91780. getClassName(): string;
  91781. /**
  91782. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  91783. */
  91784. get position(): Vector3;
  91785. set position(newPosition: Vector3);
  91786. /**
  91787. * 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)).
  91788. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  91789. */
  91790. get rotation(): Vector3;
  91791. set rotation(newRotation: Vector3);
  91792. /**
  91793. * 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)).
  91794. */
  91795. get scaling(): Vector3;
  91796. set scaling(newScaling: Vector3);
  91797. /**
  91798. * 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).
  91799. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  91800. */
  91801. get rotationQuaternion(): Nullable<Quaternion>;
  91802. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  91803. /**
  91804. * The forward direction of that transform in world space.
  91805. */
  91806. get forward(): Vector3;
  91807. /**
  91808. * The up direction of that transform in world space.
  91809. */
  91810. get up(): Vector3;
  91811. /**
  91812. * The right direction of that transform in world space.
  91813. */
  91814. get right(): Vector3;
  91815. /**
  91816. * Copies the parameter passed Matrix into the mesh Pose matrix.
  91817. * @param matrix the matrix to copy the pose from
  91818. * @returns this TransformNode.
  91819. */
  91820. updatePoseMatrix(matrix: Matrix): TransformNode;
  91821. /**
  91822. * Returns the mesh Pose matrix.
  91823. * @returns the pose matrix
  91824. */
  91825. getPoseMatrix(): Matrix;
  91826. /** @hidden */
  91827. _isSynchronized(): boolean;
  91828. /** @hidden */
  91829. _initCache(): void;
  91830. /**
  91831. * Flag the transform node as dirty (Forcing it to update everything)
  91832. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  91833. * @returns this transform node
  91834. */
  91835. markAsDirty(property: string): TransformNode;
  91836. /**
  91837. * Returns the current mesh absolute position.
  91838. * Returns a Vector3.
  91839. */
  91840. get absolutePosition(): Vector3;
  91841. /**
  91842. * Returns the current mesh absolute scaling.
  91843. * Returns a Vector3.
  91844. */
  91845. get absoluteScaling(): Vector3;
  91846. /**
  91847. * Returns the current mesh absolute rotation.
  91848. * Returns a Quaternion.
  91849. */
  91850. get absoluteRotationQuaternion(): Quaternion;
  91851. /**
  91852. * Sets a new matrix to apply before all other transformation
  91853. * @param matrix defines the transform matrix
  91854. * @returns the current TransformNode
  91855. */
  91856. setPreTransformMatrix(matrix: Matrix): TransformNode;
  91857. /**
  91858. * Sets a new pivot matrix to the current node
  91859. * @param matrix defines the new pivot matrix to use
  91860. * @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
  91861. * @returns the current TransformNode
  91862. */
  91863. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  91864. /**
  91865. * Returns the mesh pivot matrix.
  91866. * Default : Identity.
  91867. * @returns the matrix
  91868. */
  91869. getPivotMatrix(): Matrix;
  91870. /**
  91871. * Instantiate (when possible) or clone that node with its hierarchy
  91872. * @param newParent defines the new parent to use for the instance (or clone)
  91873. * @param options defines options to configure how copy is done
  91874. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  91875. * @returns an instance (or a clone) of the current node with its hiearchy
  91876. */
  91877. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  91878. doNotInstantiate: boolean;
  91879. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  91880. /**
  91881. * Prevents the World matrix to be computed any longer
  91882. * @param newWorldMatrix defines an optional matrix to use as world matrix
  91883. * @returns the TransformNode.
  91884. */
  91885. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  91886. /**
  91887. * Allows back the World matrix computation.
  91888. * @returns the TransformNode.
  91889. */
  91890. unfreezeWorldMatrix(): this;
  91891. /**
  91892. * True if the World matrix has been frozen.
  91893. */
  91894. get isWorldMatrixFrozen(): boolean;
  91895. /**
  91896. * Retuns the mesh absolute position in the World.
  91897. * @returns a Vector3.
  91898. */
  91899. getAbsolutePosition(): Vector3;
  91900. /**
  91901. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  91902. * @param absolutePosition the absolute position to set
  91903. * @returns the TransformNode.
  91904. */
  91905. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  91906. /**
  91907. * Sets the mesh position in its local space.
  91908. * @param vector3 the position to set in localspace
  91909. * @returns the TransformNode.
  91910. */
  91911. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  91912. /**
  91913. * Returns the mesh position in the local space from the current World matrix values.
  91914. * @returns a new Vector3.
  91915. */
  91916. getPositionExpressedInLocalSpace(): Vector3;
  91917. /**
  91918. * Translates the mesh along the passed Vector3 in its local space.
  91919. * @param vector3 the distance to translate in localspace
  91920. * @returns the TransformNode.
  91921. */
  91922. locallyTranslate(vector3: Vector3): TransformNode;
  91923. private static _lookAtVectorCache;
  91924. /**
  91925. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  91926. * @param targetPoint the position (must be in same space as current mesh) to look at
  91927. * @param yawCor optional yaw (y-axis) correction in radians
  91928. * @param pitchCor optional pitch (x-axis) correction in radians
  91929. * @param rollCor optional roll (z-axis) correction in radians
  91930. * @param space the choosen space of the target
  91931. * @returns the TransformNode.
  91932. */
  91933. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  91934. /**
  91935. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  91936. * This Vector3 is expressed in the World space.
  91937. * @param localAxis axis to rotate
  91938. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  91939. */
  91940. getDirection(localAxis: Vector3): Vector3;
  91941. /**
  91942. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  91943. * localAxis is expressed in the mesh local space.
  91944. * result is computed in the Wordl space from the mesh World matrix.
  91945. * @param localAxis axis to rotate
  91946. * @param result the resulting transformnode
  91947. * @returns this TransformNode.
  91948. */
  91949. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  91950. /**
  91951. * Sets this transform node rotation to the given local axis.
  91952. * @param localAxis the axis in local space
  91953. * @param yawCor optional yaw (y-axis) correction in radians
  91954. * @param pitchCor optional pitch (x-axis) correction in radians
  91955. * @param rollCor optional roll (z-axis) correction in radians
  91956. * @returns this TransformNode
  91957. */
  91958. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  91959. /**
  91960. * Sets a new pivot point to the current node
  91961. * @param point defines the new pivot point to use
  91962. * @param space defines if the point is in world or local space (local by default)
  91963. * @returns the current TransformNode
  91964. */
  91965. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  91966. /**
  91967. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  91968. * @returns the pivot point
  91969. */
  91970. getPivotPoint(): Vector3;
  91971. /**
  91972. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  91973. * @param result the vector3 to store the result
  91974. * @returns this TransformNode.
  91975. */
  91976. getPivotPointToRef(result: Vector3): TransformNode;
  91977. /**
  91978. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  91979. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  91980. */
  91981. getAbsolutePivotPoint(): Vector3;
  91982. /**
  91983. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  91984. * @param result vector3 to store the result
  91985. * @returns this TransformNode.
  91986. */
  91987. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  91988. /**
  91989. * Defines the passed node as the parent of the current node.
  91990. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  91991. * @see https://doc.babylonjs.com/how_to/parenting
  91992. * @param node the node ot set as the parent
  91993. * @returns this TransformNode.
  91994. */
  91995. setParent(node: Nullable<Node>): TransformNode;
  91996. private _nonUniformScaling;
  91997. /**
  91998. * True if the scaling property of this object is non uniform eg. (1,2,1)
  91999. */
  92000. get nonUniformScaling(): boolean;
  92001. /** @hidden */
  92002. _updateNonUniformScalingState(value: boolean): boolean;
  92003. /**
  92004. * Attach the current TransformNode to another TransformNode associated with a bone
  92005. * @param bone Bone affecting the TransformNode
  92006. * @param affectedTransformNode TransformNode associated with the bone
  92007. * @returns this object
  92008. */
  92009. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  92010. /**
  92011. * Detach the transform node if its associated with a bone
  92012. * @returns this object
  92013. */
  92014. detachFromBone(): TransformNode;
  92015. private static _rotationAxisCache;
  92016. /**
  92017. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  92018. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  92019. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  92020. * The passed axis is also normalized.
  92021. * @param axis the axis to rotate around
  92022. * @param amount the amount to rotate in radians
  92023. * @param space Space to rotate in (Default: local)
  92024. * @returns the TransformNode.
  92025. */
  92026. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  92027. /**
  92028. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  92029. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  92030. * The passed axis is also normalized. .
  92031. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  92032. * @param point the point to rotate around
  92033. * @param axis the axis to rotate around
  92034. * @param amount the amount to rotate in radians
  92035. * @returns the TransformNode
  92036. */
  92037. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  92038. /**
  92039. * Translates the mesh along the axis vector for the passed distance in the given space.
  92040. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  92041. * @param axis the axis to translate in
  92042. * @param distance the distance to translate
  92043. * @param space Space to rotate in (Default: local)
  92044. * @returns the TransformNode.
  92045. */
  92046. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  92047. /**
  92048. * Adds a rotation step to the mesh current rotation.
  92049. * x, y, z are Euler angles expressed in radians.
  92050. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  92051. * This means this rotation is made in the mesh local space only.
  92052. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  92053. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  92054. * ```javascript
  92055. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  92056. * ```
  92057. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  92058. * 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.
  92059. * @param x Rotation to add
  92060. * @param y Rotation to add
  92061. * @param z Rotation to add
  92062. * @returns the TransformNode.
  92063. */
  92064. addRotation(x: number, y: number, z: number): TransformNode;
  92065. /**
  92066. * @hidden
  92067. */
  92068. protected _getEffectiveParent(): Nullable<Node>;
  92069. /**
  92070. * Computes the world matrix of the node
  92071. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  92072. * @returns the world matrix
  92073. */
  92074. computeWorldMatrix(force?: boolean): Matrix;
  92075. /**
  92076. * Resets this nodeTransform's local matrix to Matrix.Identity().
  92077. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  92078. */
  92079. resetLocalMatrix(independentOfChildren?: boolean): void;
  92080. protected _afterComputeWorldMatrix(): void;
  92081. /**
  92082. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  92083. * @param func callback function to add
  92084. *
  92085. * @returns the TransformNode.
  92086. */
  92087. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  92088. /**
  92089. * Removes a registered callback function.
  92090. * @param func callback function to remove
  92091. * @returns the TransformNode.
  92092. */
  92093. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  92094. /**
  92095. * Gets the position of the current mesh in camera space
  92096. * @param camera defines the camera to use
  92097. * @returns a position
  92098. */
  92099. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  92100. /**
  92101. * Returns the distance from the mesh to the active camera
  92102. * @param camera defines the camera to use
  92103. * @returns the distance
  92104. */
  92105. getDistanceToCamera(camera?: Nullable<Camera>): number;
  92106. /**
  92107. * Clone the current transform node
  92108. * @param name Name of the new clone
  92109. * @param newParent New parent for the clone
  92110. * @param doNotCloneChildren Do not clone children hierarchy
  92111. * @returns the new transform node
  92112. */
  92113. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  92114. /**
  92115. * Serializes the objects information.
  92116. * @param currentSerializationObject defines the object to serialize in
  92117. * @returns the serialized object
  92118. */
  92119. serialize(currentSerializationObject?: any): any;
  92120. /**
  92121. * Returns a new TransformNode object parsed from the source provided.
  92122. * @param parsedTransformNode is the source.
  92123. * @param scene the scne the object belongs to
  92124. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  92125. * @returns a new TransformNode object parsed from the source provided.
  92126. */
  92127. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  92128. /**
  92129. * Get all child-transformNodes of this node
  92130. * @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
  92131. * @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
  92132. * @returns an array of TransformNode
  92133. */
  92134. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  92135. /**
  92136. * Releases resources associated with this transform node.
  92137. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  92138. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  92139. */
  92140. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  92141. /**
  92142. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  92143. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  92144. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  92145. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  92146. * @returns the current mesh
  92147. */
  92148. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  92149. private _syncAbsoluteScalingAndRotation;
  92150. }
  92151. }
  92152. declare module BABYLON {
  92153. /**
  92154. * Class used to override all child animations of a given target
  92155. */
  92156. export class AnimationPropertiesOverride {
  92157. /**
  92158. * Gets or sets a value indicating if animation blending must be used
  92159. */
  92160. enableBlending: boolean;
  92161. /**
  92162. * Gets or sets the blending speed to use when enableBlending is true
  92163. */
  92164. blendingSpeed: number;
  92165. /**
  92166. * Gets or sets the default loop mode to use
  92167. */
  92168. loopMode: number;
  92169. }
  92170. }
  92171. declare module BABYLON {
  92172. /**
  92173. * Class used to store bone information
  92174. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  92175. */
  92176. export class Bone extends Node {
  92177. /**
  92178. * defines the bone name
  92179. */
  92180. name: string;
  92181. private static _tmpVecs;
  92182. private static _tmpQuat;
  92183. private static _tmpMats;
  92184. /**
  92185. * Gets the list of child bones
  92186. */
  92187. children: Bone[];
  92188. /** Gets the animations associated with this bone */
  92189. animations: Animation[];
  92190. /**
  92191. * Gets or sets bone length
  92192. */
  92193. length: number;
  92194. /**
  92195. * @hidden Internal only
  92196. * Set this value to map this bone to a different index in the transform matrices
  92197. * Set this value to -1 to exclude the bone from the transform matrices
  92198. */
  92199. _index: Nullable<number>;
  92200. private _skeleton;
  92201. private _localMatrix;
  92202. private _restPose;
  92203. private _baseMatrix;
  92204. private _absoluteTransform;
  92205. private _invertedAbsoluteTransform;
  92206. private _parent;
  92207. private _scalingDeterminant;
  92208. private _worldTransform;
  92209. private _localScaling;
  92210. private _localRotation;
  92211. private _localPosition;
  92212. private _needToDecompose;
  92213. private _needToCompose;
  92214. /** @hidden */
  92215. _linkedTransformNode: Nullable<TransformNode>;
  92216. /** @hidden */
  92217. _waitingTransformNodeId: Nullable<string>;
  92218. /** @hidden */
  92219. get _matrix(): Matrix;
  92220. /** @hidden */
  92221. set _matrix(value: Matrix);
  92222. /**
  92223. * Create a new bone
  92224. * @param name defines the bone name
  92225. * @param skeleton defines the parent skeleton
  92226. * @param parentBone defines the parent (can be null if the bone is the root)
  92227. * @param localMatrix defines the local matrix
  92228. * @param restPose defines the rest pose matrix
  92229. * @param baseMatrix defines the base matrix
  92230. * @param index defines index of the bone in the hiearchy
  92231. */
  92232. constructor(
  92233. /**
  92234. * defines the bone name
  92235. */
  92236. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  92237. /**
  92238. * Gets the current object class name.
  92239. * @return the class name
  92240. */
  92241. getClassName(): string;
  92242. /**
  92243. * Gets the parent skeleton
  92244. * @returns a skeleton
  92245. */
  92246. getSkeleton(): Skeleton;
  92247. /**
  92248. * Gets parent bone
  92249. * @returns a bone or null if the bone is the root of the bone hierarchy
  92250. */
  92251. getParent(): Nullable<Bone>;
  92252. /**
  92253. * Returns an array containing the root bones
  92254. * @returns an array containing the root bones
  92255. */
  92256. getChildren(): Array<Bone>;
  92257. /**
  92258. * Gets the node index in matrix array generated for rendering
  92259. * @returns the node index
  92260. */
  92261. getIndex(): number;
  92262. /**
  92263. * Sets the parent bone
  92264. * @param parent defines the parent (can be null if the bone is the root)
  92265. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  92266. */
  92267. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  92268. /**
  92269. * Gets the local matrix
  92270. * @returns a matrix
  92271. */
  92272. getLocalMatrix(): Matrix;
  92273. /**
  92274. * Gets the base matrix (initial matrix which remains unchanged)
  92275. * @returns a matrix
  92276. */
  92277. getBaseMatrix(): Matrix;
  92278. /**
  92279. * Gets the rest pose matrix
  92280. * @returns a matrix
  92281. */
  92282. getRestPose(): Matrix;
  92283. /**
  92284. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  92285. */
  92286. getWorldMatrix(): Matrix;
  92287. /**
  92288. * Sets the local matrix to rest pose matrix
  92289. */
  92290. returnToRest(): void;
  92291. /**
  92292. * Gets the inverse of the absolute transform matrix.
  92293. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  92294. * @returns a matrix
  92295. */
  92296. getInvertedAbsoluteTransform(): Matrix;
  92297. /**
  92298. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  92299. * @returns a matrix
  92300. */
  92301. getAbsoluteTransform(): Matrix;
  92302. /**
  92303. * Links with the given transform node.
  92304. * The local matrix of this bone is copied from the transform node every frame.
  92305. * @param transformNode defines the transform node to link to
  92306. */
  92307. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  92308. /**
  92309. * Gets the node used to drive the bone's transformation
  92310. * @returns a transform node or null
  92311. */
  92312. getTransformNode(): Nullable<TransformNode>;
  92313. /** Gets or sets current position (in local space) */
  92314. get position(): Vector3;
  92315. set position(newPosition: Vector3);
  92316. /** Gets or sets current rotation (in local space) */
  92317. get rotation(): Vector3;
  92318. set rotation(newRotation: Vector3);
  92319. /** Gets or sets current rotation quaternion (in local space) */
  92320. get rotationQuaternion(): Quaternion;
  92321. set rotationQuaternion(newRotation: Quaternion);
  92322. /** Gets or sets current scaling (in local space) */
  92323. get scaling(): Vector3;
  92324. set scaling(newScaling: Vector3);
  92325. /**
  92326. * Gets the animation properties override
  92327. */
  92328. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  92329. private _decompose;
  92330. private _compose;
  92331. /**
  92332. * Update the base and local matrices
  92333. * @param matrix defines the new base or local matrix
  92334. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  92335. * @param updateLocalMatrix defines if the local matrix should be updated
  92336. */
  92337. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  92338. /** @hidden */
  92339. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  92340. /**
  92341. * Flag the bone as dirty (Forcing it to update everything)
  92342. */
  92343. markAsDirty(): void;
  92344. /** @hidden */
  92345. _markAsDirtyAndCompose(): void;
  92346. private _markAsDirtyAndDecompose;
  92347. /**
  92348. * Translate the bone in local or world space
  92349. * @param vec The amount to translate the bone
  92350. * @param space The space that the translation is in
  92351. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92352. */
  92353. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  92354. /**
  92355. * Set the postion of the bone in local or world space
  92356. * @param position The position to set the bone
  92357. * @param space The space that the position is in
  92358. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92359. */
  92360. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  92361. /**
  92362. * Set the absolute position of the bone (world space)
  92363. * @param position The position to set the bone
  92364. * @param mesh The mesh that this bone is attached to
  92365. */
  92366. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  92367. /**
  92368. * Scale the bone on the x, y and z axes (in local space)
  92369. * @param x The amount to scale the bone on the x axis
  92370. * @param y The amount to scale the bone on the y axis
  92371. * @param z The amount to scale the bone on the z axis
  92372. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  92373. */
  92374. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  92375. /**
  92376. * Set the bone scaling in local space
  92377. * @param scale defines the scaling vector
  92378. */
  92379. setScale(scale: Vector3): void;
  92380. /**
  92381. * Gets the current scaling in local space
  92382. * @returns the current scaling vector
  92383. */
  92384. getScale(): Vector3;
  92385. /**
  92386. * Gets the current scaling in local space and stores it in a target vector
  92387. * @param result defines the target vector
  92388. */
  92389. getScaleToRef(result: Vector3): void;
  92390. /**
  92391. * Set the yaw, pitch, and roll of the bone in local or world space
  92392. * @param yaw The rotation of the bone on the y axis
  92393. * @param pitch The rotation of the bone on the x axis
  92394. * @param roll The rotation of the bone on the z axis
  92395. * @param space The space that the axes of rotation are in
  92396. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92397. */
  92398. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  92399. /**
  92400. * Add a rotation to the bone on an axis in local or world space
  92401. * @param axis The axis to rotate the bone on
  92402. * @param amount The amount to rotate the bone
  92403. * @param space The space that the axis is in
  92404. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92405. */
  92406. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  92407. /**
  92408. * Set the rotation of the bone to a particular axis angle in local or world space
  92409. * @param axis The axis to rotate the bone on
  92410. * @param angle The angle that the bone should be rotated to
  92411. * @param space The space that the axis is in
  92412. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92413. */
  92414. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  92415. /**
  92416. * Set the euler rotation of the bone in local of world space
  92417. * @param rotation The euler rotation that the bone should be set to
  92418. * @param space The space that the rotation is in
  92419. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92420. */
  92421. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  92422. /**
  92423. * Set the quaternion rotation of the bone in local of world space
  92424. * @param quat The quaternion rotation that the bone should be set to
  92425. * @param space The space that the rotation is in
  92426. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92427. */
  92428. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  92429. /**
  92430. * Set the rotation matrix of the bone in local of world space
  92431. * @param rotMat The rotation matrix that the bone should be set to
  92432. * @param space The space that the rotation is in
  92433. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92434. */
  92435. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  92436. private _rotateWithMatrix;
  92437. private _getNegativeRotationToRef;
  92438. /**
  92439. * Get the position of the bone in local or world space
  92440. * @param space The space that the returned position is in
  92441. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92442. * @returns The position of the bone
  92443. */
  92444. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  92445. /**
  92446. * Copy the position of the bone to a vector3 in local or world space
  92447. * @param space The space that the returned position is in
  92448. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92449. * @param result The vector3 to copy the position to
  92450. */
  92451. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  92452. /**
  92453. * Get the absolute position of the bone (world space)
  92454. * @param mesh The mesh that this bone is attached to
  92455. * @returns The absolute position of the bone
  92456. */
  92457. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  92458. /**
  92459. * Copy the absolute position of the bone (world space) to the result param
  92460. * @param mesh The mesh that this bone is attached to
  92461. * @param result The vector3 to copy the absolute position to
  92462. */
  92463. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  92464. /**
  92465. * Compute the absolute transforms of this bone and its children
  92466. */
  92467. computeAbsoluteTransforms(): void;
  92468. /**
  92469. * Get the world direction from an axis that is in the local space of the bone
  92470. * @param localAxis The local direction that is used to compute the world direction
  92471. * @param mesh The mesh that this bone is attached to
  92472. * @returns The world direction
  92473. */
  92474. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  92475. /**
  92476. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  92477. * @param localAxis The local direction that is used to compute the world direction
  92478. * @param mesh The mesh that this bone is attached to
  92479. * @param result The vector3 that the world direction will be copied to
  92480. */
  92481. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  92482. /**
  92483. * Get the euler rotation of the bone in local or world space
  92484. * @param space The space that the rotation should be in
  92485. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92486. * @returns The euler rotation
  92487. */
  92488. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  92489. /**
  92490. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  92491. * @param space The space that the rotation should be in
  92492. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92493. * @param result The vector3 that the rotation should be copied to
  92494. */
  92495. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  92496. /**
  92497. * Get the quaternion rotation of the bone in either local or world space
  92498. * @param space The space that the rotation should be in
  92499. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92500. * @returns The quaternion rotation
  92501. */
  92502. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  92503. /**
  92504. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  92505. * @param space The space that the rotation should be in
  92506. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92507. * @param result The quaternion that the rotation should be copied to
  92508. */
  92509. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  92510. /**
  92511. * Get the rotation matrix of the bone in local or world space
  92512. * @param space The space that the rotation should be in
  92513. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92514. * @returns The rotation matrix
  92515. */
  92516. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  92517. /**
  92518. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  92519. * @param space The space that the rotation should be in
  92520. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92521. * @param result The quaternion that the rotation should be copied to
  92522. */
  92523. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  92524. /**
  92525. * Get the world position of a point that is in the local space of the bone
  92526. * @param position The local position
  92527. * @param mesh The mesh that this bone is attached to
  92528. * @returns The world position
  92529. */
  92530. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  92531. /**
  92532. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  92533. * @param position The local position
  92534. * @param mesh The mesh that this bone is attached to
  92535. * @param result The vector3 that the world position should be copied to
  92536. */
  92537. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  92538. /**
  92539. * Get the local position of a point that is in world space
  92540. * @param position The world position
  92541. * @param mesh The mesh that this bone is attached to
  92542. * @returns The local position
  92543. */
  92544. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  92545. /**
  92546. * Get the local position of a point that is in world space and copy it to the result param
  92547. * @param position The world position
  92548. * @param mesh The mesh that this bone is attached to
  92549. * @param result The vector3 that the local position should be copied to
  92550. */
  92551. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  92552. }
  92553. }
  92554. declare module BABYLON {
  92555. /**
  92556. * Defines a runtime animation
  92557. */
  92558. export class RuntimeAnimation {
  92559. private _events;
  92560. /**
  92561. * The current frame of the runtime animation
  92562. */
  92563. private _currentFrame;
  92564. /**
  92565. * The animation used by the runtime animation
  92566. */
  92567. private _animation;
  92568. /**
  92569. * The target of the runtime animation
  92570. */
  92571. private _target;
  92572. /**
  92573. * The initiating animatable
  92574. */
  92575. private _host;
  92576. /**
  92577. * The original value of the runtime animation
  92578. */
  92579. private _originalValue;
  92580. /**
  92581. * The original blend value of the runtime animation
  92582. */
  92583. private _originalBlendValue;
  92584. /**
  92585. * The offsets cache of the runtime animation
  92586. */
  92587. private _offsetsCache;
  92588. /**
  92589. * The high limits cache of the runtime animation
  92590. */
  92591. private _highLimitsCache;
  92592. /**
  92593. * Specifies if the runtime animation has been stopped
  92594. */
  92595. private _stopped;
  92596. /**
  92597. * The blending factor of the runtime animation
  92598. */
  92599. private _blendingFactor;
  92600. /**
  92601. * The BabylonJS scene
  92602. */
  92603. private _scene;
  92604. /**
  92605. * The current value of the runtime animation
  92606. */
  92607. private _currentValue;
  92608. /** @hidden */
  92609. _animationState: _IAnimationState;
  92610. /**
  92611. * The active target of the runtime animation
  92612. */
  92613. private _activeTargets;
  92614. private _currentActiveTarget;
  92615. private _directTarget;
  92616. /**
  92617. * The target path of the runtime animation
  92618. */
  92619. private _targetPath;
  92620. /**
  92621. * The weight of the runtime animation
  92622. */
  92623. private _weight;
  92624. /**
  92625. * The ratio offset of the runtime animation
  92626. */
  92627. private _ratioOffset;
  92628. /**
  92629. * The previous delay of the runtime animation
  92630. */
  92631. private _previousDelay;
  92632. /**
  92633. * The previous ratio of the runtime animation
  92634. */
  92635. private _previousRatio;
  92636. private _enableBlending;
  92637. private _keys;
  92638. private _minFrame;
  92639. private _maxFrame;
  92640. private _minValue;
  92641. private _maxValue;
  92642. private _targetIsArray;
  92643. /**
  92644. * Gets the current frame of the runtime animation
  92645. */
  92646. get currentFrame(): number;
  92647. /**
  92648. * Gets the weight of the runtime animation
  92649. */
  92650. get weight(): number;
  92651. /**
  92652. * Gets the current value of the runtime animation
  92653. */
  92654. get currentValue(): any;
  92655. /**
  92656. * Gets the target path of the runtime animation
  92657. */
  92658. get targetPath(): string;
  92659. /**
  92660. * Gets the actual target of the runtime animation
  92661. */
  92662. get target(): any;
  92663. /**
  92664. * Gets the additive state of the runtime animation
  92665. */
  92666. get isAdditive(): boolean;
  92667. /** @hidden */
  92668. _onLoop: () => void;
  92669. /**
  92670. * Create a new RuntimeAnimation object
  92671. * @param target defines the target of the animation
  92672. * @param animation defines the source animation object
  92673. * @param scene defines the hosting scene
  92674. * @param host defines the initiating Animatable
  92675. */
  92676. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  92677. private _preparePath;
  92678. /**
  92679. * Gets the animation from the runtime animation
  92680. */
  92681. get animation(): Animation;
  92682. /**
  92683. * Resets the runtime animation to the beginning
  92684. * @param restoreOriginal defines whether to restore the target property to the original value
  92685. */
  92686. reset(restoreOriginal?: boolean): void;
  92687. /**
  92688. * Specifies if the runtime animation is stopped
  92689. * @returns Boolean specifying if the runtime animation is stopped
  92690. */
  92691. isStopped(): boolean;
  92692. /**
  92693. * Disposes of the runtime animation
  92694. */
  92695. dispose(): void;
  92696. /**
  92697. * Apply the interpolated value to the target
  92698. * @param currentValue defines the value computed by the animation
  92699. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  92700. */
  92701. setValue(currentValue: any, weight: number): void;
  92702. private _getOriginalValues;
  92703. private _setValue;
  92704. /**
  92705. * Gets the loop pmode of the runtime animation
  92706. * @returns Loop Mode
  92707. */
  92708. private _getCorrectLoopMode;
  92709. /**
  92710. * Move the current animation to a given frame
  92711. * @param frame defines the frame to move to
  92712. */
  92713. goToFrame(frame: number): void;
  92714. /**
  92715. * @hidden Internal use only
  92716. */
  92717. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  92718. /**
  92719. * Execute the current animation
  92720. * @param delay defines the delay to add to the current frame
  92721. * @param from defines the lower bound of the animation range
  92722. * @param to defines the upper bound of the animation range
  92723. * @param loop defines if the current animation must loop
  92724. * @param speedRatio defines the current speed ratio
  92725. * @param weight defines the weight of the animation (default is -1 so no weight)
  92726. * @param onLoop optional callback called when animation loops
  92727. * @returns a boolean indicating if the animation is running
  92728. */
  92729. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  92730. }
  92731. }
  92732. declare module BABYLON {
  92733. /**
  92734. * Class used to store an actual running animation
  92735. */
  92736. export class Animatable {
  92737. /** defines the target object */
  92738. target: any;
  92739. /** defines the starting frame number (default is 0) */
  92740. fromFrame: number;
  92741. /** defines the ending frame number (default is 100) */
  92742. toFrame: number;
  92743. /** defines if the animation must loop (default is false) */
  92744. loopAnimation: boolean;
  92745. /** defines a callback to call when animation ends if it is not looping */
  92746. onAnimationEnd?: (() => void) | null | undefined;
  92747. /** defines a callback to call when animation loops */
  92748. onAnimationLoop?: (() => void) | null | undefined;
  92749. /** defines whether the animation should be evaluated additively */
  92750. isAdditive: boolean;
  92751. private _localDelayOffset;
  92752. private _pausedDelay;
  92753. private _runtimeAnimations;
  92754. private _paused;
  92755. private _scene;
  92756. private _speedRatio;
  92757. private _weight;
  92758. private _syncRoot;
  92759. /**
  92760. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  92761. * This will only apply for non looping animation (default is true)
  92762. */
  92763. disposeOnEnd: boolean;
  92764. /**
  92765. * Gets a boolean indicating if the animation has started
  92766. */
  92767. animationStarted: boolean;
  92768. /**
  92769. * Observer raised when the animation ends
  92770. */
  92771. onAnimationEndObservable: Observable<Animatable>;
  92772. /**
  92773. * Observer raised when the animation loops
  92774. */
  92775. onAnimationLoopObservable: Observable<Animatable>;
  92776. /**
  92777. * Gets the root Animatable used to synchronize and normalize animations
  92778. */
  92779. get syncRoot(): Nullable<Animatable>;
  92780. /**
  92781. * Gets the current frame of the first RuntimeAnimation
  92782. * Used to synchronize Animatables
  92783. */
  92784. get masterFrame(): number;
  92785. /**
  92786. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  92787. */
  92788. get weight(): number;
  92789. set weight(value: number);
  92790. /**
  92791. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  92792. */
  92793. get speedRatio(): number;
  92794. set speedRatio(value: number);
  92795. /**
  92796. * Creates a new Animatable
  92797. * @param scene defines the hosting scene
  92798. * @param target defines the target object
  92799. * @param fromFrame defines the starting frame number (default is 0)
  92800. * @param toFrame defines the ending frame number (default is 100)
  92801. * @param loopAnimation defines if the animation must loop (default is false)
  92802. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  92803. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  92804. * @param animations defines a group of animation to add to the new Animatable
  92805. * @param onAnimationLoop defines a callback to call when animation loops
  92806. * @param isAdditive defines whether the animation should be evaluated additively
  92807. */
  92808. constructor(scene: Scene,
  92809. /** defines the target object */
  92810. target: any,
  92811. /** defines the starting frame number (default is 0) */
  92812. fromFrame?: number,
  92813. /** defines the ending frame number (default is 100) */
  92814. toFrame?: number,
  92815. /** defines if the animation must loop (default is false) */
  92816. loopAnimation?: boolean, speedRatio?: number,
  92817. /** defines a callback to call when animation ends if it is not looping */
  92818. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  92819. /** defines a callback to call when animation loops */
  92820. onAnimationLoop?: (() => void) | null | undefined,
  92821. /** defines whether the animation should be evaluated additively */
  92822. isAdditive?: boolean);
  92823. /**
  92824. * Synchronize and normalize current Animatable with a source Animatable
  92825. * This is useful when using animation weights and when animations are not of the same length
  92826. * @param root defines the root Animatable to synchronize with
  92827. * @returns the current Animatable
  92828. */
  92829. syncWith(root: Animatable): Animatable;
  92830. /**
  92831. * Gets the list of runtime animations
  92832. * @returns an array of RuntimeAnimation
  92833. */
  92834. getAnimations(): RuntimeAnimation[];
  92835. /**
  92836. * Adds more animations to the current animatable
  92837. * @param target defines the target of the animations
  92838. * @param animations defines the new animations to add
  92839. */
  92840. appendAnimations(target: any, animations: Animation[]): void;
  92841. /**
  92842. * Gets the source animation for a specific property
  92843. * @param property defines the propertyu to look for
  92844. * @returns null or the source animation for the given property
  92845. */
  92846. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  92847. /**
  92848. * Gets the runtime animation for a specific property
  92849. * @param property defines the propertyu to look for
  92850. * @returns null or the runtime animation for the given property
  92851. */
  92852. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  92853. /**
  92854. * Resets the animatable to its original state
  92855. */
  92856. reset(): void;
  92857. /**
  92858. * Allows the animatable to blend with current running animations
  92859. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  92860. * @param blendingSpeed defines the blending speed to use
  92861. */
  92862. enableBlending(blendingSpeed: number): void;
  92863. /**
  92864. * Disable animation blending
  92865. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  92866. */
  92867. disableBlending(): void;
  92868. /**
  92869. * Jump directly to a given frame
  92870. * @param frame defines the frame to jump to
  92871. */
  92872. goToFrame(frame: number): void;
  92873. /**
  92874. * Pause the animation
  92875. */
  92876. pause(): void;
  92877. /**
  92878. * Restart the animation
  92879. */
  92880. restart(): void;
  92881. private _raiseOnAnimationEnd;
  92882. /**
  92883. * Stop and delete the current animation
  92884. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  92885. * @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)
  92886. */
  92887. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  92888. /**
  92889. * Wait asynchronously for the animation to end
  92890. * @returns a promise which will be fullfilled when the animation ends
  92891. */
  92892. waitAsync(): Promise<Animatable>;
  92893. /** @hidden */
  92894. _animate(delay: number): boolean;
  92895. }
  92896. interface Scene {
  92897. /** @hidden */
  92898. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  92899. /** @hidden */
  92900. _processLateAnimationBindingsForMatrices(holder: {
  92901. totalWeight: number;
  92902. totalAdditiveWeight: number;
  92903. animations: RuntimeAnimation[];
  92904. additiveAnimations: RuntimeAnimation[];
  92905. originalValue: Matrix;
  92906. }): any;
  92907. /** @hidden */
  92908. _processLateAnimationBindingsForQuaternions(holder: {
  92909. totalWeight: number;
  92910. totalAdditiveWeight: number;
  92911. animations: RuntimeAnimation[];
  92912. additiveAnimations: RuntimeAnimation[];
  92913. originalValue: Quaternion;
  92914. }, refQuaternion: Quaternion): Quaternion;
  92915. /** @hidden */
  92916. _processLateAnimationBindings(): void;
  92917. /**
  92918. * Will start the animation sequence of a given target
  92919. * @param target defines the target
  92920. * @param from defines from which frame should animation start
  92921. * @param to defines until which frame should animation run.
  92922. * @param weight defines the weight to apply to the animation (1.0 by default)
  92923. * @param loop defines if the animation loops
  92924. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  92925. * @param onAnimationEnd defines the function to be executed when the animation ends
  92926. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  92927. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  92928. * @param onAnimationLoop defines the callback to call when an animation loops
  92929. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  92930. * @returns the animatable object created for this animation
  92931. */
  92932. 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;
  92933. /**
  92934. * Will start the animation sequence of a given target
  92935. * @param target defines the target
  92936. * @param from defines from which frame should animation start
  92937. * @param to defines until which frame should animation run.
  92938. * @param loop defines if the animation loops
  92939. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  92940. * @param onAnimationEnd defines the function to be executed when the animation ends
  92941. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  92942. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  92943. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  92944. * @param onAnimationLoop defines the callback to call when an animation loops
  92945. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  92946. * @returns the animatable object created for this animation
  92947. */
  92948. 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;
  92949. /**
  92950. * Will start the animation sequence of a given target and its hierarchy
  92951. * @param target defines the target
  92952. * @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.
  92953. * @param from defines from which frame should animation start
  92954. * @param to defines until which frame should animation run.
  92955. * @param loop defines if the animation loops
  92956. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  92957. * @param onAnimationEnd defines the function to be executed when the animation ends
  92958. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  92959. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  92960. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  92961. * @param onAnimationLoop defines the callback to call when an animation loops
  92962. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  92963. * @returns the list of created animatables
  92964. */
  92965. 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[];
  92966. /**
  92967. * Begin a new animation on a given node
  92968. * @param target defines the target where the animation will take place
  92969. * @param animations defines the list of animations to start
  92970. * @param from defines the initial value
  92971. * @param to defines the final value
  92972. * @param loop defines if you want animation to loop (off by default)
  92973. * @param speedRatio defines the speed ratio to apply to all animations
  92974. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  92975. * @param onAnimationLoop defines the callback to call when an animation loops
  92976. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  92977. * @returns the list of created animatables
  92978. */
  92979. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  92980. /**
  92981. * Begin a new animation on a given node and its hierarchy
  92982. * @param target defines the root node where the animation will take place
  92983. * @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.
  92984. * @param animations defines the list of animations to start
  92985. * @param from defines the initial value
  92986. * @param to defines the final value
  92987. * @param loop defines if you want animation to loop (off by default)
  92988. * @param speedRatio defines the speed ratio to apply to all animations
  92989. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  92990. * @param onAnimationLoop defines the callback to call when an animation loops
  92991. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  92992. * @returns the list of animatables created for all nodes
  92993. */
  92994. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  92995. /**
  92996. * Gets the animatable associated with a specific target
  92997. * @param target defines the target of the animatable
  92998. * @returns the required animatable if found
  92999. */
  93000. getAnimatableByTarget(target: any): Nullable<Animatable>;
  93001. /**
  93002. * Gets all animatables associated with a given target
  93003. * @param target defines the target to look animatables for
  93004. * @returns an array of Animatables
  93005. */
  93006. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  93007. /**
  93008. * Stops and removes all animations that have been applied to the scene
  93009. */
  93010. stopAllAnimations(): void;
  93011. /**
  93012. * Gets the current delta time used by animation engine
  93013. */
  93014. deltaTime: number;
  93015. }
  93016. interface Bone {
  93017. /**
  93018. * Copy an animation range from another bone
  93019. * @param source defines the source bone
  93020. * @param rangeName defines the range name to copy
  93021. * @param frameOffset defines the frame offset
  93022. * @param rescaleAsRequired defines if rescaling must be applied if required
  93023. * @param skelDimensionsRatio defines the scaling ratio
  93024. * @returns true if operation was successful
  93025. */
  93026. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  93027. }
  93028. }
  93029. declare module BABYLON {
  93030. /**
  93031. * Class used to handle skinning animations
  93032. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  93033. */
  93034. export class Skeleton implements IAnimatable {
  93035. /** defines the skeleton name */
  93036. name: string;
  93037. /** defines the skeleton Id */
  93038. id: string;
  93039. /**
  93040. * Defines the list of child bones
  93041. */
  93042. bones: Bone[];
  93043. /**
  93044. * Defines an estimate of the dimension of the skeleton at rest
  93045. */
  93046. dimensionsAtRest: Vector3;
  93047. /**
  93048. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  93049. */
  93050. needInitialSkinMatrix: boolean;
  93051. /**
  93052. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  93053. */
  93054. overrideMesh: Nullable<AbstractMesh>;
  93055. /**
  93056. * Gets the list of animations attached to this skeleton
  93057. */
  93058. animations: Array<Animation>;
  93059. private _scene;
  93060. private _isDirty;
  93061. private _transformMatrices;
  93062. private _transformMatrixTexture;
  93063. private _meshesWithPoseMatrix;
  93064. private _animatables;
  93065. private _identity;
  93066. private _synchronizedWithMesh;
  93067. private _ranges;
  93068. private _lastAbsoluteTransformsUpdateId;
  93069. private _canUseTextureForBones;
  93070. private _uniqueId;
  93071. /** @hidden */
  93072. _numBonesWithLinkedTransformNode: number;
  93073. /** @hidden */
  93074. _hasWaitingData: Nullable<boolean>;
  93075. /**
  93076. * Specifies if the skeleton should be serialized
  93077. */
  93078. doNotSerialize: boolean;
  93079. private _useTextureToStoreBoneMatrices;
  93080. /**
  93081. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  93082. * Please note that this option is not available if the hardware does not support it
  93083. */
  93084. get useTextureToStoreBoneMatrices(): boolean;
  93085. set useTextureToStoreBoneMatrices(value: boolean);
  93086. private _animationPropertiesOverride;
  93087. /**
  93088. * Gets or sets the animation properties override
  93089. */
  93090. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  93091. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  93092. /**
  93093. * List of inspectable custom properties (used by the Inspector)
  93094. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  93095. */
  93096. inspectableCustomProperties: IInspectable[];
  93097. /**
  93098. * An observable triggered before computing the skeleton's matrices
  93099. */
  93100. onBeforeComputeObservable: Observable<Skeleton>;
  93101. /**
  93102. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  93103. */
  93104. get isUsingTextureForMatrices(): boolean;
  93105. /**
  93106. * Gets the unique ID of this skeleton
  93107. */
  93108. get uniqueId(): number;
  93109. /**
  93110. * Creates a new skeleton
  93111. * @param name defines the skeleton name
  93112. * @param id defines the skeleton Id
  93113. * @param scene defines the hosting scene
  93114. */
  93115. constructor(
  93116. /** defines the skeleton name */
  93117. name: string,
  93118. /** defines the skeleton Id */
  93119. id: string, scene: Scene);
  93120. /**
  93121. * Gets the current object class name.
  93122. * @return the class name
  93123. */
  93124. getClassName(): string;
  93125. /**
  93126. * Returns an array containing the root bones
  93127. * @returns an array containing the root bones
  93128. */
  93129. getChildren(): Array<Bone>;
  93130. /**
  93131. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  93132. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  93133. * @returns a Float32Array containing matrices data
  93134. */
  93135. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  93136. /**
  93137. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  93138. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  93139. * @returns a raw texture containing the data
  93140. */
  93141. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  93142. /**
  93143. * Gets the current hosting scene
  93144. * @returns a scene object
  93145. */
  93146. getScene(): Scene;
  93147. /**
  93148. * Gets a string representing the current skeleton data
  93149. * @param fullDetails defines a boolean indicating if we want a verbose version
  93150. * @returns a string representing the current skeleton data
  93151. */
  93152. toString(fullDetails?: boolean): string;
  93153. /**
  93154. * Get bone's index searching by name
  93155. * @param name defines bone's name to search for
  93156. * @return the indice of the bone. Returns -1 if not found
  93157. */
  93158. getBoneIndexByName(name: string): number;
  93159. /**
  93160. * Creater a new animation range
  93161. * @param name defines the name of the range
  93162. * @param from defines the start key
  93163. * @param to defines the end key
  93164. */
  93165. createAnimationRange(name: string, from: number, to: number): void;
  93166. /**
  93167. * Delete a specific animation range
  93168. * @param name defines the name of the range
  93169. * @param deleteFrames defines if frames must be removed as well
  93170. */
  93171. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  93172. /**
  93173. * Gets a specific animation range
  93174. * @param name defines the name of the range to look for
  93175. * @returns the requested animation range or null if not found
  93176. */
  93177. getAnimationRange(name: string): Nullable<AnimationRange>;
  93178. /**
  93179. * Gets the list of all animation ranges defined on this skeleton
  93180. * @returns an array
  93181. */
  93182. getAnimationRanges(): Nullable<AnimationRange>[];
  93183. /**
  93184. * Copy animation range from a source skeleton.
  93185. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  93186. * @param source defines the source skeleton
  93187. * @param name defines the name of the range to copy
  93188. * @param rescaleAsRequired defines if rescaling must be applied if required
  93189. * @returns true if operation was successful
  93190. */
  93191. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  93192. /**
  93193. * Forces the skeleton to go to rest pose
  93194. */
  93195. returnToRest(): void;
  93196. private _getHighestAnimationFrame;
  93197. /**
  93198. * Begin a specific animation range
  93199. * @param name defines the name of the range to start
  93200. * @param loop defines if looping must be turned on (false by default)
  93201. * @param speedRatio defines the speed ratio to apply (1 by default)
  93202. * @param onAnimationEnd defines a callback which will be called when animation will end
  93203. * @returns a new animatable
  93204. */
  93205. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  93206. /**
  93207. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  93208. * @param skeleton defines the Skeleton containing the animation range to convert
  93209. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  93210. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  93211. * @returns the original skeleton
  93212. */
  93213. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  93214. /** @hidden */
  93215. _markAsDirty(): void;
  93216. /** @hidden */
  93217. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  93218. /** @hidden */
  93219. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  93220. private _computeTransformMatrices;
  93221. /**
  93222. * Build all resources required to render a skeleton
  93223. */
  93224. prepare(): void;
  93225. /**
  93226. * Gets the list of animatables currently running for this skeleton
  93227. * @returns an array of animatables
  93228. */
  93229. getAnimatables(): IAnimatable[];
  93230. /**
  93231. * Clone the current skeleton
  93232. * @param name defines the name of the new skeleton
  93233. * @param id defines the id of the new skeleton
  93234. * @returns the new skeleton
  93235. */
  93236. clone(name: string, id?: string): Skeleton;
  93237. /**
  93238. * Enable animation blending for this skeleton
  93239. * @param blendingSpeed defines the blending speed to apply
  93240. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  93241. */
  93242. enableBlending(blendingSpeed?: number): void;
  93243. /**
  93244. * Releases all resources associated with the current skeleton
  93245. */
  93246. dispose(): void;
  93247. /**
  93248. * Serialize the skeleton in a JSON object
  93249. * @returns a JSON object
  93250. */
  93251. serialize(): any;
  93252. /**
  93253. * Creates a new skeleton from serialized data
  93254. * @param parsedSkeleton defines the serialized data
  93255. * @param scene defines the hosting scene
  93256. * @returns a new skeleton
  93257. */
  93258. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  93259. /**
  93260. * Compute all node absolute transforms
  93261. * @param forceUpdate defines if computation must be done even if cache is up to date
  93262. */
  93263. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  93264. /**
  93265. * Gets the root pose matrix
  93266. * @returns a matrix
  93267. */
  93268. getPoseMatrix(): Nullable<Matrix>;
  93269. /**
  93270. * Sorts bones per internal index
  93271. */
  93272. sortBones(): void;
  93273. private _sortBones;
  93274. }
  93275. }
  93276. declare module BABYLON {
  93277. /**
  93278. * Creates an instance based on a source mesh.
  93279. */
  93280. export class InstancedMesh extends AbstractMesh {
  93281. private _sourceMesh;
  93282. private _currentLOD;
  93283. /** @hidden */
  93284. _indexInSourceMeshInstanceArray: number;
  93285. constructor(name: string, source: Mesh);
  93286. /**
  93287. * Returns the string "InstancedMesh".
  93288. */
  93289. getClassName(): string;
  93290. /** Gets the list of lights affecting that mesh */
  93291. get lightSources(): Light[];
  93292. _resyncLightSources(): void;
  93293. _resyncLightSource(light: Light): void;
  93294. _removeLightSource(light: Light, dispose: boolean): void;
  93295. /**
  93296. * If the source mesh receives shadows
  93297. */
  93298. get receiveShadows(): boolean;
  93299. /**
  93300. * The material of the source mesh
  93301. */
  93302. get material(): Nullable<Material>;
  93303. /**
  93304. * Visibility of the source mesh
  93305. */
  93306. get visibility(): number;
  93307. /**
  93308. * Skeleton of the source mesh
  93309. */
  93310. get skeleton(): Nullable<Skeleton>;
  93311. /**
  93312. * Rendering ground id of the source mesh
  93313. */
  93314. get renderingGroupId(): number;
  93315. set renderingGroupId(value: number);
  93316. /**
  93317. * Returns the total number of vertices (integer).
  93318. */
  93319. getTotalVertices(): number;
  93320. /**
  93321. * Returns a positive integer : the total number of indices in this mesh geometry.
  93322. * @returns the numner of indices or zero if the mesh has no geometry.
  93323. */
  93324. getTotalIndices(): number;
  93325. /**
  93326. * The source mesh of the instance
  93327. */
  93328. get sourceMesh(): Mesh;
  93329. /**
  93330. * Creates a new InstancedMesh object from the mesh model.
  93331. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  93332. * @param name defines the name of the new instance
  93333. * @returns a new InstancedMesh
  93334. */
  93335. createInstance(name: string): InstancedMesh;
  93336. /**
  93337. * Is this node ready to be used/rendered
  93338. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  93339. * @return {boolean} is it ready
  93340. */
  93341. isReady(completeCheck?: boolean): boolean;
  93342. /**
  93343. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  93344. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  93345. * @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.
  93346. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  93347. */
  93348. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  93349. /**
  93350. * Sets the vertex data of the mesh geometry for the requested `kind`.
  93351. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  93352. * The `data` are either a numeric array either a Float32Array.
  93353. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  93354. * 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).
  93355. * Note that a new underlying VertexBuffer object is created each call.
  93356. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  93357. *
  93358. * Possible `kind` values :
  93359. * - VertexBuffer.PositionKind
  93360. * - VertexBuffer.UVKind
  93361. * - VertexBuffer.UV2Kind
  93362. * - VertexBuffer.UV3Kind
  93363. * - VertexBuffer.UV4Kind
  93364. * - VertexBuffer.UV5Kind
  93365. * - VertexBuffer.UV6Kind
  93366. * - VertexBuffer.ColorKind
  93367. * - VertexBuffer.MatricesIndicesKind
  93368. * - VertexBuffer.MatricesIndicesExtraKind
  93369. * - VertexBuffer.MatricesWeightsKind
  93370. * - VertexBuffer.MatricesWeightsExtraKind
  93371. *
  93372. * Returns the Mesh.
  93373. */
  93374. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  93375. /**
  93376. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  93377. * If the mesh has no geometry, it is simply returned as it is.
  93378. * The `data` are either a numeric array either a Float32Array.
  93379. * No new underlying VertexBuffer object is created.
  93380. * 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.
  93381. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  93382. *
  93383. * Possible `kind` values :
  93384. * - VertexBuffer.PositionKind
  93385. * - VertexBuffer.UVKind
  93386. * - VertexBuffer.UV2Kind
  93387. * - VertexBuffer.UV3Kind
  93388. * - VertexBuffer.UV4Kind
  93389. * - VertexBuffer.UV5Kind
  93390. * - VertexBuffer.UV6Kind
  93391. * - VertexBuffer.ColorKind
  93392. * - VertexBuffer.MatricesIndicesKind
  93393. * - VertexBuffer.MatricesIndicesExtraKind
  93394. * - VertexBuffer.MatricesWeightsKind
  93395. * - VertexBuffer.MatricesWeightsExtraKind
  93396. *
  93397. * Returns the Mesh.
  93398. */
  93399. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  93400. /**
  93401. * Sets the mesh indices.
  93402. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  93403. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  93404. * This method creates a new index buffer each call.
  93405. * Returns the Mesh.
  93406. */
  93407. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  93408. /**
  93409. * Boolean : True if the mesh owns the requested kind of data.
  93410. */
  93411. isVerticesDataPresent(kind: string): boolean;
  93412. /**
  93413. * Returns an array of indices (IndicesArray).
  93414. */
  93415. getIndices(): Nullable<IndicesArray>;
  93416. get _positions(): Nullable<Vector3[]>;
  93417. /**
  93418. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  93419. * This means the mesh underlying bounding box and sphere are recomputed.
  93420. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  93421. * @returns the current mesh
  93422. */
  93423. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  93424. /** @hidden */
  93425. _preActivate(): InstancedMesh;
  93426. /** @hidden */
  93427. _activate(renderId: number, intermediateRendering: boolean): boolean;
  93428. /** @hidden */
  93429. _postActivate(): void;
  93430. getWorldMatrix(): Matrix;
  93431. get isAnInstance(): boolean;
  93432. /**
  93433. * Returns the current associated LOD AbstractMesh.
  93434. */
  93435. getLOD(camera: Camera): AbstractMesh;
  93436. /** @hidden */
  93437. _preActivateForIntermediateRendering(renderId: number): Mesh;
  93438. /** @hidden */
  93439. _syncSubMeshes(): InstancedMesh;
  93440. /** @hidden */
  93441. _generatePointsArray(): boolean;
  93442. /**
  93443. * Creates a new InstancedMesh from the current mesh.
  93444. * - name (string) : the cloned mesh name
  93445. * - newParent (optional Node) : the optional Node to parent the clone to.
  93446. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  93447. *
  93448. * Returns the clone.
  93449. */
  93450. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  93451. /**
  93452. * Disposes the InstancedMesh.
  93453. * Returns nothing.
  93454. */
  93455. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93456. }
  93457. interface Mesh {
  93458. /**
  93459. * Register a custom buffer that will be instanced
  93460. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  93461. * @param kind defines the buffer kind
  93462. * @param stride defines the stride in floats
  93463. */
  93464. registerInstancedBuffer(kind: string, stride: number): void;
  93465. /** @hidden */
  93466. _userInstancedBuffersStorage: {
  93467. data: {
  93468. [key: string]: Float32Array;
  93469. };
  93470. sizes: {
  93471. [key: string]: number;
  93472. };
  93473. vertexBuffers: {
  93474. [key: string]: Nullable<VertexBuffer>;
  93475. };
  93476. strides: {
  93477. [key: string]: number;
  93478. };
  93479. };
  93480. }
  93481. interface AbstractMesh {
  93482. /**
  93483. * Object used to store instanced buffers defined by user
  93484. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  93485. */
  93486. instancedBuffers: {
  93487. [key: string]: any;
  93488. };
  93489. }
  93490. }
  93491. declare module BABYLON {
  93492. /**
  93493. * Defines the options associated with the creation of a shader material.
  93494. */
  93495. export interface IShaderMaterialOptions {
  93496. /**
  93497. * Does the material work in alpha blend mode
  93498. */
  93499. needAlphaBlending: boolean;
  93500. /**
  93501. * Does the material work in alpha test mode
  93502. */
  93503. needAlphaTesting: boolean;
  93504. /**
  93505. * The list of attribute names used in the shader
  93506. */
  93507. attributes: string[];
  93508. /**
  93509. * The list of unifrom names used in the shader
  93510. */
  93511. uniforms: string[];
  93512. /**
  93513. * The list of UBO names used in the shader
  93514. */
  93515. uniformBuffers: string[];
  93516. /**
  93517. * The list of sampler names used in the shader
  93518. */
  93519. samplers: string[];
  93520. /**
  93521. * The list of defines used in the shader
  93522. */
  93523. defines: string[];
  93524. }
  93525. /**
  93526. * 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.
  93527. *
  93528. * This returned material effects how the mesh will look based on the code in the shaders.
  93529. *
  93530. * @see http://doc.babylonjs.com/how_to/shader_material
  93531. */
  93532. export class ShaderMaterial extends Material {
  93533. private _shaderPath;
  93534. private _options;
  93535. private _textures;
  93536. private _textureArrays;
  93537. private _floats;
  93538. private _ints;
  93539. private _floatsArrays;
  93540. private _colors3;
  93541. private _colors3Arrays;
  93542. private _colors4;
  93543. private _colors4Arrays;
  93544. private _vectors2;
  93545. private _vectors3;
  93546. private _vectors4;
  93547. private _matrices;
  93548. private _matrixArrays;
  93549. private _matrices3x3;
  93550. private _matrices2x2;
  93551. private _vectors2Arrays;
  93552. private _vectors3Arrays;
  93553. private _vectors4Arrays;
  93554. private _cachedWorldViewMatrix;
  93555. private _cachedWorldViewProjectionMatrix;
  93556. private _renderId;
  93557. private _multiview;
  93558. private _cachedDefines;
  93559. /**
  93560. * Instantiate a new shader material.
  93561. * 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.
  93562. * This returned material effects how the mesh will look based on the code in the shaders.
  93563. * @see http://doc.babylonjs.com/how_to/shader_material
  93564. * @param name Define the name of the material in the scene
  93565. * @param scene Define the scene the material belongs to
  93566. * @param shaderPath Defines the route to the shader code in one of three ways:
  93567. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  93568. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  93569. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  93570. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  93571. * @param options Define the options used to create the shader
  93572. */
  93573. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  93574. /**
  93575. * Gets the shader path used to define the shader code
  93576. * It can be modified to trigger a new compilation
  93577. */
  93578. get shaderPath(): any;
  93579. /**
  93580. * Sets the shader path used to define the shader code
  93581. * It can be modified to trigger a new compilation
  93582. */
  93583. set shaderPath(shaderPath: any);
  93584. /**
  93585. * Gets the options used to compile the shader.
  93586. * They can be modified to trigger a new compilation
  93587. */
  93588. get options(): IShaderMaterialOptions;
  93589. /**
  93590. * Gets the current class name of the material e.g. "ShaderMaterial"
  93591. * Mainly use in serialization.
  93592. * @returns the class name
  93593. */
  93594. getClassName(): string;
  93595. /**
  93596. * Specifies if the material will require alpha blending
  93597. * @returns a boolean specifying if alpha blending is needed
  93598. */
  93599. needAlphaBlending(): boolean;
  93600. /**
  93601. * Specifies if this material should be rendered in alpha test mode
  93602. * @returns a boolean specifying if an alpha test is needed.
  93603. */
  93604. needAlphaTesting(): boolean;
  93605. private _checkUniform;
  93606. /**
  93607. * Set a texture in the shader.
  93608. * @param name Define the name of the uniform samplers as defined in the shader
  93609. * @param texture Define the texture to bind to this sampler
  93610. * @return the material itself allowing "fluent" like uniform updates
  93611. */
  93612. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  93613. /**
  93614. * Set a texture array in the shader.
  93615. * @param name Define the name of the uniform sampler array as defined in the shader
  93616. * @param textures Define the list of textures to bind to this sampler
  93617. * @return the material itself allowing "fluent" like uniform updates
  93618. */
  93619. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  93620. /**
  93621. * Set a float in the shader.
  93622. * @param name Define the name of the uniform as defined in the shader
  93623. * @param value Define the value to give to the uniform
  93624. * @return the material itself allowing "fluent" like uniform updates
  93625. */
  93626. setFloat(name: string, value: number): ShaderMaterial;
  93627. /**
  93628. * Set a int in the shader.
  93629. * @param name Define the name of the uniform as defined in the shader
  93630. * @param value Define the value to give to the uniform
  93631. * @return the material itself allowing "fluent" like uniform updates
  93632. */
  93633. setInt(name: string, value: number): ShaderMaterial;
  93634. /**
  93635. * Set an array of floats in the shader.
  93636. * @param name Define the name of the uniform as defined in the shader
  93637. * @param value Define the value to give to the uniform
  93638. * @return the material itself allowing "fluent" like uniform updates
  93639. */
  93640. setFloats(name: string, value: number[]): ShaderMaterial;
  93641. /**
  93642. * Set a vec3 in the shader from a Color3.
  93643. * @param name Define the name of the uniform as defined in the shader
  93644. * @param value Define the value to give to the uniform
  93645. * @return the material itself allowing "fluent" like uniform updates
  93646. */
  93647. setColor3(name: string, value: Color3): ShaderMaterial;
  93648. /**
  93649. * Set a vec3 array in the shader from a Color3 array.
  93650. * @param name Define the name of the uniform as defined in the shader
  93651. * @param value Define the value to give to the uniform
  93652. * @return the material itself allowing "fluent" like uniform updates
  93653. */
  93654. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  93655. /**
  93656. * Set a vec4 in the shader from a Color4.
  93657. * @param name Define the name of the uniform as defined in the shader
  93658. * @param value Define the value to give to the uniform
  93659. * @return the material itself allowing "fluent" like uniform updates
  93660. */
  93661. setColor4(name: string, value: Color4): ShaderMaterial;
  93662. /**
  93663. * Set a vec4 array in the shader from a Color4 array.
  93664. * @param name Define the name of the uniform as defined in the shader
  93665. * @param value Define the value to give to the uniform
  93666. * @return the material itself allowing "fluent" like uniform updates
  93667. */
  93668. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  93669. /**
  93670. * Set a vec2 in the shader from a Vector2.
  93671. * @param name Define the name of the uniform as defined in the shader
  93672. * @param value Define the value to give to the uniform
  93673. * @return the material itself allowing "fluent" like uniform updates
  93674. */
  93675. setVector2(name: string, value: Vector2): ShaderMaterial;
  93676. /**
  93677. * Set a vec3 in the shader from a Vector3.
  93678. * @param name Define the name of the uniform as defined in the shader
  93679. * @param value Define the value to give to the uniform
  93680. * @return the material itself allowing "fluent" like uniform updates
  93681. */
  93682. setVector3(name: string, value: Vector3): ShaderMaterial;
  93683. /**
  93684. * Set a vec4 in the shader from a Vector4.
  93685. * @param name Define the name of the uniform as defined in the shader
  93686. * @param value Define the value to give to the uniform
  93687. * @return the material itself allowing "fluent" like uniform updates
  93688. */
  93689. setVector4(name: string, value: Vector4): ShaderMaterial;
  93690. /**
  93691. * Set a mat4 in the shader from a Matrix.
  93692. * @param name Define the name of the uniform as defined in the shader
  93693. * @param value Define the value to give to the uniform
  93694. * @return the material itself allowing "fluent" like uniform updates
  93695. */
  93696. setMatrix(name: string, value: Matrix): ShaderMaterial;
  93697. /**
  93698. * Set a float32Array in the shader from a matrix array.
  93699. * @param name Define the name of the uniform as defined in the shader
  93700. * @param value Define the value to give to the uniform
  93701. * @return the material itself allowing "fluent" like uniform updates
  93702. */
  93703. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  93704. /**
  93705. * Set a mat3 in the shader from a Float32Array.
  93706. * @param name Define the name of the uniform as defined in the shader
  93707. * @param value Define the value to give to the uniform
  93708. * @return the material itself allowing "fluent" like uniform updates
  93709. */
  93710. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  93711. /**
  93712. * Set a mat2 in the shader from a Float32Array.
  93713. * @param name Define the name of the uniform as defined in the shader
  93714. * @param value Define the value to give to the uniform
  93715. * @return the material itself allowing "fluent" like uniform updates
  93716. */
  93717. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  93718. /**
  93719. * Set a vec2 array in the shader from a number array.
  93720. * @param name Define the name of the uniform as defined in the shader
  93721. * @param value Define the value to give to the uniform
  93722. * @return the material itself allowing "fluent" like uniform updates
  93723. */
  93724. setArray2(name: string, value: number[]): ShaderMaterial;
  93725. /**
  93726. * Set a vec3 array in the shader from a number array.
  93727. * @param name Define the name of the uniform as defined in the shader
  93728. * @param value Define the value to give to the uniform
  93729. * @return the material itself allowing "fluent" like uniform updates
  93730. */
  93731. setArray3(name: string, value: number[]): ShaderMaterial;
  93732. /**
  93733. * Set a vec4 array in the shader from a number array.
  93734. * @param name Define the name of the uniform as defined in the shader
  93735. * @param value Define the value to give to the uniform
  93736. * @return the material itself allowing "fluent" like uniform updates
  93737. */
  93738. setArray4(name: string, value: number[]): ShaderMaterial;
  93739. private _checkCache;
  93740. /**
  93741. * Specifies that the submesh is ready to be used
  93742. * @param mesh defines the mesh to check
  93743. * @param subMesh defines which submesh to check
  93744. * @param useInstances specifies that instances should be used
  93745. * @returns a boolean indicating that the submesh is ready or not
  93746. */
  93747. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  93748. /**
  93749. * Checks if the material is ready to render the requested mesh
  93750. * @param mesh Define the mesh to render
  93751. * @param useInstances Define whether or not the material is used with instances
  93752. * @returns true if ready, otherwise false
  93753. */
  93754. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  93755. /**
  93756. * Binds the world matrix to the material
  93757. * @param world defines the world transformation matrix
  93758. * @param effectOverride - If provided, use this effect instead of internal effect
  93759. */
  93760. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  93761. /**
  93762. * Binds the submesh to this material by preparing the effect and shader to draw
  93763. * @param world defines the world transformation matrix
  93764. * @param mesh defines the mesh containing the submesh
  93765. * @param subMesh defines the submesh to bind the material to
  93766. */
  93767. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  93768. /**
  93769. * Binds the material to the mesh
  93770. * @param world defines the world transformation matrix
  93771. * @param mesh defines the mesh to bind the material to
  93772. * @param effectOverride - If provided, use this effect instead of internal effect
  93773. */
  93774. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  93775. protected _afterBind(mesh?: Mesh): void;
  93776. /**
  93777. * Gets the active textures from the material
  93778. * @returns an array of textures
  93779. */
  93780. getActiveTextures(): BaseTexture[];
  93781. /**
  93782. * Specifies if the material uses a texture
  93783. * @param texture defines the texture to check against the material
  93784. * @returns a boolean specifying if the material uses the texture
  93785. */
  93786. hasTexture(texture: BaseTexture): boolean;
  93787. /**
  93788. * Makes a duplicate of the material, and gives it a new name
  93789. * @param name defines the new name for the duplicated material
  93790. * @returns the cloned material
  93791. */
  93792. clone(name: string): ShaderMaterial;
  93793. /**
  93794. * Disposes the material
  93795. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  93796. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  93797. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  93798. */
  93799. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  93800. /**
  93801. * Serializes this material in a JSON representation
  93802. * @returns the serialized material object
  93803. */
  93804. serialize(): any;
  93805. /**
  93806. * Creates a shader material from parsed shader material data
  93807. * @param source defines the JSON represnetation of the material
  93808. * @param scene defines the hosting scene
  93809. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  93810. * @returns a new material
  93811. */
  93812. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  93813. }
  93814. }
  93815. declare module BABYLON {
  93816. /** @hidden */
  93817. export var colorPixelShader: {
  93818. name: string;
  93819. shader: string;
  93820. };
  93821. }
  93822. declare module BABYLON {
  93823. /** @hidden */
  93824. export var colorVertexShader: {
  93825. name: string;
  93826. shader: string;
  93827. };
  93828. }
  93829. declare module BABYLON {
  93830. /**
  93831. * Line mesh
  93832. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  93833. */
  93834. export class LinesMesh extends Mesh {
  93835. /**
  93836. * If vertex color should be applied to the mesh
  93837. */
  93838. readonly useVertexColor?: boolean | undefined;
  93839. /**
  93840. * If vertex alpha should be applied to the mesh
  93841. */
  93842. readonly useVertexAlpha?: boolean | undefined;
  93843. /**
  93844. * Color of the line (Default: White)
  93845. */
  93846. color: Color3;
  93847. /**
  93848. * Alpha of the line (Default: 1)
  93849. */
  93850. alpha: number;
  93851. /**
  93852. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  93853. * This margin is expressed in world space coordinates, so its value may vary.
  93854. * Default value is 0.1
  93855. */
  93856. intersectionThreshold: number;
  93857. private _colorShader;
  93858. private color4;
  93859. /**
  93860. * Creates a new LinesMesh
  93861. * @param name defines the name
  93862. * @param scene defines the hosting scene
  93863. * @param parent defines the parent mesh if any
  93864. * @param source defines the optional source LinesMesh used to clone data from
  93865. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  93866. * When false, achieved by calling a clone(), also passing False.
  93867. * This will make creation of children, recursive.
  93868. * @param useVertexColor defines if this LinesMesh supports vertex color
  93869. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  93870. */
  93871. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  93872. /**
  93873. * If vertex color should be applied to the mesh
  93874. */
  93875. useVertexColor?: boolean | undefined,
  93876. /**
  93877. * If vertex alpha should be applied to the mesh
  93878. */
  93879. useVertexAlpha?: boolean | undefined);
  93880. private _addClipPlaneDefine;
  93881. private _removeClipPlaneDefine;
  93882. isReady(): boolean;
  93883. /**
  93884. * Returns the string "LineMesh"
  93885. */
  93886. getClassName(): string;
  93887. /**
  93888. * @hidden
  93889. */
  93890. get material(): Material;
  93891. /**
  93892. * @hidden
  93893. */
  93894. set material(value: Material);
  93895. /**
  93896. * @hidden
  93897. */
  93898. get checkCollisions(): boolean;
  93899. /** @hidden */
  93900. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  93901. /** @hidden */
  93902. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  93903. /**
  93904. * Disposes of the line mesh
  93905. * @param doNotRecurse If children should be disposed
  93906. */
  93907. dispose(doNotRecurse?: boolean): void;
  93908. /**
  93909. * Returns a new LineMesh object cloned from the current one.
  93910. */
  93911. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  93912. /**
  93913. * Creates a new InstancedLinesMesh object from the mesh model.
  93914. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  93915. * @param name defines the name of the new instance
  93916. * @returns a new InstancedLinesMesh
  93917. */
  93918. createInstance(name: string): InstancedLinesMesh;
  93919. }
  93920. /**
  93921. * Creates an instance based on a source LinesMesh
  93922. */
  93923. export class InstancedLinesMesh extends InstancedMesh {
  93924. /**
  93925. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  93926. * This margin is expressed in world space coordinates, so its value may vary.
  93927. * Initilized with the intersectionThreshold value of the source LinesMesh
  93928. */
  93929. intersectionThreshold: number;
  93930. constructor(name: string, source: LinesMesh);
  93931. /**
  93932. * Returns the string "InstancedLinesMesh".
  93933. */
  93934. getClassName(): string;
  93935. }
  93936. }
  93937. declare module BABYLON {
  93938. /** @hidden */
  93939. export var linePixelShader: {
  93940. name: string;
  93941. shader: string;
  93942. };
  93943. }
  93944. declare module BABYLON {
  93945. /** @hidden */
  93946. export var lineVertexShader: {
  93947. name: string;
  93948. shader: string;
  93949. };
  93950. }
  93951. declare module BABYLON {
  93952. interface AbstractMesh {
  93953. /**
  93954. * Gets the edgesRenderer associated with the mesh
  93955. */
  93956. edgesRenderer: Nullable<EdgesRenderer>;
  93957. }
  93958. interface LinesMesh {
  93959. /**
  93960. * Enables the edge rendering mode on the mesh.
  93961. * This mode makes the mesh edges visible
  93962. * @param epsilon defines the maximal distance between two angles to detect a face
  93963. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  93964. * @returns the currentAbstractMesh
  93965. * @see https://www.babylonjs-playground.com/#19O9TU#0
  93966. */
  93967. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  93968. }
  93969. interface InstancedLinesMesh {
  93970. /**
  93971. * Enables the edge rendering mode on the mesh.
  93972. * This mode makes the mesh edges visible
  93973. * @param epsilon defines the maximal distance between two angles to detect a face
  93974. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  93975. * @returns the current InstancedLinesMesh
  93976. * @see https://www.babylonjs-playground.com/#19O9TU#0
  93977. */
  93978. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  93979. }
  93980. /**
  93981. * Defines the minimum contract an Edges renderer should follow.
  93982. */
  93983. export interface IEdgesRenderer extends IDisposable {
  93984. /**
  93985. * Gets or sets a boolean indicating if the edgesRenderer is active
  93986. */
  93987. isEnabled: boolean;
  93988. /**
  93989. * Renders the edges of the attached mesh,
  93990. */
  93991. render(): void;
  93992. /**
  93993. * Checks wether or not the edges renderer is ready to render.
  93994. * @return true if ready, otherwise false.
  93995. */
  93996. isReady(): boolean;
  93997. }
  93998. /**
  93999. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  94000. */
  94001. export class EdgesRenderer implements IEdgesRenderer {
  94002. /**
  94003. * Define the size of the edges with an orthographic camera
  94004. */
  94005. edgesWidthScalerForOrthographic: number;
  94006. /**
  94007. * Define the size of the edges with a perspective camera
  94008. */
  94009. edgesWidthScalerForPerspective: number;
  94010. protected _source: AbstractMesh;
  94011. protected _linesPositions: number[];
  94012. protected _linesNormals: number[];
  94013. protected _linesIndices: number[];
  94014. protected _epsilon: number;
  94015. protected _indicesCount: number;
  94016. protected _lineShader: ShaderMaterial;
  94017. protected _ib: DataBuffer;
  94018. protected _buffers: {
  94019. [key: string]: Nullable<VertexBuffer>;
  94020. };
  94021. protected _checkVerticesInsteadOfIndices: boolean;
  94022. private _meshRebuildObserver;
  94023. private _meshDisposeObserver;
  94024. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  94025. isEnabled: boolean;
  94026. /**
  94027. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  94028. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  94029. * @param source Mesh used to create edges
  94030. * @param epsilon sum of angles in adjacency to check for edge
  94031. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  94032. * @param generateEdgesLines - should generate Lines or only prepare resources.
  94033. */
  94034. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  94035. protected _prepareRessources(): void;
  94036. /** @hidden */
  94037. _rebuild(): void;
  94038. /**
  94039. * Releases the required resources for the edges renderer
  94040. */
  94041. dispose(): void;
  94042. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  94043. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  94044. /**
  94045. * Checks if the pair of p0 and p1 is en edge
  94046. * @param faceIndex
  94047. * @param edge
  94048. * @param faceNormals
  94049. * @param p0
  94050. * @param p1
  94051. * @private
  94052. */
  94053. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  94054. /**
  94055. * push line into the position, normal and index buffer
  94056. * @protected
  94057. */
  94058. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  94059. /**
  94060. * Generates lines edges from adjacencjes
  94061. * @private
  94062. */
  94063. _generateEdgesLines(): void;
  94064. /**
  94065. * Checks wether or not the edges renderer is ready to render.
  94066. * @return true if ready, otherwise false.
  94067. */
  94068. isReady(): boolean;
  94069. /**
  94070. * Renders the edges of the attached mesh,
  94071. */
  94072. render(): void;
  94073. }
  94074. /**
  94075. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  94076. */
  94077. export class LineEdgesRenderer extends EdgesRenderer {
  94078. /**
  94079. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  94080. * @param source LineMesh used to generate edges
  94081. * @param epsilon not important (specified angle for edge detection)
  94082. * @param checkVerticesInsteadOfIndices not important for LineMesh
  94083. */
  94084. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  94085. /**
  94086. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  94087. */
  94088. _generateEdgesLines(): void;
  94089. }
  94090. }
  94091. declare module BABYLON {
  94092. /**
  94093. * This represents the object necessary to create a rendering group.
  94094. * This is exclusively used and created by the rendering manager.
  94095. * To modify the behavior, you use the available helpers in your scene or meshes.
  94096. * @hidden
  94097. */
  94098. export class RenderingGroup {
  94099. index: number;
  94100. private static _zeroVector;
  94101. private _scene;
  94102. private _opaqueSubMeshes;
  94103. private _transparentSubMeshes;
  94104. private _alphaTestSubMeshes;
  94105. private _depthOnlySubMeshes;
  94106. private _particleSystems;
  94107. private _spriteManagers;
  94108. private _opaqueSortCompareFn;
  94109. private _alphaTestSortCompareFn;
  94110. private _transparentSortCompareFn;
  94111. private _renderOpaque;
  94112. private _renderAlphaTest;
  94113. private _renderTransparent;
  94114. /** @hidden */
  94115. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  94116. onBeforeTransparentRendering: () => void;
  94117. /**
  94118. * Set the opaque sort comparison function.
  94119. * If null the sub meshes will be render in the order they were created
  94120. */
  94121. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  94122. /**
  94123. * Set the alpha test sort comparison function.
  94124. * If null the sub meshes will be render in the order they were created
  94125. */
  94126. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  94127. /**
  94128. * Set the transparent sort comparison function.
  94129. * If null the sub meshes will be render in the order they were created
  94130. */
  94131. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  94132. /**
  94133. * Creates a new rendering group.
  94134. * @param index The rendering group index
  94135. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  94136. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  94137. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  94138. */
  94139. 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>);
  94140. /**
  94141. * Render all the sub meshes contained in the group.
  94142. * @param customRenderFunction Used to override the default render behaviour of the group.
  94143. * @returns true if rendered some submeshes.
  94144. */
  94145. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  94146. /**
  94147. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  94148. * @param subMeshes The submeshes to render
  94149. */
  94150. private renderOpaqueSorted;
  94151. /**
  94152. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  94153. * @param subMeshes The submeshes to render
  94154. */
  94155. private renderAlphaTestSorted;
  94156. /**
  94157. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  94158. * @param subMeshes The submeshes to render
  94159. */
  94160. private renderTransparentSorted;
  94161. /**
  94162. * Renders the submeshes in a specified order.
  94163. * @param subMeshes The submeshes to sort before render
  94164. * @param sortCompareFn The comparison function use to sort
  94165. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  94166. * @param transparent Specifies to activate blending if true
  94167. */
  94168. private static renderSorted;
  94169. /**
  94170. * Renders the submeshes in the order they were dispatched (no sort applied).
  94171. * @param subMeshes The submeshes to render
  94172. */
  94173. private static renderUnsorted;
  94174. /**
  94175. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  94176. * are rendered back to front if in the same alpha index.
  94177. *
  94178. * @param a The first submesh
  94179. * @param b The second submesh
  94180. * @returns The result of the comparison
  94181. */
  94182. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  94183. /**
  94184. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  94185. * are rendered back to front.
  94186. *
  94187. * @param a The first submesh
  94188. * @param b The second submesh
  94189. * @returns The result of the comparison
  94190. */
  94191. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  94192. /**
  94193. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  94194. * are rendered front to back (prevent overdraw).
  94195. *
  94196. * @param a The first submesh
  94197. * @param b The second submesh
  94198. * @returns The result of the comparison
  94199. */
  94200. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  94201. /**
  94202. * Resets the different lists of submeshes to prepare a new frame.
  94203. */
  94204. prepare(): void;
  94205. dispose(): void;
  94206. /**
  94207. * Inserts the submesh in its correct queue depending on its material.
  94208. * @param subMesh The submesh to dispatch
  94209. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  94210. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  94211. */
  94212. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  94213. dispatchSprites(spriteManager: ISpriteManager): void;
  94214. dispatchParticles(particleSystem: IParticleSystem): void;
  94215. private _renderParticles;
  94216. private _renderSprites;
  94217. }
  94218. }
  94219. declare module BABYLON {
  94220. /**
  94221. * Interface describing the different options available in the rendering manager
  94222. * regarding Auto Clear between groups.
  94223. */
  94224. export interface IRenderingManagerAutoClearSetup {
  94225. /**
  94226. * Defines whether or not autoclear is enable.
  94227. */
  94228. autoClear: boolean;
  94229. /**
  94230. * Defines whether or not to autoclear the depth buffer.
  94231. */
  94232. depth: boolean;
  94233. /**
  94234. * Defines whether or not to autoclear the stencil buffer.
  94235. */
  94236. stencil: boolean;
  94237. }
  94238. /**
  94239. * This class is used by the onRenderingGroupObservable
  94240. */
  94241. export class RenderingGroupInfo {
  94242. /**
  94243. * The Scene that being rendered
  94244. */
  94245. scene: Scene;
  94246. /**
  94247. * The camera currently used for the rendering pass
  94248. */
  94249. camera: Nullable<Camera>;
  94250. /**
  94251. * The ID of the renderingGroup being processed
  94252. */
  94253. renderingGroupId: number;
  94254. }
  94255. /**
  94256. * This is the manager responsible of all the rendering for meshes sprites and particles.
  94257. * It is enable to manage the different groups as well as the different necessary sort functions.
  94258. * This should not be used directly aside of the few static configurations
  94259. */
  94260. export class RenderingManager {
  94261. /**
  94262. * The max id used for rendering groups (not included)
  94263. */
  94264. static MAX_RENDERINGGROUPS: number;
  94265. /**
  94266. * The min id used for rendering groups (included)
  94267. */
  94268. static MIN_RENDERINGGROUPS: number;
  94269. /**
  94270. * Used to globally prevent autoclearing scenes.
  94271. */
  94272. static AUTOCLEAR: boolean;
  94273. /**
  94274. * @hidden
  94275. */
  94276. _useSceneAutoClearSetup: boolean;
  94277. private _scene;
  94278. private _renderingGroups;
  94279. private _depthStencilBufferAlreadyCleaned;
  94280. private _autoClearDepthStencil;
  94281. private _customOpaqueSortCompareFn;
  94282. private _customAlphaTestSortCompareFn;
  94283. private _customTransparentSortCompareFn;
  94284. private _renderingGroupInfo;
  94285. /**
  94286. * Instantiates a new rendering group for a particular scene
  94287. * @param scene Defines the scene the groups belongs to
  94288. */
  94289. constructor(scene: Scene);
  94290. private _clearDepthStencilBuffer;
  94291. /**
  94292. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  94293. * @hidden
  94294. */
  94295. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  94296. /**
  94297. * Resets the different information of the group to prepare a new frame
  94298. * @hidden
  94299. */
  94300. reset(): void;
  94301. /**
  94302. * Dispose and release the group and its associated resources.
  94303. * @hidden
  94304. */
  94305. dispose(): void;
  94306. /**
  94307. * Clear the info related to rendering groups preventing retention points during dispose.
  94308. */
  94309. freeRenderingGroups(): void;
  94310. private _prepareRenderingGroup;
  94311. /**
  94312. * Add a sprite manager to the rendering manager in order to render it this frame.
  94313. * @param spriteManager Define the sprite manager to render
  94314. */
  94315. dispatchSprites(spriteManager: ISpriteManager): void;
  94316. /**
  94317. * Add a particle system to the rendering manager in order to render it this frame.
  94318. * @param particleSystem Define the particle system to render
  94319. */
  94320. dispatchParticles(particleSystem: IParticleSystem): void;
  94321. /**
  94322. * Add a submesh to the manager in order to render it this frame
  94323. * @param subMesh The submesh to dispatch
  94324. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  94325. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  94326. */
  94327. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  94328. /**
  94329. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  94330. * This allowed control for front to back rendering or reversly depending of the special needs.
  94331. *
  94332. * @param renderingGroupId The rendering group id corresponding to its index
  94333. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  94334. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  94335. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  94336. */
  94337. 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;
  94338. /**
  94339. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  94340. *
  94341. * @param renderingGroupId The rendering group id corresponding to its index
  94342. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  94343. * @param depth Automatically clears depth between groups if true and autoClear is true.
  94344. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  94345. */
  94346. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  94347. /**
  94348. * Gets the current auto clear configuration for one rendering group of the rendering
  94349. * manager.
  94350. * @param index the rendering group index to get the information for
  94351. * @returns The auto clear setup for the requested rendering group
  94352. */
  94353. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  94354. }
  94355. }
  94356. declare module BABYLON {
  94357. /**
  94358. * Defines the options associated with the creation of a custom shader for a shadow generator.
  94359. */
  94360. export interface ICustomShaderOptions {
  94361. /**
  94362. * Gets or sets the custom shader name to use
  94363. */
  94364. shaderName: string;
  94365. /**
  94366. * The list of attribute names used in the shader
  94367. */
  94368. attributes?: string[];
  94369. /**
  94370. * The list of unifrom names used in the shader
  94371. */
  94372. uniforms?: string[];
  94373. /**
  94374. * The list of sampler names used in the shader
  94375. */
  94376. samplers?: string[];
  94377. /**
  94378. * The list of defines used in the shader
  94379. */
  94380. defines?: string[];
  94381. }
  94382. /**
  94383. * Interface to implement to create a shadow generator compatible with BJS.
  94384. */
  94385. export interface IShadowGenerator {
  94386. /**
  94387. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  94388. * @returns The render target texture if present otherwise, null
  94389. */
  94390. getShadowMap(): Nullable<RenderTargetTexture>;
  94391. /**
  94392. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  94393. * @param subMesh The submesh we want to render in the shadow map
  94394. * @param useInstances Defines wether will draw in the map using instances
  94395. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  94396. * @returns true if ready otherwise, false
  94397. */
  94398. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  94399. /**
  94400. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  94401. * @param defines Defines of the material we want to update
  94402. * @param lightIndex Index of the light in the enabled light list of the material
  94403. */
  94404. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  94405. /**
  94406. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  94407. * defined in the generator but impacting the effect).
  94408. * It implies the unifroms available on the materials are the standard BJS ones.
  94409. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  94410. * @param effect The effect we are binfing the information for
  94411. */
  94412. bindShadowLight(lightIndex: string, effect: Effect): void;
  94413. /**
  94414. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  94415. * (eq to shadow prjection matrix * light transform matrix)
  94416. * @returns The transform matrix used to create the shadow map
  94417. */
  94418. getTransformMatrix(): Matrix;
  94419. /**
  94420. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  94421. * Cube and 2D textures for instance.
  94422. */
  94423. recreateShadowMap(): void;
  94424. /**
  94425. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  94426. * @param onCompiled Callback triggered at the and of the effects compilation
  94427. * @param options Sets of optional options forcing the compilation with different modes
  94428. */
  94429. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  94430. useInstances: boolean;
  94431. }>): void;
  94432. /**
  94433. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  94434. * @param options Sets of optional options forcing the compilation with different modes
  94435. * @returns A promise that resolves when the compilation completes
  94436. */
  94437. forceCompilationAsync(options?: Partial<{
  94438. useInstances: boolean;
  94439. }>): Promise<void>;
  94440. /**
  94441. * Serializes the shadow generator setup to a json object.
  94442. * @returns The serialized JSON object
  94443. */
  94444. serialize(): any;
  94445. /**
  94446. * Disposes the Shadow map and related Textures and effects.
  94447. */
  94448. dispose(): void;
  94449. }
  94450. /**
  94451. * Default implementation IShadowGenerator.
  94452. * This is the main object responsible of generating shadows in the framework.
  94453. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  94454. */
  94455. export class ShadowGenerator implements IShadowGenerator {
  94456. /**
  94457. * Name of the shadow generator class
  94458. */
  94459. static CLASSNAME: string;
  94460. /**
  94461. * Shadow generator mode None: no filtering applied.
  94462. */
  94463. static readonly FILTER_NONE: number;
  94464. /**
  94465. * Shadow generator mode ESM: Exponential Shadow Mapping.
  94466. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  94467. */
  94468. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  94469. /**
  94470. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  94471. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  94472. */
  94473. static readonly FILTER_POISSONSAMPLING: number;
  94474. /**
  94475. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  94476. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  94477. */
  94478. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  94479. /**
  94480. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  94481. * edge artifacts on steep falloff.
  94482. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  94483. */
  94484. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  94485. /**
  94486. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  94487. * edge artifacts on steep falloff.
  94488. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  94489. */
  94490. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  94491. /**
  94492. * Shadow generator mode PCF: Percentage Closer Filtering
  94493. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  94494. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  94495. */
  94496. static readonly FILTER_PCF: number;
  94497. /**
  94498. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  94499. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  94500. * Contact Hardening
  94501. */
  94502. static readonly FILTER_PCSS: number;
  94503. /**
  94504. * Reserved for PCF and PCSS
  94505. * Highest Quality.
  94506. *
  94507. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  94508. *
  94509. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  94510. */
  94511. static readonly QUALITY_HIGH: number;
  94512. /**
  94513. * Reserved for PCF and PCSS
  94514. * Good tradeoff for quality/perf cross devices
  94515. *
  94516. * Execute PCF on a 3*3 kernel.
  94517. *
  94518. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  94519. */
  94520. static readonly QUALITY_MEDIUM: number;
  94521. /**
  94522. * Reserved for PCF and PCSS
  94523. * The lowest quality but the fastest.
  94524. *
  94525. * Execute PCF on a 1*1 kernel.
  94526. *
  94527. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  94528. */
  94529. static readonly QUALITY_LOW: number;
  94530. /** Gets or sets the custom shader name to use */
  94531. customShaderOptions: ICustomShaderOptions;
  94532. /**
  94533. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  94534. */
  94535. onBeforeShadowMapRenderObservable: Observable<Effect>;
  94536. /**
  94537. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  94538. */
  94539. onAfterShadowMapRenderObservable: Observable<Effect>;
  94540. /**
  94541. * Observable triggered before a mesh is rendered in the shadow map.
  94542. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  94543. */
  94544. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  94545. /**
  94546. * Observable triggered after a mesh is rendered in the shadow map.
  94547. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  94548. */
  94549. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  94550. protected _bias: number;
  94551. /**
  94552. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  94553. */
  94554. get bias(): number;
  94555. /**
  94556. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  94557. */
  94558. set bias(bias: number);
  94559. protected _normalBias: number;
  94560. /**
  94561. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  94562. */
  94563. get normalBias(): number;
  94564. /**
  94565. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  94566. */
  94567. set normalBias(normalBias: number);
  94568. protected _blurBoxOffset: number;
  94569. /**
  94570. * Gets the blur box offset: offset applied during the blur pass.
  94571. * Only useful if useKernelBlur = false
  94572. */
  94573. get blurBoxOffset(): number;
  94574. /**
  94575. * Sets the blur box offset: offset applied during the blur pass.
  94576. * Only useful if useKernelBlur = false
  94577. */
  94578. set blurBoxOffset(value: number);
  94579. protected _blurScale: number;
  94580. /**
  94581. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  94582. * 2 means half of the size.
  94583. */
  94584. get blurScale(): number;
  94585. /**
  94586. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  94587. * 2 means half of the size.
  94588. */
  94589. set blurScale(value: number);
  94590. protected _blurKernel: number;
  94591. /**
  94592. * Gets the blur kernel: kernel size of the blur pass.
  94593. * Only useful if useKernelBlur = true
  94594. */
  94595. get blurKernel(): number;
  94596. /**
  94597. * Sets the blur kernel: kernel size of the blur pass.
  94598. * Only useful if useKernelBlur = true
  94599. */
  94600. set blurKernel(value: number);
  94601. protected _useKernelBlur: boolean;
  94602. /**
  94603. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  94604. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  94605. */
  94606. get useKernelBlur(): boolean;
  94607. /**
  94608. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  94609. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  94610. */
  94611. set useKernelBlur(value: boolean);
  94612. protected _depthScale: number;
  94613. /**
  94614. * Gets the depth scale used in ESM mode.
  94615. */
  94616. get depthScale(): number;
  94617. /**
  94618. * Sets the depth scale used in ESM mode.
  94619. * This can override the scale stored on the light.
  94620. */
  94621. set depthScale(value: number);
  94622. protected _validateFilter(filter: number): number;
  94623. protected _filter: number;
  94624. /**
  94625. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  94626. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  94627. */
  94628. get filter(): number;
  94629. /**
  94630. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  94631. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  94632. */
  94633. set filter(value: number);
  94634. /**
  94635. * Gets if the current filter is set to Poisson Sampling.
  94636. */
  94637. get usePoissonSampling(): boolean;
  94638. /**
  94639. * Sets the current filter to Poisson Sampling.
  94640. */
  94641. set usePoissonSampling(value: boolean);
  94642. /**
  94643. * Gets if the current filter is set to ESM.
  94644. */
  94645. get useExponentialShadowMap(): boolean;
  94646. /**
  94647. * Sets the current filter is to ESM.
  94648. */
  94649. set useExponentialShadowMap(value: boolean);
  94650. /**
  94651. * Gets if the current filter is set to filtered ESM.
  94652. */
  94653. get useBlurExponentialShadowMap(): boolean;
  94654. /**
  94655. * Gets if the current filter is set to filtered ESM.
  94656. */
  94657. set useBlurExponentialShadowMap(value: boolean);
  94658. /**
  94659. * Gets if the current filter is set to "close ESM" (using the inverse of the
  94660. * exponential to prevent steep falloff artifacts).
  94661. */
  94662. get useCloseExponentialShadowMap(): boolean;
  94663. /**
  94664. * Sets the current filter to "close ESM" (using the inverse of the
  94665. * exponential to prevent steep falloff artifacts).
  94666. */
  94667. set useCloseExponentialShadowMap(value: boolean);
  94668. /**
  94669. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  94670. * exponential to prevent steep falloff artifacts).
  94671. */
  94672. get useBlurCloseExponentialShadowMap(): boolean;
  94673. /**
  94674. * Sets the current filter to filtered "close ESM" (using the inverse of the
  94675. * exponential to prevent steep falloff artifacts).
  94676. */
  94677. set useBlurCloseExponentialShadowMap(value: boolean);
  94678. /**
  94679. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  94680. */
  94681. get usePercentageCloserFiltering(): boolean;
  94682. /**
  94683. * Sets the current filter to "PCF" (percentage closer filtering).
  94684. */
  94685. set usePercentageCloserFiltering(value: boolean);
  94686. protected _filteringQuality: number;
  94687. /**
  94688. * Gets the PCF or PCSS Quality.
  94689. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  94690. */
  94691. get filteringQuality(): number;
  94692. /**
  94693. * Sets the PCF or PCSS Quality.
  94694. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  94695. */
  94696. set filteringQuality(filteringQuality: number);
  94697. /**
  94698. * Gets if the current filter is set to "PCSS" (contact hardening).
  94699. */
  94700. get useContactHardeningShadow(): boolean;
  94701. /**
  94702. * Sets the current filter to "PCSS" (contact hardening).
  94703. */
  94704. set useContactHardeningShadow(value: boolean);
  94705. protected _contactHardeningLightSizeUVRatio: number;
  94706. /**
  94707. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  94708. * Using a ratio helps keeping shape stability independently of the map size.
  94709. *
  94710. * It does not account for the light projection as it was having too much
  94711. * instability during the light setup or during light position changes.
  94712. *
  94713. * Only valid if useContactHardeningShadow is true.
  94714. */
  94715. get contactHardeningLightSizeUVRatio(): number;
  94716. /**
  94717. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  94718. * Using a ratio helps keeping shape stability independently of the map size.
  94719. *
  94720. * It does not account for the light projection as it was having too much
  94721. * instability during the light setup or during light position changes.
  94722. *
  94723. * Only valid if useContactHardeningShadow is true.
  94724. */
  94725. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  94726. protected _darkness: number;
  94727. /** Gets or sets the actual darkness of a shadow */
  94728. get darkness(): number;
  94729. set darkness(value: number);
  94730. /**
  94731. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  94732. * 0 means strongest and 1 would means no shadow.
  94733. * @returns the darkness.
  94734. */
  94735. getDarkness(): number;
  94736. /**
  94737. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  94738. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  94739. * @returns the shadow generator allowing fluent coding.
  94740. */
  94741. setDarkness(darkness: number): ShadowGenerator;
  94742. protected _transparencyShadow: boolean;
  94743. /** Gets or sets the ability to have transparent shadow */
  94744. get transparencyShadow(): boolean;
  94745. set transparencyShadow(value: boolean);
  94746. /**
  94747. * Sets the ability to have transparent shadow (boolean).
  94748. * @param transparent True if transparent else False
  94749. * @returns the shadow generator allowing fluent coding
  94750. */
  94751. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  94752. /**
  94753. * Enables or disables shadows with varying strength based on the transparency
  94754. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  94755. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  94756. * mesh.visibility * alphaTexture.a
  94757. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  94758. */
  94759. enableSoftTransparentShadow: boolean;
  94760. protected _shadowMap: Nullable<RenderTargetTexture>;
  94761. protected _shadowMap2: Nullable<RenderTargetTexture>;
  94762. /**
  94763. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  94764. * @returns The render target texture if present otherwise, null
  94765. */
  94766. getShadowMap(): Nullable<RenderTargetTexture>;
  94767. /**
  94768. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  94769. * @returns The render target texture if the shadow map is present otherwise, null
  94770. */
  94771. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  94772. /**
  94773. * Gets the class name of that object
  94774. * @returns "ShadowGenerator"
  94775. */
  94776. getClassName(): string;
  94777. /**
  94778. * Helper function to add a mesh and its descendants to the list of shadow casters.
  94779. * @param mesh Mesh to add
  94780. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  94781. * @returns the Shadow Generator itself
  94782. */
  94783. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  94784. /**
  94785. * Helper function to remove a mesh and its descendants from the list of shadow casters
  94786. * @param mesh Mesh to remove
  94787. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  94788. * @returns the Shadow Generator itself
  94789. */
  94790. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  94791. /**
  94792. * Controls the extent to which the shadows fade out at the edge of the frustum
  94793. */
  94794. frustumEdgeFalloff: number;
  94795. protected _light: IShadowLight;
  94796. /**
  94797. * Returns the associated light object.
  94798. * @returns the light generating the shadow
  94799. */
  94800. getLight(): IShadowLight;
  94801. /**
  94802. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  94803. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  94804. * It might on the other hand introduce peter panning.
  94805. */
  94806. forceBackFacesOnly: boolean;
  94807. protected _scene: Scene;
  94808. protected _lightDirection: Vector3;
  94809. protected _effect: Effect;
  94810. protected _viewMatrix: Matrix;
  94811. protected _projectionMatrix: Matrix;
  94812. protected _transformMatrix: Matrix;
  94813. protected _cachedPosition: Vector3;
  94814. protected _cachedDirection: Vector3;
  94815. protected _cachedDefines: string;
  94816. protected _currentRenderID: number;
  94817. protected _boxBlurPostprocess: Nullable<PostProcess>;
  94818. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  94819. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  94820. protected _blurPostProcesses: PostProcess[];
  94821. protected _mapSize: number;
  94822. protected _currentFaceIndex: number;
  94823. protected _currentFaceIndexCache: number;
  94824. protected _textureType: number;
  94825. protected _defaultTextureMatrix: Matrix;
  94826. protected _storedUniqueId: Nullable<number>;
  94827. /** @hidden */
  94828. static _SceneComponentInitialization: (scene: Scene) => void;
  94829. /**
  94830. * Creates a ShadowGenerator object.
  94831. * A ShadowGenerator is the required tool to use the shadows.
  94832. * Each light casting shadows needs to use its own ShadowGenerator.
  94833. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  94834. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  94835. * @param light The light object generating the shadows.
  94836. * @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.
  94837. */
  94838. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  94839. protected _initializeGenerator(): void;
  94840. protected _createTargetRenderTexture(): void;
  94841. protected _initializeShadowMap(): void;
  94842. protected _initializeBlurRTTAndPostProcesses(): void;
  94843. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  94844. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  94845. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  94846. protected _applyFilterValues(): void;
  94847. /**
  94848. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  94849. * @param onCompiled Callback triggered at the and of the effects compilation
  94850. * @param options Sets of optional options forcing the compilation with different modes
  94851. */
  94852. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  94853. useInstances: boolean;
  94854. }>): void;
  94855. /**
  94856. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  94857. * @param options Sets of optional options forcing the compilation with different modes
  94858. * @returns A promise that resolves when the compilation completes
  94859. */
  94860. forceCompilationAsync(options?: Partial<{
  94861. useInstances: boolean;
  94862. }>): Promise<void>;
  94863. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  94864. private _prepareShadowDefines;
  94865. /**
  94866. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  94867. * @param subMesh The submesh we want to render in the shadow map
  94868. * @param useInstances Defines wether will draw in the map using instances
  94869. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  94870. * @returns true if ready otherwise, false
  94871. */
  94872. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  94873. /**
  94874. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  94875. * @param defines Defines of the material we want to update
  94876. * @param lightIndex Index of the light in the enabled light list of the material
  94877. */
  94878. prepareDefines(defines: any, lightIndex: number): void;
  94879. /**
  94880. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  94881. * defined in the generator but impacting the effect).
  94882. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  94883. * @param effect The effect we are binfing the information for
  94884. */
  94885. bindShadowLight(lightIndex: string, effect: Effect): void;
  94886. /**
  94887. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  94888. * (eq to shadow prjection matrix * light transform matrix)
  94889. * @returns The transform matrix used to create the shadow map
  94890. */
  94891. getTransformMatrix(): Matrix;
  94892. /**
  94893. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  94894. * Cube and 2D textures for instance.
  94895. */
  94896. recreateShadowMap(): void;
  94897. protected _disposeBlurPostProcesses(): void;
  94898. protected _disposeRTTandPostProcesses(): void;
  94899. /**
  94900. * Disposes the ShadowGenerator.
  94901. * Returns nothing.
  94902. */
  94903. dispose(): void;
  94904. /**
  94905. * Serializes the shadow generator setup to a json object.
  94906. * @returns The serialized JSON object
  94907. */
  94908. serialize(): any;
  94909. /**
  94910. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  94911. * @param parsedShadowGenerator The JSON object to parse
  94912. * @param scene The scene to create the shadow map for
  94913. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  94914. * @returns The parsed shadow generator
  94915. */
  94916. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  94917. }
  94918. }
  94919. declare module BABYLON {
  94920. /**
  94921. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  94922. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  94923. * 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.
  94924. */
  94925. export abstract class Light extends Node {
  94926. /**
  94927. * Falloff Default: light is falling off following the material specification:
  94928. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  94929. */
  94930. static readonly FALLOFF_DEFAULT: number;
  94931. /**
  94932. * Falloff Physical: light is falling off following the inverse squared distance law.
  94933. */
  94934. static readonly FALLOFF_PHYSICAL: number;
  94935. /**
  94936. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  94937. * to enhance interoperability with other engines.
  94938. */
  94939. static readonly FALLOFF_GLTF: number;
  94940. /**
  94941. * Falloff Standard: light is falling off like in the standard material
  94942. * to enhance interoperability with other materials.
  94943. */
  94944. static readonly FALLOFF_STANDARD: number;
  94945. /**
  94946. * If every light affecting the material is in this lightmapMode,
  94947. * material.lightmapTexture adds or multiplies
  94948. * (depends on material.useLightmapAsShadowmap)
  94949. * after every other light calculations.
  94950. */
  94951. static readonly LIGHTMAP_DEFAULT: number;
  94952. /**
  94953. * material.lightmapTexture as only diffuse lighting from this light
  94954. * adds only specular lighting from this light
  94955. * adds dynamic shadows
  94956. */
  94957. static readonly LIGHTMAP_SPECULAR: number;
  94958. /**
  94959. * material.lightmapTexture as only lighting
  94960. * no light calculation from this light
  94961. * only adds dynamic shadows from this light
  94962. */
  94963. static readonly LIGHTMAP_SHADOWSONLY: number;
  94964. /**
  94965. * Each light type uses the default quantity according to its type:
  94966. * point/spot lights use luminous intensity
  94967. * directional lights use illuminance
  94968. */
  94969. static readonly INTENSITYMODE_AUTOMATIC: number;
  94970. /**
  94971. * lumen (lm)
  94972. */
  94973. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  94974. /**
  94975. * candela (lm/sr)
  94976. */
  94977. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  94978. /**
  94979. * lux (lm/m^2)
  94980. */
  94981. static readonly INTENSITYMODE_ILLUMINANCE: number;
  94982. /**
  94983. * nit (cd/m^2)
  94984. */
  94985. static readonly INTENSITYMODE_LUMINANCE: number;
  94986. /**
  94987. * Light type const id of the point light.
  94988. */
  94989. static readonly LIGHTTYPEID_POINTLIGHT: number;
  94990. /**
  94991. * Light type const id of the directional light.
  94992. */
  94993. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  94994. /**
  94995. * Light type const id of the spot light.
  94996. */
  94997. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  94998. /**
  94999. * Light type const id of the hemispheric light.
  95000. */
  95001. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  95002. /**
  95003. * Diffuse gives the basic color to an object.
  95004. */
  95005. diffuse: Color3;
  95006. /**
  95007. * Specular produces a highlight color on an object.
  95008. * Note: This is note affecting PBR materials.
  95009. */
  95010. specular: Color3;
  95011. /**
  95012. * Defines the falloff type for this light. This lets overrriding how punctual light are
  95013. * falling off base on range or angle.
  95014. * This can be set to any values in Light.FALLOFF_x.
  95015. *
  95016. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  95017. * other types of materials.
  95018. */
  95019. falloffType: number;
  95020. /**
  95021. * Strength of the light.
  95022. * Note: By default it is define in the framework own unit.
  95023. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  95024. */
  95025. intensity: number;
  95026. private _range;
  95027. protected _inverseSquaredRange: number;
  95028. /**
  95029. * Defines how far from the source the light is impacting in scene units.
  95030. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  95031. */
  95032. get range(): number;
  95033. /**
  95034. * Defines how far from the source the light is impacting in scene units.
  95035. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  95036. */
  95037. set range(value: number);
  95038. /**
  95039. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  95040. * of light.
  95041. */
  95042. private _photometricScale;
  95043. private _intensityMode;
  95044. /**
  95045. * Gets the photometric scale used to interpret the intensity.
  95046. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  95047. */
  95048. get intensityMode(): number;
  95049. /**
  95050. * Sets the photometric scale used to interpret the intensity.
  95051. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  95052. */
  95053. set intensityMode(value: number);
  95054. private _radius;
  95055. /**
  95056. * Gets the light radius used by PBR Materials to simulate soft area lights.
  95057. */
  95058. get radius(): number;
  95059. /**
  95060. * sets the light radius used by PBR Materials to simulate soft area lights.
  95061. */
  95062. set radius(value: number);
  95063. private _renderPriority;
  95064. /**
  95065. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  95066. * exceeding the number allowed of the materials.
  95067. */
  95068. renderPriority: number;
  95069. private _shadowEnabled;
  95070. /**
  95071. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  95072. * the current shadow generator.
  95073. */
  95074. get shadowEnabled(): boolean;
  95075. /**
  95076. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  95077. * the current shadow generator.
  95078. */
  95079. set shadowEnabled(value: boolean);
  95080. private _includedOnlyMeshes;
  95081. /**
  95082. * Gets the only meshes impacted by this light.
  95083. */
  95084. get includedOnlyMeshes(): AbstractMesh[];
  95085. /**
  95086. * Sets the only meshes impacted by this light.
  95087. */
  95088. set includedOnlyMeshes(value: AbstractMesh[]);
  95089. private _excludedMeshes;
  95090. /**
  95091. * Gets the meshes not impacted by this light.
  95092. */
  95093. get excludedMeshes(): AbstractMesh[];
  95094. /**
  95095. * Sets the meshes not impacted by this light.
  95096. */
  95097. set excludedMeshes(value: AbstractMesh[]);
  95098. private _excludeWithLayerMask;
  95099. /**
  95100. * Gets the layer id use to find what meshes are not impacted by the light.
  95101. * Inactive if 0
  95102. */
  95103. get excludeWithLayerMask(): number;
  95104. /**
  95105. * Sets the layer id use to find what meshes are not impacted by the light.
  95106. * Inactive if 0
  95107. */
  95108. set excludeWithLayerMask(value: number);
  95109. private _includeOnlyWithLayerMask;
  95110. /**
  95111. * Gets the layer id use to find what meshes are impacted by the light.
  95112. * Inactive if 0
  95113. */
  95114. get includeOnlyWithLayerMask(): number;
  95115. /**
  95116. * Sets the layer id use to find what meshes are impacted by the light.
  95117. * Inactive if 0
  95118. */
  95119. set includeOnlyWithLayerMask(value: number);
  95120. private _lightmapMode;
  95121. /**
  95122. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  95123. */
  95124. get lightmapMode(): number;
  95125. /**
  95126. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  95127. */
  95128. set lightmapMode(value: number);
  95129. /**
  95130. * Shadow generator associted to the light.
  95131. * @hidden Internal use only.
  95132. */
  95133. _shadowGenerator: Nullable<IShadowGenerator>;
  95134. /**
  95135. * @hidden Internal use only.
  95136. */
  95137. _excludedMeshesIds: string[];
  95138. /**
  95139. * @hidden Internal use only.
  95140. */
  95141. _includedOnlyMeshesIds: string[];
  95142. /**
  95143. * The current light unifom buffer.
  95144. * @hidden Internal use only.
  95145. */
  95146. _uniformBuffer: UniformBuffer;
  95147. /** @hidden */
  95148. _renderId: number;
  95149. /**
  95150. * Creates a Light object in the scene.
  95151. * Documentation : https://doc.babylonjs.com/babylon101/lights
  95152. * @param name The firendly name of the light
  95153. * @param scene The scene the light belongs too
  95154. */
  95155. constructor(name: string, scene: Scene);
  95156. protected abstract _buildUniformLayout(): void;
  95157. /**
  95158. * Sets the passed Effect "effect" with the Light information.
  95159. * @param effect The effect to update
  95160. * @param lightIndex The index of the light in the effect to update
  95161. * @returns The light
  95162. */
  95163. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  95164. /**
  95165. * Sets the passed Effect "effect" with the Light textures.
  95166. * @param effect The effect to update
  95167. * @param lightIndex The index of the light in the effect to update
  95168. * @returns The light
  95169. */
  95170. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  95171. /**
  95172. * Binds the lights information from the scene to the effect for the given mesh.
  95173. * @param lightIndex Light index
  95174. * @param scene The scene where the light belongs to
  95175. * @param effect The effect we are binding the data to
  95176. * @param useSpecular Defines if specular is supported
  95177. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  95178. */
  95179. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  95180. /**
  95181. * Sets the passed Effect "effect" with the Light information.
  95182. * @param effect The effect to update
  95183. * @param lightDataUniformName The uniform used to store light data (position or direction)
  95184. * @returns The light
  95185. */
  95186. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  95187. /**
  95188. * Returns the string "Light".
  95189. * @returns the class name
  95190. */
  95191. getClassName(): string;
  95192. /** @hidden */
  95193. readonly _isLight: boolean;
  95194. /**
  95195. * Converts the light information to a readable string for debug purpose.
  95196. * @param fullDetails Supports for multiple levels of logging within scene loading
  95197. * @returns the human readable light info
  95198. */
  95199. toString(fullDetails?: boolean): string;
  95200. /** @hidden */
  95201. protected _syncParentEnabledState(): void;
  95202. /**
  95203. * Set the enabled state of this node.
  95204. * @param value - the new enabled state
  95205. */
  95206. setEnabled(value: boolean): void;
  95207. /**
  95208. * Returns the Light associated shadow generator if any.
  95209. * @return the associated shadow generator.
  95210. */
  95211. getShadowGenerator(): Nullable<IShadowGenerator>;
  95212. /**
  95213. * Returns a Vector3, the absolute light position in the World.
  95214. * @returns the world space position of the light
  95215. */
  95216. getAbsolutePosition(): Vector3;
  95217. /**
  95218. * Specifies if the light will affect the passed mesh.
  95219. * @param mesh The mesh to test against the light
  95220. * @return true the mesh is affected otherwise, false.
  95221. */
  95222. canAffectMesh(mesh: AbstractMesh): boolean;
  95223. /**
  95224. * Sort function to order lights for rendering.
  95225. * @param a First Light object to compare to second.
  95226. * @param b Second Light object to compare first.
  95227. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  95228. */
  95229. static CompareLightsPriority(a: Light, b: Light): number;
  95230. /**
  95231. * Releases resources associated with this node.
  95232. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  95233. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  95234. */
  95235. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  95236. /**
  95237. * Returns the light type ID (integer).
  95238. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  95239. */
  95240. getTypeID(): number;
  95241. /**
  95242. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  95243. * @returns the scaled intensity in intensity mode unit
  95244. */
  95245. getScaledIntensity(): number;
  95246. /**
  95247. * Returns a new Light object, named "name", from the current one.
  95248. * @param name The name of the cloned light
  95249. * @param newParent The parent of this light, if it has one
  95250. * @returns the new created light
  95251. */
  95252. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  95253. /**
  95254. * Serializes the current light into a Serialization object.
  95255. * @returns the serialized object.
  95256. */
  95257. serialize(): any;
  95258. /**
  95259. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  95260. * This new light is named "name" and added to the passed scene.
  95261. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  95262. * @param name The friendly name of the light
  95263. * @param scene The scene the new light will belong to
  95264. * @returns the constructor function
  95265. */
  95266. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  95267. /**
  95268. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  95269. * @param parsedLight The JSON representation of the light
  95270. * @param scene The scene to create the parsed light in
  95271. * @returns the created light after parsing
  95272. */
  95273. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  95274. private _hookArrayForExcluded;
  95275. private _hookArrayForIncludedOnly;
  95276. private _resyncMeshes;
  95277. /**
  95278. * Forces the meshes to update their light related information in their rendering used effects
  95279. * @hidden Internal Use Only
  95280. */
  95281. _markMeshesAsLightDirty(): void;
  95282. /**
  95283. * Recomputes the cached photometric scale if needed.
  95284. */
  95285. private _computePhotometricScale;
  95286. /**
  95287. * Returns the Photometric Scale according to the light type and intensity mode.
  95288. */
  95289. private _getPhotometricScale;
  95290. /**
  95291. * Reorder the light in the scene according to their defined priority.
  95292. * @hidden Internal Use Only
  95293. */
  95294. _reorderLightsInScene(): void;
  95295. /**
  95296. * Prepares the list of defines specific to the light type.
  95297. * @param defines the list of defines
  95298. * @param lightIndex defines the index of the light for the effect
  95299. */
  95300. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  95301. }
  95302. }
  95303. declare module BABYLON {
  95304. /**
  95305. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  95306. * This is the base of the follow, arc rotate cameras and Free camera
  95307. * @see http://doc.babylonjs.com/features/cameras
  95308. */
  95309. export class TargetCamera extends Camera {
  95310. private static _RigCamTransformMatrix;
  95311. private static _TargetTransformMatrix;
  95312. private static _TargetFocalPoint;
  95313. /**
  95314. * Define the current direction the camera is moving to
  95315. */
  95316. cameraDirection: Vector3;
  95317. /**
  95318. * Define the current rotation the camera is rotating to
  95319. */
  95320. cameraRotation: Vector2;
  95321. /**
  95322. * When set, the up vector of the camera will be updated by the rotation of the camera
  95323. */
  95324. updateUpVectorFromRotation: boolean;
  95325. private _tmpQuaternion;
  95326. /**
  95327. * Define the current rotation of the camera
  95328. */
  95329. rotation: Vector3;
  95330. /**
  95331. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  95332. */
  95333. rotationQuaternion: Quaternion;
  95334. /**
  95335. * Define the current speed of the camera
  95336. */
  95337. speed: number;
  95338. /**
  95339. * Add constraint to the camera to prevent it to move freely in all directions and
  95340. * around all axis.
  95341. */
  95342. noRotationConstraint: boolean;
  95343. /**
  95344. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  95345. * panning
  95346. */
  95347. invertRotation: boolean;
  95348. /**
  95349. * Speed multiplier for inverse camera panning
  95350. */
  95351. inverseRotationSpeed: number;
  95352. /**
  95353. * Define the current target of the camera as an object or a position.
  95354. */
  95355. lockedTarget: any;
  95356. /** @hidden */
  95357. _currentTarget: Vector3;
  95358. /** @hidden */
  95359. _initialFocalDistance: number;
  95360. /** @hidden */
  95361. _viewMatrix: Matrix;
  95362. /** @hidden */
  95363. _camMatrix: Matrix;
  95364. /** @hidden */
  95365. _cameraTransformMatrix: Matrix;
  95366. /** @hidden */
  95367. _cameraRotationMatrix: Matrix;
  95368. /** @hidden */
  95369. _referencePoint: Vector3;
  95370. /** @hidden */
  95371. _transformedReferencePoint: Vector3;
  95372. protected _globalCurrentTarget: Vector3;
  95373. protected _globalCurrentUpVector: Vector3;
  95374. /** @hidden */
  95375. _reset: () => void;
  95376. private _defaultUp;
  95377. /**
  95378. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  95379. * This is the base of the follow, arc rotate cameras and Free camera
  95380. * @see http://doc.babylonjs.com/features/cameras
  95381. * @param name Defines the name of the camera in the scene
  95382. * @param position Defines the start position of the camera in the scene
  95383. * @param scene Defines the scene the camera belongs to
  95384. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  95385. */
  95386. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  95387. /**
  95388. * Gets the position in front of the camera at a given distance.
  95389. * @param distance The distance from the camera we want the position to be
  95390. * @returns the position
  95391. */
  95392. getFrontPosition(distance: number): Vector3;
  95393. /** @hidden */
  95394. _getLockedTargetPosition(): Nullable<Vector3>;
  95395. private _storedPosition;
  95396. private _storedRotation;
  95397. private _storedRotationQuaternion;
  95398. /**
  95399. * Store current camera state of the camera (fov, position, rotation, etc..)
  95400. * @returns the camera
  95401. */
  95402. storeState(): Camera;
  95403. /**
  95404. * Restored camera state. You must call storeState() first
  95405. * @returns whether it was successful or not
  95406. * @hidden
  95407. */
  95408. _restoreStateValues(): boolean;
  95409. /** @hidden */
  95410. _initCache(): void;
  95411. /** @hidden */
  95412. _updateCache(ignoreParentClass?: boolean): void;
  95413. /** @hidden */
  95414. _isSynchronizedViewMatrix(): boolean;
  95415. /** @hidden */
  95416. _computeLocalCameraSpeed(): number;
  95417. /**
  95418. * Defines the target the camera should look at.
  95419. * @param target Defines the new target as a Vector or a mesh
  95420. */
  95421. setTarget(target: Vector3): void;
  95422. /**
  95423. * Return the current target position of the camera. This value is expressed in local space.
  95424. * @returns the target position
  95425. */
  95426. getTarget(): Vector3;
  95427. /** @hidden */
  95428. _decideIfNeedsToMove(): boolean;
  95429. /** @hidden */
  95430. _updatePosition(): void;
  95431. /** @hidden */
  95432. _checkInputs(): void;
  95433. protected _updateCameraRotationMatrix(): void;
  95434. /**
  95435. * 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)
  95436. * @returns the current camera
  95437. */
  95438. private _rotateUpVectorWithCameraRotationMatrix;
  95439. private _cachedRotationZ;
  95440. private _cachedQuaternionRotationZ;
  95441. /** @hidden */
  95442. _getViewMatrix(): Matrix;
  95443. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  95444. /**
  95445. * @hidden
  95446. */
  95447. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  95448. /**
  95449. * @hidden
  95450. */
  95451. _updateRigCameras(): void;
  95452. private _getRigCamPositionAndTarget;
  95453. /**
  95454. * Gets the current object class name.
  95455. * @return the class name
  95456. */
  95457. getClassName(): string;
  95458. }
  95459. }
  95460. declare module BABYLON {
  95461. /**
  95462. * Gather the list of keyboard event types as constants.
  95463. */
  95464. export class KeyboardEventTypes {
  95465. /**
  95466. * The keydown event is fired when a key becomes active (pressed).
  95467. */
  95468. static readonly KEYDOWN: number;
  95469. /**
  95470. * The keyup event is fired when a key has been released.
  95471. */
  95472. static readonly KEYUP: number;
  95473. }
  95474. /**
  95475. * This class is used to store keyboard related info for the onKeyboardObservable event.
  95476. */
  95477. export class KeyboardInfo {
  95478. /**
  95479. * Defines the type of event (KeyboardEventTypes)
  95480. */
  95481. type: number;
  95482. /**
  95483. * Defines the related dom event
  95484. */
  95485. event: KeyboardEvent;
  95486. /**
  95487. * Instantiates a new keyboard info.
  95488. * This class is used to store keyboard related info for the onKeyboardObservable event.
  95489. * @param type Defines the type of event (KeyboardEventTypes)
  95490. * @param event Defines the related dom event
  95491. */
  95492. constructor(
  95493. /**
  95494. * Defines the type of event (KeyboardEventTypes)
  95495. */
  95496. type: number,
  95497. /**
  95498. * Defines the related dom event
  95499. */
  95500. event: KeyboardEvent);
  95501. }
  95502. /**
  95503. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  95504. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  95505. */
  95506. export class KeyboardInfoPre extends KeyboardInfo {
  95507. /**
  95508. * Defines the type of event (KeyboardEventTypes)
  95509. */
  95510. type: number;
  95511. /**
  95512. * Defines the related dom event
  95513. */
  95514. event: KeyboardEvent;
  95515. /**
  95516. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  95517. */
  95518. skipOnPointerObservable: boolean;
  95519. /**
  95520. * Instantiates a new keyboard pre info.
  95521. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  95522. * @param type Defines the type of event (KeyboardEventTypes)
  95523. * @param event Defines the related dom event
  95524. */
  95525. constructor(
  95526. /**
  95527. * Defines the type of event (KeyboardEventTypes)
  95528. */
  95529. type: number,
  95530. /**
  95531. * Defines the related dom event
  95532. */
  95533. event: KeyboardEvent);
  95534. }
  95535. }
  95536. declare module BABYLON {
  95537. /**
  95538. * Manage the keyboard inputs to control the movement of a free camera.
  95539. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95540. */
  95541. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  95542. /**
  95543. * Defines the camera the input is attached to.
  95544. */
  95545. camera: FreeCamera;
  95546. /**
  95547. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  95548. */
  95549. keysUp: number[];
  95550. /**
  95551. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  95552. */
  95553. keysUpward: number[];
  95554. /**
  95555. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  95556. */
  95557. keysDown: number[];
  95558. /**
  95559. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  95560. */
  95561. keysDownward: number[];
  95562. /**
  95563. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  95564. */
  95565. keysLeft: number[];
  95566. /**
  95567. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  95568. */
  95569. keysRight: number[];
  95570. private _keys;
  95571. private _onCanvasBlurObserver;
  95572. private _onKeyboardObserver;
  95573. private _engine;
  95574. private _scene;
  95575. /**
  95576. * Attach the input controls to a specific dom element to get the input from.
  95577. * @param element Defines the element the controls should be listened from
  95578. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95579. */
  95580. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95581. /**
  95582. * Detach the current controls from the specified dom element.
  95583. * @param element Defines the element to stop listening the inputs from
  95584. */
  95585. detachControl(element: Nullable<HTMLElement>): void;
  95586. /**
  95587. * Update the current camera state depending on the inputs that have been used this frame.
  95588. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  95589. */
  95590. checkInputs(): void;
  95591. /**
  95592. * Gets the class name of the current intput.
  95593. * @returns the class name
  95594. */
  95595. getClassName(): string;
  95596. /** @hidden */
  95597. _onLostFocus(): void;
  95598. /**
  95599. * Get the friendly name associated with the input class.
  95600. * @returns the input friendly name
  95601. */
  95602. getSimpleName(): string;
  95603. }
  95604. }
  95605. declare module BABYLON {
  95606. /**
  95607. * Gather the list of pointer event types as constants.
  95608. */
  95609. export class PointerEventTypes {
  95610. /**
  95611. * 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.
  95612. */
  95613. static readonly POINTERDOWN: number;
  95614. /**
  95615. * The pointerup event is fired when a pointer is no longer active.
  95616. */
  95617. static readonly POINTERUP: number;
  95618. /**
  95619. * The pointermove event is fired when a pointer changes coordinates.
  95620. */
  95621. static readonly POINTERMOVE: number;
  95622. /**
  95623. * The pointerwheel event is fired when a mouse wheel has been rotated.
  95624. */
  95625. static readonly POINTERWHEEL: number;
  95626. /**
  95627. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  95628. */
  95629. static readonly POINTERPICK: number;
  95630. /**
  95631. * The pointertap event is fired when a the object has been touched and released without drag.
  95632. */
  95633. static readonly POINTERTAP: number;
  95634. /**
  95635. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  95636. */
  95637. static readonly POINTERDOUBLETAP: number;
  95638. }
  95639. /**
  95640. * Base class of pointer info types.
  95641. */
  95642. export class PointerInfoBase {
  95643. /**
  95644. * Defines the type of event (PointerEventTypes)
  95645. */
  95646. type: number;
  95647. /**
  95648. * Defines the related dom event
  95649. */
  95650. event: PointerEvent | MouseWheelEvent;
  95651. /**
  95652. * Instantiates the base class of pointers info.
  95653. * @param type Defines the type of event (PointerEventTypes)
  95654. * @param event Defines the related dom event
  95655. */
  95656. constructor(
  95657. /**
  95658. * Defines the type of event (PointerEventTypes)
  95659. */
  95660. type: number,
  95661. /**
  95662. * Defines the related dom event
  95663. */
  95664. event: PointerEvent | MouseWheelEvent);
  95665. }
  95666. /**
  95667. * This class is used to store pointer related info for the onPrePointerObservable event.
  95668. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  95669. */
  95670. export class PointerInfoPre extends PointerInfoBase {
  95671. /**
  95672. * Ray from a pointer if availible (eg. 6dof controller)
  95673. */
  95674. ray: Nullable<Ray>;
  95675. /**
  95676. * Defines the local position of the pointer on the canvas.
  95677. */
  95678. localPosition: Vector2;
  95679. /**
  95680. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  95681. */
  95682. skipOnPointerObservable: boolean;
  95683. /**
  95684. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  95685. * @param type Defines the type of event (PointerEventTypes)
  95686. * @param event Defines the related dom event
  95687. * @param localX Defines the local x coordinates of the pointer when the event occured
  95688. * @param localY Defines the local y coordinates of the pointer when the event occured
  95689. */
  95690. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  95691. }
  95692. /**
  95693. * This type contains all the data related to a pointer event in Babylon.js.
  95694. * 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.
  95695. */
  95696. export class PointerInfo extends PointerInfoBase {
  95697. /**
  95698. * Defines the picking info associated to the info (if any)\
  95699. */
  95700. pickInfo: Nullable<PickingInfo>;
  95701. /**
  95702. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  95703. * @param type Defines the type of event (PointerEventTypes)
  95704. * @param event Defines the related dom event
  95705. * @param pickInfo Defines the picking info associated to the info (if any)\
  95706. */
  95707. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  95708. /**
  95709. * Defines the picking info associated to the info (if any)\
  95710. */
  95711. pickInfo: Nullable<PickingInfo>);
  95712. }
  95713. /**
  95714. * Data relating to a touch event on the screen.
  95715. */
  95716. export interface PointerTouch {
  95717. /**
  95718. * X coordinate of touch.
  95719. */
  95720. x: number;
  95721. /**
  95722. * Y coordinate of touch.
  95723. */
  95724. y: number;
  95725. /**
  95726. * Id of touch. Unique for each finger.
  95727. */
  95728. pointerId: number;
  95729. /**
  95730. * Event type passed from DOM.
  95731. */
  95732. type: any;
  95733. }
  95734. }
  95735. declare module BABYLON {
  95736. /**
  95737. * Manage the mouse inputs to control the movement of a free camera.
  95738. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95739. */
  95740. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  95741. /**
  95742. * Define if touch is enabled in the mouse input
  95743. */
  95744. touchEnabled: boolean;
  95745. /**
  95746. * Defines the camera the input is attached to.
  95747. */
  95748. camera: FreeCamera;
  95749. /**
  95750. * Defines the buttons associated with the input to handle camera move.
  95751. */
  95752. buttons: number[];
  95753. /**
  95754. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  95755. */
  95756. angularSensibility: number;
  95757. private _pointerInput;
  95758. private _onMouseMove;
  95759. private _observer;
  95760. private previousPosition;
  95761. /**
  95762. * Observable for when a pointer move event occurs containing the move offset
  95763. */
  95764. onPointerMovedObservable: Observable<{
  95765. offsetX: number;
  95766. offsetY: number;
  95767. }>;
  95768. /**
  95769. * @hidden
  95770. * If the camera should be rotated automatically based on pointer movement
  95771. */
  95772. _allowCameraRotation: boolean;
  95773. /**
  95774. * Manage the mouse inputs to control the movement of a free camera.
  95775. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95776. * @param touchEnabled Defines if touch is enabled or not
  95777. */
  95778. constructor(
  95779. /**
  95780. * Define if touch is enabled in the mouse input
  95781. */
  95782. touchEnabled?: boolean);
  95783. /**
  95784. * Attach the input controls to a specific dom element to get the input from.
  95785. * @param element Defines the element the controls should be listened from
  95786. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95787. */
  95788. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95789. /**
  95790. * Called on JS contextmenu event.
  95791. * Override this method to provide functionality.
  95792. */
  95793. protected onContextMenu(evt: PointerEvent): void;
  95794. /**
  95795. * Detach the current controls from the specified dom element.
  95796. * @param element Defines the element to stop listening the inputs from
  95797. */
  95798. detachControl(element: Nullable<HTMLElement>): void;
  95799. /**
  95800. * Gets the class name of the current intput.
  95801. * @returns the class name
  95802. */
  95803. getClassName(): string;
  95804. /**
  95805. * Get the friendly name associated with the input class.
  95806. * @returns the input friendly name
  95807. */
  95808. getSimpleName(): string;
  95809. }
  95810. }
  95811. declare module BABYLON {
  95812. /**
  95813. * Manage the touch inputs to control the movement of a free camera.
  95814. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95815. */
  95816. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  95817. /**
  95818. * Defines the camera the input is attached to.
  95819. */
  95820. camera: FreeCamera;
  95821. /**
  95822. * Defines the touch sensibility for rotation.
  95823. * The higher the faster.
  95824. */
  95825. touchAngularSensibility: number;
  95826. /**
  95827. * Defines the touch sensibility for move.
  95828. * The higher the faster.
  95829. */
  95830. touchMoveSensibility: number;
  95831. private _offsetX;
  95832. private _offsetY;
  95833. private _pointerPressed;
  95834. private _pointerInput;
  95835. private _observer;
  95836. private _onLostFocus;
  95837. /**
  95838. * Attach the input controls to a specific dom element to get the input from.
  95839. * @param element Defines the element the controls should be listened from
  95840. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95841. */
  95842. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95843. /**
  95844. * Detach the current controls from the specified dom element.
  95845. * @param element Defines the element to stop listening the inputs from
  95846. */
  95847. detachControl(element: Nullable<HTMLElement>): void;
  95848. /**
  95849. * Update the current camera state depending on the inputs that have been used this frame.
  95850. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  95851. */
  95852. checkInputs(): void;
  95853. /**
  95854. * Gets the class name of the current intput.
  95855. * @returns the class name
  95856. */
  95857. getClassName(): string;
  95858. /**
  95859. * Get the friendly name associated with the input class.
  95860. * @returns the input friendly name
  95861. */
  95862. getSimpleName(): string;
  95863. }
  95864. }
  95865. declare module BABYLON {
  95866. /**
  95867. * Default Inputs manager for the FreeCamera.
  95868. * It groups all the default supported inputs for ease of use.
  95869. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95870. */
  95871. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  95872. /**
  95873. * @hidden
  95874. */
  95875. _mouseInput: Nullable<FreeCameraMouseInput>;
  95876. /**
  95877. * Instantiates a new FreeCameraInputsManager.
  95878. * @param camera Defines the camera the inputs belong to
  95879. */
  95880. constructor(camera: FreeCamera);
  95881. /**
  95882. * Add keyboard input support to the input manager.
  95883. * @returns the current input manager
  95884. */
  95885. addKeyboard(): FreeCameraInputsManager;
  95886. /**
  95887. * Add mouse input support to the input manager.
  95888. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  95889. * @returns the current input manager
  95890. */
  95891. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  95892. /**
  95893. * Removes the mouse input support from the manager
  95894. * @returns the current input manager
  95895. */
  95896. removeMouse(): FreeCameraInputsManager;
  95897. /**
  95898. * Add touch input support to the input manager.
  95899. * @returns the current input manager
  95900. */
  95901. addTouch(): FreeCameraInputsManager;
  95902. /**
  95903. * Remove all attached input methods from a camera
  95904. */
  95905. clear(): void;
  95906. }
  95907. }
  95908. declare module BABYLON {
  95909. /**
  95910. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  95911. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  95912. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  95913. */
  95914. export class FreeCamera extends TargetCamera {
  95915. /**
  95916. * Define the collision ellipsoid of the camera.
  95917. * This is helpful to simulate a camera body like the player body around the camera
  95918. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  95919. */
  95920. ellipsoid: Vector3;
  95921. /**
  95922. * Define an offset for the position of the ellipsoid around the camera.
  95923. * This can be helpful to determine the center of the body near the gravity center of the body
  95924. * instead of its head.
  95925. */
  95926. ellipsoidOffset: Vector3;
  95927. /**
  95928. * Enable or disable collisions of the camera with the rest of the scene objects.
  95929. */
  95930. checkCollisions: boolean;
  95931. /**
  95932. * Enable or disable gravity on the camera.
  95933. */
  95934. applyGravity: boolean;
  95935. /**
  95936. * Define the input manager associated to the camera.
  95937. */
  95938. inputs: FreeCameraInputsManager;
  95939. /**
  95940. * Gets the input sensibility for a mouse input. (default is 2000.0)
  95941. * Higher values reduce sensitivity.
  95942. */
  95943. get angularSensibility(): number;
  95944. /**
  95945. * Sets the input sensibility for a mouse input. (default is 2000.0)
  95946. * Higher values reduce sensitivity.
  95947. */
  95948. set angularSensibility(value: number);
  95949. /**
  95950. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  95951. */
  95952. get keysUp(): number[];
  95953. set keysUp(value: number[]);
  95954. /**
  95955. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  95956. */
  95957. get keysUpward(): number[];
  95958. set keysUpward(value: number[]);
  95959. /**
  95960. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  95961. */
  95962. get keysDown(): number[];
  95963. set keysDown(value: number[]);
  95964. /**
  95965. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  95966. */
  95967. get keysDownward(): number[];
  95968. set keysDownward(value: number[]);
  95969. /**
  95970. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  95971. */
  95972. get keysLeft(): number[];
  95973. set keysLeft(value: number[]);
  95974. /**
  95975. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  95976. */
  95977. get keysRight(): number[];
  95978. set keysRight(value: number[]);
  95979. /**
  95980. * Event raised when the camera collide with a mesh in the scene.
  95981. */
  95982. onCollide: (collidedMesh: AbstractMesh) => void;
  95983. private _collider;
  95984. private _needMoveForGravity;
  95985. private _oldPosition;
  95986. private _diffPosition;
  95987. private _newPosition;
  95988. /** @hidden */
  95989. _localDirection: Vector3;
  95990. /** @hidden */
  95991. _transformedDirection: Vector3;
  95992. /**
  95993. * Instantiates a Free Camera.
  95994. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  95995. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  95996. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  95997. * @param name Define the name of the camera in the scene
  95998. * @param position Define the start position of the camera in the scene
  95999. * @param scene Define the scene the camera belongs to
  96000. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  96001. */
  96002. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  96003. /**
  96004. * Attached controls to the current camera.
  96005. * @param element Defines the element the controls should be listened from
  96006. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96007. */
  96008. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96009. /**
  96010. * Detach the current controls from the camera.
  96011. * The camera will stop reacting to inputs.
  96012. * @param element Defines the element to stop listening the inputs from
  96013. */
  96014. detachControl(element: HTMLElement): void;
  96015. private _collisionMask;
  96016. /**
  96017. * Define a collision mask to limit the list of object the camera can collide with
  96018. */
  96019. get collisionMask(): number;
  96020. set collisionMask(mask: number);
  96021. /** @hidden */
  96022. _collideWithWorld(displacement: Vector3): void;
  96023. private _onCollisionPositionChange;
  96024. /** @hidden */
  96025. _checkInputs(): void;
  96026. /** @hidden */
  96027. _decideIfNeedsToMove(): boolean;
  96028. /** @hidden */
  96029. _updatePosition(): void;
  96030. /**
  96031. * Destroy the camera and release the current resources hold by it.
  96032. */
  96033. dispose(): void;
  96034. /**
  96035. * Gets the current object class name.
  96036. * @return the class name
  96037. */
  96038. getClassName(): string;
  96039. }
  96040. }
  96041. declare module BABYLON {
  96042. /**
  96043. * Represents a gamepad control stick position
  96044. */
  96045. export class StickValues {
  96046. /**
  96047. * The x component of the control stick
  96048. */
  96049. x: number;
  96050. /**
  96051. * The y component of the control stick
  96052. */
  96053. y: number;
  96054. /**
  96055. * Initializes the gamepad x and y control stick values
  96056. * @param x The x component of the gamepad control stick value
  96057. * @param y The y component of the gamepad control stick value
  96058. */
  96059. constructor(
  96060. /**
  96061. * The x component of the control stick
  96062. */
  96063. x: number,
  96064. /**
  96065. * The y component of the control stick
  96066. */
  96067. y: number);
  96068. }
  96069. /**
  96070. * An interface which manages callbacks for gamepad button changes
  96071. */
  96072. export interface GamepadButtonChanges {
  96073. /**
  96074. * Called when a gamepad has been changed
  96075. */
  96076. changed: boolean;
  96077. /**
  96078. * Called when a gamepad press event has been triggered
  96079. */
  96080. pressChanged: boolean;
  96081. /**
  96082. * Called when a touch event has been triggered
  96083. */
  96084. touchChanged: boolean;
  96085. /**
  96086. * Called when a value has changed
  96087. */
  96088. valueChanged: boolean;
  96089. }
  96090. /**
  96091. * Represents a gamepad
  96092. */
  96093. export class Gamepad {
  96094. /**
  96095. * The id of the gamepad
  96096. */
  96097. id: string;
  96098. /**
  96099. * The index of the gamepad
  96100. */
  96101. index: number;
  96102. /**
  96103. * The browser gamepad
  96104. */
  96105. browserGamepad: any;
  96106. /**
  96107. * Specifies what type of gamepad this represents
  96108. */
  96109. type: number;
  96110. private _leftStick;
  96111. private _rightStick;
  96112. /** @hidden */
  96113. _isConnected: boolean;
  96114. private _leftStickAxisX;
  96115. private _leftStickAxisY;
  96116. private _rightStickAxisX;
  96117. private _rightStickAxisY;
  96118. /**
  96119. * Triggered when the left control stick has been changed
  96120. */
  96121. private _onleftstickchanged;
  96122. /**
  96123. * Triggered when the right control stick has been changed
  96124. */
  96125. private _onrightstickchanged;
  96126. /**
  96127. * Represents a gamepad controller
  96128. */
  96129. static GAMEPAD: number;
  96130. /**
  96131. * Represents a generic controller
  96132. */
  96133. static GENERIC: number;
  96134. /**
  96135. * Represents an XBox controller
  96136. */
  96137. static XBOX: number;
  96138. /**
  96139. * Represents a pose-enabled controller
  96140. */
  96141. static POSE_ENABLED: number;
  96142. /**
  96143. * Represents an Dual Shock controller
  96144. */
  96145. static DUALSHOCK: number;
  96146. /**
  96147. * Specifies whether the left control stick should be Y-inverted
  96148. */
  96149. protected _invertLeftStickY: boolean;
  96150. /**
  96151. * Specifies if the gamepad has been connected
  96152. */
  96153. get isConnected(): boolean;
  96154. /**
  96155. * Initializes the gamepad
  96156. * @param id The id of the gamepad
  96157. * @param index The index of the gamepad
  96158. * @param browserGamepad The browser gamepad
  96159. * @param leftStickX The x component of the left joystick
  96160. * @param leftStickY The y component of the left joystick
  96161. * @param rightStickX The x component of the right joystick
  96162. * @param rightStickY The y component of the right joystick
  96163. */
  96164. constructor(
  96165. /**
  96166. * The id of the gamepad
  96167. */
  96168. id: string,
  96169. /**
  96170. * The index of the gamepad
  96171. */
  96172. index: number,
  96173. /**
  96174. * The browser gamepad
  96175. */
  96176. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  96177. /**
  96178. * Callback triggered when the left joystick has changed
  96179. * @param callback
  96180. */
  96181. onleftstickchanged(callback: (values: StickValues) => void): void;
  96182. /**
  96183. * Callback triggered when the right joystick has changed
  96184. * @param callback
  96185. */
  96186. onrightstickchanged(callback: (values: StickValues) => void): void;
  96187. /**
  96188. * Gets the left joystick
  96189. */
  96190. get leftStick(): StickValues;
  96191. /**
  96192. * Sets the left joystick values
  96193. */
  96194. set leftStick(newValues: StickValues);
  96195. /**
  96196. * Gets the right joystick
  96197. */
  96198. get rightStick(): StickValues;
  96199. /**
  96200. * Sets the right joystick value
  96201. */
  96202. set rightStick(newValues: StickValues);
  96203. /**
  96204. * Updates the gamepad joystick positions
  96205. */
  96206. update(): void;
  96207. /**
  96208. * Disposes the gamepad
  96209. */
  96210. dispose(): void;
  96211. }
  96212. /**
  96213. * Represents a generic gamepad
  96214. */
  96215. export class GenericPad extends Gamepad {
  96216. private _buttons;
  96217. private _onbuttondown;
  96218. private _onbuttonup;
  96219. /**
  96220. * Observable triggered when a button has been pressed
  96221. */
  96222. onButtonDownObservable: Observable<number>;
  96223. /**
  96224. * Observable triggered when a button has been released
  96225. */
  96226. onButtonUpObservable: Observable<number>;
  96227. /**
  96228. * Callback triggered when a button has been pressed
  96229. * @param callback Called when a button has been pressed
  96230. */
  96231. onbuttondown(callback: (buttonPressed: number) => void): void;
  96232. /**
  96233. * Callback triggered when a button has been released
  96234. * @param callback Called when a button has been released
  96235. */
  96236. onbuttonup(callback: (buttonReleased: number) => void): void;
  96237. /**
  96238. * Initializes the generic gamepad
  96239. * @param id The id of the generic gamepad
  96240. * @param index The index of the generic gamepad
  96241. * @param browserGamepad The browser gamepad
  96242. */
  96243. constructor(id: string, index: number, browserGamepad: any);
  96244. private _setButtonValue;
  96245. /**
  96246. * Updates the generic gamepad
  96247. */
  96248. update(): void;
  96249. /**
  96250. * Disposes the generic gamepad
  96251. */
  96252. dispose(): void;
  96253. }
  96254. }
  96255. declare module BABYLON {
  96256. /**
  96257. * Defines the types of pose enabled controllers that are supported
  96258. */
  96259. export enum PoseEnabledControllerType {
  96260. /**
  96261. * HTC Vive
  96262. */
  96263. VIVE = 0,
  96264. /**
  96265. * Oculus Rift
  96266. */
  96267. OCULUS = 1,
  96268. /**
  96269. * Windows mixed reality
  96270. */
  96271. WINDOWS = 2,
  96272. /**
  96273. * Samsung gear VR
  96274. */
  96275. GEAR_VR = 3,
  96276. /**
  96277. * Google Daydream
  96278. */
  96279. DAYDREAM = 4,
  96280. /**
  96281. * Generic
  96282. */
  96283. GENERIC = 5
  96284. }
  96285. /**
  96286. * Defines the MutableGamepadButton interface for the state of a gamepad button
  96287. */
  96288. export interface MutableGamepadButton {
  96289. /**
  96290. * Value of the button/trigger
  96291. */
  96292. value: number;
  96293. /**
  96294. * If the button/trigger is currently touched
  96295. */
  96296. touched: boolean;
  96297. /**
  96298. * If the button/trigger is currently pressed
  96299. */
  96300. pressed: boolean;
  96301. }
  96302. /**
  96303. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  96304. * @hidden
  96305. */
  96306. export interface ExtendedGamepadButton extends GamepadButton {
  96307. /**
  96308. * If the button/trigger is currently pressed
  96309. */
  96310. readonly pressed: boolean;
  96311. /**
  96312. * If the button/trigger is currently touched
  96313. */
  96314. readonly touched: boolean;
  96315. /**
  96316. * Value of the button/trigger
  96317. */
  96318. readonly value: number;
  96319. }
  96320. /** @hidden */
  96321. export interface _GamePadFactory {
  96322. /**
  96323. * Returns whether or not the current gamepad can be created for this type of controller.
  96324. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  96325. * @returns true if it can be created, otherwise false
  96326. */
  96327. canCreate(gamepadInfo: any): boolean;
  96328. /**
  96329. * Creates a new instance of the Gamepad.
  96330. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  96331. * @returns the new gamepad instance
  96332. */
  96333. create(gamepadInfo: any): Gamepad;
  96334. }
  96335. /**
  96336. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  96337. */
  96338. export class PoseEnabledControllerHelper {
  96339. /** @hidden */
  96340. static _ControllerFactories: _GamePadFactory[];
  96341. /** @hidden */
  96342. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  96343. /**
  96344. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  96345. * @param vrGamepad the gamepad to initialized
  96346. * @returns a vr controller of the type the gamepad identified as
  96347. */
  96348. static InitiateController(vrGamepad: any): Gamepad;
  96349. }
  96350. /**
  96351. * Defines the PoseEnabledController object that contains state of a vr capable controller
  96352. */
  96353. export class PoseEnabledController extends Gamepad implements PoseControlled {
  96354. /**
  96355. * If the controller is used in a webXR session
  96356. */
  96357. isXR: boolean;
  96358. private _deviceRoomPosition;
  96359. private _deviceRoomRotationQuaternion;
  96360. /**
  96361. * The device position in babylon space
  96362. */
  96363. devicePosition: Vector3;
  96364. /**
  96365. * The device rotation in babylon space
  96366. */
  96367. deviceRotationQuaternion: Quaternion;
  96368. /**
  96369. * The scale factor of the device in babylon space
  96370. */
  96371. deviceScaleFactor: number;
  96372. /**
  96373. * (Likely devicePosition should be used instead) The device position in its room space
  96374. */
  96375. position: Vector3;
  96376. /**
  96377. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  96378. */
  96379. rotationQuaternion: Quaternion;
  96380. /**
  96381. * The type of controller (Eg. Windows mixed reality)
  96382. */
  96383. controllerType: PoseEnabledControllerType;
  96384. protected _calculatedPosition: Vector3;
  96385. private _calculatedRotation;
  96386. /**
  96387. * The raw pose from the device
  96388. */
  96389. rawPose: DevicePose;
  96390. private _trackPosition;
  96391. private _maxRotationDistFromHeadset;
  96392. private _draggedRoomRotation;
  96393. /**
  96394. * @hidden
  96395. */
  96396. _disableTrackPosition(fixedPosition: Vector3): void;
  96397. /**
  96398. * Internal, the mesh attached to the controller
  96399. * @hidden
  96400. */
  96401. _mesh: Nullable<AbstractMesh>;
  96402. private _poseControlledCamera;
  96403. private _leftHandSystemQuaternion;
  96404. /**
  96405. * Internal, matrix used to convert room space to babylon space
  96406. * @hidden
  96407. */
  96408. _deviceToWorld: Matrix;
  96409. /**
  96410. * Node to be used when casting a ray from the controller
  96411. * @hidden
  96412. */
  96413. _pointingPoseNode: Nullable<TransformNode>;
  96414. /**
  96415. * Name of the child mesh that can be used to cast a ray from the controller
  96416. */
  96417. static readonly POINTING_POSE: string;
  96418. /**
  96419. * Creates a new PoseEnabledController from a gamepad
  96420. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  96421. */
  96422. constructor(browserGamepad: any);
  96423. private _workingMatrix;
  96424. /**
  96425. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  96426. */
  96427. update(): void;
  96428. /**
  96429. * Updates only the pose device and mesh without doing any button event checking
  96430. */
  96431. protected _updatePoseAndMesh(): void;
  96432. /**
  96433. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  96434. * @param poseData raw pose fromthe device
  96435. */
  96436. updateFromDevice(poseData: DevicePose): void;
  96437. /**
  96438. * @hidden
  96439. */
  96440. _meshAttachedObservable: Observable<AbstractMesh>;
  96441. /**
  96442. * Attaches a mesh to the controller
  96443. * @param mesh the mesh to be attached
  96444. */
  96445. attachToMesh(mesh: AbstractMesh): void;
  96446. /**
  96447. * Attaches the controllers mesh to a camera
  96448. * @param camera the camera the mesh should be attached to
  96449. */
  96450. attachToPoseControlledCamera(camera: TargetCamera): void;
  96451. /**
  96452. * Disposes of the controller
  96453. */
  96454. dispose(): void;
  96455. /**
  96456. * The mesh that is attached to the controller
  96457. */
  96458. get mesh(): Nullable<AbstractMesh>;
  96459. /**
  96460. * Gets the ray of the controller in the direction the controller is pointing
  96461. * @param length the length the resulting ray should be
  96462. * @returns a ray in the direction the controller is pointing
  96463. */
  96464. getForwardRay(length?: number): Ray;
  96465. }
  96466. }
  96467. declare module BABYLON {
  96468. /**
  96469. * Defines the WebVRController object that represents controllers tracked in 3D space
  96470. */
  96471. export abstract class WebVRController extends PoseEnabledController {
  96472. /**
  96473. * Internal, the default controller model for the controller
  96474. */
  96475. protected _defaultModel: Nullable<AbstractMesh>;
  96476. /**
  96477. * Fired when the trigger state has changed
  96478. */
  96479. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  96480. /**
  96481. * Fired when the main button state has changed
  96482. */
  96483. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  96484. /**
  96485. * Fired when the secondary button state has changed
  96486. */
  96487. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  96488. /**
  96489. * Fired when the pad state has changed
  96490. */
  96491. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  96492. /**
  96493. * Fired when controllers stick values have changed
  96494. */
  96495. onPadValuesChangedObservable: Observable<StickValues>;
  96496. /**
  96497. * Array of button availible on the controller
  96498. */
  96499. protected _buttons: Array<MutableGamepadButton>;
  96500. private _onButtonStateChange;
  96501. /**
  96502. * Fired when a controller button's state has changed
  96503. * @param callback the callback containing the button that was modified
  96504. */
  96505. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  96506. /**
  96507. * X and Y axis corresponding to the controllers joystick
  96508. */
  96509. pad: StickValues;
  96510. /**
  96511. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  96512. */
  96513. hand: string;
  96514. /**
  96515. * The default controller model for the controller
  96516. */
  96517. get defaultModel(): Nullable<AbstractMesh>;
  96518. /**
  96519. * Creates a new WebVRController from a gamepad
  96520. * @param vrGamepad the gamepad that the WebVRController should be created from
  96521. */
  96522. constructor(vrGamepad: any);
  96523. /**
  96524. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  96525. */
  96526. update(): void;
  96527. /**
  96528. * Function to be called when a button is modified
  96529. */
  96530. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  96531. /**
  96532. * Loads a mesh and attaches it to the controller
  96533. * @param scene the scene the mesh should be added to
  96534. * @param meshLoaded callback for when the mesh has been loaded
  96535. */
  96536. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  96537. private _setButtonValue;
  96538. private _changes;
  96539. private _checkChanges;
  96540. /**
  96541. * Disposes of th webVRCOntroller
  96542. */
  96543. dispose(): void;
  96544. }
  96545. }
  96546. declare module BABYLON {
  96547. /**
  96548. * The HemisphericLight simulates the ambient environment light,
  96549. * so the passed direction is the light reflection direction, not the incoming direction.
  96550. */
  96551. export class HemisphericLight extends Light {
  96552. /**
  96553. * The groundColor is the light in the opposite direction to the one specified during creation.
  96554. * 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.
  96555. */
  96556. groundColor: Color3;
  96557. /**
  96558. * The light reflection direction, not the incoming direction.
  96559. */
  96560. direction: Vector3;
  96561. /**
  96562. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  96563. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  96564. * The HemisphericLight can't cast shadows.
  96565. * Documentation : https://doc.babylonjs.com/babylon101/lights
  96566. * @param name The friendly name of the light
  96567. * @param direction The direction of the light reflection
  96568. * @param scene The scene the light belongs to
  96569. */
  96570. constructor(name: string, direction: Vector3, scene: Scene);
  96571. protected _buildUniformLayout(): void;
  96572. /**
  96573. * Returns the string "HemisphericLight".
  96574. * @return The class name
  96575. */
  96576. getClassName(): string;
  96577. /**
  96578. * Sets the HemisphericLight direction towards the passed target (Vector3).
  96579. * Returns the updated direction.
  96580. * @param target The target the direction should point to
  96581. * @return The computed direction
  96582. */
  96583. setDirectionToTarget(target: Vector3): Vector3;
  96584. /**
  96585. * Returns the shadow generator associated to the light.
  96586. * @returns Always null for hemispheric lights because it does not support shadows.
  96587. */
  96588. getShadowGenerator(): Nullable<IShadowGenerator>;
  96589. /**
  96590. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  96591. * @param effect The effect to update
  96592. * @param lightIndex The index of the light in the effect to update
  96593. * @returns The hemispheric light
  96594. */
  96595. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  96596. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  96597. /**
  96598. * Computes the world matrix of the node
  96599. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  96600. * @param useWasUpdatedFlag defines a reserved property
  96601. * @returns the world matrix
  96602. */
  96603. computeWorldMatrix(): Matrix;
  96604. /**
  96605. * Returns the integer 3.
  96606. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  96607. */
  96608. getTypeID(): number;
  96609. /**
  96610. * Prepares the list of defines specific to the light type.
  96611. * @param defines the list of defines
  96612. * @param lightIndex defines the index of the light for the effect
  96613. */
  96614. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  96615. }
  96616. }
  96617. declare module BABYLON {
  96618. /** @hidden */
  96619. export var vrMultiviewToSingleviewPixelShader: {
  96620. name: string;
  96621. shader: string;
  96622. };
  96623. }
  96624. declare module BABYLON {
  96625. /**
  96626. * Renders to multiple views with a single draw call
  96627. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  96628. */
  96629. export class MultiviewRenderTarget extends RenderTargetTexture {
  96630. /**
  96631. * Creates a multiview render target
  96632. * @param scene scene used with the render target
  96633. * @param size the size of the render target (used for each view)
  96634. */
  96635. constructor(scene: Scene, size?: number | {
  96636. width: number;
  96637. height: number;
  96638. } | {
  96639. ratio: number;
  96640. });
  96641. /**
  96642. * @hidden
  96643. * @param faceIndex the face index, if its a cube texture
  96644. */
  96645. _bindFrameBuffer(faceIndex?: number): void;
  96646. /**
  96647. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  96648. * @returns the view count
  96649. */
  96650. getViewCount(): number;
  96651. }
  96652. }
  96653. declare module BABYLON {
  96654. interface Engine {
  96655. /**
  96656. * Creates a new multiview render target
  96657. * @param width defines the width of the texture
  96658. * @param height defines the height of the texture
  96659. * @returns the created multiview texture
  96660. */
  96661. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  96662. /**
  96663. * Binds a multiview framebuffer to be drawn to
  96664. * @param multiviewTexture texture to bind
  96665. */
  96666. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  96667. }
  96668. interface Camera {
  96669. /**
  96670. * @hidden
  96671. * 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)
  96672. */
  96673. _useMultiviewToSingleView: boolean;
  96674. /**
  96675. * @hidden
  96676. * 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)
  96677. */
  96678. _multiviewTexture: Nullable<RenderTargetTexture>;
  96679. /**
  96680. * @hidden
  96681. * ensures the multiview texture of the camera exists and has the specified width/height
  96682. * @param width height to set on the multiview texture
  96683. * @param height width to set on the multiview texture
  96684. */
  96685. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  96686. }
  96687. interface Scene {
  96688. /** @hidden */
  96689. _transformMatrixR: Matrix;
  96690. /** @hidden */
  96691. _multiviewSceneUbo: Nullable<UniformBuffer>;
  96692. /** @hidden */
  96693. _createMultiviewUbo(): void;
  96694. /** @hidden */
  96695. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  96696. /** @hidden */
  96697. _renderMultiviewToSingleView(camera: Camera): void;
  96698. }
  96699. }
  96700. declare module BABYLON {
  96701. /**
  96702. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  96703. * This will not be used for webXR as it supports displaying texture arrays directly
  96704. */
  96705. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  96706. /**
  96707. * Initializes a VRMultiviewToSingleview
  96708. * @param name name of the post process
  96709. * @param camera camera to be applied to
  96710. * @param scaleFactor scaling factor to the size of the output texture
  96711. */
  96712. constructor(name: string, camera: Camera, scaleFactor: number);
  96713. }
  96714. }
  96715. declare module BABYLON {
  96716. /**
  96717. * Interface used to define additional presentation attributes
  96718. */
  96719. export interface IVRPresentationAttributes {
  96720. /**
  96721. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  96722. */
  96723. highRefreshRate: boolean;
  96724. /**
  96725. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  96726. */
  96727. foveationLevel: number;
  96728. }
  96729. interface Engine {
  96730. /** @hidden */
  96731. _vrDisplay: any;
  96732. /** @hidden */
  96733. _vrSupported: boolean;
  96734. /** @hidden */
  96735. _oldSize: Size;
  96736. /** @hidden */
  96737. _oldHardwareScaleFactor: number;
  96738. /** @hidden */
  96739. _vrExclusivePointerMode: boolean;
  96740. /** @hidden */
  96741. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  96742. /** @hidden */
  96743. _onVRDisplayPointerRestricted: () => void;
  96744. /** @hidden */
  96745. _onVRDisplayPointerUnrestricted: () => void;
  96746. /** @hidden */
  96747. _onVrDisplayConnect: Nullable<(display: any) => void>;
  96748. /** @hidden */
  96749. _onVrDisplayDisconnect: Nullable<() => void>;
  96750. /** @hidden */
  96751. _onVrDisplayPresentChange: Nullable<() => void>;
  96752. /**
  96753. * Observable signaled when VR display mode changes
  96754. */
  96755. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  96756. /**
  96757. * Observable signaled when VR request present is complete
  96758. */
  96759. onVRRequestPresentComplete: Observable<boolean>;
  96760. /**
  96761. * Observable signaled when VR request present starts
  96762. */
  96763. onVRRequestPresentStart: Observable<Engine>;
  96764. /**
  96765. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  96766. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  96767. */
  96768. isInVRExclusivePointerMode: boolean;
  96769. /**
  96770. * Gets a boolean indicating if a webVR device was detected
  96771. * @returns true if a webVR device was detected
  96772. */
  96773. isVRDevicePresent(): boolean;
  96774. /**
  96775. * Gets the current webVR device
  96776. * @returns the current webVR device (or null)
  96777. */
  96778. getVRDevice(): any;
  96779. /**
  96780. * Initializes a webVR display and starts listening to display change events
  96781. * The onVRDisplayChangedObservable will be notified upon these changes
  96782. * @returns A promise containing a VRDisplay and if vr is supported
  96783. */
  96784. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  96785. /** @hidden */
  96786. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  96787. /**
  96788. * Gets or sets the presentation attributes used to configure VR rendering
  96789. */
  96790. vrPresentationAttributes?: IVRPresentationAttributes;
  96791. /**
  96792. * Call this function to switch to webVR mode
  96793. * Will do nothing if webVR is not supported or if there is no webVR device
  96794. * @param options the webvr options provided to the camera. mainly used for multiview
  96795. * @see http://doc.babylonjs.com/how_to/webvr_camera
  96796. */
  96797. enableVR(options: WebVROptions): void;
  96798. /** @hidden */
  96799. _onVRFullScreenTriggered(): void;
  96800. }
  96801. }
  96802. declare module BABYLON {
  96803. /**
  96804. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  96805. * IMPORTANT!! The data is right-hand data.
  96806. * @export
  96807. * @interface DevicePose
  96808. */
  96809. export interface DevicePose {
  96810. /**
  96811. * The position of the device, values in array are [x,y,z].
  96812. */
  96813. readonly position: Nullable<Float32Array>;
  96814. /**
  96815. * The linearVelocity of the device, values in array are [x,y,z].
  96816. */
  96817. readonly linearVelocity: Nullable<Float32Array>;
  96818. /**
  96819. * The linearAcceleration of the device, values in array are [x,y,z].
  96820. */
  96821. readonly linearAcceleration: Nullable<Float32Array>;
  96822. /**
  96823. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  96824. */
  96825. readonly orientation: Nullable<Float32Array>;
  96826. /**
  96827. * The angularVelocity of the device, values in array are [x,y,z].
  96828. */
  96829. readonly angularVelocity: Nullable<Float32Array>;
  96830. /**
  96831. * The angularAcceleration of the device, values in array are [x,y,z].
  96832. */
  96833. readonly angularAcceleration: Nullable<Float32Array>;
  96834. }
  96835. /**
  96836. * Interface representing a pose controlled object in Babylon.
  96837. * A pose controlled object has both regular pose values as well as pose values
  96838. * from an external device such as a VR head mounted display
  96839. */
  96840. export interface PoseControlled {
  96841. /**
  96842. * The position of the object in babylon space.
  96843. */
  96844. position: Vector3;
  96845. /**
  96846. * The rotation quaternion of the object in babylon space.
  96847. */
  96848. rotationQuaternion: Quaternion;
  96849. /**
  96850. * The position of the device in babylon space.
  96851. */
  96852. devicePosition?: Vector3;
  96853. /**
  96854. * The rotation quaternion of the device in babylon space.
  96855. */
  96856. deviceRotationQuaternion: Quaternion;
  96857. /**
  96858. * The raw pose coming from the device.
  96859. */
  96860. rawPose: Nullable<DevicePose>;
  96861. /**
  96862. * The scale of the device to be used when translating from device space to babylon space.
  96863. */
  96864. deviceScaleFactor: number;
  96865. /**
  96866. * Updates the poseControlled values based on the input device pose.
  96867. * @param poseData the pose data to update the object with
  96868. */
  96869. updateFromDevice(poseData: DevicePose): void;
  96870. }
  96871. /**
  96872. * Set of options to customize the webVRCamera
  96873. */
  96874. export interface WebVROptions {
  96875. /**
  96876. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  96877. */
  96878. trackPosition?: boolean;
  96879. /**
  96880. * Sets the scale of the vrDevice in babylon space. (default: 1)
  96881. */
  96882. positionScale?: number;
  96883. /**
  96884. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  96885. */
  96886. displayName?: string;
  96887. /**
  96888. * Should the native controller meshes be initialized. (default: true)
  96889. */
  96890. controllerMeshes?: boolean;
  96891. /**
  96892. * Creating a default HemiLight only on controllers. (default: true)
  96893. */
  96894. defaultLightingOnControllers?: boolean;
  96895. /**
  96896. * If you don't want to use the default VR button of the helper. (default: false)
  96897. */
  96898. useCustomVRButton?: boolean;
  96899. /**
  96900. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  96901. */
  96902. customVRButton?: HTMLButtonElement;
  96903. /**
  96904. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  96905. */
  96906. rayLength?: number;
  96907. /**
  96908. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  96909. */
  96910. defaultHeight?: number;
  96911. /**
  96912. * If multiview should be used if availible (default: false)
  96913. */
  96914. useMultiview?: boolean;
  96915. }
  96916. /**
  96917. * This represents a WebVR camera.
  96918. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  96919. * @example http://doc.babylonjs.com/how_to/webvr_camera
  96920. */
  96921. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  96922. private webVROptions;
  96923. /**
  96924. * @hidden
  96925. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  96926. */
  96927. _vrDevice: any;
  96928. /**
  96929. * The rawPose of the vrDevice.
  96930. */
  96931. rawPose: Nullable<DevicePose>;
  96932. private _onVREnabled;
  96933. private _specsVersion;
  96934. private _attached;
  96935. private _frameData;
  96936. protected _descendants: Array<Node>;
  96937. private _deviceRoomPosition;
  96938. /** @hidden */
  96939. _deviceRoomRotationQuaternion: Quaternion;
  96940. private _standingMatrix;
  96941. /**
  96942. * Represents device position in babylon space.
  96943. */
  96944. devicePosition: Vector3;
  96945. /**
  96946. * Represents device rotation in babylon space.
  96947. */
  96948. deviceRotationQuaternion: Quaternion;
  96949. /**
  96950. * The scale of the device to be used when translating from device space to babylon space.
  96951. */
  96952. deviceScaleFactor: number;
  96953. private _deviceToWorld;
  96954. private _worldToDevice;
  96955. /**
  96956. * References to the webVR controllers for the vrDevice.
  96957. */
  96958. controllers: Array<WebVRController>;
  96959. /**
  96960. * Emits an event when a controller is attached.
  96961. */
  96962. onControllersAttachedObservable: Observable<WebVRController[]>;
  96963. /**
  96964. * Emits an event when a controller's mesh has been loaded;
  96965. */
  96966. onControllerMeshLoadedObservable: Observable<WebVRController>;
  96967. /**
  96968. * Emits an event when the HMD's pose has been updated.
  96969. */
  96970. onPoseUpdatedFromDeviceObservable: Observable<any>;
  96971. private _poseSet;
  96972. /**
  96973. * If the rig cameras be used as parent instead of this camera.
  96974. */
  96975. rigParenting: boolean;
  96976. private _lightOnControllers;
  96977. private _defaultHeight?;
  96978. /**
  96979. * Instantiates a WebVRFreeCamera.
  96980. * @param name The name of the WebVRFreeCamera
  96981. * @param position The starting anchor position for the camera
  96982. * @param scene The scene the camera belongs to
  96983. * @param webVROptions a set of customizable options for the webVRCamera
  96984. */
  96985. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  96986. /**
  96987. * Gets the device distance from the ground in meters.
  96988. * @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.
  96989. */
  96990. deviceDistanceToRoomGround(): number;
  96991. /**
  96992. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  96993. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  96994. */
  96995. useStandingMatrix(callback?: (bool: boolean) => void): void;
  96996. /**
  96997. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  96998. * @returns A promise with a boolean set to if the standing matrix is supported.
  96999. */
  97000. useStandingMatrixAsync(): Promise<boolean>;
  97001. /**
  97002. * Disposes the camera
  97003. */
  97004. dispose(): void;
  97005. /**
  97006. * Gets a vrController by name.
  97007. * @param name The name of the controller to retreive
  97008. * @returns the controller matching the name specified or null if not found
  97009. */
  97010. getControllerByName(name: string): Nullable<WebVRController>;
  97011. private _leftController;
  97012. /**
  97013. * The controller corresponding to the users left hand.
  97014. */
  97015. get leftController(): Nullable<WebVRController>;
  97016. private _rightController;
  97017. /**
  97018. * The controller corresponding to the users right hand.
  97019. */
  97020. get rightController(): Nullable<WebVRController>;
  97021. /**
  97022. * Casts a ray forward from the vrCamera's gaze.
  97023. * @param length Length of the ray (default: 100)
  97024. * @returns the ray corresponding to the gaze
  97025. */
  97026. getForwardRay(length?: number): Ray;
  97027. /**
  97028. * @hidden
  97029. * Updates the camera based on device's frame data
  97030. */
  97031. _checkInputs(): void;
  97032. /**
  97033. * Updates the poseControlled values based on the input device pose.
  97034. * @param poseData Pose coming from the device
  97035. */
  97036. updateFromDevice(poseData: DevicePose): void;
  97037. private _htmlElementAttached;
  97038. private _detachIfAttached;
  97039. /**
  97040. * WebVR's attach control will start broadcasting frames to the device.
  97041. * Note that in certain browsers (chrome for example) this function must be called
  97042. * within a user-interaction callback. Example:
  97043. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  97044. *
  97045. * @param element html element to attach the vrDevice to
  97046. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  97047. */
  97048. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97049. /**
  97050. * Detaches the camera from the html element and disables VR
  97051. *
  97052. * @param element html element to detach from
  97053. */
  97054. detachControl(element: HTMLElement): void;
  97055. /**
  97056. * @returns the name of this class
  97057. */
  97058. getClassName(): string;
  97059. /**
  97060. * Calls resetPose on the vrDisplay
  97061. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  97062. */
  97063. resetToCurrentRotation(): void;
  97064. /**
  97065. * @hidden
  97066. * Updates the rig cameras (left and right eye)
  97067. */
  97068. _updateRigCameras(): void;
  97069. private _workingVector;
  97070. private _oneVector;
  97071. private _workingMatrix;
  97072. private updateCacheCalled;
  97073. private _correctPositionIfNotTrackPosition;
  97074. /**
  97075. * @hidden
  97076. * Updates the cached values of the camera
  97077. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  97078. */
  97079. _updateCache(ignoreParentClass?: boolean): void;
  97080. /**
  97081. * @hidden
  97082. * Get current device position in babylon world
  97083. */
  97084. _computeDevicePosition(): void;
  97085. /**
  97086. * Updates the current device position and rotation in the babylon world
  97087. */
  97088. update(): void;
  97089. /**
  97090. * @hidden
  97091. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  97092. * @returns an identity matrix
  97093. */
  97094. _getViewMatrix(): Matrix;
  97095. private _tmpMatrix;
  97096. /**
  97097. * This function is called by the two RIG cameras.
  97098. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  97099. * @hidden
  97100. */
  97101. _getWebVRViewMatrix(): Matrix;
  97102. /** @hidden */
  97103. _getWebVRProjectionMatrix(): Matrix;
  97104. private _onGamepadConnectedObserver;
  97105. private _onGamepadDisconnectedObserver;
  97106. private _updateCacheWhenTrackingDisabledObserver;
  97107. /**
  97108. * Initializes the controllers and their meshes
  97109. */
  97110. initControllers(): void;
  97111. }
  97112. }
  97113. declare module BABYLON {
  97114. /**
  97115. * "Static Class" containing the most commonly used helper while dealing with material for
  97116. * rendering purpose.
  97117. *
  97118. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  97119. *
  97120. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  97121. */
  97122. export class MaterialHelper {
  97123. /**
  97124. * Bind the current view position to an effect.
  97125. * @param effect The effect to be bound
  97126. * @param scene The scene the eyes position is used from
  97127. * @param variableName name of the shader variable that will hold the eye position
  97128. */
  97129. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  97130. /**
  97131. * Helps preparing the defines values about the UVs in used in the effect.
  97132. * UVs are shared as much as we can accross channels in the shaders.
  97133. * @param texture The texture we are preparing the UVs for
  97134. * @param defines The defines to update
  97135. * @param key The channel key "diffuse", "specular"... used in the shader
  97136. */
  97137. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  97138. /**
  97139. * Binds a texture matrix value to its corrsponding uniform
  97140. * @param texture The texture to bind the matrix for
  97141. * @param uniformBuffer The uniform buffer receivin the data
  97142. * @param key The channel key "diffuse", "specular"... used in the shader
  97143. */
  97144. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  97145. /**
  97146. * Gets the current status of the fog (should it be enabled?)
  97147. * @param mesh defines the mesh to evaluate for fog support
  97148. * @param scene defines the hosting scene
  97149. * @returns true if fog must be enabled
  97150. */
  97151. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  97152. /**
  97153. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  97154. * @param mesh defines the current mesh
  97155. * @param scene defines the current scene
  97156. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  97157. * @param pointsCloud defines if point cloud rendering has to be turned on
  97158. * @param fogEnabled defines if fog has to be turned on
  97159. * @param alphaTest defines if alpha testing has to be turned on
  97160. * @param defines defines the current list of defines
  97161. */
  97162. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  97163. /**
  97164. * Helper used to prepare the list of defines associated with frame values for shader compilation
  97165. * @param scene defines the current scene
  97166. * @param engine defines the current engine
  97167. * @param defines specifies the list of active defines
  97168. * @param useInstances defines if instances have to be turned on
  97169. * @param useClipPlane defines if clip plane have to be turned on
  97170. * @param useInstances defines if instances have to be turned on
  97171. * @param useThinInstances defines if thin instances have to be turned on
  97172. */
  97173. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  97174. /**
  97175. * Prepares the defines for bones
  97176. * @param mesh The mesh containing the geometry data we will draw
  97177. * @param defines The defines to update
  97178. */
  97179. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  97180. /**
  97181. * Prepares the defines for morph targets
  97182. * @param mesh The mesh containing the geometry data we will draw
  97183. * @param defines The defines to update
  97184. */
  97185. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  97186. /**
  97187. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  97188. * @param mesh The mesh containing the geometry data we will draw
  97189. * @param defines The defines to update
  97190. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  97191. * @param useBones Precise whether bones should be used or not (override mesh info)
  97192. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  97193. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  97194. * @returns false if defines are considered not dirty and have not been checked
  97195. */
  97196. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  97197. /**
  97198. * Prepares the defines related to multiview
  97199. * @param scene The scene we are intending to draw
  97200. * @param defines The defines to update
  97201. */
  97202. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  97203. /**
  97204. * Prepares the defines related to the light information passed in parameter
  97205. * @param scene The scene we are intending to draw
  97206. * @param mesh The mesh the effect is compiling for
  97207. * @param light The light the effect is compiling for
  97208. * @param lightIndex The index of the light
  97209. * @param defines The defines to update
  97210. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  97211. * @param state Defines the current state regarding what is needed (normals, etc...)
  97212. */
  97213. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  97214. needNormals: boolean;
  97215. needRebuild: boolean;
  97216. shadowEnabled: boolean;
  97217. specularEnabled: boolean;
  97218. lightmapMode: boolean;
  97219. }): void;
  97220. /**
  97221. * Prepares the defines related to the light information passed in parameter
  97222. * @param scene The scene we are intending to draw
  97223. * @param mesh The mesh the effect is compiling for
  97224. * @param defines The defines to update
  97225. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  97226. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  97227. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  97228. * @returns true if normals will be required for the rest of the effect
  97229. */
  97230. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  97231. /**
  97232. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  97233. * @param lightIndex defines the light index
  97234. * @param uniformsList The uniform list
  97235. * @param samplersList The sampler list
  97236. * @param projectedLightTexture defines if projected texture must be used
  97237. * @param uniformBuffersList defines an optional list of uniform buffers
  97238. */
  97239. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  97240. /**
  97241. * Prepares the uniforms and samplers list to be used in the effect
  97242. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  97243. * @param samplersList The sampler list
  97244. * @param defines The defines helping in the list generation
  97245. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  97246. */
  97247. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  97248. /**
  97249. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  97250. * @param defines The defines to update while falling back
  97251. * @param fallbacks The authorized effect fallbacks
  97252. * @param maxSimultaneousLights The maximum number of lights allowed
  97253. * @param rank the current rank of the Effect
  97254. * @returns The newly affected rank
  97255. */
  97256. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  97257. private static _TmpMorphInfluencers;
  97258. /**
  97259. * Prepares the list of attributes required for morph targets according to the effect defines.
  97260. * @param attribs The current list of supported attribs
  97261. * @param mesh The mesh to prepare the morph targets attributes for
  97262. * @param influencers The number of influencers
  97263. */
  97264. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  97265. /**
  97266. * Prepares the list of attributes required for morph targets according to the effect defines.
  97267. * @param attribs The current list of supported attribs
  97268. * @param mesh The mesh to prepare the morph targets attributes for
  97269. * @param defines The current Defines of the effect
  97270. */
  97271. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  97272. /**
  97273. * Prepares the list of attributes required for bones according to the effect defines.
  97274. * @param attribs The current list of supported attribs
  97275. * @param mesh The mesh to prepare the bones attributes for
  97276. * @param defines The current Defines of the effect
  97277. * @param fallbacks The current efffect fallback strategy
  97278. */
  97279. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  97280. /**
  97281. * Check and prepare the list of attributes required for instances according to the effect defines.
  97282. * @param attribs The current list of supported attribs
  97283. * @param defines The current MaterialDefines of the effect
  97284. */
  97285. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  97286. /**
  97287. * Add the list of attributes required for instances to the attribs array.
  97288. * @param attribs The current list of supported attribs
  97289. */
  97290. static PushAttributesForInstances(attribs: string[]): void;
  97291. /**
  97292. * Binds the light information to the effect.
  97293. * @param light The light containing the generator
  97294. * @param effect The effect we are binding the data to
  97295. * @param lightIndex The light index in the effect used to render
  97296. */
  97297. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  97298. /**
  97299. * Binds the lights information from the scene to the effect for the given mesh.
  97300. * @param light Light to bind
  97301. * @param lightIndex Light index
  97302. * @param scene The scene where the light belongs to
  97303. * @param effect The effect we are binding the data to
  97304. * @param useSpecular Defines if specular is supported
  97305. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  97306. */
  97307. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  97308. /**
  97309. * Binds the lights information from the scene to the effect for the given mesh.
  97310. * @param scene The scene the lights belongs to
  97311. * @param mesh The mesh we are binding the information to render
  97312. * @param effect The effect we are binding the data to
  97313. * @param defines The generated defines for the effect
  97314. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  97315. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  97316. */
  97317. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  97318. private static _tempFogColor;
  97319. /**
  97320. * Binds the fog information from the scene to the effect for the given mesh.
  97321. * @param scene The scene the lights belongs to
  97322. * @param mesh The mesh we are binding the information to render
  97323. * @param effect The effect we are binding the data to
  97324. * @param linearSpace Defines if the fog effect is applied in linear space
  97325. */
  97326. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  97327. /**
  97328. * Binds the bones information from the mesh to the effect.
  97329. * @param mesh The mesh we are binding the information to render
  97330. * @param effect The effect we are binding the data to
  97331. */
  97332. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  97333. /**
  97334. * Binds the morph targets information from the mesh to the effect.
  97335. * @param abstractMesh The mesh we are binding the information to render
  97336. * @param effect The effect we are binding the data to
  97337. */
  97338. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  97339. /**
  97340. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  97341. * @param defines The generated defines used in the effect
  97342. * @param effect The effect we are binding the data to
  97343. * @param scene The scene we are willing to render with logarithmic scale for
  97344. */
  97345. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  97346. /**
  97347. * Binds the clip plane information from the scene to the effect.
  97348. * @param scene The scene the clip plane information are extracted from
  97349. * @param effect The effect we are binding the data to
  97350. */
  97351. static BindClipPlane(effect: Effect, scene: Scene): void;
  97352. }
  97353. }
  97354. declare module BABYLON {
  97355. /**
  97356. * Block used to expose an input value
  97357. */
  97358. export class InputBlock extends NodeMaterialBlock {
  97359. private _mode;
  97360. private _associatedVariableName;
  97361. private _storedValue;
  97362. private _valueCallback;
  97363. private _type;
  97364. private _animationType;
  97365. /** Gets or set a value used to limit the range of float values */
  97366. min: number;
  97367. /** Gets or set a value used to limit the range of float values */
  97368. max: number;
  97369. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  97370. isBoolean: boolean;
  97371. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  97372. matrixMode: number;
  97373. /** @hidden */
  97374. _systemValue: Nullable<NodeMaterialSystemValues>;
  97375. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  97376. visibleInInspector: boolean;
  97377. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  97378. isConstant: boolean;
  97379. /** Gets or sets the group to use to display this block in the Inspector */
  97380. groupInInspector: string;
  97381. /** Gets an observable raised when the value is changed */
  97382. onValueChangedObservable: Observable<InputBlock>;
  97383. /**
  97384. * Gets or sets the connection point type (default is float)
  97385. */
  97386. get type(): NodeMaterialBlockConnectionPointTypes;
  97387. /**
  97388. * Creates a new InputBlock
  97389. * @param name defines the block name
  97390. * @param target defines the target of that block (Vertex by default)
  97391. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  97392. */
  97393. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  97394. /**
  97395. * Gets the output component
  97396. */
  97397. get output(): NodeMaterialConnectionPoint;
  97398. /**
  97399. * Set the source of this connection point to a vertex attribute
  97400. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  97401. * @returns the current connection point
  97402. */
  97403. setAsAttribute(attributeName?: string): InputBlock;
  97404. /**
  97405. * Set the source of this connection point to a system value
  97406. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  97407. * @returns the current connection point
  97408. */
  97409. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  97410. /**
  97411. * Gets or sets the value of that point.
  97412. * Please note that this value will be ignored if valueCallback is defined
  97413. */
  97414. get value(): any;
  97415. set value(value: any);
  97416. /**
  97417. * Gets or sets a callback used to get the value of that point.
  97418. * Please note that setting this value will force the connection point to ignore the value property
  97419. */
  97420. get valueCallback(): () => any;
  97421. set valueCallback(value: () => any);
  97422. /**
  97423. * Gets or sets the associated variable name in the shader
  97424. */
  97425. get associatedVariableName(): string;
  97426. set associatedVariableName(value: string);
  97427. /** Gets or sets the type of animation applied to the input */
  97428. get animationType(): AnimatedInputBlockTypes;
  97429. set animationType(value: AnimatedInputBlockTypes);
  97430. /**
  97431. * Gets a boolean indicating that this connection point not defined yet
  97432. */
  97433. get isUndefined(): boolean;
  97434. /**
  97435. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  97436. * In this case the connection point name must be the name of the uniform to use.
  97437. * Can only be set on inputs
  97438. */
  97439. get isUniform(): boolean;
  97440. set isUniform(value: boolean);
  97441. /**
  97442. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  97443. * In this case the connection point name must be the name of the attribute to use
  97444. * Can only be set on inputs
  97445. */
  97446. get isAttribute(): boolean;
  97447. set isAttribute(value: boolean);
  97448. /**
  97449. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  97450. * Can only be set on exit points
  97451. */
  97452. get isVarying(): boolean;
  97453. set isVarying(value: boolean);
  97454. /**
  97455. * Gets a boolean indicating that the current connection point is a system value
  97456. */
  97457. get isSystemValue(): boolean;
  97458. /**
  97459. * Gets or sets the current well known value or null if not defined as a system value
  97460. */
  97461. get systemValue(): Nullable<NodeMaterialSystemValues>;
  97462. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  97463. /**
  97464. * Gets the current class name
  97465. * @returns the class name
  97466. */
  97467. getClassName(): string;
  97468. /**
  97469. * Animate the input if animationType !== None
  97470. * @param scene defines the rendering scene
  97471. */
  97472. animate(scene: Scene): void;
  97473. private _emitDefine;
  97474. initialize(state: NodeMaterialBuildState): void;
  97475. /**
  97476. * Set the input block to its default value (based on its type)
  97477. */
  97478. setDefaultValue(): void;
  97479. private _emitConstant;
  97480. /** @hidden */
  97481. get _noContextSwitch(): boolean;
  97482. private _emit;
  97483. /** @hidden */
  97484. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  97485. /** @hidden */
  97486. _transmit(effect: Effect, scene: Scene): void;
  97487. protected _buildBlock(state: NodeMaterialBuildState): void;
  97488. protected _dumpPropertiesCode(): string;
  97489. dispose(): void;
  97490. serialize(): any;
  97491. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  97492. }
  97493. }
  97494. declare module BABYLON {
  97495. /**
  97496. * Enum used to define the compatibility state between two connection points
  97497. */
  97498. export enum NodeMaterialConnectionPointCompatibilityStates {
  97499. /** Points are compatibles */
  97500. Compatible = 0,
  97501. /** Points are incompatible because of their types */
  97502. TypeIncompatible = 1,
  97503. /** Points are incompatible because of their targets (vertex vs fragment) */
  97504. TargetIncompatible = 2
  97505. }
  97506. /**
  97507. * Defines the direction of a connection point
  97508. */
  97509. export enum NodeMaterialConnectionPointDirection {
  97510. /** Input */
  97511. Input = 0,
  97512. /** Output */
  97513. Output = 1
  97514. }
  97515. /**
  97516. * Defines a connection point for a block
  97517. */
  97518. export class NodeMaterialConnectionPoint {
  97519. /** @hidden */
  97520. _ownerBlock: NodeMaterialBlock;
  97521. /** @hidden */
  97522. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  97523. private _endpoints;
  97524. private _associatedVariableName;
  97525. private _direction;
  97526. /** @hidden */
  97527. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  97528. /** @hidden */
  97529. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  97530. private _type;
  97531. /** @hidden */
  97532. _enforceAssociatedVariableName: boolean;
  97533. /** Gets the direction of the point */
  97534. get direction(): NodeMaterialConnectionPointDirection;
  97535. /** Indicates that this connection point needs dual validation before being connected to another point */
  97536. needDualDirectionValidation: boolean;
  97537. /**
  97538. * Gets or sets the additional types supported by this connection point
  97539. */
  97540. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  97541. /**
  97542. * Gets or sets the additional types excluded by this connection point
  97543. */
  97544. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  97545. /**
  97546. * Observable triggered when this point is connected
  97547. */
  97548. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  97549. /**
  97550. * Gets or sets the associated variable name in the shader
  97551. */
  97552. get associatedVariableName(): string;
  97553. set associatedVariableName(value: string);
  97554. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  97555. get innerType(): NodeMaterialBlockConnectionPointTypes;
  97556. /**
  97557. * Gets or sets the connection point type (default is float)
  97558. */
  97559. get type(): NodeMaterialBlockConnectionPointTypes;
  97560. set type(value: NodeMaterialBlockConnectionPointTypes);
  97561. /**
  97562. * Gets or sets the connection point name
  97563. */
  97564. name: string;
  97565. /**
  97566. * Gets or sets the connection point name
  97567. */
  97568. displayName: string;
  97569. /**
  97570. * Gets or sets a boolean indicating that this connection point can be omitted
  97571. */
  97572. isOptional: boolean;
  97573. /**
  97574. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  97575. */
  97576. define: string;
  97577. /** @hidden */
  97578. _prioritizeVertex: boolean;
  97579. private _target;
  97580. /** Gets or sets the target of that connection point */
  97581. get target(): NodeMaterialBlockTargets;
  97582. set target(value: NodeMaterialBlockTargets);
  97583. /**
  97584. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  97585. */
  97586. get isConnected(): boolean;
  97587. /**
  97588. * Gets a boolean indicating that the current point is connected to an input block
  97589. */
  97590. get isConnectedToInputBlock(): boolean;
  97591. /**
  97592. * Gets a the connected input block (if any)
  97593. */
  97594. get connectInputBlock(): Nullable<InputBlock>;
  97595. /** Get the other side of the connection (if any) */
  97596. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  97597. /** Get the block that owns this connection point */
  97598. get ownerBlock(): NodeMaterialBlock;
  97599. /** Get the block connected on the other side of this connection (if any) */
  97600. get sourceBlock(): Nullable<NodeMaterialBlock>;
  97601. /** Get the block connected on the endpoints of this connection (if any) */
  97602. get connectedBlocks(): Array<NodeMaterialBlock>;
  97603. /** Gets the list of connected endpoints */
  97604. get endpoints(): NodeMaterialConnectionPoint[];
  97605. /** Gets a boolean indicating if that output point is connected to at least one input */
  97606. get hasEndpoints(): boolean;
  97607. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  97608. get isConnectedInVertexShader(): boolean;
  97609. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  97610. get isConnectedInFragmentShader(): boolean;
  97611. /**
  97612. * Creates a block suitable to be used as an input for this input point.
  97613. * If null is returned, a block based on the point type will be created.
  97614. * @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
  97615. */
  97616. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  97617. /**
  97618. * Creates a new connection point
  97619. * @param name defines the connection point name
  97620. * @param ownerBlock defines the block hosting this connection point
  97621. * @param direction defines the direction of the connection point
  97622. */
  97623. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  97624. /**
  97625. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  97626. * @returns the class name
  97627. */
  97628. getClassName(): string;
  97629. /**
  97630. * Gets a boolean indicating if the current point can be connected to another point
  97631. * @param connectionPoint defines the other connection point
  97632. * @returns a boolean
  97633. */
  97634. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  97635. /**
  97636. * Gets a number indicating if the current point can be connected to another point
  97637. * @param connectionPoint defines the other connection point
  97638. * @returns a number defining the compatibility state
  97639. */
  97640. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  97641. /**
  97642. * Connect this point to another connection point
  97643. * @param connectionPoint defines the other connection point
  97644. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  97645. * @returns the current connection point
  97646. */
  97647. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  97648. /**
  97649. * Disconnect this point from one of his endpoint
  97650. * @param endpoint defines the other connection point
  97651. * @returns the current connection point
  97652. */
  97653. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  97654. /**
  97655. * Serializes this point in a JSON representation
  97656. * @param isInput defines if the connection point is an input (default is true)
  97657. * @returns the serialized point object
  97658. */
  97659. serialize(isInput?: boolean): any;
  97660. /**
  97661. * Release resources
  97662. */
  97663. dispose(): void;
  97664. }
  97665. }
  97666. declare module BABYLON {
  97667. /**
  97668. * Enum used to define the material modes
  97669. */
  97670. export enum NodeMaterialModes {
  97671. /** Regular material */
  97672. Material = 0,
  97673. /** For post process */
  97674. PostProcess = 1,
  97675. /** For particle system */
  97676. Particle = 2
  97677. }
  97678. }
  97679. declare module BABYLON {
  97680. /**
  97681. * Block used to read a texture from a sampler
  97682. */
  97683. export class TextureBlock extends NodeMaterialBlock {
  97684. private _defineName;
  97685. private _linearDefineName;
  97686. private _gammaDefineName;
  97687. private _tempTextureRead;
  97688. private _samplerName;
  97689. private _transformedUVName;
  97690. private _textureTransformName;
  97691. private _textureInfoName;
  97692. private _mainUVName;
  97693. private _mainUVDefineName;
  97694. private _fragmentOnly;
  97695. /**
  97696. * Gets or sets the texture associated with the node
  97697. */
  97698. texture: Nullable<Texture>;
  97699. /**
  97700. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  97701. */
  97702. convertToGammaSpace: boolean;
  97703. /**
  97704. * Gets or sets a boolean indicating if content needs to be converted to linear space
  97705. */
  97706. convertToLinearSpace: boolean;
  97707. /**
  97708. * Create a new TextureBlock
  97709. * @param name defines the block name
  97710. */
  97711. constructor(name: string, fragmentOnly?: boolean);
  97712. /**
  97713. * Gets the current class name
  97714. * @returns the class name
  97715. */
  97716. getClassName(): string;
  97717. /**
  97718. * Gets the uv input component
  97719. */
  97720. get uv(): NodeMaterialConnectionPoint;
  97721. /**
  97722. * Gets the rgba output component
  97723. */
  97724. get rgba(): NodeMaterialConnectionPoint;
  97725. /**
  97726. * Gets the rgb output component
  97727. */
  97728. get rgb(): NodeMaterialConnectionPoint;
  97729. /**
  97730. * Gets the r output component
  97731. */
  97732. get r(): NodeMaterialConnectionPoint;
  97733. /**
  97734. * Gets the g output component
  97735. */
  97736. get g(): NodeMaterialConnectionPoint;
  97737. /**
  97738. * Gets the b output component
  97739. */
  97740. get b(): NodeMaterialConnectionPoint;
  97741. /**
  97742. * Gets the a output component
  97743. */
  97744. get a(): NodeMaterialConnectionPoint;
  97745. get target(): NodeMaterialBlockTargets;
  97746. autoConfigure(material: NodeMaterial): void;
  97747. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  97748. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  97749. isReady(): boolean;
  97750. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  97751. private get _isMixed();
  97752. private _injectVertexCode;
  97753. private _writeTextureRead;
  97754. private _writeOutput;
  97755. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  97756. protected _dumpPropertiesCode(): string;
  97757. serialize(): any;
  97758. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  97759. }
  97760. }
  97761. declare module BABYLON {
  97762. /** @hidden */
  97763. export var reflectionFunction: {
  97764. name: string;
  97765. shader: string;
  97766. };
  97767. }
  97768. declare module BABYLON {
  97769. /**
  97770. * Base block used to read a reflection texture from a sampler
  97771. */
  97772. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  97773. /** @hidden */
  97774. _define3DName: string;
  97775. /** @hidden */
  97776. _defineCubicName: string;
  97777. /** @hidden */
  97778. _defineExplicitName: string;
  97779. /** @hidden */
  97780. _defineProjectionName: string;
  97781. /** @hidden */
  97782. _defineLocalCubicName: string;
  97783. /** @hidden */
  97784. _defineSphericalName: string;
  97785. /** @hidden */
  97786. _definePlanarName: string;
  97787. /** @hidden */
  97788. _defineEquirectangularName: string;
  97789. /** @hidden */
  97790. _defineMirroredEquirectangularFixedName: string;
  97791. /** @hidden */
  97792. _defineEquirectangularFixedName: string;
  97793. /** @hidden */
  97794. _defineSkyboxName: string;
  97795. /** @hidden */
  97796. _defineOppositeZ: string;
  97797. /** @hidden */
  97798. _cubeSamplerName: string;
  97799. /** @hidden */
  97800. _2DSamplerName: string;
  97801. protected _positionUVWName: string;
  97802. protected _directionWName: string;
  97803. protected _reflectionVectorName: string;
  97804. /** @hidden */
  97805. _reflectionCoordsName: string;
  97806. /** @hidden */
  97807. _reflectionMatrixName: string;
  97808. protected _reflectionColorName: string;
  97809. /**
  97810. * Gets or sets the texture associated with the node
  97811. */
  97812. texture: Nullable<BaseTexture>;
  97813. /**
  97814. * Create a new ReflectionTextureBaseBlock
  97815. * @param name defines the block name
  97816. */
  97817. constructor(name: string);
  97818. /**
  97819. * Gets the current class name
  97820. * @returns the class name
  97821. */
  97822. getClassName(): string;
  97823. /**
  97824. * Gets the world position input component
  97825. */
  97826. abstract get position(): NodeMaterialConnectionPoint;
  97827. /**
  97828. * Gets the world position input component
  97829. */
  97830. abstract get worldPosition(): NodeMaterialConnectionPoint;
  97831. /**
  97832. * Gets the world normal input component
  97833. */
  97834. abstract get worldNormal(): NodeMaterialConnectionPoint;
  97835. /**
  97836. * Gets the world input component
  97837. */
  97838. abstract get world(): NodeMaterialConnectionPoint;
  97839. /**
  97840. * Gets the camera (or eye) position component
  97841. */
  97842. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  97843. /**
  97844. * Gets the view input component
  97845. */
  97846. abstract get view(): NodeMaterialConnectionPoint;
  97847. protected _getTexture(): Nullable<BaseTexture>;
  97848. autoConfigure(material: NodeMaterial): void;
  97849. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  97850. isReady(): boolean;
  97851. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  97852. /**
  97853. * Gets the code to inject in the vertex shader
  97854. * @param state current state of the node material building
  97855. * @returns the shader code
  97856. */
  97857. handleVertexSide(state: NodeMaterialBuildState): string;
  97858. /**
  97859. * Handles the inits for the fragment code path
  97860. * @param state node material build state
  97861. */
  97862. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  97863. /**
  97864. * Generates the reflection coords code for the fragment code path
  97865. * @param worldNormalVarName name of the world normal variable
  97866. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  97867. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  97868. * @returns the shader code
  97869. */
  97870. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  97871. /**
  97872. * Generates the reflection color code for the fragment code path
  97873. * @param lodVarName name of the lod variable
  97874. * @param swizzleLookupTexture swizzle to use for the final color variable
  97875. * @returns the shader code
  97876. */
  97877. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  97878. /**
  97879. * Generates the code corresponding to the connected output points
  97880. * @param state node material build state
  97881. * @param varName name of the variable to output
  97882. * @returns the shader code
  97883. */
  97884. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  97885. protected _buildBlock(state: NodeMaterialBuildState): this;
  97886. protected _dumpPropertiesCode(): string;
  97887. serialize(): any;
  97888. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  97889. }
  97890. }
  97891. declare module BABYLON {
  97892. /**
  97893. * Defines a connection point to be used for points with a custom object type
  97894. */
  97895. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  97896. private _blockType;
  97897. private _blockName;
  97898. private _nameForCheking?;
  97899. /**
  97900. * Creates a new connection point
  97901. * @param name defines the connection point name
  97902. * @param ownerBlock defines the block hosting this connection point
  97903. * @param direction defines the direction of the connection point
  97904. */
  97905. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  97906. /**
  97907. * Gets a number indicating if the current point can be connected to another point
  97908. * @param connectionPoint defines the other connection point
  97909. * @returns a number defining the compatibility state
  97910. */
  97911. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  97912. /**
  97913. * Creates a block suitable to be used as an input for this input point.
  97914. * If null is returned, a block based on the point type will be created.
  97915. * @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
  97916. */
  97917. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  97918. }
  97919. }
  97920. declare module BABYLON {
  97921. /**
  97922. * Enum defining the type of properties that can be edited in the property pages in the NME
  97923. */
  97924. export enum PropertyTypeForEdition {
  97925. /** property is a boolean */
  97926. Boolean = 0,
  97927. /** property is a float */
  97928. Float = 1,
  97929. /** property is a Vector2 */
  97930. Vector2 = 2,
  97931. /** property is a list of values */
  97932. List = 3
  97933. }
  97934. /**
  97935. * Interface that defines an option in a variable of type list
  97936. */
  97937. export interface IEditablePropertyListOption {
  97938. /** label of the option */
  97939. "label": string;
  97940. /** value of the option */
  97941. "value": number;
  97942. }
  97943. /**
  97944. * Interface that defines the options available for an editable property
  97945. */
  97946. export interface IEditablePropertyOption {
  97947. /** min value */
  97948. "min"?: number;
  97949. /** max value */
  97950. "max"?: number;
  97951. /** notifiers: indicates which actions to take when the property is changed */
  97952. "notifiers"?: {
  97953. /** the material should be rebuilt */
  97954. "rebuild"?: boolean;
  97955. /** the preview should be updated */
  97956. "update"?: boolean;
  97957. };
  97958. /** list of the options for a variable of type list */
  97959. "options"?: IEditablePropertyListOption[];
  97960. }
  97961. /**
  97962. * Interface that describes an editable property
  97963. */
  97964. export interface IPropertyDescriptionForEdition {
  97965. /** name of the property */
  97966. "propertyName": string;
  97967. /** display name of the property */
  97968. "displayName": string;
  97969. /** type of the property */
  97970. "type": PropertyTypeForEdition;
  97971. /** group of the property - all properties with the same group value will be displayed in a specific section */
  97972. "groupName": string;
  97973. /** options for the property */
  97974. "options": IEditablePropertyOption;
  97975. }
  97976. /**
  97977. * Decorator that flags a property in a node material block as being editable
  97978. */
  97979. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  97980. }
  97981. declare module BABYLON {
  97982. /**
  97983. * Block used to implement the refraction part of the sub surface module of the PBR material
  97984. */
  97985. export class RefractionBlock extends NodeMaterialBlock {
  97986. /** @hidden */
  97987. _define3DName: string;
  97988. /** @hidden */
  97989. _refractionMatrixName: string;
  97990. /** @hidden */
  97991. _defineLODRefractionAlpha: string;
  97992. /** @hidden */
  97993. _defineLinearSpecularRefraction: string;
  97994. /** @hidden */
  97995. _defineOppositeZ: string;
  97996. /** @hidden */
  97997. _cubeSamplerName: string;
  97998. /** @hidden */
  97999. _2DSamplerName: string;
  98000. /** @hidden */
  98001. _vRefractionMicrosurfaceInfosName: string;
  98002. /** @hidden */
  98003. _vRefractionInfosName: string;
  98004. private _scene;
  98005. /**
  98006. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  98007. * Materials half opaque for instance using refraction could benefit from this control.
  98008. */
  98009. linkRefractionWithTransparency: boolean;
  98010. /**
  98011. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  98012. */
  98013. invertRefractionY: boolean;
  98014. /**
  98015. * Gets or sets the texture associated with the node
  98016. */
  98017. texture: Nullable<BaseTexture>;
  98018. /**
  98019. * Create a new RefractionBlock
  98020. * @param name defines the block name
  98021. */
  98022. constructor(name: string);
  98023. /**
  98024. * Gets the current class name
  98025. * @returns the class name
  98026. */
  98027. getClassName(): string;
  98028. /**
  98029. * Gets the intensity input component
  98030. */
  98031. get intensity(): NodeMaterialConnectionPoint;
  98032. /**
  98033. * Gets the index of refraction input component
  98034. */
  98035. get indexOfRefraction(): NodeMaterialConnectionPoint;
  98036. /**
  98037. * Gets the tint at distance input component
  98038. */
  98039. get tintAtDistance(): NodeMaterialConnectionPoint;
  98040. /**
  98041. * Gets the view input component
  98042. */
  98043. get view(): NodeMaterialConnectionPoint;
  98044. /**
  98045. * Gets the refraction object output component
  98046. */
  98047. get refraction(): NodeMaterialConnectionPoint;
  98048. /**
  98049. * Returns true if the block has a texture
  98050. */
  98051. get hasTexture(): boolean;
  98052. protected _getTexture(): Nullable<BaseTexture>;
  98053. autoConfigure(material: NodeMaterial): void;
  98054. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  98055. isReady(): boolean;
  98056. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  98057. /**
  98058. * Gets the main code of the block (fragment side)
  98059. * @param state current state of the node material building
  98060. * @returns the shader code
  98061. */
  98062. getCode(state: NodeMaterialBuildState): string;
  98063. protected _buildBlock(state: NodeMaterialBuildState): this;
  98064. protected _dumpPropertiesCode(): string;
  98065. serialize(): any;
  98066. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98067. }
  98068. }
  98069. declare module BABYLON {
  98070. /**
  98071. * Base block used as input for post process
  98072. */
  98073. export class CurrentScreenBlock extends NodeMaterialBlock {
  98074. private _samplerName;
  98075. private _linearDefineName;
  98076. private _gammaDefineName;
  98077. private _mainUVName;
  98078. private _tempTextureRead;
  98079. /**
  98080. * Gets or sets the texture associated with the node
  98081. */
  98082. texture: Nullable<BaseTexture>;
  98083. /**
  98084. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  98085. */
  98086. convertToGammaSpace: boolean;
  98087. /**
  98088. * Gets or sets a boolean indicating if content needs to be converted to linear space
  98089. */
  98090. convertToLinearSpace: boolean;
  98091. /**
  98092. * Create a new CurrentScreenBlock
  98093. * @param name defines the block name
  98094. */
  98095. constructor(name: string);
  98096. /**
  98097. * Gets the current class name
  98098. * @returns the class name
  98099. */
  98100. getClassName(): string;
  98101. /**
  98102. * Gets the uv input component
  98103. */
  98104. get uv(): NodeMaterialConnectionPoint;
  98105. /**
  98106. * Gets the rgba output component
  98107. */
  98108. get rgba(): NodeMaterialConnectionPoint;
  98109. /**
  98110. * Gets the rgb output component
  98111. */
  98112. get rgb(): NodeMaterialConnectionPoint;
  98113. /**
  98114. * Gets the r output component
  98115. */
  98116. get r(): NodeMaterialConnectionPoint;
  98117. /**
  98118. * Gets the g output component
  98119. */
  98120. get g(): NodeMaterialConnectionPoint;
  98121. /**
  98122. * Gets the b output component
  98123. */
  98124. get b(): NodeMaterialConnectionPoint;
  98125. /**
  98126. * Gets the a output component
  98127. */
  98128. get a(): NodeMaterialConnectionPoint;
  98129. /**
  98130. * Initialize the block and prepare the context for build
  98131. * @param state defines the state that will be used for the build
  98132. */
  98133. initialize(state: NodeMaterialBuildState): void;
  98134. get target(): NodeMaterialBlockTargets;
  98135. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  98136. isReady(): boolean;
  98137. private _injectVertexCode;
  98138. private _writeTextureRead;
  98139. private _writeOutput;
  98140. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  98141. serialize(): any;
  98142. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98143. }
  98144. }
  98145. declare module BABYLON {
  98146. /**
  98147. * Base block used for the particle texture
  98148. */
  98149. export class ParticleTextureBlock extends NodeMaterialBlock {
  98150. private _samplerName;
  98151. private _linearDefineName;
  98152. private _gammaDefineName;
  98153. private _tempTextureRead;
  98154. /**
  98155. * Gets or sets the texture associated with the node
  98156. */
  98157. texture: Nullable<BaseTexture>;
  98158. /**
  98159. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  98160. */
  98161. convertToGammaSpace: boolean;
  98162. /**
  98163. * Gets or sets a boolean indicating if content needs to be converted to linear space
  98164. */
  98165. convertToLinearSpace: boolean;
  98166. /**
  98167. * Create a new ParticleTextureBlock
  98168. * @param name defines the block name
  98169. */
  98170. constructor(name: string);
  98171. /**
  98172. * Gets the current class name
  98173. * @returns the class name
  98174. */
  98175. getClassName(): string;
  98176. /**
  98177. * Gets the uv input component
  98178. */
  98179. get uv(): NodeMaterialConnectionPoint;
  98180. /**
  98181. * Gets the rgba output component
  98182. */
  98183. get rgba(): NodeMaterialConnectionPoint;
  98184. /**
  98185. * Gets the rgb output component
  98186. */
  98187. get rgb(): NodeMaterialConnectionPoint;
  98188. /**
  98189. * Gets the r output component
  98190. */
  98191. get r(): NodeMaterialConnectionPoint;
  98192. /**
  98193. * Gets the g output component
  98194. */
  98195. get g(): NodeMaterialConnectionPoint;
  98196. /**
  98197. * Gets the b output component
  98198. */
  98199. get b(): NodeMaterialConnectionPoint;
  98200. /**
  98201. * Gets the a output component
  98202. */
  98203. get a(): NodeMaterialConnectionPoint;
  98204. /**
  98205. * Initialize the block and prepare the context for build
  98206. * @param state defines the state that will be used for the build
  98207. */
  98208. initialize(state: NodeMaterialBuildState): void;
  98209. autoConfigure(material: NodeMaterial): void;
  98210. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  98211. isReady(): boolean;
  98212. private _writeOutput;
  98213. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  98214. serialize(): any;
  98215. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98216. }
  98217. }
  98218. declare module BABYLON {
  98219. /**
  98220. * Class used to store shared data between 2 NodeMaterialBuildState
  98221. */
  98222. export class NodeMaterialBuildStateSharedData {
  98223. /**
  98224. * Gets the list of emitted varyings
  98225. */
  98226. temps: string[];
  98227. /**
  98228. * Gets the list of emitted varyings
  98229. */
  98230. varyings: string[];
  98231. /**
  98232. * Gets the varying declaration string
  98233. */
  98234. varyingDeclaration: string;
  98235. /**
  98236. * Input blocks
  98237. */
  98238. inputBlocks: InputBlock[];
  98239. /**
  98240. * Input blocks
  98241. */
  98242. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  98243. /**
  98244. * Bindable blocks (Blocks that need to set data to the effect)
  98245. */
  98246. bindableBlocks: NodeMaterialBlock[];
  98247. /**
  98248. * List of blocks that can provide a compilation fallback
  98249. */
  98250. blocksWithFallbacks: NodeMaterialBlock[];
  98251. /**
  98252. * List of blocks that can provide a define update
  98253. */
  98254. blocksWithDefines: NodeMaterialBlock[];
  98255. /**
  98256. * List of blocks that can provide a repeatable content
  98257. */
  98258. repeatableContentBlocks: NodeMaterialBlock[];
  98259. /**
  98260. * List of blocks that can provide a dynamic list of uniforms
  98261. */
  98262. dynamicUniformBlocks: NodeMaterialBlock[];
  98263. /**
  98264. * List of blocks that can block the isReady function for the material
  98265. */
  98266. blockingBlocks: NodeMaterialBlock[];
  98267. /**
  98268. * Gets the list of animated inputs
  98269. */
  98270. animatedInputs: InputBlock[];
  98271. /**
  98272. * Build Id used to avoid multiple recompilations
  98273. */
  98274. buildId: number;
  98275. /** List of emitted variables */
  98276. variableNames: {
  98277. [key: string]: number;
  98278. };
  98279. /** List of emitted defines */
  98280. defineNames: {
  98281. [key: string]: number;
  98282. };
  98283. /** Should emit comments? */
  98284. emitComments: boolean;
  98285. /** Emit build activity */
  98286. verbose: boolean;
  98287. /** Gets or sets the hosting scene */
  98288. scene: Scene;
  98289. /**
  98290. * Gets the compilation hints emitted at compilation time
  98291. */
  98292. hints: {
  98293. needWorldViewMatrix: boolean;
  98294. needWorldViewProjectionMatrix: boolean;
  98295. needAlphaBlending: boolean;
  98296. needAlphaTesting: boolean;
  98297. };
  98298. /**
  98299. * List of compilation checks
  98300. */
  98301. checks: {
  98302. emitVertex: boolean;
  98303. emitFragment: boolean;
  98304. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  98305. };
  98306. /**
  98307. * Is vertex program allowed to be empty?
  98308. */
  98309. allowEmptyVertexProgram: boolean;
  98310. /** Creates a new shared data */
  98311. constructor();
  98312. /**
  98313. * Emits console errors and exceptions if there is a failing check
  98314. */
  98315. emitErrors(): void;
  98316. }
  98317. }
  98318. declare module BABYLON {
  98319. /**
  98320. * Class used to store node based material build state
  98321. */
  98322. export class NodeMaterialBuildState {
  98323. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  98324. supportUniformBuffers: boolean;
  98325. /**
  98326. * Gets the list of emitted attributes
  98327. */
  98328. attributes: string[];
  98329. /**
  98330. * Gets the list of emitted uniforms
  98331. */
  98332. uniforms: string[];
  98333. /**
  98334. * Gets the list of emitted constants
  98335. */
  98336. constants: string[];
  98337. /**
  98338. * Gets the list of emitted samplers
  98339. */
  98340. samplers: string[];
  98341. /**
  98342. * Gets the list of emitted functions
  98343. */
  98344. functions: {
  98345. [key: string]: string;
  98346. };
  98347. /**
  98348. * Gets the list of emitted extensions
  98349. */
  98350. extensions: {
  98351. [key: string]: string;
  98352. };
  98353. /**
  98354. * Gets the target of the compilation state
  98355. */
  98356. target: NodeMaterialBlockTargets;
  98357. /**
  98358. * Gets the list of emitted counters
  98359. */
  98360. counters: {
  98361. [key: string]: number;
  98362. };
  98363. /**
  98364. * Shared data between multiple NodeMaterialBuildState instances
  98365. */
  98366. sharedData: NodeMaterialBuildStateSharedData;
  98367. /** @hidden */
  98368. _vertexState: NodeMaterialBuildState;
  98369. /** @hidden */
  98370. _attributeDeclaration: string;
  98371. /** @hidden */
  98372. _uniformDeclaration: string;
  98373. /** @hidden */
  98374. _constantDeclaration: string;
  98375. /** @hidden */
  98376. _samplerDeclaration: string;
  98377. /** @hidden */
  98378. _varyingTransfer: string;
  98379. /** @hidden */
  98380. _injectAtEnd: string;
  98381. private _repeatableContentAnchorIndex;
  98382. /** @hidden */
  98383. _builtCompilationString: string;
  98384. /**
  98385. * Gets the emitted compilation strings
  98386. */
  98387. compilationString: string;
  98388. /**
  98389. * Finalize the compilation strings
  98390. * @param state defines the current compilation state
  98391. */
  98392. finalize(state: NodeMaterialBuildState): void;
  98393. /** @hidden */
  98394. get _repeatableContentAnchor(): string;
  98395. /** @hidden */
  98396. _getFreeVariableName(prefix: string): string;
  98397. /** @hidden */
  98398. _getFreeDefineName(prefix: string): string;
  98399. /** @hidden */
  98400. _excludeVariableName(name: string): void;
  98401. /** @hidden */
  98402. _emit2DSampler(name: string): void;
  98403. /** @hidden */
  98404. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  98405. /** @hidden */
  98406. _emitExtension(name: string, extension: string, define?: string): void;
  98407. /** @hidden */
  98408. _emitFunction(name: string, code: string, comments: string): void;
  98409. /** @hidden */
  98410. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  98411. replaceStrings?: {
  98412. search: RegExp;
  98413. replace: string;
  98414. }[];
  98415. repeatKey?: string;
  98416. }): string;
  98417. /** @hidden */
  98418. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  98419. repeatKey?: string;
  98420. removeAttributes?: boolean;
  98421. removeUniforms?: boolean;
  98422. removeVaryings?: boolean;
  98423. removeIfDef?: boolean;
  98424. replaceStrings?: {
  98425. search: RegExp;
  98426. replace: string;
  98427. }[];
  98428. }, storeKey?: string): void;
  98429. /** @hidden */
  98430. _registerTempVariable(name: string): boolean;
  98431. /** @hidden */
  98432. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  98433. /** @hidden */
  98434. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  98435. /** @hidden */
  98436. _emitFloat(value: number): string;
  98437. }
  98438. }
  98439. declare module BABYLON {
  98440. /**
  98441. * Helper class used to generate session unique ID
  98442. */
  98443. export class UniqueIdGenerator {
  98444. private static _UniqueIdCounter;
  98445. /**
  98446. * Gets an unique (relatively to the current scene) Id
  98447. */
  98448. static get UniqueId(): number;
  98449. }
  98450. }
  98451. declare module BABYLON {
  98452. /**
  98453. * Defines a block that can be used inside a node based material
  98454. */
  98455. export class NodeMaterialBlock {
  98456. private _buildId;
  98457. private _buildTarget;
  98458. private _target;
  98459. private _isFinalMerger;
  98460. private _isInput;
  98461. protected _isUnique: boolean;
  98462. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  98463. inputsAreExclusive: boolean;
  98464. /** @hidden */
  98465. _codeVariableName: string;
  98466. /** @hidden */
  98467. _inputs: NodeMaterialConnectionPoint[];
  98468. /** @hidden */
  98469. _outputs: NodeMaterialConnectionPoint[];
  98470. /** @hidden */
  98471. _preparationId: number;
  98472. /**
  98473. * Gets or sets the name of the block
  98474. */
  98475. name: string;
  98476. /**
  98477. * Gets or sets the unique id of the node
  98478. */
  98479. uniqueId: number;
  98480. /**
  98481. * Gets or sets the comments associated with this block
  98482. */
  98483. comments: string;
  98484. /**
  98485. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  98486. */
  98487. get isUnique(): boolean;
  98488. /**
  98489. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  98490. */
  98491. get isFinalMerger(): boolean;
  98492. /**
  98493. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  98494. */
  98495. get isInput(): boolean;
  98496. /**
  98497. * Gets or sets the build Id
  98498. */
  98499. get buildId(): number;
  98500. set buildId(value: number);
  98501. /**
  98502. * Gets or sets the target of the block
  98503. */
  98504. get target(): NodeMaterialBlockTargets;
  98505. set target(value: NodeMaterialBlockTargets);
  98506. /**
  98507. * Gets the list of input points
  98508. */
  98509. get inputs(): NodeMaterialConnectionPoint[];
  98510. /** Gets the list of output points */
  98511. get outputs(): NodeMaterialConnectionPoint[];
  98512. /**
  98513. * Find an input by its name
  98514. * @param name defines the name of the input to look for
  98515. * @returns the input or null if not found
  98516. */
  98517. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  98518. /**
  98519. * Find an output by its name
  98520. * @param name defines the name of the outputto look for
  98521. * @returns the output or null if not found
  98522. */
  98523. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  98524. /**
  98525. * Creates a new NodeMaterialBlock
  98526. * @param name defines the block name
  98527. * @param target defines the target of that block (Vertex by default)
  98528. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  98529. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  98530. */
  98531. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  98532. /**
  98533. * Initialize the block and prepare the context for build
  98534. * @param state defines the state that will be used for the build
  98535. */
  98536. initialize(state: NodeMaterialBuildState): void;
  98537. /**
  98538. * Bind data to effect. Will only be called for blocks with isBindable === true
  98539. * @param effect defines the effect to bind data to
  98540. * @param nodeMaterial defines the hosting NodeMaterial
  98541. * @param mesh defines the mesh that will be rendered
  98542. * @param subMesh defines the submesh that will be rendered
  98543. */
  98544. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  98545. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  98546. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  98547. protected _writeFloat(value: number): string;
  98548. /**
  98549. * Gets the current class name e.g. "NodeMaterialBlock"
  98550. * @returns the class name
  98551. */
  98552. getClassName(): string;
  98553. /**
  98554. * Register a new input. Must be called inside a block constructor
  98555. * @param name defines the connection point name
  98556. * @param type defines the connection point type
  98557. * @param isOptional defines a boolean indicating that this input can be omitted
  98558. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  98559. * @param point an already created connection point. If not provided, create a new one
  98560. * @returns the current block
  98561. */
  98562. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  98563. /**
  98564. * Register a new output. Must be called inside a block constructor
  98565. * @param name defines the connection point name
  98566. * @param type defines the connection point type
  98567. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  98568. * @param point an already created connection point. If not provided, create a new one
  98569. * @returns the current block
  98570. */
  98571. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  98572. /**
  98573. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  98574. * @param forOutput defines an optional connection point to check compatibility with
  98575. * @returns the first available input or null
  98576. */
  98577. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  98578. /**
  98579. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  98580. * @param forBlock defines an optional block to check compatibility with
  98581. * @returns the first available input or null
  98582. */
  98583. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  98584. /**
  98585. * Gets the sibling of the given output
  98586. * @param current defines the current output
  98587. * @returns the next output in the list or null
  98588. */
  98589. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  98590. /**
  98591. * Connect current block with another block
  98592. * @param other defines the block to connect with
  98593. * @param options define the various options to help pick the right connections
  98594. * @returns the current block
  98595. */
  98596. connectTo(other: NodeMaterialBlock, options?: {
  98597. input?: string;
  98598. output?: string;
  98599. outputSwizzle?: string;
  98600. }): this | undefined;
  98601. protected _buildBlock(state: NodeMaterialBuildState): void;
  98602. /**
  98603. * Add uniforms, samplers and uniform buffers at compilation time
  98604. * @param state defines the state to update
  98605. * @param nodeMaterial defines the node material requesting the update
  98606. * @param defines defines the material defines to update
  98607. * @param uniformBuffers defines the list of uniform buffer names
  98608. */
  98609. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  98610. /**
  98611. * Add potential fallbacks if shader compilation fails
  98612. * @param mesh defines the mesh to be rendered
  98613. * @param fallbacks defines the current prioritized list of fallbacks
  98614. */
  98615. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  98616. /**
  98617. * Initialize defines for shader compilation
  98618. * @param mesh defines the mesh to be rendered
  98619. * @param nodeMaterial defines the node material requesting the update
  98620. * @param defines defines the material defines to update
  98621. * @param useInstances specifies that instances should be used
  98622. */
  98623. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  98624. /**
  98625. * Update defines for shader compilation
  98626. * @param mesh defines the mesh to be rendered
  98627. * @param nodeMaterial defines the node material requesting the update
  98628. * @param defines defines the material defines to update
  98629. * @param useInstances specifies that instances should be used
  98630. * @param subMesh defines which submesh to render
  98631. */
  98632. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  98633. /**
  98634. * Lets the block try to connect some inputs automatically
  98635. * @param material defines the hosting NodeMaterial
  98636. */
  98637. autoConfigure(material: NodeMaterial): void;
  98638. /**
  98639. * Function called when a block is declared as repeatable content generator
  98640. * @param vertexShaderState defines the current compilation state for the vertex shader
  98641. * @param fragmentShaderState defines the current compilation state for the fragment shader
  98642. * @param mesh defines the mesh to be rendered
  98643. * @param defines defines the material defines to update
  98644. */
  98645. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  98646. /**
  98647. * Checks if the block is ready
  98648. * @param mesh defines the mesh to be rendered
  98649. * @param nodeMaterial defines the node material requesting the update
  98650. * @param defines defines the material defines to update
  98651. * @param useInstances specifies that instances should be used
  98652. * @returns true if the block is ready
  98653. */
  98654. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  98655. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  98656. private _processBuild;
  98657. /**
  98658. * Compile the current node and generate the shader code
  98659. * @param state defines the current compilation state (uniforms, samplers, current string)
  98660. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  98661. * @returns true if already built
  98662. */
  98663. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  98664. protected _inputRename(name: string): string;
  98665. protected _outputRename(name: string): string;
  98666. protected _dumpPropertiesCode(): string;
  98667. /** @hidden */
  98668. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  98669. /** @hidden */
  98670. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  98671. /**
  98672. * Clone the current block to a new identical block
  98673. * @param scene defines the hosting scene
  98674. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  98675. * @returns a copy of the current block
  98676. */
  98677. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  98678. /**
  98679. * Serializes this block in a JSON representation
  98680. * @returns the serialized block object
  98681. */
  98682. serialize(): any;
  98683. /** @hidden */
  98684. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98685. private _deserializePortDisplayNames;
  98686. /**
  98687. * Release resources
  98688. */
  98689. dispose(): void;
  98690. }
  98691. }
  98692. declare module BABYLON {
  98693. /**
  98694. * Base class of materials working in push mode in babylon JS
  98695. * @hidden
  98696. */
  98697. export class PushMaterial extends Material {
  98698. protected _activeEffect: Effect;
  98699. protected _normalMatrix: Matrix;
  98700. /**
  98701. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  98702. * This means that the material can keep using a previous shader while a new one is being compiled.
  98703. * This is mostly used when shader parallel compilation is supported (true by default)
  98704. */
  98705. allowShaderHotSwapping: boolean;
  98706. constructor(name: string, scene: Scene);
  98707. getEffect(): Effect;
  98708. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  98709. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  98710. /**
  98711. * Binds the given world matrix to the active effect
  98712. *
  98713. * @param world the matrix to bind
  98714. */
  98715. bindOnlyWorldMatrix(world: Matrix): void;
  98716. /**
  98717. * Binds the given normal matrix to the active effect
  98718. *
  98719. * @param normalMatrix the matrix to bind
  98720. */
  98721. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  98722. bind(world: Matrix, mesh?: Mesh): void;
  98723. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  98724. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  98725. }
  98726. }
  98727. declare module BABYLON {
  98728. /**
  98729. * Root class for all node material optimizers
  98730. */
  98731. export class NodeMaterialOptimizer {
  98732. /**
  98733. * Function used to optimize a NodeMaterial graph
  98734. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  98735. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  98736. */
  98737. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  98738. }
  98739. }
  98740. declare module BABYLON {
  98741. /**
  98742. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  98743. */
  98744. export class TransformBlock extends NodeMaterialBlock {
  98745. /**
  98746. * Defines the value to use to complement W value to transform it to a Vector4
  98747. */
  98748. complementW: number;
  98749. /**
  98750. * Defines the value to use to complement z value to transform it to a Vector4
  98751. */
  98752. complementZ: number;
  98753. /**
  98754. * Creates a new TransformBlock
  98755. * @param name defines the block name
  98756. */
  98757. constructor(name: string);
  98758. /**
  98759. * Gets the current class name
  98760. * @returns the class name
  98761. */
  98762. getClassName(): string;
  98763. /**
  98764. * Gets the vector input
  98765. */
  98766. get vector(): NodeMaterialConnectionPoint;
  98767. /**
  98768. * Gets the output component
  98769. */
  98770. get output(): NodeMaterialConnectionPoint;
  98771. /**
  98772. * Gets the xyz output component
  98773. */
  98774. get xyz(): NodeMaterialConnectionPoint;
  98775. /**
  98776. * Gets the matrix transform input
  98777. */
  98778. get transform(): NodeMaterialConnectionPoint;
  98779. protected _buildBlock(state: NodeMaterialBuildState): this;
  98780. serialize(): any;
  98781. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98782. protected _dumpPropertiesCode(): string;
  98783. }
  98784. }
  98785. declare module BABYLON {
  98786. /**
  98787. * Block used to output the vertex position
  98788. */
  98789. export class VertexOutputBlock extends NodeMaterialBlock {
  98790. /**
  98791. * Creates a new VertexOutputBlock
  98792. * @param name defines the block name
  98793. */
  98794. constructor(name: string);
  98795. /**
  98796. * Gets the current class name
  98797. * @returns the class name
  98798. */
  98799. getClassName(): string;
  98800. /**
  98801. * Gets the vector input component
  98802. */
  98803. get vector(): NodeMaterialConnectionPoint;
  98804. protected _buildBlock(state: NodeMaterialBuildState): this;
  98805. }
  98806. }
  98807. declare module BABYLON {
  98808. /**
  98809. * Block used to output the final color
  98810. */
  98811. export class FragmentOutputBlock extends NodeMaterialBlock {
  98812. /**
  98813. * Create a new FragmentOutputBlock
  98814. * @param name defines the block name
  98815. */
  98816. constructor(name: string);
  98817. /**
  98818. * Gets the current class name
  98819. * @returns the class name
  98820. */
  98821. getClassName(): string;
  98822. /**
  98823. * Gets the rgba input component
  98824. */
  98825. get rgba(): NodeMaterialConnectionPoint;
  98826. /**
  98827. * Gets the rgb input component
  98828. */
  98829. get rgb(): NodeMaterialConnectionPoint;
  98830. /**
  98831. * Gets the a input component
  98832. */
  98833. get a(): NodeMaterialConnectionPoint;
  98834. protected _buildBlock(state: NodeMaterialBuildState): this;
  98835. }
  98836. }
  98837. declare module BABYLON {
  98838. /**
  98839. * Block used for the particle ramp gradient section
  98840. */
  98841. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  98842. /**
  98843. * Create a new ParticleRampGradientBlock
  98844. * @param name defines the block name
  98845. */
  98846. constructor(name: string);
  98847. /**
  98848. * Gets the current class name
  98849. * @returns the class name
  98850. */
  98851. getClassName(): string;
  98852. /**
  98853. * Gets the color input component
  98854. */
  98855. get color(): NodeMaterialConnectionPoint;
  98856. /**
  98857. * Gets the rampColor output component
  98858. */
  98859. get rampColor(): NodeMaterialConnectionPoint;
  98860. /**
  98861. * Initialize the block and prepare the context for build
  98862. * @param state defines the state that will be used for the build
  98863. */
  98864. initialize(state: NodeMaterialBuildState): void;
  98865. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  98866. }
  98867. }
  98868. declare module BABYLON {
  98869. /**
  98870. * Block used for the particle blend multiply section
  98871. */
  98872. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  98873. /**
  98874. * Create a new ParticleBlendMultiplyBlock
  98875. * @param name defines the block name
  98876. */
  98877. constructor(name: string);
  98878. /**
  98879. * Gets the current class name
  98880. * @returns the class name
  98881. */
  98882. getClassName(): string;
  98883. /**
  98884. * Gets the color input component
  98885. */
  98886. get color(): NodeMaterialConnectionPoint;
  98887. /**
  98888. * Gets the alphaTexture input component
  98889. */
  98890. get alphaTexture(): NodeMaterialConnectionPoint;
  98891. /**
  98892. * Gets the alphaColor input component
  98893. */
  98894. get alphaColor(): NodeMaterialConnectionPoint;
  98895. /**
  98896. * Gets the blendColor output component
  98897. */
  98898. get blendColor(): NodeMaterialConnectionPoint;
  98899. /**
  98900. * Initialize the block and prepare the context for build
  98901. * @param state defines the state that will be used for the build
  98902. */
  98903. initialize(state: NodeMaterialBuildState): void;
  98904. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  98905. }
  98906. }
  98907. declare module BABYLON {
  98908. /**
  98909. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  98910. */
  98911. export class VectorMergerBlock extends NodeMaterialBlock {
  98912. /**
  98913. * Create a new VectorMergerBlock
  98914. * @param name defines the block name
  98915. */
  98916. constructor(name: string);
  98917. /**
  98918. * Gets the current class name
  98919. * @returns the class name
  98920. */
  98921. getClassName(): string;
  98922. /**
  98923. * Gets the xyz component (input)
  98924. */
  98925. get xyzIn(): NodeMaterialConnectionPoint;
  98926. /**
  98927. * Gets the xy component (input)
  98928. */
  98929. get xyIn(): NodeMaterialConnectionPoint;
  98930. /**
  98931. * Gets the x component (input)
  98932. */
  98933. get x(): NodeMaterialConnectionPoint;
  98934. /**
  98935. * Gets the y component (input)
  98936. */
  98937. get y(): NodeMaterialConnectionPoint;
  98938. /**
  98939. * Gets the z component (input)
  98940. */
  98941. get z(): NodeMaterialConnectionPoint;
  98942. /**
  98943. * Gets the w component (input)
  98944. */
  98945. get w(): NodeMaterialConnectionPoint;
  98946. /**
  98947. * Gets the xyzw component (output)
  98948. */
  98949. get xyzw(): NodeMaterialConnectionPoint;
  98950. /**
  98951. * Gets the xyz component (output)
  98952. */
  98953. get xyzOut(): NodeMaterialConnectionPoint;
  98954. /**
  98955. * Gets the xy component (output)
  98956. */
  98957. get xyOut(): NodeMaterialConnectionPoint;
  98958. /**
  98959. * Gets the xy component (output)
  98960. * @deprecated Please use xyOut instead.
  98961. */
  98962. get xy(): NodeMaterialConnectionPoint;
  98963. /**
  98964. * Gets the xyz component (output)
  98965. * @deprecated Please use xyzOut instead.
  98966. */
  98967. get xyz(): NodeMaterialConnectionPoint;
  98968. protected _buildBlock(state: NodeMaterialBuildState): this;
  98969. }
  98970. }
  98971. declare module BABYLON {
  98972. /**
  98973. * Block used to remap a float from a range to a new one
  98974. */
  98975. export class RemapBlock extends NodeMaterialBlock {
  98976. /**
  98977. * Gets or sets the source range
  98978. */
  98979. sourceRange: Vector2;
  98980. /**
  98981. * Gets or sets the target range
  98982. */
  98983. targetRange: Vector2;
  98984. /**
  98985. * Creates a new RemapBlock
  98986. * @param name defines the block name
  98987. */
  98988. constructor(name: string);
  98989. /**
  98990. * Gets the current class name
  98991. * @returns the class name
  98992. */
  98993. getClassName(): string;
  98994. /**
  98995. * Gets the input component
  98996. */
  98997. get input(): NodeMaterialConnectionPoint;
  98998. /**
  98999. * Gets the source min input component
  99000. */
  99001. get sourceMin(): NodeMaterialConnectionPoint;
  99002. /**
  99003. * Gets the source max input component
  99004. */
  99005. get sourceMax(): NodeMaterialConnectionPoint;
  99006. /**
  99007. * Gets the target min input component
  99008. */
  99009. get targetMin(): NodeMaterialConnectionPoint;
  99010. /**
  99011. * Gets the target max input component
  99012. */
  99013. get targetMax(): NodeMaterialConnectionPoint;
  99014. /**
  99015. * Gets the output component
  99016. */
  99017. get output(): NodeMaterialConnectionPoint;
  99018. protected _buildBlock(state: NodeMaterialBuildState): this;
  99019. protected _dumpPropertiesCode(): string;
  99020. serialize(): any;
  99021. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99022. }
  99023. }
  99024. declare module BABYLON {
  99025. /**
  99026. * Block used to multiply 2 values
  99027. */
  99028. export class MultiplyBlock extends NodeMaterialBlock {
  99029. /**
  99030. * Creates a new MultiplyBlock
  99031. * @param name defines the block name
  99032. */
  99033. constructor(name: string);
  99034. /**
  99035. * Gets the current class name
  99036. * @returns the class name
  99037. */
  99038. getClassName(): string;
  99039. /**
  99040. * Gets the left operand input component
  99041. */
  99042. get left(): NodeMaterialConnectionPoint;
  99043. /**
  99044. * Gets the right operand input component
  99045. */
  99046. get right(): NodeMaterialConnectionPoint;
  99047. /**
  99048. * Gets the output component
  99049. */
  99050. get output(): NodeMaterialConnectionPoint;
  99051. protected _buildBlock(state: NodeMaterialBuildState): this;
  99052. }
  99053. }
  99054. declare module BABYLON {
  99055. /**
  99056. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  99057. */
  99058. export class ColorSplitterBlock extends NodeMaterialBlock {
  99059. /**
  99060. * Create a new ColorSplitterBlock
  99061. * @param name defines the block name
  99062. */
  99063. constructor(name: string);
  99064. /**
  99065. * Gets the current class name
  99066. * @returns the class name
  99067. */
  99068. getClassName(): string;
  99069. /**
  99070. * Gets the rgba component (input)
  99071. */
  99072. get rgba(): NodeMaterialConnectionPoint;
  99073. /**
  99074. * Gets the rgb component (input)
  99075. */
  99076. get rgbIn(): NodeMaterialConnectionPoint;
  99077. /**
  99078. * Gets the rgb component (output)
  99079. */
  99080. get rgbOut(): NodeMaterialConnectionPoint;
  99081. /**
  99082. * Gets the r component (output)
  99083. */
  99084. get r(): NodeMaterialConnectionPoint;
  99085. /**
  99086. * Gets the g component (output)
  99087. */
  99088. get g(): NodeMaterialConnectionPoint;
  99089. /**
  99090. * Gets the b component (output)
  99091. */
  99092. get b(): NodeMaterialConnectionPoint;
  99093. /**
  99094. * Gets the a component (output)
  99095. */
  99096. get a(): NodeMaterialConnectionPoint;
  99097. protected _inputRename(name: string): string;
  99098. protected _outputRename(name: string): string;
  99099. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  99100. }
  99101. }
  99102. declare module BABYLON {
  99103. /**
  99104. * Interface used to configure the node material editor
  99105. */
  99106. export interface INodeMaterialEditorOptions {
  99107. /** Define the URl to load node editor script */
  99108. editorURL?: string;
  99109. }
  99110. /** @hidden */
  99111. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  99112. NORMAL: boolean;
  99113. TANGENT: boolean;
  99114. UV1: boolean;
  99115. /** BONES */
  99116. NUM_BONE_INFLUENCERS: number;
  99117. BonesPerMesh: number;
  99118. BONETEXTURE: boolean;
  99119. /** MORPH TARGETS */
  99120. MORPHTARGETS: boolean;
  99121. MORPHTARGETS_NORMAL: boolean;
  99122. MORPHTARGETS_TANGENT: boolean;
  99123. MORPHTARGETS_UV: boolean;
  99124. NUM_MORPH_INFLUENCERS: number;
  99125. /** IMAGE PROCESSING */
  99126. IMAGEPROCESSING: boolean;
  99127. VIGNETTE: boolean;
  99128. VIGNETTEBLENDMODEMULTIPLY: boolean;
  99129. VIGNETTEBLENDMODEOPAQUE: boolean;
  99130. TONEMAPPING: boolean;
  99131. TONEMAPPING_ACES: boolean;
  99132. CONTRAST: boolean;
  99133. EXPOSURE: boolean;
  99134. COLORCURVES: boolean;
  99135. COLORGRADING: boolean;
  99136. COLORGRADING3D: boolean;
  99137. SAMPLER3DGREENDEPTH: boolean;
  99138. SAMPLER3DBGRMAP: boolean;
  99139. IMAGEPROCESSINGPOSTPROCESS: boolean;
  99140. /** MISC. */
  99141. BUMPDIRECTUV: number;
  99142. constructor();
  99143. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  99144. }
  99145. /**
  99146. * Class used to configure NodeMaterial
  99147. */
  99148. export interface INodeMaterialOptions {
  99149. /**
  99150. * Defines if blocks should emit comments
  99151. */
  99152. emitComments: boolean;
  99153. }
  99154. /**
  99155. * Class used to create a node based material built by assembling shader blocks
  99156. */
  99157. export class NodeMaterial extends PushMaterial {
  99158. private static _BuildIdGenerator;
  99159. private _options;
  99160. private _vertexCompilationState;
  99161. private _fragmentCompilationState;
  99162. private _sharedData;
  99163. private _buildId;
  99164. private _buildWasSuccessful;
  99165. private _cachedWorldViewMatrix;
  99166. private _cachedWorldViewProjectionMatrix;
  99167. private _optimizers;
  99168. private _animationFrame;
  99169. /** Define the Url to load node editor script */
  99170. static EditorURL: string;
  99171. /** Define the Url to load snippets */
  99172. static SnippetUrl: string;
  99173. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  99174. static IgnoreTexturesAtLoadTime: boolean;
  99175. private BJSNODEMATERIALEDITOR;
  99176. /** Get the inspector from bundle or global */
  99177. private _getGlobalNodeMaterialEditor;
  99178. /**
  99179. * Snippet ID if the material was created from the snippet server
  99180. */
  99181. snippetId: string;
  99182. /**
  99183. * Gets or sets data used by visual editor
  99184. * @see https://nme.babylonjs.com
  99185. */
  99186. editorData: any;
  99187. /**
  99188. * 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)
  99189. */
  99190. ignoreAlpha: boolean;
  99191. /**
  99192. * Defines the maximum number of lights that can be used in the material
  99193. */
  99194. maxSimultaneousLights: number;
  99195. /**
  99196. * Observable raised when the material is built
  99197. */
  99198. onBuildObservable: Observable<NodeMaterial>;
  99199. /**
  99200. * Gets or sets the root nodes of the material vertex shader
  99201. */
  99202. _vertexOutputNodes: NodeMaterialBlock[];
  99203. /**
  99204. * Gets or sets the root nodes of the material fragment (pixel) shader
  99205. */
  99206. _fragmentOutputNodes: NodeMaterialBlock[];
  99207. /** Gets or sets options to control the node material overall behavior */
  99208. get options(): INodeMaterialOptions;
  99209. set options(options: INodeMaterialOptions);
  99210. /**
  99211. * Default configuration related to image processing available in the standard Material.
  99212. */
  99213. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  99214. /**
  99215. * Gets the image processing configuration used either in this material.
  99216. */
  99217. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  99218. /**
  99219. * Sets the Default image processing configuration used either in the this material.
  99220. *
  99221. * If sets to null, the scene one is in use.
  99222. */
  99223. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  99224. /**
  99225. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  99226. */
  99227. attachedBlocks: NodeMaterialBlock[];
  99228. /**
  99229. * Specifies the mode of the node material
  99230. * @hidden
  99231. */
  99232. _mode: NodeMaterialModes;
  99233. /**
  99234. * Gets the mode property
  99235. */
  99236. get mode(): NodeMaterialModes;
  99237. /**
  99238. * Create a new node based material
  99239. * @param name defines the material name
  99240. * @param scene defines the hosting scene
  99241. * @param options defines creation option
  99242. */
  99243. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  99244. /**
  99245. * Gets the current class name of the material e.g. "NodeMaterial"
  99246. * @returns the class name
  99247. */
  99248. getClassName(): string;
  99249. /**
  99250. * Keep track of the image processing observer to allow dispose and replace.
  99251. */
  99252. private _imageProcessingObserver;
  99253. /**
  99254. * Attaches a new image processing configuration to the Standard Material.
  99255. * @param configuration
  99256. */
  99257. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  99258. /**
  99259. * Get a block by its name
  99260. * @param name defines the name of the block to retrieve
  99261. * @returns the required block or null if not found
  99262. */
  99263. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  99264. /**
  99265. * Get a block by its name
  99266. * @param predicate defines the predicate used to find the good candidate
  99267. * @returns the required block or null if not found
  99268. */
  99269. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  99270. /**
  99271. * Get an input block by its name
  99272. * @param predicate defines the predicate used to find the good candidate
  99273. * @returns the required input block or null if not found
  99274. */
  99275. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  99276. /**
  99277. * Gets the list of input blocks attached to this material
  99278. * @returns an array of InputBlocks
  99279. */
  99280. getInputBlocks(): InputBlock[];
  99281. /**
  99282. * Adds a new optimizer to the list of optimizers
  99283. * @param optimizer defines the optimizers to add
  99284. * @returns the current material
  99285. */
  99286. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  99287. /**
  99288. * Remove an optimizer from the list of optimizers
  99289. * @param optimizer defines the optimizers to remove
  99290. * @returns the current material
  99291. */
  99292. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  99293. /**
  99294. * Add a new block to the list of output nodes
  99295. * @param node defines the node to add
  99296. * @returns the current material
  99297. */
  99298. addOutputNode(node: NodeMaterialBlock): this;
  99299. /**
  99300. * Remove a block from the list of root nodes
  99301. * @param node defines the node to remove
  99302. * @returns the current material
  99303. */
  99304. removeOutputNode(node: NodeMaterialBlock): this;
  99305. private _addVertexOutputNode;
  99306. private _removeVertexOutputNode;
  99307. private _addFragmentOutputNode;
  99308. private _removeFragmentOutputNode;
  99309. /**
  99310. * Specifies if the material will require alpha blending
  99311. * @returns a boolean specifying if alpha blending is needed
  99312. */
  99313. needAlphaBlending(): boolean;
  99314. /**
  99315. * Specifies if this material should be rendered in alpha test mode
  99316. * @returns a boolean specifying if an alpha test is needed.
  99317. */
  99318. needAlphaTesting(): boolean;
  99319. private _initializeBlock;
  99320. private _resetDualBlocks;
  99321. /**
  99322. * Remove a block from the current node material
  99323. * @param block defines the block to remove
  99324. */
  99325. removeBlock(block: NodeMaterialBlock): void;
  99326. /**
  99327. * Build the material and generates the inner effect
  99328. * @param verbose defines if the build should log activity
  99329. */
  99330. build(verbose?: boolean): void;
  99331. /**
  99332. * Runs an otpimization phase to try to improve the shader code
  99333. */
  99334. optimize(): void;
  99335. private _prepareDefinesForAttributes;
  99336. /**
  99337. * Create a post process from the material
  99338. * @param camera The camera to apply the render pass to.
  99339. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  99340. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  99341. * @param engine The engine which the post process will be applied. (default: current engine)
  99342. * @param reusable If the post process can be reused on the same frame. (default: false)
  99343. * @param textureType Type of textures used when performing the post process. (default: 0)
  99344. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  99345. * @returns the post process created
  99346. */
  99347. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  99348. /**
  99349. * Create the post process effect from the material
  99350. * @param postProcess The post process to create the effect for
  99351. */
  99352. createEffectForPostProcess(postProcess: PostProcess): void;
  99353. private _createEffectOrPostProcess;
  99354. private _createEffectForParticles;
  99355. /**
  99356. * Create the effect to be used as the custom effect for a particle system
  99357. * @param particleSystem Particle system to create the effect for
  99358. * @param onCompiled defines a function to call when the effect creation is successful
  99359. * @param onError defines a function to call when the effect creation has failed
  99360. */
  99361. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  99362. private _processDefines;
  99363. /**
  99364. * Get if the submesh is ready to be used and all its information available.
  99365. * Child classes can use it to update shaders
  99366. * @param mesh defines the mesh to check
  99367. * @param subMesh defines which submesh to check
  99368. * @param useInstances specifies that instances should be used
  99369. * @returns a boolean indicating that the submesh is ready or not
  99370. */
  99371. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  99372. /**
  99373. * Get a string representing the shaders built by the current node graph
  99374. */
  99375. get compiledShaders(): string;
  99376. /**
  99377. * Binds the world matrix to the material
  99378. * @param world defines the world transformation matrix
  99379. */
  99380. bindOnlyWorldMatrix(world: Matrix): void;
  99381. /**
  99382. * Binds the submesh to this material by preparing the effect and shader to draw
  99383. * @param world defines the world transformation matrix
  99384. * @param mesh defines the mesh containing the submesh
  99385. * @param subMesh defines the submesh to bind the material to
  99386. */
  99387. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  99388. /**
  99389. * Gets the active textures from the material
  99390. * @returns an array of textures
  99391. */
  99392. getActiveTextures(): BaseTexture[];
  99393. /**
  99394. * Gets the list of texture blocks
  99395. * @returns an array of texture blocks
  99396. */
  99397. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  99398. /**
  99399. * Specifies if the material uses a texture
  99400. * @param texture defines the texture to check against the material
  99401. * @returns a boolean specifying if the material uses the texture
  99402. */
  99403. hasTexture(texture: BaseTexture): boolean;
  99404. /**
  99405. * Disposes the material
  99406. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  99407. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  99408. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  99409. */
  99410. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  99411. /** Creates the node editor window. */
  99412. private _createNodeEditor;
  99413. /**
  99414. * Launch the node material editor
  99415. * @param config Define the configuration of the editor
  99416. * @return a promise fulfilled when the node editor is visible
  99417. */
  99418. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  99419. /**
  99420. * Clear the current material
  99421. */
  99422. clear(): void;
  99423. /**
  99424. * Clear the current material and set it to a default state
  99425. */
  99426. setToDefault(): void;
  99427. /**
  99428. * Clear the current material and set it to a default state for post process
  99429. */
  99430. setToDefaultPostProcess(): void;
  99431. /**
  99432. * Clear the current material and set it to a default state for particle
  99433. */
  99434. setToDefaultParticle(): void;
  99435. /**
  99436. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  99437. * @param url defines the url to load from
  99438. * @returns a promise that will fullfil when the material is fully loaded
  99439. */
  99440. loadAsync(url: string): Promise<void>;
  99441. private _gatherBlocks;
  99442. /**
  99443. * Generate a string containing the code declaration required to create an equivalent of this material
  99444. * @returns a string
  99445. */
  99446. generateCode(): string;
  99447. /**
  99448. * Serializes this material in a JSON representation
  99449. * @returns the serialized material object
  99450. */
  99451. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  99452. private _restoreConnections;
  99453. /**
  99454. * Clear the current graph and load a new one from a serialization object
  99455. * @param source defines the JSON representation of the material
  99456. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  99457. */
  99458. loadFromSerialization(source: any, rootUrl?: string): void;
  99459. /**
  99460. * Makes a duplicate of the current material.
  99461. * @param name - name to use for the new material.
  99462. */
  99463. clone(name: string): NodeMaterial;
  99464. /**
  99465. * Creates a node material from parsed material data
  99466. * @param source defines the JSON representation of the material
  99467. * @param scene defines the hosting scene
  99468. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  99469. * @returns a new node material
  99470. */
  99471. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  99472. /**
  99473. * Creates a node material from a snippet saved in a remote file
  99474. * @param name defines the name of the material to create
  99475. * @param url defines the url to load from
  99476. * @param scene defines the hosting scene
  99477. * @returns a promise that will resolve to the new node material
  99478. */
  99479. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  99480. /**
  99481. * Creates a node material from a snippet saved by the node material editor
  99482. * @param snippetId defines the snippet to load
  99483. * @param scene defines the hosting scene
  99484. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  99485. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  99486. * @returns a promise that will resolve to the new node material
  99487. */
  99488. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  99489. /**
  99490. * Creates a new node material set to default basic configuration
  99491. * @param name defines the name of the material
  99492. * @param scene defines the hosting scene
  99493. * @returns a new NodeMaterial
  99494. */
  99495. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  99496. }
  99497. }
  99498. declare module BABYLON {
  99499. /**
  99500. * Size options for a post process
  99501. */
  99502. export type PostProcessOptions = {
  99503. width: number;
  99504. height: number;
  99505. };
  99506. /**
  99507. * PostProcess can be used to apply a shader to a texture after it has been rendered
  99508. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  99509. */
  99510. export class PostProcess {
  99511. /** Name of the PostProcess. */
  99512. name: string;
  99513. /**
  99514. * Gets or sets the unique id of the post process
  99515. */
  99516. uniqueId: number;
  99517. /**
  99518. * Width of the texture to apply the post process on
  99519. */
  99520. width: number;
  99521. /**
  99522. * Height of the texture to apply the post process on
  99523. */
  99524. height: number;
  99525. /**
  99526. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  99527. */
  99528. nodeMaterialSource: Nullable<NodeMaterial>;
  99529. /**
  99530. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  99531. * @hidden
  99532. */
  99533. _outputTexture: Nullable<InternalTexture>;
  99534. /**
  99535. * Sampling mode used by the shader
  99536. * See https://doc.babylonjs.com/classes/3.1/texture
  99537. */
  99538. renderTargetSamplingMode: number;
  99539. /**
  99540. * Clear color to use when screen clearing
  99541. */
  99542. clearColor: Color4;
  99543. /**
  99544. * If the buffer needs to be cleared before applying the post process. (default: true)
  99545. * Should be set to false if shader will overwrite all previous pixels.
  99546. */
  99547. autoClear: boolean;
  99548. /**
  99549. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  99550. */
  99551. alphaMode: number;
  99552. /**
  99553. * Sets the setAlphaBlendConstants of the babylon engine
  99554. */
  99555. alphaConstants: Color4;
  99556. /**
  99557. * Animations to be used for the post processing
  99558. */
  99559. animations: Animation[];
  99560. /**
  99561. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  99562. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  99563. */
  99564. enablePixelPerfectMode: boolean;
  99565. /**
  99566. * Force the postprocess to be applied without taking in account viewport
  99567. */
  99568. forceFullscreenViewport: boolean;
  99569. /**
  99570. * List of inspectable custom properties (used by the Inspector)
  99571. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  99572. */
  99573. inspectableCustomProperties: IInspectable[];
  99574. /**
  99575. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  99576. *
  99577. * | Value | Type | Description |
  99578. * | ----- | ----------------------------------- | ----------- |
  99579. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  99580. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  99581. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  99582. *
  99583. */
  99584. scaleMode: number;
  99585. /**
  99586. * Force textures to be a power of two (default: false)
  99587. */
  99588. alwaysForcePOT: boolean;
  99589. private _samples;
  99590. /**
  99591. * Number of sample textures (default: 1)
  99592. */
  99593. get samples(): number;
  99594. set samples(n: number);
  99595. /**
  99596. * Modify the scale of the post process to be the same as the viewport (default: false)
  99597. */
  99598. adaptScaleToCurrentViewport: boolean;
  99599. private _camera;
  99600. private _scene;
  99601. private _engine;
  99602. private _options;
  99603. private _reusable;
  99604. private _textureType;
  99605. private _textureFormat;
  99606. /**
  99607. * Smart array of input and output textures for the post process.
  99608. * @hidden
  99609. */
  99610. _textures: SmartArray<InternalTexture>;
  99611. /**
  99612. * The index in _textures that corresponds to the output texture.
  99613. * @hidden
  99614. */
  99615. _currentRenderTextureInd: number;
  99616. private _effect;
  99617. private _samplers;
  99618. private _fragmentUrl;
  99619. private _vertexUrl;
  99620. private _parameters;
  99621. private _scaleRatio;
  99622. protected _indexParameters: any;
  99623. private _shareOutputWithPostProcess;
  99624. private _texelSize;
  99625. private _forcedOutputTexture;
  99626. /**
  99627. * Returns the fragment url or shader name used in the post process.
  99628. * @returns the fragment url or name in the shader store.
  99629. */
  99630. getEffectName(): string;
  99631. /**
  99632. * An event triggered when the postprocess is activated.
  99633. */
  99634. onActivateObservable: Observable<Camera>;
  99635. private _onActivateObserver;
  99636. /**
  99637. * A function that is added to the onActivateObservable
  99638. */
  99639. set onActivate(callback: Nullable<(camera: Camera) => void>);
  99640. /**
  99641. * An event triggered when the postprocess changes its size.
  99642. */
  99643. onSizeChangedObservable: Observable<PostProcess>;
  99644. private _onSizeChangedObserver;
  99645. /**
  99646. * A function that is added to the onSizeChangedObservable
  99647. */
  99648. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  99649. /**
  99650. * An event triggered when the postprocess applies its effect.
  99651. */
  99652. onApplyObservable: Observable<Effect>;
  99653. private _onApplyObserver;
  99654. /**
  99655. * A function that is added to the onApplyObservable
  99656. */
  99657. set onApply(callback: (effect: Effect) => void);
  99658. /**
  99659. * An event triggered before rendering the postprocess
  99660. */
  99661. onBeforeRenderObservable: Observable<Effect>;
  99662. private _onBeforeRenderObserver;
  99663. /**
  99664. * A function that is added to the onBeforeRenderObservable
  99665. */
  99666. set onBeforeRender(callback: (effect: Effect) => void);
  99667. /**
  99668. * An event triggered after rendering the postprocess
  99669. */
  99670. onAfterRenderObservable: Observable<Effect>;
  99671. private _onAfterRenderObserver;
  99672. /**
  99673. * A function that is added to the onAfterRenderObservable
  99674. */
  99675. set onAfterRender(callback: (efect: Effect) => void);
  99676. /**
  99677. * 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
  99678. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  99679. */
  99680. get inputTexture(): InternalTexture;
  99681. set inputTexture(value: InternalTexture);
  99682. /**
  99683. * Gets the camera which post process is applied to.
  99684. * @returns The camera the post process is applied to.
  99685. */
  99686. getCamera(): Camera;
  99687. /**
  99688. * Gets the texel size of the postprocess.
  99689. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  99690. */
  99691. get texelSize(): Vector2;
  99692. /**
  99693. * Creates a new instance PostProcess
  99694. * @param name The name of the PostProcess.
  99695. * @param fragmentUrl The url of the fragment shader to be used.
  99696. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  99697. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  99698. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  99699. * @param camera The camera to apply the render pass to.
  99700. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  99701. * @param engine The engine which the post process will be applied. (default: current engine)
  99702. * @param reusable If the post process can be reused on the same frame. (default: false)
  99703. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  99704. * @param textureType Type of textures used when performing the post process. (default: 0)
  99705. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  99706. * @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
  99707. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  99708. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  99709. */
  99710. constructor(
  99711. /** Name of the PostProcess. */
  99712. 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);
  99713. /**
  99714. * Gets a string idenfifying the name of the class
  99715. * @returns "PostProcess" string
  99716. */
  99717. getClassName(): string;
  99718. /**
  99719. * Gets the engine which this post process belongs to.
  99720. * @returns The engine the post process was enabled with.
  99721. */
  99722. getEngine(): Engine;
  99723. /**
  99724. * The effect that is created when initializing the post process.
  99725. * @returns The created effect corresponding the the postprocess.
  99726. */
  99727. getEffect(): Effect;
  99728. /**
  99729. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  99730. * @param postProcess The post process to share the output with.
  99731. * @returns This post process.
  99732. */
  99733. shareOutputWith(postProcess: PostProcess): PostProcess;
  99734. /**
  99735. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  99736. * This should be called if the post process that shares output with this post process is disabled/disposed.
  99737. */
  99738. useOwnOutput(): void;
  99739. /**
  99740. * Updates the effect with the current post process compile time values and recompiles the shader.
  99741. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  99742. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  99743. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  99744. * @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
  99745. * @param onCompiled Called when the shader has been compiled.
  99746. * @param onError Called if there is an error when compiling a shader.
  99747. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  99748. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  99749. */
  99750. 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;
  99751. /**
  99752. * The post process is reusable if it can be used multiple times within one frame.
  99753. * @returns If the post process is reusable
  99754. */
  99755. isReusable(): boolean;
  99756. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  99757. markTextureDirty(): void;
  99758. /**
  99759. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  99760. * 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.
  99761. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  99762. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  99763. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  99764. * @returns The target texture that was bound to be written to.
  99765. */
  99766. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  99767. /**
  99768. * If the post process is supported.
  99769. */
  99770. get isSupported(): boolean;
  99771. /**
  99772. * The aspect ratio of the output texture.
  99773. */
  99774. get aspectRatio(): number;
  99775. /**
  99776. * Get a value indicating if the post-process is ready to be used
  99777. * @returns true if the post-process is ready (shader is compiled)
  99778. */
  99779. isReady(): boolean;
  99780. /**
  99781. * Binds all textures and uniforms to the shader, this will be run on every pass.
  99782. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  99783. */
  99784. apply(): Nullable<Effect>;
  99785. private _disposeTextures;
  99786. /**
  99787. * Disposes the post process.
  99788. * @param camera The camera to dispose the post process on.
  99789. */
  99790. dispose(camera?: Camera): void;
  99791. }
  99792. }
  99793. declare module BABYLON {
  99794. /** @hidden */
  99795. export var kernelBlurVaryingDeclaration: {
  99796. name: string;
  99797. shader: string;
  99798. };
  99799. }
  99800. declare module BABYLON {
  99801. /** @hidden */
  99802. export var kernelBlurFragment: {
  99803. name: string;
  99804. shader: string;
  99805. };
  99806. }
  99807. declare module BABYLON {
  99808. /** @hidden */
  99809. export var kernelBlurFragment2: {
  99810. name: string;
  99811. shader: string;
  99812. };
  99813. }
  99814. declare module BABYLON {
  99815. /** @hidden */
  99816. export var kernelBlurPixelShader: {
  99817. name: string;
  99818. shader: string;
  99819. };
  99820. }
  99821. declare module BABYLON {
  99822. /** @hidden */
  99823. export var kernelBlurVertex: {
  99824. name: string;
  99825. shader: string;
  99826. };
  99827. }
  99828. declare module BABYLON {
  99829. /** @hidden */
  99830. export var kernelBlurVertexShader: {
  99831. name: string;
  99832. shader: string;
  99833. };
  99834. }
  99835. declare module BABYLON {
  99836. /**
  99837. * The Blur Post Process which blurs an image based on a kernel and direction.
  99838. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  99839. */
  99840. export class BlurPostProcess extends PostProcess {
  99841. /** The direction in which to blur the image. */
  99842. direction: Vector2;
  99843. private blockCompilation;
  99844. protected _kernel: number;
  99845. protected _idealKernel: number;
  99846. protected _packedFloat: boolean;
  99847. private _staticDefines;
  99848. /**
  99849. * Sets the length in pixels of the blur sample region
  99850. */
  99851. set kernel(v: number);
  99852. /**
  99853. * Gets the length in pixels of the blur sample region
  99854. */
  99855. get kernel(): number;
  99856. /**
  99857. * Sets wether or not the blur needs to unpack/repack floats
  99858. */
  99859. set packedFloat(v: boolean);
  99860. /**
  99861. * Gets wether or not the blur is unpacking/repacking floats
  99862. */
  99863. get packedFloat(): boolean;
  99864. /**
  99865. * Creates a new instance BlurPostProcess
  99866. * @param name The name of the effect.
  99867. * @param direction The direction in which to blur the image.
  99868. * @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.
  99869. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  99870. * @param camera The camera to apply the render pass to.
  99871. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  99872. * @param engine The engine which the post process will be applied. (default: current engine)
  99873. * @param reusable If the post process can be reused on the same frame. (default: false)
  99874. * @param textureType Type of textures used when performing the post process. (default: 0)
  99875. * @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)
  99876. */
  99877. constructor(name: string,
  99878. /** The direction in which to blur the image. */
  99879. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  99880. /**
  99881. * Updates the effect with the current post process compile time values and recompiles the shader.
  99882. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  99883. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  99884. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  99885. * @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
  99886. * @param onCompiled Called when the shader has been compiled.
  99887. * @param onError Called if there is an error when compiling a shader.
  99888. */
  99889. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  99890. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  99891. /**
  99892. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  99893. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  99894. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  99895. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  99896. * The gaps between physical kernels are compensated for in the weighting of the samples
  99897. * @param idealKernel Ideal blur kernel.
  99898. * @return Nearest best kernel.
  99899. */
  99900. protected _nearestBestKernel(idealKernel: number): number;
  99901. /**
  99902. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  99903. * @param x The point on the Gaussian distribution to sample.
  99904. * @return the value of the Gaussian function at x.
  99905. */
  99906. protected _gaussianWeight(x: number): number;
  99907. /**
  99908. * Generates a string that can be used as a floating point number in GLSL.
  99909. * @param x Value to print.
  99910. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  99911. * @return GLSL float string.
  99912. */
  99913. protected _glslFloat(x: number, decimalFigures?: number): string;
  99914. }
  99915. }
  99916. declare module BABYLON {
  99917. /**
  99918. * Mirror texture can be used to simulate the view from a mirror in a scene.
  99919. * It will dynamically be rendered every frame to adapt to the camera point of view.
  99920. * You can then easily use it as a reflectionTexture on a flat surface.
  99921. * In case the surface is not a plane, please consider relying on reflection probes.
  99922. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  99923. */
  99924. export class MirrorTexture extends RenderTargetTexture {
  99925. private scene;
  99926. /**
  99927. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  99928. * 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.
  99929. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  99930. */
  99931. mirrorPlane: Plane;
  99932. /**
  99933. * Define the blur ratio used to blur the reflection if needed.
  99934. */
  99935. set blurRatio(value: number);
  99936. get blurRatio(): number;
  99937. /**
  99938. * Define the adaptive blur kernel used to blur the reflection if needed.
  99939. * This will autocompute the closest best match for the `blurKernel`
  99940. */
  99941. set adaptiveBlurKernel(value: number);
  99942. /**
  99943. * Define the blur kernel used to blur the reflection if needed.
  99944. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  99945. */
  99946. set blurKernel(value: number);
  99947. /**
  99948. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  99949. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  99950. */
  99951. set blurKernelX(value: number);
  99952. get blurKernelX(): number;
  99953. /**
  99954. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  99955. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  99956. */
  99957. set blurKernelY(value: number);
  99958. get blurKernelY(): number;
  99959. private _autoComputeBlurKernel;
  99960. protected _onRatioRescale(): void;
  99961. private _updateGammaSpace;
  99962. private _imageProcessingConfigChangeObserver;
  99963. private _transformMatrix;
  99964. private _mirrorMatrix;
  99965. private _savedViewMatrix;
  99966. private _blurX;
  99967. private _blurY;
  99968. private _adaptiveBlurKernel;
  99969. private _blurKernelX;
  99970. private _blurKernelY;
  99971. private _blurRatio;
  99972. /**
  99973. * Instantiates a Mirror Texture.
  99974. * Mirror texture can be used to simulate the view from a mirror in a scene.
  99975. * It will dynamically be rendered every frame to adapt to the camera point of view.
  99976. * You can then easily use it as a reflectionTexture on a flat surface.
  99977. * In case the surface is not a plane, please consider relying on reflection probes.
  99978. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  99979. * @param name
  99980. * @param size
  99981. * @param scene
  99982. * @param generateMipMaps
  99983. * @param type
  99984. * @param samplingMode
  99985. * @param generateDepthBuffer
  99986. */
  99987. constructor(name: string, size: number | {
  99988. width: number;
  99989. height: number;
  99990. } | {
  99991. ratio: number;
  99992. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  99993. private _preparePostProcesses;
  99994. /**
  99995. * Clone the mirror texture.
  99996. * @returns the cloned texture
  99997. */
  99998. clone(): MirrorTexture;
  99999. /**
  100000. * Serialize the texture to a JSON representation you could use in Parse later on
  100001. * @returns the serialized JSON representation
  100002. */
  100003. serialize(): any;
  100004. /**
  100005. * Dispose the texture and release its associated resources.
  100006. */
  100007. dispose(): void;
  100008. }
  100009. }
  100010. declare module BABYLON {
  100011. /**
  100012. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  100013. * @see http://doc.babylonjs.com/babylon101/materials#texture
  100014. */
  100015. export class Texture extends BaseTexture {
  100016. /**
  100017. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  100018. */
  100019. static SerializeBuffers: boolean;
  100020. /** @hidden */
  100021. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  100022. /** @hidden */
  100023. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  100024. /** @hidden */
  100025. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  100026. /** nearest is mag = nearest and min = nearest and mip = linear */
  100027. static readonly NEAREST_SAMPLINGMODE: number;
  100028. /** nearest is mag = nearest and min = nearest and mip = linear */
  100029. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  100030. /** Bilinear is mag = linear and min = linear and mip = nearest */
  100031. static readonly BILINEAR_SAMPLINGMODE: number;
  100032. /** Bilinear is mag = linear and min = linear and mip = nearest */
  100033. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  100034. /** Trilinear is mag = linear and min = linear and mip = linear */
  100035. static readonly TRILINEAR_SAMPLINGMODE: number;
  100036. /** Trilinear is mag = linear and min = linear and mip = linear */
  100037. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  100038. /** mag = nearest and min = nearest and mip = nearest */
  100039. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  100040. /** mag = nearest and min = linear and mip = nearest */
  100041. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  100042. /** mag = nearest and min = linear and mip = linear */
  100043. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  100044. /** mag = nearest and min = linear and mip = none */
  100045. static readonly NEAREST_LINEAR: number;
  100046. /** mag = nearest and min = nearest and mip = none */
  100047. static readonly NEAREST_NEAREST: number;
  100048. /** mag = linear and min = nearest and mip = nearest */
  100049. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  100050. /** mag = linear and min = nearest and mip = linear */
  100051. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  100052. /** mag = linear and min = linear and mip = none */
  100053. static readonly LINEAR_LINEAR: number;
  100054. /** mag = linear and min = nearest and mip = none */
  100055. static readonly LINEAR_NEAREST: number;
  100056. /** Explicit coordinates mode */
  100057. static readonly EXPLICIT_MODE: number;
  100058. /** Spherical coordinates mode */
  100059. static readonly SPHERICAL_MODE: number;
  100060. /** Planar coordinates mode */
  100061. static readonly PLANAR_MODE: number;
  100062. /** Cubic coordinates mode */
  100063. static readonly CUBIC_MODE: number;
  100064. /** Projection coordinates mode */
  100065. static readonly PROJECTION_MODE: number;
  100066. /** Inverse Cubic coordinates mode */
  100067. static readonly SKYBOX_MODE: number;
  100068. /** Inverse Cubic coordinates mode */
  100069. static readonly INVCUBIC_MODE: number;
  100070. /** Equirectangular coordinates mode */
  100071. static readonly EQUIRECTANGULAR_MODE: number;
  100072. /** Equirectangular Fixed coordinates mode */
  100073. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  100074. /** Equirectangular Fixed Mirrored coordinates mode */
  100075. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  100076. /** Texture is not repeating outside of 0..1 UVs */
  100077. static readonly CLAMP_ADDRESSMODE: number;
  100078. /** Texture is repeating outside of 0..1 UVs */
  100079. static readonly WRAP_ADDRESSMODE: number;
  100080. /** Texture is repeating and mirrored */
  100081. static readonly MIRROR_ADDRESSMODE: number;
  100082. /**
  100083. * 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
  100084. */
  100085. static UseSerializedUrlIfAny: boolean;
  100086. /**
  100087. * Define the url of the texture.
  100088. */
  100089. url: Nullable<string>;
  100090. /**
  100091. * Define an offset on the texture to offset the u coordinates of the UVs
  100092. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  100093. */
  100094. uOffset: number;
  100095. /**
  100096. * Define an offset on the texture to offset the v coordinates of the UVs
  100097. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  100098. */
  100099. vOffset: number;
  100100. /**
  100101. * Define an offset on the texture to scale the u coordinates of the UVs
  100102. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  100103. */
  100104. uScale: number;
  100105. /**
  100106. * Define an offset on the texture to scale the v coordinates of the UVs
  100107. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  100108. */
  100109. vScale: number;
  100110. /**
  100111. * Define an offset on the texture to rotate around the u coordinates of the UVs
  100112. * @see http://doc.babylonjs.com/how_to/more_materials
  100113. */
  100114. uAng: number;
  100115. /**
  100116. * Define an offset on the texture to rotate around the v coordinates of the UVs
  100117. * @see http://doc.babylonjs.com/how_to/more_materials
  100118. */
  100119. vAng: number;
  100120. /**
  100121. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  100122. * @see http://doc.babylonjs.com/how_to/more_materials
  100123. */
  100124. wAng: number;
  100125. /**
  100126. * Defines the center of rotation (U)
  100127. */
  100128. uRotationCenter: number;
  100129. /**
  100130. * Defines the center of rotation (V)
  100131. */
  100132. vRotationCenter: number;
  100133. /**
  100134. * Defines the center of rotation (W)
  100135. */
  100136. wRotationCenter: number;
  100137. /**
  100138. * Are mip maps generated for this texture or not.
  100139. */
  100140. get noMipmap(): boolean;
  100141. /**
  100142. * List of inspectable custom properties (used by the Inspector)
  100143. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  100144. */
  100145. inspectableCustomProperties: Nullable<IInspectable[]>;
  100146. private _noMipmap;
  100147. /** @hidden */
  100148. _invertY: boolean;
  100149. private _rowGenerationMatrix;
  100150. private _cachedTextureMatrix;
  100151. private _projectionModeMatrix;
  100152. private _t0;
  100153. private _t1;
  100154. private _t2;
  100155. private _cachedUOffset;
  100156. private _cachedVOffset;
  100157. private _cachedUScale;
  100158. private _cachedVScale;
  100159. private _cachedUAng;
  100160. private _cachedVAng;
  100161. private _cachedWAng;
  100162. private _cachedProjectionMatrixId;
  100163. private _cachedCoordinatesMode;
  100164. /** @hidden */
  100165. protected _initialSamplingMode: number;
  100166. /** @hidden */
  100167. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  100168. private _deleteBuffer;
  100169. protected _format: Nullable<number>;
  100170. private _delayedOnLoad;
  100171. private _delayedOnError;
  100172. private _mimeType?;
  100173. /**
  100174. * Observable triggered once the texture has been loaded.
  100175. */
  100176. onLoadObservable: Observable<Texture>;
  100177. protected _isBlocking: boolean;
  100178. /**
  100179. * Is the texture preventing material to render while loading.
  100180. * If false, a default texture will be used instead of the loading one during the preparation step.
  100181. */
  100182. set isBlocking(value: boolean);
  100183. get isBlocking(): boolean;
  100184. /**
  100185. * Get the current sampling mode associated with the texture.
  100186. */
  100187. get samplingMode(): number;
  100188. /**
  100189. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  100190. */
  100191. get invertY(): boolean;
  100192. /**
  100193. * Instantiates a new texture.
  100194. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  100195. * @see http://doc.babylonjs.com/babylon101/materials#texture
  100196. * @param url defines the url of the picture to load as a texture
  100197. * @param sceneOrEngine defines the scene or engine the texture will belong to
  100198. * @param noMipmap defines if the texture will require mip maps or not
  100199. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  100200. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  100201. * @param onLoad defines a callback triggered when the texture has been loaded
  100202. * @param onError defines a callback triggered when an error occurred during the loading session
  100203. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  100204. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  100205. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  100206. * @param mimeType defines an optional mime type information
  100207. */
  100208. 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);
  100209. /**
  100210. * Update the url (and optional buffer) of this texture if url was null during construction.
  100211. * @param url the url of the texture
  100212. * @param buffer the buffer of the texture (defaults to null)
  100213. * @param onLoad callback called when the texture is loaded (defaults to null)
  100214. */
  100215. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  100216. /**
  100217. * Finish the loading sequence of a texture flagged as delayed load.
  100218. * @hidden
  100219. */
  100220. delayLoad(): void;
  100221. private _prepareRowForTextureGeneration;
  100222. /**
  100223. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  100224. * @returns the transform matrix of the texture.
  100225. */
  100226. getTextureMatrix(uBase?: number): Matrix;
  100227. /**
  100228. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  100229. * @returns The reflection texture transform
  100230. */
  100231. getReflectionTextureMatrix(): Matrix;
  100232. /**
  100233. * Clones the texture.
  100234. * @returns the cloned texture
  100235. */
  100236. clone(): Texture;
  100237. /**
  100238. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  100239. * @returns The JSON representation of the texture
  100240. */
  100241. serialize(): any;
  100242. /**
  100243. * Get the current class name of the texture useful for serialization or dynamic coding.
  100244. * @returns "Texture"
  100245. */
  100246. getClassName(): string;
  100247. /**
  100248. * Dispose the texture and release its associated resources.
  100249. */
  100250. dispose(): void;
  100251. /**
  100252. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  100253. * @param parsedTexture Define the JSON representation of the texture
  100254. * @param scene Define the scene the parsed texture should be instantiated in
  100255. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  100256. * @returns The parsed texture if successful
  100257. */
  100258. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  100259. /**
  100260. * Creates a texture from its base 64 representation.
  100261. * @param data Define the base64 payload without the data: prefix
  100262. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  100263. * @param scene Define the scene the texture should belong to
  100264. * @param noMipmap Forces the texture to not create mip map information if true
  100265. * @param invertY define if the texture needs to be inverted on the y axis during loading
  100266. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  100267. * @param onLoad define a callback triggered when the texture has been loaded
  100268. * @param onError define a callback triggered when an error occurred during the loading session
  100269. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  100270. * @returns the created texture
  100271. */
  100272. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  100273. /**
  100274. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  100275. * @param data Define the base64 payload without the data: prefix
  100276. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  100277. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  100278. * @param scene Define the scene the texture should belong to
  100279. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  100280. * @param noMipmap Forces the texture to not create mip map information if true
  100281. * @param invertY define if the texture needs to be inverted on the y axis during loading
  100282. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  100283. * @param onLoad define a callback triggered when the texture has been loaded
  100284. * @param onError define a callback triggered when an error occurred during the loading session
  100285. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  100286. * @returns the created texture
  100287. */
  100288. 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;
  100289. }
  100290. }
  100291. declare module BABYLON {
  100292. /**
  100293. * PostProcessManager is used to manage one or more post processes or post process pipelines
  100294. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  100295. */
  100296. export class PostProcessManager {
  100297. private _scene;
  100298. private _indexBuffer;
  100299. private _vertexBuffers;
  100300. /**
  100301. * Creates a new instance PostProcess
  100302. * @param scene The scene that the post process is associated with.
  100303. */
  100304. constructor(scene: Scene);
  100305. private _prepareBuffers;
  100306. private _buildIndexBuffer;
  100307. /**
  100308. * Rebuilds the vertex buffers of the manager.
  100309. * @hidden
  100310. */
  100311. _rebuild(): void;
  100312. /**
  100313. * Prepares a frame to be run through a post process.
  100314. * @param sourceTexture The input texture to the post procesess. (default: null)
  100315. * @param postProcesses An array of post processes to be run. (default: null)
  100316. * @returns True if the post processes were able to be run.
  100317. * @hidden
  100318. */
  100319. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  100320. /**
  100321. * Manually render a set of post processes to a texture.
  100322. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  100323. * @param postProcesses An array of post processes to be run.
  100324. * @param targetTexture The target texture to render to.
  100325. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  100326. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  100327. * @param lodLevel defines which lod of the texture to render to
  100328. */
  100329. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  100330. /**
  100331. * Finalize the result of the output of the postprocesses.
  100332. * @param doNotPresent If true the result will not be displayed to the screen.
  100333. * @param targetTexture The target texture to render to.
  100334. * @param faceIndex The index of the face to bind the target texture to.
  100335. * @param postProcesses The array of post processes to render.
  100336. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  100337. * @hidden
  100338. */
  100339. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  100340. /**
  100341. * Disposes of the post process manager.
  100342. */
  100343. dispose(): void;
  100344. }
  100345. }
  100346. declare module BABYLON {
  100347. /**
  100348. * This Helps creating a texture that will be created from a camera in your scene.
  100349. * It is basically a dynamic texture that could be used to create special effects for instance.
  100350. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  100351. */
  100352. export class RenderTargetTexture extends Texture {
  100353. isCube: boolean;
  100354. /**
  100355. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  100356. */
  100357. static readonly REFRESHRATE_RENDER_ONCE: number;
  100358. /**
  100359. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  100360. */
  100361. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  100362. /**
  100363. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  100364. * the central point of your effect and can save a lot of performances.
  100365. */
  100366. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  100367. /**
  100368. * Use this predicate to dynamically define the list of mesh you want to render.
  100369. * If set, the renderList property will be overwritten.
  100370. */
  100371. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  100372. private _renderList;
  100373. /**
  100374. * Use this list to define the list of mesh you want to render.
  100375. */
  100376. get renderList(): Nullable<Array<AbstractMesh>>;
  100377. set renderList(value: Nullable<Array<AbstractMesh>>);
  100378. /**
  100379. * Use this function to overload the renderList array at rendering time.
  100380. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  100381. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  100382. * the cube (if the RTT is a cube, else layerOrFace=0).
  100383. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  100384. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  100385. * hold dummy elements!
  100386. */
  100387. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  100388. private _hookArray;
  100389. /**
  100390. * Define if particles should be rendered in your texture.
  100391. */
  100392. renderParticles: boolean;
  100393. /**
  100394. * Define if sprites should be rendered in your texture.
  100395. */
  100396. renderSprites: boolean;
  100397. /**
  100398. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  100399. */
  100400. coordinatesMode: number;
  100401. /**
  100402. * Define the camera used to render the texture.
  100403. */
  100404. activeCamera: Nullable<Camera>;
  100405. /**
  100406. * Override the mesh isReady function with your own one.
  100407. */
  100408. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  100409. /**
  100410. * Override the render function of the texture with your own one.
  100411. */
  100412. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  100413. /**
  100414. * Define if camera post processes should be use while rendering the texture.
  100415. */
  100416. useCameraPostProcesses: boolean;
  100417. /**
  100418. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  100419. */
  100420. ignoreCameraViewport: boolean;
  100421. private _postProcessManager;
  100422. private _postProcesses;
  100423. private _resizeObserver;
  100424. /**
  100425. * An event triggered when the texture is unbind.
  100426. */
  100427. onBeforeBindObservable: Observable<RenderTargetTexture>;
  100428. /**
  100429. * An event triggered when the texture is unbind.
  100430. */
  100431. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  100432. private _onAfterUnbindObserver;
  100433. /**
  100434. * Set a after unbind callback in the texture.
  100435. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  100436. */
  100437. set onAfterUnbind(callback: () => void);
  100438. /**
  100439. * An event triggered before rendering the texture
  100440. */
  100441. onBeforeRenderObservable: Observable<number>;
  100442. private _onBeforeRenderObserver;
  100443. /**
  100444. * Set a before render callback in the texture.
  100445. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  100446. */
  100447. set onBeforeRender(callback: (faceIndex: number) => void);
  100448. /**
  100449. * An event triggered after rendering the texture
  100450. */
  100451. onAfterRenderObservable: Observable<number>;
  100452. private _onAfterRenderObserver;
  100453. /**
  100454. * Set a after render callback in the texture.
  100455. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  100456. */
  100457. set onAfterRender(callback: (faceIndex: number) => void);
  100458. /**
  100459. * An event triggered after the texture clear
  100460. */
  100461. onClearObservable: Observable<Engine>;
  100462. private _onClearObserver;
  100463. /**
  100464. * Set a clear callback in the texture.
  100465. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  100466. */
  100467. set onClear(callback: (Engine: Engine) => void);
  100468. /**
  100469. * An event triggered when the texture is resized.
  100470. */
  100471. onResizeObservable: Observable<RenderTargetTexture>;
  100472. /**
  100473. * Define the clear color of the Render Target if it should be different from the scene.
  100474. */
  100475. clearColor: Color4;
  100476. protected _size: number | {
  100477. width: number;
  100478. height: number;
  100479. layers?: number;
  100480. };
  100481. protected _initialSizeParameter: number | {
  100482. width: number;
  100483. height: number;
  100484. } | {
  100485. ratio: number;
  100486. };
  100487. protected _sizeRatio: Nullable<number>;
  100488. /** @hidden */
  100489. _generateMipMaps: boolean;
  100490. protected _renderingManager: RenderingManager;
  100491. /** @hidden */
  100492. _waitingRenderList: string[];
  100493. protected _doNotChangeAspectRatio: boolean;
  100494. protected _currentRefreshId: number;
  100495. protected _refreshRate: number;
  100496. protected _textureMatrix: Matrix;
  100497. protected _samples: number;
  100498. protected _renderTargetOptions: RenderTargetCreationOptions;
  100499. /**
  100500. * Gets render target creation options that were used.
  100501. */
  100502. get renderTargetOptions(): RenderTargetCreationOptions;
  100503. protected _onRatioRescale(): void;
  100504. /**
  100505. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  100506. * It must define where the camera used to render the texture is set
  100507. */
  100508. boundingBoxPosition: Vector3;
  100509. private _boundingBoxSize;
  100510. /**
  100511. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  100512. * When defined, the cubemap will switch to local mode
  100513. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  100514. * @example https://www.babylonjs-playground.com/#RNASML
  100515. */
  100516. set boundingBoxSize(value: Vector3);
  100517. get boundingBoxSize(): Vector3;
  100518. /**
  100519. * In case the RTT has been created with a depth texture, get the associated
  100520. * depth texture.
  100521. * Otherwise, return null.
  100522. */
  100523. get depthStencilTexture(): Nullable<InternalTexture>;
  100524. /**
  100525. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  100526. * or used a shadow, depth texture...
  100527. * @param name The friendly name of the texture
  100528. * @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)
  100529. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  100530. * @param generateMipMaps True if mip maps need to be generated after render.
  100531. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  100532. * @param type The type of the buffer in the RTT (int, half float, float...)
  100533. * @param isCube True if a cube texture needs to be created
  100534. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  100535. * @param generateDepthBuffer True to generate a depth buffer
  100536. * @param generateStencilBuffer True to generate a stencil buffer
  100537. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  100538. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  100539. * @param delayAllocation if the texture allocation should be delayed (default: false)
  100540. */
  100541. constructor(name: string, size: number | {
  100542. width: number;
  100543. height: number;
  100544. layers?: number;
  100545. } | {
  100546. ratio: number;
  100547. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  100548. /**
  100549. * Creates a depth stencil texture.
  100550. * This is only available in WebGL 2 or with the depth texture extension available.
  100551. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  100552. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  100553. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  100554. */
  100555. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  100556. private _processSizeParameter;
  100557. /**
  100558. * Define the number of samples to use in case of MSAA.
  100559. * It defaults to one meaning no MSAA has been enabled.
  100560. */
  100561. get samples(): number;
  100562. set samples(value: number);
  100563. /**
  100564. * Resets the refresh counter of the texture and start bak from scratch.
  100565. * Could be useful to regenerate the texture if it is setup to render only once.
  100566. */
  100567. resetRefreshCounter(): void;
  100568. /**
  100569. * Define the refresh rate of the texture or the rendering frequency.
  100570. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  100571. */
  100572. get refreshRate(): number;
  100573. set refreshRate(value: number);
  100574. /**
  100575. * Adds a post process to the render target rendering passes.
  100576. * @param postProcess define the post process to add
  100577. */
  100578. addPostProcess(postProcess: PostProcess): void;
  100579. /**
  100580. * Clear all the post processes attached to the render target
  100581. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  100582. */
  100583. clearPostProcesses(dispose?: boolean): void;
  100584. /**
  100585. * Remove one of the post process from the list of attached post processes to the texture
  100586. * @param postProcess define the post process to remove from the list
  100587. */
  100588. removePostProcess(postProcess: PostProcess): void;
  100589. /** @hidden */
  100590. _shouldRender(): boolean;
  100591. /**
  100592. * Gets the actual render size of the texture.
  100593. * @returns the width of the render size
  100594. */
  100595. getRenderSize(): number;
  100596. /**
  100597. * Gets the actual render width of the texture.
  100598. * @returns the width of the render size
  100599. */
  100600. getRenderWidth(): number;
  100601. /**
  100602. * Gets the actual render height of the texture.
  100603. * @returns the height of the render size
  100604. */
  100605. getRenderHeight(): number;
  100606. /**
  100607. * Gets the actual number of layers of the texture.
  100608. * @returns the number of layers
  100609. */
  100610. getRenderLayers(): number;
  100611. /**
  100612. * Get if the texture can be rescaled or not.
  100613. */
  100614. get canRescale(): boolean;
  100615. /**
  100616. * Resize the texture using a ratio.
  100617. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  100618. */
  100619. scale(ratio: number): void;
  100620. /**
  100621. * Get the texture reflection matrix used to rotate/transform the reflection.
  100622. * @returns the reflection matrix
  100623. */
  100624. getReflectionTextureMatrix(): Matrix;
  100625. /**
  100626. * Resize the texture to a new desired size.
  100627. * Be carrefull as it will recreate all the data in the new texture.
  100628. * @param size Define the new size. It can be:
  100629. * - a number for squared texture,
  100630. * - an object containing { width: number, height: number }
  100631. * - or an object containing a ratio { ratio: number }
  100632. */
  100633. resize(size: number | {
  100634. width: number;
  100635. height: number;
  100636. } | {
  100637. ratio: number;
  100638. }): void;
  100639. private _defaultRenderListPrepared;
  100640. /**
  100641. * Renders all the objects from the render list into the texture.
  100642. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  100643. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  100644. */
  100645. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  100646. private _bestReflectionRenderTargetDimension;
  100647. private _prepareRenderingManager;
  100648. /**
  100649. * @hidden
  100650. * @param faceIndex face index to bind to if this is a cubetexture
  100651. * @param layer defines the index of the texture to bind in the array
  100652. */
  100653. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  100654. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  100655. private renderToTarget;
  100656. /**
  100657. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  100658. * This allowed control for front to back rendering or reversly depending of the special needs.
  100659. *
  100660. * @param renderingGroupId The rendering group id corresponding to its index
  100661. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  100662. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  100663. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  100664. */
  100665. 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;
  100666. /**
  100667. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  100668. *
  100669. * @param renderingGroupId The rendering group id corresponding to its index
  100670. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  100671. */
  100672. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  100673. /**
  100674. * Clones the texture.
  100675. * @returns the cloned texture
  100676. */
  100677. clone(): RenderTargetTexture;
  100678. /**
  100679. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  100680. * @returns The JSON representation of the texture
  100681. */
  100682. serialize(): any;
  100683. /**
  100684. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  100685. */
  100686. disposeFramebufferObjects(): void;
  100687. /**
  100688. * Dispose the texture and release its associated resources.
  100689. */
  100690. dispose(): void;
  100691. /** @hidden */
  100692. _rebuild(): void;
  100693. /**
  100694. * Clear the info related to rendering groups preventing retention point in material dispose.
  100695. */
  100696. freeRenderingGroups(): void;
  100697. /**
  100698. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  100699. * @returns the view count
  100700. */
  100701. getViewCount(): number;
  100702. }
  100703. }
  100704. declare module BABYLON {
  100705. /**
  100706. * Class used to manipulate GUIDs
  100707. */
  100708. export class GUID {
  100709. /**
  100710. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  100711. * Be aware Math.random() could cause collisions, but:
  100712. * "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"
  100713. * @returns a pseudo random id
  100714. */
  100715. static RandomId(): string;
  100716. }
  100717. }
  100718. declare module BABYLON {
  100719. /**
  100720. * Options to be used when creating a shadow depth material
  100721. */
  100722. export interface IIOptionShadowDepthMaterial {
  100723. /** Variables in the vertex shader code that need to have their names remapped.
  100724. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  100725. * "var_name" should be either: worldPos or vNormalW
  100726. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  100727. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  100728. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  100729. */
  100730. remappedVariables?: string[];
  100731. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  100732. standalone?: boolean;
  100733. }
  100734. /**
  100735. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  100736. */
  100737. export class ShadowDepthWrapper {
  100738. private _scene;
  100739. private _options?;
  100740. private _baseMaterial;
  100741. private _onEffectCreatedObserver;
  100742. private _subMeshToEffect;
  100743. private _subMeshToDepthEffect;
  100744. private _meshes;
  100745. /** @hidden */
  100746. _matriceNames: any;
  100747. /** Gets the standalone status of the wrapper */
  100748. get standalone(): boolean;
  100749. /** Gets the base material the wrapper is built upon */
  100750. get baseMaterial(): Material;
  100751. /**
  100752. * Instantiate a new shadow depth wrapper.
  100753. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  100754. * generate the shadow depth map. For more information, please refer to the documentation:
  100755. * https://doc.babylonjs.com/babylon101/shadows
  100756. * @param baseMaterial Material to wrap
  100757. * @param scene Define the scene the material belongs to
  100758. * @param options Options used to create the wrapper
  100759. */
  100760. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  100761. /**
  100762. * Gets the effect to use to generate the depth map
  100763. * @param subMesh subMesh to get the effect for
  100764. * @param shadowGenerator shadow generator to get the effect for
  100765. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  100766. */
  100767. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  100768. /**
  100769. * Specifies that the submesh is ready to be used for depth rendering
  100770. * @param subMesh submesh to check
  100771. * @param defines the list of defines to take into account when checking the effect
  100772. * @param shadowGenerator combined with subMesh, it defines the effect to check
  100773. * @param useInstances specifies that instances should be used
  100774. * @returns a boolean indicating that the submesh is ready or not
  100775. */
  100776. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  100777. /**
  100778. * Disposes the resources
  100779. */
  100780. dispose(): void;
  100781. private _makeEffect;
  100782. }
  100783. }
  100784. declare module BABYLON {
  100785. /**
  100786. * Options for compiling materials.
  100787. */
  100788. export interface IMaterialCompilationOptions {
  100789. /**
  100790. * Defines whether clip planes are enabled.
  100791. */
  100792. clipPlane: boolean;
  100793. /**
  100794. * Defines whether instances are enabled.
  100795. */
  100796. useInstances: boolean;
  100797. }
  100798. /**
  100799. * Options passed when calling customShaderNameResolve
  100800. */
  100801. export interface ICustomShaderNameResolveOptions {
  100802. /**
  100803. * 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
  100804. */
  100805. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  100806. }
  100807. /**
  100808. * Base class for the main features of a material in Babylon.js
  100809. */
  100810. export class Material implements IAnimatable {
  100811. /**
  100812. * Returns the triangle fill mode
  100813. */
  100814. static readonly TriangleFillMode: number;
  100815. /**
  100816. * Returns the wireframe mode
  100817. */
  100818. static readonly WireFrameFillMode: number;
  100819. /**
  100820. * Returns the point fill mode
  100821. */
  100822. static readonly PointFillMode: number;
  100823. /**
  100824. * Returns the point list draw mode
  100825. */
  100826. static readonly PointListDrawMode: number;
  100827. /**
  100828. * Returns the line list draw mode
  100829. */
  100830. static readonly LineListDrawMode: number;
  100831. /**
  100832. * Returns the line loop draw mode
  100833. */
  100834. static readonly LineLoopDrawMode: number;
  100835. /**
  100836. * Returns the line strip draw mode
  100837. */
  100838. static readonly LineStripDrawMode: number;
  100839. /**
  100840. * Returns the triangle strip draw mode
  100841. */
  100842. static readonly TriangleStripDrawMode: number;
  100843. /**
  100844. * Returns the triangle fan draw mode
  100845. */
  100846. static readonly TriangleFanDrawMode: number;
  100847. /**
  100848. * Stores the clock-wise side orientation
  100849. */
  100850. static readonly ClockWiseSideOrientation: number;
  100851. /**
  100852. * Stores the counter clock-wise side orientation
  100853. */
  100854. static readonly CounterClockWiseSideOrientation: number;
  100855. /**
  100856. * The dirty texture flag value
  100857. */
  100858. static readonly TextureDirtyFlag: number;
  100859. /**
  100860. * The dirty light flag value
  100861. */
  100862. static readonly LightDirtyFlag: number;
  100863. /**
  100864. * The dirty fresnel flag value
  100865. */
  100866. static readonly FresnelDirtyFlag: number;
  100867. /**
  100868. * The dirty attribute flag value
  100869. */
  100870. static readonly AttributesDirtyFlag: number;
  100871. /**
  100872. * The dirty misc flag value
  100873. */
  100874. static readonly MiscDirtyFlag: number;
  100875. /**
  100876. * The all dirty flag value
  100877. */
  100878. static readonly AllDirtyFlag: number;
  100879. /**
  100880. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  100881. */
  100882. static readonly MATERIAL_OPAQUE: number;
  100883. /**
  100884. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  100885. */
  100886. static readonly MATERIAL_ALPHATEST: number;
  100887. /**
  100888. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  100889. */
  100890. static readonly MATERIAL_ALPHABLEND: number;
  100891. /**
  100892. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  100893. * They are also discarded below the alpha cutoff threshold to improve performances.
  100894. */
  100895. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  100896. /**
  100897. * Custom callback helping to override the default shader used in the material.
  100898. */
  100899. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  100900. /**
  100901. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  100902. */
  100903. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  100904. /**
  100905. * The ID of the material
  100906. */
  100907. id: string;
  100908. /**
  100909. * Gets or sets the unique id of the material
  100910. */
  100911. uniqueId: number;
  100912. /**
  100913. * The name of the material
  100914. */
  100915. name: string;
  100916. /**
  100917. * Gets or sets user defined metadata
  100918. */
  100919. metadata: any;
  100920. /**
  100921. * For internal use only. Please do not use.
  100922. */
  100923. reservedDataStore: any;
  100924. /**
  100925. * Specifies if the ready state should be checked on each call
  100926. */
  100927. checkReadyOnEveryCall: boolean;
  100928. /**
  100929. * Specifies if the ready state should be checked once
  100930. */
  100931. checkReadyOnlyOnce: boolean;
  100932. /**
  100933. * The state of the material
  100934. */
  100935. state: string;
  100936. /**
  100937. * The alpha value of the material
  100938. */
  100939. protected _alpha: number;
  100940. /**
  100941. * List of inspectable custom properties (used by the Inspector)
  100942. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  100943. */
  100944. inspectableCustomProperties: IInspectable[];
  100945. /**
  100946. * Sets the alpha value of the material
  100947. */
  100948. set alpha(value: number);
  100949. /**
  100950. * Gets the alpha value of the material
  100951. */
  100952. get alpha(): number;
  100953. /**
  100954. * Specifies if back face culling is enabled
  100955. */
  100956. protected _backFaceCulling: boolean;
  100957. /**
  100958. * Sets the back-face culling state
  100959. */
  100960. set backFaceCulling(value: boolean);
  100961. /**
  100962. * Gets the back-face culling state
  100963. */
  100964. get backFaceCulling(): boolean;
  100965. /**
  100966. * Stores the value for side orientation
  100967. */
  100968. sideOrientation: number;
  100969. /**
  100970. * Callback triggered when the material is compiled
  100971. */
  100972. onCompiled: Nullable<(effect: Effect) => void>;
  100973. /**
  100974. * Callback triggered when an error occurs
  100975. */
  100976. onError: Nullable<(effect: Effect, errors: string) => void>;
  100977. /**
  100978. * Callback triggered to get the render target textures
  100979. */
  100980. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  100981. /**
  100982. * Gets a boolean indicating that current material needs to register RTT
  100983. */
  100984. get hasRenderTargetTextures(): boolean;
  100985. /**
  100986. * Specifies if the material should be serialized
  100987. */
  100988. doNotSerialize: boolean;
  100989. /**
  100990. * @hidden
  100991. */
  100992. _storeEffectOnSubMeshes: boolean;
  100993. /**
  100994. * Stores the animations for the material
  100995. */
  100996. animations: Nullable<Array<Animation>>;
  100997. /**
  100998. * An event triggered when the material is disposed
  100999. */
  101000. onDisposeObservable: Observable<Material>;
  101001. /**
  101002. * An observer which watches for dispose events
  101003. */
  101004. private _onDisposeObserver;
  101005. private _onUnBindObservable;
  101006. /**
  101007. * Called during a dispose event
  101008. */
  101009. set onDispose(callback: () => void);
  101010. private _onBindObservable;
  101011. /**
  101012. * An event triggered when the material is bound
  101013. */
  101014. get onBindObservable(): Observable<AbstractMesh>;
  101015. /**
  101016. * An observer which watches for bind events
  101017. */
  101018. private _onBindObserver;
  101019. /**
  101020. * Called during a bind event
  101021. */
  101022. set onBind(callback: (Mesh: AbstractMesh) => void);
  101023. /**
  101024. * An event triggered when the material is unbound
  101025. */
  101026. get onUnBindObservable(): Observable<Material>;
  101027. protected _onEffectCreatedObservable: Nullable<Observable<{
  101028. effect: Effect;
  101029. subMesh: Nullable<SubMesh>;
  101030. }>>;
  101031. /**
  101032. * An event triggered when the effect is (re)created
  101033. */
  101034. get onEffectCreatedObservable(): Observable<{
  101035. effect: Effect;
  101036. subMesh: Nullable<SubMesh>;
  101037. }>;
  101038. /**
  101039. * Stores the value of the alpha mode
  101040. */
  101041. private _alphaMode;
  101042. /**
  101043. * Sets the value of the alpha mode.
  101044. *
  101045. * | Value | Type | Description |
  101046. * | --- | --- | --- |
  101047. * | 0 | ALPHA_DISABLE | |
  101048. * | 1 | ALPHA_ADD | |
  101049. * | 2 | ALPHA_COMBINE | |
  101050. * | 3 | ALPHA_SUBTRACT | |
  101051. * | 4 | ALPHA_MULTIPLY | |
  101052. * | 5 | ALPHA_MAXIMIZED | |
  101053. * | 6 | ALPHA_ONEONE | |
  101054. * | 7 | ALPHA_PREMULTIPLIED | |
  101055. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  101056. * | 9 | ALPHA_INTERPOLATE | |
  101057. * | 10 | ALPHA_SCREENMODE | |
  101058. *
  101059. */
  101060. set alphaMode(value: number);
  101061. /**
  101062. * Gets the value of the alpha mode
  101063. */
  101064. get alphaMode(): number;
  101065. /**
  101066. * Stores the state of the need depth pre-pass value
  101067. */
  101068. private _needDepthPrePass;
  101069. /**
  101070. * Sets the need depth pre-pass value
  101071. */
  101072. set needDepthPrePass(value: boolean);
  101073. /**
  101074. * Gets the depth pre-pass value
  101075. */
  101076. get needDepthPrePass(): boolean;
  101077. /**
  101078. * Specifies if depth writing should be disabled
  101079. */
  101080. disableDepthWrite: boolean;
  101081. /**
  101082. * Specifies if color writing should be disabled
  101083. */
  101084. disableColorWrite: boolean;
  101085. /**
  101086. * Specifies if depth writing should be forced
  101087. */
  101088. forceDepthWrite: boolean;
  101089. /**
  101090. * Specifies the depth function that should be used. 0 means the default engine function
  101091. */
  101092. depthFunction: number;
  101093. /**
  101094. * Specifies if there should be a separate pass for culling
  101095. */
  101096. separateCullingPass: boolean;
  101097. /**
  101098. * Stores the state specifing if fog should be enabled
  101099. */
  101100. private _fogEnabled;
  101101. /**
  101102. * Sets the state for enabling fog
  101103. */
  101104. set fogEnabled(value: boolean);
  101105. /**
  101106. * Gets the value of the fog enabled state
  101107. */
  101108. get fogEnabled(): boolean;
  101109. /**
  101110. * Stores the size of points
  101111. */
  101112. pointSize: number;
  101113. /**
  101114. * Stores the z offset value
  101115. */
  101116. zOffset: number;
  101117. get wireframe(): boolean;
  101118. /**
  101119. * Sets the state of wireframe mode
  101120. */
  101121. set wireframe(value: boolean);
  101122. /**
  101123. * Gets the value specifying if point clouds are enabled
  101124. */
  101125. get pointsCloud(): boolean;
  101126. /**
  101127. * Sets the state of point cloud mode
  101128. */
  101129. set pointsCloud(value: boolean);
  101130. /**
  101131. * Gets the material fill mode
  101132. */
  101133. get fillMode(): number;
  101134. /**
  101135. * Sets the material fill mode
  101136. */
  101137. set fillMode(value: number);
  101138. /**
  101139. * @hidden
  101140. * Stores the effects for the material
  101141. */
  101142. _effect: Nullable<Effect>;
  101143. /**
  101144. * Specifies if uniform buffers should be used
  101145. */
  101146. private _useUBO;
  101147. /**
  101148. * Stores a reference to the scene
  101149. */
  101150. private _scene;
  101151. /**
  101152. * Stores the fill mode state
  101153. */
  101154. private _fillMode;
  101155. /**
  101156. * Specifies if the depth write state should be cached
  101157. */
  101158. private _cachedDepthWriteState;
  101159. /**
  101160. * Specifies if the color write state should be cached
  101161. */
  101162. private _cachedColorWriteState;
  101163. /**
  101164. * Specifies if the depth function state should be cached
  101165. */
  101166. private _cachedDepthFunctionState;
  101167. /**
  101168. * Stores the uniform buffer
  101169. */
  101170. protected _uniformBuffer: UniformBuffer;
  101171. /** @hidden */
  101172. _indexInSceneMaterialArray: number;
  101173. /** @hidden */
  101174. meshMap: Nullable<{
  101175. [id: string]: AbstractMesh | undefined;
  101176. }>;
  101177. /**
  101178. * Creates a material instance
  101179. * @param name defines the name of the material
  101180. * @param scene defines the scene to reference
  101181. * @param doNotAdd specifies if the material should be added to the scene
  101182. */
  101183. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  101184. /**
  101185. * Returns a string representation of the current material
  101186. * @param fullDetails defines a boolean indicating which levels of logging is desired
  101187. * @returns a string with material information
  101188. */
  101189. toString(fullDetails?: boolean): string;
  101190. /**
  101191. * Gets the class name of the material
  101192. * @returns a string with the class name of the material
  101193. */
  101194. getClassName(): string;
  101195. /**
  101196. * Specifies if updates for the material been locked
  101197. */
  101198. get isFrozen(): boolean;
  101199. /**
  101200. * Locks updates for the material
  101201. */
  101202. freeze(): void;
  101203. /**
  101204. * Unlocks updates for the material
  101205. */
  101206. unfreeze(): void;
  101207. /**
  101208. * Specifies if the material is ready to be used
  101209. * @param mesh defines the mesh to check
  101210. * @param useInstances specifies if instances should be used
  101211. * @returns a boolean indicating if the material is ready to be used
  101212. */
  101213. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  101214. /**
  101215. * Specifies that the submesh is ready to be used
  101216. * @param mesh defines the mesh to check
  101217. * @param subMesh defines which submesh to check
  101218. * @param useInstances specifies that instances should be used
  101219. * @returns a boolean indicating that the submesh is ready or not
  101220. */
  101221. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  101222. /**
  101223. * Returns the material effect
  101224. * @returns the effect associated with the material
  101225. */
  101226. getEffect(): Nullable<Effect>;
  101227. /**
  101228. * Returns the current scene
  101229. * @returns a Scene
  101230. */
  101231. getScene(): Scene;
  101232. /**
  101233. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  101234. */
  101235. protected _forceAlphaTest: boolean;
  101236. /**
  101237. * The transparency mode of the material.
  101238. */
  101239. protected _transparencyMode: Nullable<number>;
  101240. /**
  101241. * Gets the current transparency mode.
  101242. */
  101243. get transparencyMode(): Nullable<number>;
  101244. /**
  101245. * Sets the transparency mode of the material.
  101246. *
  101247. * | Value | Type | Description |
  101248. * | ----- | ----------------------------------- | ----------- |
  101249. * | 0 | OPAQUE | |
  101250. * | 1 | ALPHATEST | |
  101251. * | 2 | ALPHABLEND | |
  101252. * | 3 | ALPHATESTANDBLEND | |
  101253. *
  101254. */
  101255. set transparencyMode(value: Nullable<number>);
  101256. /**
  101257. * Returns true if alpha blending should be disabled.
  101258. */
  101259. protected get _disableAlphaBlending(): boolean;
  101260. /**
  101261. * Specifies whether or not this material should be rendered in alpha blend mode.
  101262. * @returns a boolean specifying if alpha blending is needed
  101263. */
  101264. needAlphaBlending(): boolean;
  101265. /**
  101266. * Specifies if the mesh will require alpha blending
  101267. * @param mesh defines the mesh to check
  101268. * @returns a boolean specifying if alpha blending is needed for the mesh
  101269. */
  101270. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  101271. /**
  101272. * Specifies whether or not this material should be rendered in alpha test mode.
  101273. * @returns a boolean specifying if an alpha test is needed.
  101274. */
  101275. needAlphaTesting(): boolean;
  101276. /**
  101277. * Specifies if material alpha testing should be turned on for the mesh
  101278. * @param mesh defines the mesh to check
  101279. */
  101280. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  101281. /**
  101282. * Gets the texture used for the alpha test
  101283. * @returns the texture to use for alpha testing
  101284. */
  101285. getAlphaTestTexture(): Nullable<BaseTexture>;
  101286. /**
  101287. * Marks the material to indicate that it needs to be re-calculated
  101288. */
  101289. markDirty(): void;
  101290. /** @hidden */
  101291. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  101292. /**
  101293. * Binds the material to the mesh
  101294. * @param world defines the world transformation matrix
  101295. * @param mesh defines the mesh to bind the material to
  101296. */
  101297. bind(world: Matrix, mesh?: Mesh): void;
  101298. /**
  101299. * Binds the submesh to the material
  101300. * @param world defines the world transformation matrix
  101301. * @param mesh defines the mesh containing the submesh
  101302. * @param subMesh defines the submesh to bind the material to
  101303. */
  101304. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  101305. /**
  101306. * Binds the world matrix to the material
  101307. * @param world defines the world transformation matrix
  101308. */
  101309. bindOnlyWorldMatrix(world: Matrix): void;
  101310. /**
  101311. * Binds the scene's uniform buffer to the effect.
  101312. * @param effect defines the effect to bind to the scene uniform buffer
  101313. * @param sceneUbo defines the uniform buffer storing scene data
  101314. */
  101315. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  101316. /**
  101317. * Binds the view matrix to the effect
  101318. * @param effect defines the effect to bind the view matrix to
  101319. */
  101320. bindView(effect: Effect): void;
  101321. /**
  101322. * Binds the view projection matrix to the effect
  101323. * @param effect defines the effect to bind the view projection matrix to
  101324. */
  101325. bindViewProjection(effect: Effect): void;
  101326. /**
  101327. * Processes to execute after binding the material to a mesh
  101328. * @param mesh defines the rendered mesh
  101329. */
  101330. protected _afterBind(mesh?: Mesh): void;
  101331. /**
  101332. * Unbinds the material from the mesh
  101333. */
  101334. unbind(): void;
  101335. /**
  101336. * Gets the active textures from the material
  101337. * @returns an array of textures
  101338. */
  101339. getActiveTextures(): BaseTexture[];
  101340. /**
  101341. * Specifies if the material uses a texture
  101342. * @param texture defines the texture to check against the material
  101343. * @returns a boolean specifying if the material uses the texture
  101344. */
  101345. hasTexture(texture: BaseTexture): boolean;
  101346. /**
  101347. * Makes a duplicate of the material, and gives it a new name
  101348. * @param name defines the new name for the duplicated material
  101349. * @returns the cloned material
  101350. */
  101351. clone(name: string): Nullable<Material>;
  101352. /**
  101353. * Gets the meshes bound to the material
  101354. * @returns an array of meshes bound to the material
  101355. */
  101356. getBindedMeshes(): AbstractMesh[];
  101357. /**
  101358. * Force shader compilation
  101359. * @param mesh defines the mesh associated with this material
  101360. * @param onCompiled defines a function to execute once the material is compiled
  101361. * @param options defines the options to configure the compilation
  101362. * @param onError defines a function to execute if the material fails compiling
  101363. */
  101364. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  101365. /**
  101366. * Force shader compilation
  101367. * @param mesh defines the mesh that will use this material
  101368. * @param options defines additional options for compiling the shaders
  101369. * @returns a promise that resolves when the compilation completes
  101370. */
  101371. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  101372. private static readonly _AllDirtyCallBack;
  101373. private static readonly _ImageProcessingDirtyCallBack;
  101374. private static readonly _TextureDirtyCallBack;
  101375. private static readonly _FresnelDirtyCallBack;
  101376. private static readonly _MiscDirtyCallBack;
  101377. private static readonly _LightsDirtyCallBack;
  101378. private static readonly _AttributeDirtyCallBack;
  101379. private static _FresnelAndMiscDirtyCallBack;
  101380. private static _TextureAndMiscDirtyCallBack;
  101381. private static readonly _DirtyCallbackArray;
  101382. private static readonly _RunDirtyCallBacks;
  101383. /**
  101384. * Marks a define in the material to indicate that it needs to be re-computed
  101385. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  101386. */
  101387. markAsDirty(flag: number): void;
  101388. /**
  101389. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  101390. * @param func defines a function which checks material defines against the submeshes
  101391. */
  101392. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  101393. /**
  101394. * Indicates that we need to re-calculated for all submeshes
  101395. */
  101396. protected _markAllSubMeshesAsAllDirty(): void;
  101397. /**
  101398. * Indicates that image processing needs to be re-calculated for all submeshes
  101399. */
  101400. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  101401. /**
  101402. * Indicates that textures need to be re-calculated for all submeshes
  101403. */
  101404. protected _markAllSubMeshesAsTexturesDirty(): void;
  101405. /**
  101406. * Indicates that fresnel needs to be re-calculated for all submeshes
  101407. */
  101408. protected _markAllSubMeshesAsFresnelDirty(): void;
  101409. /**
  101410. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  101411. */
  101412. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  101413. /**
  101414. * Indicates that lights need to be re-calculated for all submeshes
  101415. */
  101416. protected _markAllSubMeshesAsLightsDirty(): void;
  101417. /**
  101418. * Indicates that attributes need to be re-calculated for all submeshes
  101419. */
  101420. protected _markAllSubMeshesAsAttributesDirty(): void;
  101421. /**
  101422. * Indicates that misc needs to be re-calculated for all submeshes
  101423. */
  101424. protected _markAllSubMeshesAsMiscDirty(): void;
  101425. /**
  101426. * Indicates that textures and misc need to be re-calculated for all submeshes
  101427. */
  101428. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  101429. /**
  101430. * Disposes the material
  101431. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  101432. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  101433. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  101434. */
  101435. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  101436. /** @hidden */
  101437. private releaseVertexArrayObject;
  101438. /**
  101439. * Serializes this material
  101440. * @returns the serialized material object
  101441. */
  101442. serialize(): any;
  101443. /**
  101444. * Creates a material from parsed material data
  101445. * @param parsedMaterial defines parsed material data
  101446. * @param scene defines the hosting scene
  101447. * @param rootUrl defines the root URL to use to load textures
  101448. * @returns a new material
  101449. */
  101450. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  101451. }
  101452. }
  101453. declare module BABYLON {
  101454. /**
  101455. * A multi-material is used to apply different materials to different parts of the same object without the need of
  101456. * separate meshes. This can be use to improve performances.
  101457. * @see http://doc.babylonjs.com/how_to/multi_materials
  101458. */
  101459. export class MultiMaterial extends Material {
  101460. private _subMaterials;
  101461. /**
  101462. * Gets or Sets the list of Materials used within the multi material.
  101463. * They need to be ordered according to the submeshes order in the associated mesh
  101464. */
  101465. get subMaterials(): Nullable<Material>[];
  101466. set subMaterials(value: Nullable<Material>[]);
  101467. /**
  101468. * Function used to align with Node.getChildren()
  101469. * @returns the list of Materials used within the multi material
  101470. */
  101471. getChildren(): Nullable<Material>[];
  101472. /**
  101473. * Instantiates a new Multi Material
  101474. * A multi-material is used to apply different materials to different parts of the same object without the need of
  101475. * separate meshes. This can be use to improve performances.
  101476. * @see http://doc.babylonjs.com/how_to/multi_materials
  101477. * @param name Define the name in the scene
  101478. * @param scene Define the scene the material belongs to
  101479. */
  101480. constructor(name: string, scene: Scene);
  101481. private _hookArray;
  101482. /**
  101483. * Get one of the submaterial by its index in the submaterials array
  101484. * @param index The index to look the sub material at
  101485. * @returns The Material if the index has been defined
  101486. */
  101487. getSubMaterial(index: number): Nullable<Material>;
  101488. /**
  101489. * Get the list of active textures for the whole sub materials list.
  101490. * @returns All the textures that will be used during the rendering
  101491. */
  101492. getActiveTextures(): BaseTexture[];
  101493. /**
  101494. * Gets the current class name of the material e.g. "MultiMaterial"
  101495. * Mainly use in serialization.
  101496. * @returns the class name
  101497. */
  101498. getClassName(): string;
  101499. /**
  101500. * Checks if the material is ready to render the requested sub mesh
  101501. * @param mesh Define the mesh the submesh belongs to
  101502. * @param subMesh Define the sub mesh to look readyness for
  101503. * @param useInstances Define whether or not the material is used with instances
  101504. * @returns true if ready, otherwise false
  101505. */
  101506. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  101507. /**
  101508. * Clones the current material and its related sub materials
  101509. * @param name Define the name of the newly cloned material
  101510. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  101511. * @returns the cloned material
  101512. */
  101513. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  101514. /**
  101515. * Serializes the materials into a JSON representation.
  101516. * @returns the JSON representation
  101517. */
  101518. serialize(): any;
  101519. /**
  101520. * Dispose the material and release its associated resources
  101521. * @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)
  101522. * @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)
  101523. * @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)
  101524. */
  101525. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  101526. /**
  101527. * Creates a MultiMaterial from parsed MultiMaterial data.
  101528. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  101529. * @param scene defines the hosting scene
  101530. * @returns a new MultiMaterial
  101531. */
  101532. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  101533. }
  101534. }
  101535. declare module BABYLON {
  101536. /**
  101537. * Defines a subdivision inside a mesh
  101538. */
  101539. export class SubMesh implements ICullable {
  101540. /** the material index to use */
  101541. materialIndex: number;
  101542. /** vertex index start */
  101543. verticesStart: number;
  101544. /** vertices count */
  101545. verticesCount: number;
  101546. /** index start */
  101547. indexStart: number;
  101548. /** indices count */
  101549. indexCount: number;
  101550. /** @hidden */
  101551. _materialDefines: Nullable<MaterialDefines>;
  101552. /** @hidden */
  101553. _materialEffect: Nullable<Effect>;
  101554. /** @hidden */
  101555. _effectOverride: Nullable<Effect>;
  101556. /**
  101557. * Gets material defines used by the effect associated to the sub mesh
  101558. */
  101559. get materialDefines(): Nullable<MaterialDefines>;
  101560. /**
  101561. * Sets material defines used by the effect associated to the sub mesh
  101562. */
  101563. set materialDefines(defines: Nullable<MaterialDefines>);
  101564. /**
  101565. * Gets associated effect
  101566. */
  101567. get effect(): Nullable<Effect>;
  101568. /**
  101569. * Sets associated effect (effect used to render this submesh)
  101570. * @param effect defines the effect to associate with
  101571. * @param defines defines the set of defines used to compile this effect
  101572. */
  101573. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  101574. /** @hidden */
  101575. _linesIndexCount: number;
  101576. private _mesh;
  101577. private _renderingMesh;
  101578. private _boundingInfo;
  101579. private _linesIndexBuffer;
  101580. /** @hidden */
  101581. _lastColliderWorldVertices: Nullable<Vector3[]>;
  101582. /** @hidden */
  101583. _trianglePlanes: Plane[];
  101584. /** @hidden */
  101585. _lastColliderTransformMatrix: Nullable<Matrix>;
  101586. /** @hidden */
  101587. _renderId: number;
  101588. /** @hidden */
  101589. _alphaIndex: number;
  101590. /** @hidden */
  101591. _distanceToCamera: number;
  101592. /** @hidden */
  101593. _id: number;
  101594. private _currentMaterial;
  101595. /**
  101596. * Add a new submesh to a mesh
  101597. * @param materialIndex defines the material index to use
  101598. * @param verticesStart defines vertex index start
  101599. * @param verticesCount defines vertices count
  101600. * @param indexStart defines index start
  101601. * @param indexCount defines indices count
  101602. * @param mesh defines the parent mesh
  101603. * @param renderingMesh defines an optional rendering mesh
  101604. * @param createBoundingBox defines if bounding box should be created for this submesh
  101605. * @returns the new submesh
  101606. */
  101607. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  101608. /**
  101609. * Creates a new submesh
  101610. * @param materialIndex defines the material index to use
  101611. * @param verticesStart defines vertex index start
  101612. * @param verticesCount defines vertices count
  101613. * @param indexStart defines index start
  101614. * @param indexCount defines indices count
  101615. * @param mesh defines the parent mesh
  101616. * @param renderingMesh defines an optional rendering mesh
  101617. * @param createBoundingBox defines if bounding box should be created for this submesh
  101618. */
  101619. constructor(
  101620. /** the material index to use */
  101621. materialIndex: number,
  101622. /** vertex index start */
  101623. verticesStart: number,
  101624. /** vertices count */
  101625. verticesCount: number,
  101626. /** index start */
  101627. indexStart: number,
  101628. /** indices count */
  101629. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  101630. /**
  101631. * Returns true if this submesh covers the entire parent mesh
  101632. * @ignorenaming
  101633. */
  101634. get IsGlobal(): boolean;
  101635. /**
  101636. * Returns the submesh BoudingInfo object
  101637. * @returns current bounding info (or mesh's one if the submesh is global)
  101638. */
  101639. getBoundingInfo(): BoundingInfo;
  101640. /**
  101641. * Sets the submesh BoundingInfo
  101642. * @param boundingInfo defines the new bounding info to use
  101643. * @returns the SubMesh
  101644. */
  101645. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  101646. /**
  101647. * Returns the mesh of the current submesh
  101648. * @return the parent mesh
  101649. */
  101650. getMesh(): AbstractMesh;
  101651. /**
  101652. * Returns the rendering mesh of the submesh
  101653. * @returns the rendering mesh (could be different from parent mesh)
  101654. */
  101655. getRenderingMesh(): Mesh;
  101656. /**
  101657. * Returns the replacement mesh of the submesh
  101658. * @returns the replacement mesh (could be different from parent mesh)
  101659. */
  101660. getReplacementMesh(): Nullable<AbstractMesh>;
  101661. /**
  101662. * Returns the effective mesh of the submesh
  101663. * @returns the effective mesh (could be different from parent mesh)
  101664. */
  101665. getEffectiveMesh(): AbstractMesh;
  101666. /**
  101667. * Returns the submesh material
  101668. * @returns null or the current material
  101669. */
  101670. getMaterial(): Nullable<Material>;
  101671. /**
  101672. * Sets a new updated BoundingInfo object to the submesh
  101673. * @param data defines an optional position array to use to determine the bounding info
  101674. * @returns the SubMesh
  101675. */
  101676. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  101677. /** @hidden */
  101678. _checkCollision(collider: Collider): boolean;
  101679. /**
  101680. * Updates the submesh BoundingInfo
  101681. * @param world defines the world matrix to use to update the bounding info
  101682. * @returns the submesh
  101683. */
  101684. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  101685. /**
  101686. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  101687. * @param frustumPlanes defines the frustum planes
  101688. * @returns true if the submesh is intersecting with the frustum
  101689. */
  101690. isInFrustum(frustumPlanes: Plane[]): boolean;
  101691. /**
  101692. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  101693. * @param frustumPlanes defines the frustum planes
  101694. * @returns true if the submesh is inside the frustum
  101695. */
  101696. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  101697. /**
  101698. * Renders the submesh
  101699. * @param enableAlphaMode defines if alpha needs to be used
  101700. * @returns the submesh
  101701. */
  101702. render(enableAlphaMode: boolean): SubMesh;
  101703. /**
  101704. * @hidden
  101705. */
  101706. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  101707. /**
  101708. * Checks if the submesh intersects with a ray
  101709. * @param ray defines the ray to test
  101710. * @returns true is the passed ray intersects the submesh bounding box
  101711. */
  101712. canIntersects(ray: Ray): boolean;
  101713. /**
  101714. * Intersects current submesh with a ray
  101715. * @param ray defines the ray to test
  101716. * @param positions defines mesh's positions array
  101717. * @param indices defines mesh's indices array
  101718. * @param fastCheck defines if the first intersection will be used (and not the closest)
  101719. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101720. * @returns intersection info or null if no intersection
  101721. */
  101722. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  101723. /** @hidden */
  101724. private _intersectLines;
  101725. /** @hidden */
  101726. private _intersectUnIndexedLines;
  101727. /** @hidden */
  101728. private _intersectTriangles;
  101729. /** @hidden */
  101730. private _intersectUnIndexedTriangles;
  101731. /** @hidden */
  101732. _rebuild(): void;
  101733. /**
  101734. * Creates a new submesh from the passed mesh
  101735. * @param newMesh defines the new hosting mesh
  101736. * @param newRenderingMesh defines an optional rendering mesh
  101737. * @returns the new submesh
  101738. */
  101739. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  101740. /**
  101741. * Release associated resources
  101742. */
  101743. dispose(): void;
  101744. /**
  101745. * Gets the class name
  101746. * @returns the string "SubMesh".
  101747. */
  101748. getClassName(): string;
  101749. /**
  101750. * Creates a new submesh from indices data
  101751. * @param materialIndex the index of the main mesh material
  101752. * @param startIndex the index where to start the copy in the mesh indices array
  101753. * @param indexCount the number of indices to copy then from the startIndex
  101754. * @param mesh the main mesh to create the submesh from
  101755. * @param renderingMesh the optional rendering mesh
  101756. * @returns a new submesh
  101757. */
  101758. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  101759. }
  101760. }
  101761. declare module BABYLON {
  101762. /**
  101763. * Class used to represent data loading progression
  101764. */
  101765. export class SceneLoaderFlags {
  101766. private static _ForceFullSceneLoadingForIncremental;
  101767. private static _ShowLoadingScreen;
  101768. private static _CleanBoneMatrixWeights;
  101769. private static _loggingLevel;
  101770. /**
  101771. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  101772. */
  101773. static get ForceFullSceneLoadingForIncremental(): boolean;
  101774. static set ForceFullSceneLoadingForIncremental(value: boolean);
  101775. /**
  101776. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  101777. */
  101778. static get ShowLoadingScreen(): boolean;
  101779. static set ShowLoadingScreen(value: boolean);
  101780. /**
  101781. * Defines the current logging level (while loading the scene)
  101782. * @ignorenaming
  101783. */
  101784. static get loggingLevel(): number;
  101785. static set loggingLevel(value: number);
  101786. /**
  101787. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  101788. */
  101789. static get CleanBoneMatrixWeights(): boolean;
  101790. static set CleanBoneMatrixWeights(value: boolean);
  101791. }
  101792. }
  101793. declare module BABYLON {
  101794. /**
  101795. * Class used to store geometry data (vertex buffers + index buffer)
  101796. */
  101797. export class Geometry implements IGetSetVerticesData {
  101798. /**
  101799. * Gets or sets the ID of the geometry
  101800. */
  101801. id: string;
  101802. /**
  101803. * Gets or sets the unique ID of the geometry
  101804. */
  101805. uniqueId: number;
  101806. /**
  101807. * Gets the delay loading state of the geometry (none by default which means not delayed)
  101808. */
  101809. delayLoadState: number;
  101810. /**
  101811. * Gets the file containing the data to load when running in delay load state
  101812. */
  101813. delayLoadingFile: Nullable<string>;
  101814. /**
  101815. * Callback called when the geometry is updated
  101816. */
  101817. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  101818. private _scene;
  101819. private _engine;
  101820. private _meshes;
  101821. private _totalVertices;
  101822. /** @hidden */
  101823. _indices: IndicesArray;
  101824. /** @hidden */
  101825. _vertexBuffers: {
  101826. [key: string]: VertexBuffer;
  101827. };
  101828. private _isDisposed;
  101829. private _extend;
  101830. private _boundingBias;
  101831. /** @hidden */
  101832. _delayInfo: Array<string>;
  101833. private _indexBuffer;
  101834. private _indexBufferIsUpdatable;
  101835. /** @hidden */
  101836. _boundingInfo: Nullable<BoundingInfo>;
  101837. /** @hidden */
  101838. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  101839. /** @hidden */
  101840. _softwareSkinningFrameId: number;
  101841. private _vertexArrayObjects;
  101842. private _updatable;
  101843. /** @hidden */
  101844. _positions: Nullable<Vector3[]>;
  101845. /**
  101846. * 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
  101847. */
  101848. get boundingBias(): Vector2;
  101849. /**
  101850. * 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
  101851. */
  101852. set boundingBias(value: Vector2);
  101853. /**
  101854. * Static function used to attach a new empty geometry to a mesh
  101855. * @param mesh defines the mesh to attach the geometry to
  101856. * @returns the new Geometry
  101857. */
  101858. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  101859. /** Get the list of meshes using this geometry */
  101860. get meshes(): Mesh[];
  101861. /**
  101862. * Creates a new geometry
  101863. * @param id defines the unique ID
  101864. * @param scene defines the hosting scene
  101865. * @param vertexData defines the VertexData used to get geometry data
  101866. * @param updatable defines if geometry must be updatable (false by default)
  101867. * @param mesh defines the mesh that will be associated with the geometry
  101868. */
  101869. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  101870. /**
  101871. * Gets the current extend of the geometry
  101872. */
  101873. get extend(): {
  101874. minimum: Vector3;
  101875. maximum: Vector3;
  101876. };
  101877. /**
  101878. * Gets the hosting scene
  101879. * @returns the hosting Scene
  101880. */
  101881. getScene(): Scene;
  101882. /**
  101883. * Gets the hosting engine
  101884. * @returns the hosting Engine
  101885. */
  101886. getEngine(): Engine;
  101887. /**
  101888. * Defines if the geometry is ready to use
  101889. * @returns true if the geometry is ready to be used
  101890. */
  101891. isReady(): boolean;
  101892. /**
  101893. * Gets a value indicating that the geometry should not be serialized
  101894. */
  101895. get doNotSerialize(): boolean;
  101896. /** @hidden */
  101897. _rebuild(): void;
  101898. /**
  101899. * Affects all geometry data in one call
  101900. * @param vertexData defines the geometry data
  101901. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  101902. */
  101903. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  101904. /**
  101905. * Set specific vertex data
  101906. * @param kind defines the data kind (Position, normal, etc...)
  101907. * @param data defines the vertex data to use
  101908. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  101909. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  101910. */
  101911. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  101912. /**
  101913. * Removes a specific vertex data
  101914. * @param kind defines the data kind (Position, normal, etc...)
  101915. */
  101916. removeVerticesData(kind: string): void;
  101917. /**
  101918. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  101919. * @param buffer defines the vertex buffer to use
  101920. * @param totalVertices defines the total number of vertices for position kind (could be null)
  101921. */
  101922. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  101923. /**
  101924. * Update a specific vertex buffer
  101925. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  101926. * It will do nothing if the buffer is not updatable
  101927. * @param kind defines the data kind (Position, normal, etc...)
  101928. * @param data defines the data to use
  101929. * @param offset defines the offset in the target buffer where to store the data
  101930. * @param useBytes set to true if the offset is in bytes
  101931. */
  101932. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  101933. /**
  101934. * Update a specific vertex buffer
  101935. * This function will create a new buffer if the current one is not updatable
  101936. * @param kind defines the data kind (Position, normal, etc...)
  101937. * @param data defines the data to use
  101938. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  101939. */
  101940. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  101941. private _updateBoundingInfo;
  101942. /** @hidden */
  101943. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  101944. /**
  101945. * Gets total number of vertices
  101946. * @returns the total number of vertices
  101947. */
  101948. getTotalVertices(): number;
  101949. /**
  101950. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  101951. * @param kind defines the data kind (Position, normal, etc...)
  101952. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  101953. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  101954. * @returns a float array containing vertex data
  101955. */
  101956. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  101957. /**
  101958. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  101959. * @param kind defines the data kind (Position, normal, etc...)
  101960. * @returns true if the vertex buffer with the specified kind is updatable
  101961. */
  101962. isVertexBufferUpdatable(kind: string): boolean;
  101963. /**
  101964. * Gets a specific vertex buffer
  101965. * @param kind defines the data kind (Position, normal, etc...)
  101966. * @returns a VertexBuffer
  101967. */
  101968. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  101969. /**
  101970. * Returns all vertex buffers
  101971. * @return an object holding all vertex buffers indexed by kind
  101972. */
  101973. getVertexBuffers(): Nullable<{
  101974. [key: string]: VertexBuffer;
  101975. }>;
  101976. /**
  101977. * Gets a boolean indicating if specific vertex buffer is present
  101978. * @param kind defines the data kind (Position, normal, etc...)
  101979. * @returns true if data is present
  101980. */
  101981. isVerticesDataPresent(kind: string): boolean;
  101982. /**
  101983. * Gets a list of all attached data kinds (Position, normal, etc...)
  101984. * @returns a list of string containing all kinds
  101985. */
  101986. getVerticesDataKinds(): string[];
  101987. /**
  101988. * Update index buffer
  101989. * @param indices defines the indices to store in the index buffer
  101990. * @param offset defines the offset in the target buffer where to store the data
  101991. * @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)
  101992. */
  101993. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  101994. /**
  101995. * Creates a new index buffer
  101996. * @param indices defines the indices to store in the index buffer
  101997. * @param totalVertices defines the total number of vertices (could be null)
  101998. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  101999. */
  102000. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  102001. /**
  102002. * Return the total number of indices
  102003. * @returns the total number of indices
  102004. */
  102005. getTotalIndices(): number;
  102006. /**
  102007. * Gets the index buffer array
  102008. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  102009. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  102010. * @returns the index buffer array
  102011. */
  102012. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  102013. /**
  102014. * Gets the index buffer
  102015. * @return the index buffer
  102016. */
  102017. getIndexBuffer(): Nullable<DataBuffer>;
  102018. /** @hidden */
  102019. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  102020. /**
  102021. * Release the associated resources for a specific mesh
  102022. * @param mesh defines the source mesh
  102023. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  102024. */
  102025. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  102026. /**
  102027. * Apply current geometry to a given mesh
  102028. * @param mesh defines the mesh to apply geometry to
  102029. */
  102030. applyToMesh(mesh: Mesh): void;
  102031. private _updateExtend;
  102032. private _applyToMesh;
  102033. private notifyUpdate;
  102034. /**
  102035. * Load the geometry if it was flagged as delay loaded
  102036. * @param scene defines the hosting scene
  102037. * @param onLoaded defines a callback called when the geometry is loaded
  102038. */
  102039. load(scene: Scene, onLoaded?: () => void): void;
  102040. private _queueLoad;
  102041. /**
  102042. * Invert the geometry to move from a right handed system to a left handed one.
  102043. */
  102044. toLeftHanded(): void;
  102045. /** @hidden */
  102046. _resetPointsArrayCache(): void;
  102047. /** @hidden */
  102048. _generatePointsArray(): boolean;
  102049. /**
  102050. * Gets a value indicating if the geometry is disposed
  102051. * @returns true if the geometry was disposed
  102052. */
  102053. isDisposed(): boolean;
  102054. private _disposeVertexArrayObjects;
  102055. /**
  102056. * Free all associated resources
  102057. */
  102058. dispose(): void;
  102059. /**
  102060. * Clone the current geometry into a new geometry
  102061. * @param id defines the unique ID of the new geometry
  102062. * @returns a new geometry object
  102063. */
  102064. copy(id: string): Geometry;
  102065. /**
  102066. * Serialize the current geometry info (and not the vertices data) into a JSON object
  102067. * @return a JSON representation of the current geometry data (without the vertices data)
  102068. */
  102069. serialize(): any;
  102070. private toNumberArray;
  102071. /**
  102072. * Serialize all vertices data into a JSON oject
  102073. * @returns a JSON representation of the current geometry data
  102074. */
  102075. serializeVerticeData(): any;
  102076. /**
  102077. * Extracts a clone of a mesh geometry
  102078. * @param mesh defines the source mesh
  102079. * @param id defines the unique ID of the new geometry object
  102080. * @returns the new geometry object
  102081. */
  102082. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  102083. /**
  102084. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  102085. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  102086. * Be aware Math.random() could cause collisions, but:
  102087. * "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"
  102088. * @returns a string containing a new GUID
  102089. */
  102090. static RandomId(): string;
  102091. /** @hidden */
  102092. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  102093. private static _CleanMatricesWeights;
  102094. /**
  102095. * Create a new geometry from persisted data (Using .babylon file format)
  102096. * @param parsedVertexData defines the persisted data
  102097. * @param scene defines the hosting scene
  102098. * @param rootUrl defines the root url to use to load assets (like delayed data)
  102099. * @returns the new geometry object
  102100. */
  102101. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  102102. }
  102103. }
  102104. declare module BABYLON {
  102105. /**
  102106. * Define an interface for all classes that will get and set the data on vertices
  102107. */
  102108. export interface IGetSetVerticesData {
  102109. /**
  102110. * Gets a boolean indicating if specific vertex data is present
  102111. * @param kind defines the vertex data kind to use
  102112. * @returns true is data kind is present
  102113. */
  102114. isVerticesDataPresent(kind: string): boolean;
  102115. /**
  102116. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  102117. * @param kind defines the data kind (Position, normal, etc...)
  102118. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  102119. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  102120. * @returns a float array containing vertex data
  102121. */
  102122. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  102123. /**
  102124. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  102125. * @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.
  102126. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  102127. * @returns the indices array or an empty array if the mesh has no geometry
  102128. */
  102129. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  102130. /**
  102131. * Set specific vertex data
  102132. * @param kind defines the data kind (Position, normal, etc...)
  102133. * @param data defines the vertex data to use
  102134. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  102135. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  102136. */
  102137. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  102138. /**
  102139. * Update a specific associated vertex buffer
  102140. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  102141. * - VertexBuffer.PositionKind
  102142. * - VertexBuffer.UVKind
  102143. * - VertexBuffer.UV2Kind
  102144. * - VertexBuffer.UV3Kind
  102145. * - VertexBuffer.UV4Kind
  102146. * - VertexBuffer.UV5Kind
  102147. * - VertexBuffer.UV6Kind
  102148. * - VertexBuffer.ColorKind
  102149. * - VertexBuffer.MatricesIndicesKind
  102150. * - VertexBuffer.MatricesIndicesExtraKind
  102151. * - VertexBuffer.MatricesWeightsKind
  102152. * - VertexBuffer.MatricesWeightsExtraKind
  102153. * @param data defines the data source
  102154. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  102155. * @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)
  102156. */
  102157. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  102158. /**
  102159. * Creates a new index buffer
  102160. * @param indices defines the indices to store in the index buffer
  102161. * @param totalVertices defines the total number of vertices (could be null)
  102162. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  102163. */
  102164. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  102165. }
  102166. /**
  102167. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  102168. */
  102169. export class VertexData {
  102170. /**
  102171. * Mesh side orientation : usually the external or front surface
  102172. */
  102173. static readonly FRONTSIDE: number;
  102174. /**
  102175. * Mesh side orientation : usually the internal or back surface
  102176. */
  102177. static readonly BACKSIDE: number;
  102178. /**
  102179. * Mesh side orientation : both internal and external or front and back surfaces
  102180. */
  102181. static readonly DOUBLESIDE: number;
  102182. /**
  102183. * Mesh side orientation : by default, `FRONTSIDE`
  102184. */
  102185. static readonly DEFAULTSIDE: number;
  102186. /**
  102187. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  102188. */
  102189. positions: Nullable<FloatArray>;
  102190. /**
  102191. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  102192. */
  102193. normals: Nullable<FloatArray>;
  102194. /**
  102195. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  102196. */
  102197. tangents: Nullable<FloatArray>;
  102198. /**
  102199. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  102200. */
  102201. uvs: Nullable<FloatArray>;
  102202. /**
  102203. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  102204. */
  102205. uvs2: Nullable<FloatArray>;
  102206. /**
  102207. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  102208. */
  102209. uvs3: Nullable<FloatArray>;
  102210. /**
  102211. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  102212. */
  102213. uvs4: Nullable<FloatArray>;
  102214. /**
  102215. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  102216. */
  102217. uvs5: Nullable<FloatArray>;
  102218. /**
  102219. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  102220. */
  102221. uvs6: Nullable<FloatArray>;
  102222. /**
  102223. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  102224. */
  102225. colors: Nullable<FloatArray>;
  102226. /**
  102227. * 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).
  102228. */
  102229. matricesIndices: Nullable<FloatArray>;
  102230. /**
  102231. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  102232. */
  102233. matricesWeights: Nullable<FloatArray>;
  102234. /**
  102235. * An array extending the number of possible indices
  102236. */
  102237. matricesIndicesExtra: Nullable<FloatArray>;
  102238. /**
  102239. * An array extending the number of possible weights when the number of indices is extended
  102240. */
  102241. matricesWeightsExtra: Nullable<FloatArray>;
  102242. /**
  102243. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  102244. */
  102245. indices: Nullable<IndicesArray>;
  102246. /**
  102247. * Uses the passed data array to set the set the values for the specified kind of data
  102248. * @param data a linear array of floating numbers
  102249. * @param kind the type of data that is being set, eg positions, colors etc
  102250. */
  102251. set(data: FloatArray, kind: string): void;
  102252. /**
  102253. * Associates the vertexData to the passed Mesh.
  102254. * Sets it as updatable or not (default `false`)
  102255. * @param mesh the mesh the vertexData is applied to
  102256. * @param updatable when used and having the value true allows new data to update the vertexData
  102257. * @returns the VertexData
  102258. */
  102259. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  102260. /**
  102261. * Associates the vertexData to the passed Geometry.
  102262. * Sets it as updatable or not (default `false`)
  102263. * @param geometry the geometry the vertexData is applied to
  102264. * @param updatable when used and having the value true allows new data to update the vertexData
  102265. * @returns VertexData
  102266. */
  102267. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  102268. /**
  102269. * Updates the associated mesh
  102270. * @param mesh the mesh to be updated
  102271. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  102272. * @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
  102273. * @returns VertexData
  102274. */
  102275. updateMesh(mesh: Mesh): VertexData;
  102276. /**
  102277. * Updates the associated geometry
  102278. * @param geometry the geometry to be updated
  102279. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  102280. * @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
  102281. * @returns VertexData.
  102282. */
  102283. updateGeometry(geometry: Geometry): VertexData;
  102284. private _applyTo;
  102285. private _update;
  102286. /**
  102287. * Transforms each position and each normal of the vertexData according to the passed Matrix
  102288. * @param matrix the transforming matrix
  102289. * @returns the VertexData
  102290. */
  102291. transform(matrix: Matrix): VertexData;
  102292. /**
  102293. * Merges the passed VertexData into the current one
  102294. * @param other the VertexData to be merged into the current one
  102295. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  102296. * @returns the modified VertexData
  102297. */
  102298. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  102299. private _mergeElement;
  102300. private _validate;
  102301. /**
  102302. * Serializes the VertexData
  102303. * @returns a serialized object
  102304. */
  102305. serialize(): any;
  102306. /**
  102307. * Extracts the vertexData from a mesh
  102308. * @param mesh the mesh from which to extract the VertexData
  102309. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  102310. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  102311. * @returns the object VertexData associated to the passed mesh
  102312. */
  102313. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  102314. /**
  102315. * Extracts the vertexData from the geometry
  102316. * @param geometry the geometry from which to extract the VertexData
  102317. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  102318. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  102319. * @returns the object VertexData associated to the passed mesh
  102320. */
  102321. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  102322. private static _ExtractFrom;
  102323. /**
  102324. * Creates the VertexData for a Ribbon
  102325. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  102326. * * pathArray array of paths, each of which an array of successive Vector3
  102327. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  102328. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  102329. * * 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
  102330. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102331. * * 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)
  102332. * * 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)
  102333. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  102334. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  102335. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  102336. * @returns the VertexData of the ribbon
  102337. */
  102338. static CreateRibbon(options: {
  102339. pathArray: Vector3[][];
  102340. closeArray?: boolean;
  102341. closePath?: boolean;
  102342. offset?: number;
  102343. sideOrientation?: number;
  102344. frontUVs?: Vector4;
  102345. backUVs?: Vector4;
  102346. invertUV?: boolean;
  102347. uvs?: Vector2[];
  102348. colors?: Color4[];
  102349. }): VertexData;
  102350. /**
  102351. * Creates the VertexData for a box
  102352. * @param options an object used to set the following optional parameters for the box, required but can be empty
  102353. * * size sets the width, height and depth of the box to the value of size, optional default 1
  102354. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  102355. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  102356. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  102357. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  102358. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  102359. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102360. * * 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)
  102361. * * 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)
  102362. * @returns the VertexData of the box
  102363. */
  102364. static CreateBox(options: {
  102365. size?: number;
  102366. width?: number;
  102367. height?: number;
  102368. depth?: number;
  102369. faceUV?: Vector4[];
  102370. faceColors?: Color4[];
  102371. sideOrientation?: number;
  102372. frontUVs?: Vector4;
  102373. backUVs?: Vector4;
  102374. }): VertexData;
  102375. /**
  102376. * Creates the VertexData for a tiled box
  102377. * @param options an object used to set the following optional parameters for the box, required but can be empty
  102378. * * faceTiles sets the pattern, tile size and number of tiles for a face
  102379. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  102380. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  102381. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102382. * @returns the VertexData of the box
  102383. */
  102384. static CreateTiledBox(options: {
  102385. pattern?: number;
  102386. width?: number;
  102387. height?: number;
  102388. depth?: number;
  102389. tileSize?: number;
  102390. tileWidth?: number;
  102391. tileHeight?: number;
  102392. alignHorizontal?: number;
  102393. alignVertical?: number;
  102394. faceUV?: Vector4[];
  102395. faceColors?: Color4[];
  102396. sideOrientation?: number;
  102397. }): VertexData;
  102398. /**
  102399. * Creates the VertexData for a tiled plane
  102400. * @param options an object used to set the following optional parameters for the box, required but can be empty
  102401. * * pattern a limited pattern arrangement depending on the number
  102402. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  102403. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  102404. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  102405. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102406. * * 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)
  102407. * * 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)
  102408. * @returns the VertexData of the tiled plane
  102409. */
  102410. static CreateTiledPlane(options: {
  102411. pattern?: number;
  102412. tileSize?: number;
  102413. tileWidth?: number;
  102414. tileHeight?: number;
  102415. size?: number;
  102416. width?: number;
  102417. height?: number;
  102418. alignHorizontal?: number;
  102419. alignVertical?: number;
  102420. sideOrientation?: number;
  102421. frontUVs?: Vector4;
  102422. backUVs?: Vector4;
  102423. }): VertexData;
  102424. /**
  102425. * Creates the VertexData for an ellipsoid, defaults to a sphere
  102426. * @param options an object used to set the following optional parameters for the box, required but can be empty
  102427. * * segments sets the number of horizontal strips optional, default 32
  102428. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  102429. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  102430. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  102431. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  102432. * * 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
  102433. * * 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
  102434. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102435. * * 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)
  102436. * * 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)
  102437. * @returns the VertexData of the ellipsoid
  102438. */
  102439. static CreateSphere(options: {
  102440. segments?: number;
  102441. diameter?: number;
  102442. diameterX?: number;
  102443. diameterY?: number;
  102444. diameterZ?: number;
  102445. arc?: number;
  102446. slice?: number;
  102447. sideOrientation?: number;
  102448. frontUVs?: Vector4;
  102449. backUVs?: Vector4;
  102450. }): VertexData;
  102451. /**
  102452. * Creates the VertexData for a cylinder, cone or prism
  102453. * @param options an object used to set the following optional parameters for the box, required but can be empty
  102454. * * height sets the height (y direction) of the cylinder, optional, default 2
  102455. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  102456. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  102457. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  102458. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  102459. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  102460. * * 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
  102461. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  102462. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  102463. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  102464. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  102465. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102466. * * 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)
  102467. * * 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)
  102468. * @returns the VertexData of the cylinder, cone or prism
  102469. */
  102470. static CreateCylinder(options: {
  102471. height?: number;
  102472. diameterTop?: number;
  102473. diameterBottom?: number;
  102474. diameter?: number;
  102475. tessellation?: number;
  102476. subdivisions?: number;
  102477. arc?: number;
  102478. faceColors?: Color4[];
  102479. faceUV?: Vector4[];
  102480. hasRings?: boolean;
  102481. enclose?: boolean;
  102482. sideOrientation?: number;
  102483. frontUVs?: Vector4;
  102484. backUVs?: Vector4;
  102485. }): VertexData;
  102486. /**
  102487. * Creates the VertexData for a torus
  102488. * @param options an object used to set the following optional parameters for the box, required but can be empty
  102489. * * diameter the diameter of the torus, optional default 1
  102490. * * thickness the diameter of the tube forming the torus, optional default 0.5
  102491. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  102492. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102493. * * 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)
  102494. * * 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)
  102495. * @returns the VertexData of the torus
  102496. */
  102497. static CreateTorus(options: {
  102498. diameter?: number;
  102499. thickness?: number;
  102500. tessellation?: number;
  102501. sideOrientation?: number;
  102502. frontUVs?: Vector4;
  102503. backUVs?: Vector4;
  102504. }): VertexData;
  102505. /**
  102506. * Creates the VertexData of the LineSystem
  102507. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  102508. * - lines an array of lines, each line being an array of successive Vector3
  102509. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  102510. * @returns the VertexData of the LineSystem
  102511. */
  102512. static CreateLineSystem(options: {
  102513. lines: Vector3[][];
  102514. colors?: Nullable<Color4[][]>;
  102515. }): VertexData;
  102516. /**
  102517. * Create the VertexData for a DashedLines
  102518. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  102519. * - points an array successive Vector3
  102520. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  102521. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  102522. * - dashNb the intended total number of dashes, optional, default 200
  102523. * @returns the VertexData for the DashedLines
  102524. */
  102525. static CreateDashedLines(options: {
  102526. points: Vector3[];
  102527. dashSize?: number;
  102528. gapSize?: number;
  102529. dashNb?: number;
  102530. }): VertexData;
  102531. /**
  102532. * Creates the VertexData for a Ground
  102533. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  102534. * - width the width (x direction) of the ground, optional, default 1
  102535. * - height the height (z direction) of the ground, optional, default 1
  102536. * - subdivisions the number of subdivisions per side, optional, default 1
  102537. * @returns the VertexData of the Ground
  102538. */
  102539. static CreateGround(options: {
  102540. width?: number;
  102541. height?: number;
  102542. subdivisions?: number;
  102543. subdivisionsX?: number;
  102544. subdivisionsY?: number;
  102545. }): VertexData;
  102546. /**
  102547. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  102548. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  102549. * * xmin the ground minimum X coordinate, optional, default -1
  102550. * * zmin the ground minimum Z coordinate, optional, default -1
  102551. * * xmax the ground maximum X coordinate, optional, default 1
  102552. * * zmax the ground maximum Z coordinate, optional, default 1
  102553. * * 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}
  102554. * * 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}
  102555. * @returns the VertexData of the TiledGround
  102556. */
  102557. static CreateTiledGround(options: {
  102558. xmin: number;
  102559. zmin: number;
  102560. xmax: number;
  102561. zmax: number;
  102562. subdivisions?: {
  102563. w: number;
  102564. h: number;
  102565. };
  102566. precision?: {
  102567. w: number;
  102568. h: number;
  102569. };
  102570. }): VertexData;
  102571. /**
  102572. * Creates the VertexData of the Ground designed from a heightmap
  102573. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  102574. * * width the width (x direction) of the ground
  102575. * * height the height (z direction) of the ground
  102576. * * subdivisions the number of subdivisions per side
  102577. * * minHeight the minimum altitude on the ground, optional, default 0
  102578. * * maxHeight the maximum altitude on the ground, optional default 1
  102579. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  102580. * * buffer the array holding the image color data
  102581. * * bufferWidth the width of image
  102582. * * bufferHeight the height of image
  102583. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  102584. * @returns the VertexData of the Ground designed from a heightmap
  102585. */
  102586. static CreateGroundFromHeightMap(options: {
  102587. width: number;
  102588. height: number;
  102589. subdivisions: number;
  102590. minHeight: number;
  102591. maxHeight: number;
  102592. colorFilter: Color3;
  102593. buffer: Uint8Array;
  102594. bufferWidth: number;
  102595. bufferHeight: number;
  102596. alphaFilter: number;
  102597. }): VertexData;
  102598. /**
  102599. * Creates the VertexData for a Plane
  102600. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  102601. * * size sets the width and height of the plane to the value of size, optional default 1
  102602. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  102603. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  102604. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102605. * * 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)
  102606. * * 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)
  102607. * @returns the VertexData of the box
  102608. */
  102609. static CreatePlane(options: {
  102610. size?: number;
  102611. width?: number;
  102612. height?: number;
  102613. sideOrientation?: number;
  102614. frontUVs?: Vector4;
  102615. backUVs?: Vector4;
  102616. }): VertexData;
  102617. /**
  102618. * Creates the VertexData of the Disc or regular Polygon
  102619. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  102620. * * radius the radius of the disc, optional default 0.5
  102621. * * tessellation the number of polygon sides, optional, default 64
  102622. * * 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
  102623. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102624. * * 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)
  102625. * * 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)
  102626. * @returns the VertexData of the box
  102627. */
  102628. static CreateDisc(options: {
  102629. radius?: number;
  102630. tessellation?: number;
  102631. arc?: number;
  102632. sideOrientation?: number;
  102633. frontUVs?: Vector4;
  102634. backUVs?: Vector4;
  102635. }): VertexData;
  102636. /**
  102637. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  102638. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  102639. * @param polygon a mesh built from polygonTriangulation.build()
  102640. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102641. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  102642. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  102643. * @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)
  102644. * @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)
  102645. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  102646. * @returns the VertexData of the Polygon
  102647. */
  102648. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  102649. /**
  102650. * Creates the VertexData of the IcoSphere
  102651. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  102652. * * radius the radius of the IcoSphere, optional default 1
  102653. * * radiusX allows stretching in the x direction, optional, default radius
  102654. * * radiusY allows stretching in the y direction, optional, default radius
  102655. * * radiusZ allows stretching in the z direction, optional, default radius
  102656. * * flat when true creates a flat shaded mesh, optional, default true
  102657. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  102658. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102659. * * 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)
  102660. * * 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)
  102661. * @returns the VertexData of the IcoSphere
  102662. */
  102663. static CreateIcoSphere(options: {
  102664. radius?: number;
  102665. radiusX?: number;
  102666. radiusY?: number;
  102667. radiusZ?: number;
  102668. flat?: boolean;
  102669. subdivisions?: number;
  102670. sideOrientation?: number;
  102671. frontUVs?: Vector4;
  102672. backUVs?: Vector4;
  102673. }): VertexData;
  102674. /**
  102675. * Creates the VertexData for a Polyhedron
  102676. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  102677. * * type provided types are:
  102678. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  102679. * * 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)
  102680. * * size the size of the IcoSphere, optional default 1
  102681. * * sizeX allows stretching in the x direction, optional, default size
  102682. * * sizeY allows stretching in the y direction, optional, default size
  102683. * * sizeZ allows stretching in the z direction, optional, default size
  102684. * * 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
  102685. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  102686. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  102687. * * flat when true creates a flat shaded mesh, optional, default true
  102688. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  102689. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102690. * * 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)
  102691. * * 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)
  102692. * @returns the VertexData of the Polyhedron
  102693. */
  102694. static CreatePolyhedron(options: {
  102695. type?: number;
  102696. size?: number;
  102697. sizeX?: number;
  102698. sizeY?: number;
  102699. sizeZ?: number;
  102700. custom?: any;
  102701. faceUV?: Vector4[];
  102702. faceColors?: Color4[];
  102703. flat?: boolean;
  102704. sideOrientation?: number;
  102705. frontUVs?: Vector4;
  102706. backUVs?: Vector4;
  102707. }): VertexData;
  102708. /**
  102709. * Creates the VertexData for a TorusKnot
  102710. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  102711. * * radius the radius of the torus knot, optional, default 2
  102712. * * tube the thickness of the tube, optional, default 0.5
  102713. * * radialSegments the number of sides on each tube segments, optional, default 32
  102714. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  102715. * * p the number of windings around the z axis, optional, default 2
  102716. * * q the number of windings around the x axis, optional, default 3
  102717. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102718. * * 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)
  102719. * * 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)
  102720. * @returns the VertexData of the Torus Knot
  102721. */
  102722. static CreateTorusKnot(options: {
  102723. radius?: number;
  102724. tube?: number;
  102725. radialSegments?: number;
  102726. tubularSegments?: number;
  102727. p?: number;
  102728. q?: number;
  102729. sideOrientation?: number;
  102730. frontUVs?: Vector4;
  102731. backUVs?: Vector4;
  102732. }): VertexData;
  102733. /**
  102734. * Compute normals for given positions and indices
  102735. * @param positions an array of vertex positions, [...., x, y, z, ......]
  102736. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  102737. * @param normals an array of vertex normals, [...., x, y, z, ......]
  102738. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  102739. * * facetNormals : optional array of facet normals (vector3)
  102740. * * facetPositions : optional array of facet positions (vector3)
  102741. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  102742. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  102743. * * bInfo : optional bounding info, required for facetPartitioning computation
  102744. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  102745. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  102746. * * useRightHandedSystem: optional boolean to for right handed system computation
  102747. * * depthSort : optional boolean to enable the facet depth sort computation
  102748. * * distanceTo : optional Vector3 to compute the facet depth from this location
  102749. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  102750. */
  102751. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  102752. facetNormals?: any;
  102753. facetPositions?: any;
  102754. facetPartitioning?: any;
  102755. ratio?: number;
  102756. bInfo?: any;
  102757. bbSize?: Vector3;
  102758. subDiv?: any;
  102759. useRightHandedSystem?: boolean;
  102760. depthSort?: boolean;
  102761. distanceTo?: Vector3;
  102762. depthSortedFacets?: any;
  102763. }): void;
  102764. /** @hidden */
  102765. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  102766. /**
  102767. * Applies VertexData created from the imported parameters to the geometry
  102768. * @param parsedVertexData the parsed data from an imported file
  102769. * @param geometry the geometry to apply the VertexData to
  102770. */
  102771. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  102772. }
  102773. }
  102774. declare module BABYLON {
  102775. /**
  102776. * Defines a target to use with MorphTargetManager
  102777. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  102778. */
  102779. export class MorphTarget implements IAnimatable {
  102780. /** defines the name of the target */
  102781. name: string;
  102782. /**
  102783. * Gets or sets the list of animations
  102784. */
  102785. animations: Animation[];
  102786. private _scene;
  102787. private _positions;
  102788. private _normals;
  102789. private _tangents;
  102790. private _uvs;
  102791. private _influence;
  102792. private _uniqueId;
  102793. /**
  102794. * Observable raised when the influence changes
  102795. */
  102796. onInfluenceChanged: Observable<boolean>;
  102797. /** @hidden */
  102798. _onDataLayoutChanged: Observable<void>;
  102799. /**
  102800. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  102801. */
  102802. get influence(): number;
  102803. set influence(influence: number);
  102804. /**
  102805. * Gets or sets the id of the morph Target
  102806. */
  102807. id: string;
  102808. private _animationPropertiesOverride;
  102809. /**
  102810. * Gets or sets the animation properties override
  102811. */
  102812. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  102813. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  102814. /**
  102815. * Creates a new MorphTarget
  102816. * @param name defines the name of the target
  102817. * @param influence defines the influence to use
  102818. * @param scene defines the scene the morphtarget belongs to
  102819. */
  102820. constructor(
  102821. /** defines the name of the target */
  102822. name: string, influence?: number, scene?: Nullable<Scene>);
  102823. /**
  102824. * Gets the unique ID of this manager
  102825. */
  102826. get uniqueId(): number;
  102827. /**
  102828. * Gets a boolean defining if the target contains position data
  102829. */
  102830. get hasPositions(): boolean;
  102831. /**
  102832. * Gets a boolean defining if the target contains normal data
  102833. */
  102834. get hasNormals(): boolean;
  102835. /**
  102836. * Gets a boolean defining if the target contains tangent data
  102837. */
  102838. get hasTangents(): boolean;
  102839. /**
  102840. * Gets a boolean defining if the target contains texture coordinates data
  102841. */
  102842. get hasUVs(): boolean;
  102843. /**
  102844. * Affects position data to this target
  102845. * @param data defines the position data to use
  102846. */
  102847. setPositions(data: Nullable<FloatArray>): void;
  102848. /**
  102849. * Gets the position data stored in this target
  102850. * @returns a FloatArray containing the position data (or null if not present)
  102851. */
  102852. getPositions(): Nullable<FloatArray>;
  102853. /**
  102854. * Affects normal data to this target
  102855. * @param data defines the normal data to use
  102856. */
  102857. setNormals(data: Nullable<FloatArray>): void;
  102858. /**
  102859. * Gets the normal data stored in this target
  102860. * @returns a FloatArray containing the normal data (or null if not present)
  102861. */
  102862. getNormals(): Nullable<FloatArray>;
  102863. /**
  102864. * Affects tangent data to this target
  102865. * @param data defines the tangent data to use
  102866. */
  102867. setTangents(data: Nullable<FloatArray>): void;
  102868. /**
  102869. * Gets the tangent data stored in this target
  102870. * @returns a FloatArray containing the tangent data (or null if not present)
  102871. */
  102872. getTangents(): Nullable<FloatArray>;
  102873. /**
  102874. * Affects texture coordinates data to this target
  102875. * @param data defines the texture coordinates data to use
  102876. */
  102877. setUVs(data: Nullable<FloatArray>): void;
  102878. /**
  102879. * Gets the texture coordinates data stored in this target
  102880. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  102881. */
  102882. getUVs(): Nullable<FloatArray>;
  102883. /**
  102884. * Clone the current target
  102885. * @returns a new MorphTarget
  102886. */
  102887. clone(): MorphTarget;
  102888. /**
  102889. * Serializes the current target into a Serialization object
  102890. * @returns the serialized object
  102891. */
  102892. serialize(): any;
  102893. /**
  102894. * Returns the string "MorphTarget"
  102895. * @returns "MorphTarget"
  102896. */
  102897. getClassName(): string;
  102898. /**
  102899. * Creates a new target from serialized data
  102900. * @param serializationObject defines the serialized data to use
  102901. * @returns a new MorphTarget
  102902. */
  102903. static Parse(serializationObject: any): MorphTarget;
  102904. /**
  102905. * Creates a MorphTarget from mesh data
  102906. * @param mesh defines the source mesh
  102907. * @param name defines the name to use for the new target
  102908. * @param influence defines the influence to attach to the target
  102909. * @returns a new MorphTarget
  102910. */
  102911. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  102912. }
  102913. }
  102914. declare module BABYLON {
  102915. /**
  102916. * This class is used to deform meshes using morphing between different targets
  102917. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  102918. */
  102919. export class MorphTargetManager {
  102920. private _targets;
  102921. private _targetInfluenceChangedObservers;
  102922. private _targetDataLayoutChangedObservers;
  102923. private _activeTargets;
  102924. private _scene;
  102925. private _influences;
  102926. private _supportsNormals;
  102927. private _supportsTangents;
  102928. private _supportsUVs;
  102929. private _vertexCount;
  102930. private _uniqueId;
  102931. private _tempInfluences;
  102932. /**
  102933. * Gets or sets a boolean indicating if normals must be morphed
  102934. */
  102935. enableNormalMorphing: boolean;
  102936. /**
  102937. * Gets or sets a boolean indicating if tangents must be morphed
  102938. */
  102939. enableTangentMorphing: boolean;
  102940. /**
  102941. * Gets or sets a boolean indicating if UV must be morphed
  102942. */
  102943. enableUVMorphing: boolean;
  102944. /**
  102945. * Creates a new MorphTargetManager
  102946. * @param scene defines the current scene
  102947. */
  102948. constructor(scene?: Nullable<Scene>);
  102949. /**
  102950. * Gets the unique ID of this manager
  102951. */
  102952. get uniqueId(): number;
  102953. /**
  102954. * Gets the number of vertices handled by this manager
  102955. */
  102956. get vertexCount(): number;
  102957. /**
  102958. * Gets a boolean indicating if this manager supports morphing of normals
  102959. */
  102960. get supportsNormals(): boolean;
  102961. /**
  102962. * Gets a boolean indicating if this manager supports morphing of tangents
  102963. */
  102964. get supportsTangents(): boolean;
  102965. /**
  102966. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  102967. */
  102968. get supportsUVs(): boolean;
  102969. /**
  102970. * Gets the number of targets stored in this manager
  102971. */
  102972. get numTargets(): number;
  102973. /**
  102974. * Gets the number of influencers (ie. the number of targets with influences > 0)
  102975. */
  102976. get numInfluencers(): number;
  102977. /**
  102978. * Gets the list of influences (one per target)
  102979. */
  102980. get influences(): Float32Array;
  102981. /**
  102982. * Gets the active target at specified index. An active target is a target with an influence > 0
  102983. * @param index defines the index to check
  102984. * @returns the requested target
  102985. */
  102986. getActiveTarget(index: number): MorphTarget;
  102987. /**
  102988. * Gets the target at specified index
  102989. * @param index defines the index to check
  102990. * @returns the requested target
  102991. */
  102992. getTarget(index: number): MorphTarget;
  102993. /**
  102994. * Add a new target to this manager
  102995. * @param target defines the target to add
  102996. */
  102997. addTarget(target: MorphTarget): void;
  102998. /**
  102999. * Removes a target from the manager
  103000. * @param target defines the target to remove
  103001. */
  103002. removeTarget(target: MorphTarget): void;
  103003. /**
  103004. * Clone the current manager
  103005. * @returns a new MorphTargetManager
  103006. */
  103007. clone(): MorphTargetManager;
  103008. /**
  103009. * Serializes the current manager into a Serialization object
  103010. * @returns the serialized object
  103011. */
  103012. serialize(): any;
  103013. private _syncActiveTargets;
  103014. /**
  103015. * Syncrhonize the targets with all the meshes using this morph target manager
  103016. */
  103017. synchronize(): void;
  103018. /**
  103019. * Creates a new MorphTargetManager from serialized data
  103020. * @param serializationObject defines the serialized data
  103021. * @param scene defines the hosting scene
  103022. * @returns the new MorphTargetManager
  103023. */
  103024. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  103025. }
  103026. }
  103027. declare module BABYLON {
  103028. /**
  103029. * Class used to represent a specific level of detail of a mesh
  103030. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  103031. */
  103032. export class MeshLODLevel {
  103033. /** Defines the distance where this level should start being displayed */
  103034. distance: number;
  103035. /** Defines the mesh to use to render this level */
  103036. mesh: Nullable<Mesh>;
  103037. /**
  103038. * Creates a new LOD level
  103039. * @param distance defines the distance where this level should star being displayed
  103040. * @param mesh defines the mesh to use to render this level
  103041. */
  103042. constructor(
  103043. /** Defines the distance where this level should start being displayed */
  103044. distance: number,
  103045. /** Defines the mesh to use to render this level */
  103046. mesh: Nullable<Mesh>);
  103047. }
  103048. }
  103049. declare module BABYLON {
  103050. /**
  103051. * Mesh representing the gorund
  103052. */
  103053. export class GroundMesh extends Mesh {
  103054. /** If octree should be generated */
  103055. generateOctree: boolean;
  103056. private _heightQuads;
  103057. /** @hidden */
  103058. _subdivisionsX: number;
  103059. /** @hidden */
  103060. _subdivisionsY: number;
  103061. /** @hidden */
  103062. _width: number;
  103063. /** @hidden */
  103064. _height: number;
  103065. /** @hidden */
  103066. _minX: number;
  103067. /** @hidden */
  103068. _maxX: number;
  103069. /** @hidden */
  103070. _minZ: number;
  103071. /** @hidden */
  103072. _maxZ: number;
  103073. constructor(name: string, scene: Scene);
  103074. /**
  103075. * "GroundMesh"
  103076. * @returns "GroundMesh"
  103077. */
  103078. getClassName(): string;
  103079. /**
  103080. * The minimum of x and y subdivisions
  103081. */
  103082. get subdivisions(): number;
  103083. /**
  103084. * X subdivisions
  103085. */
  103086. get subdivisionsX(): number;
  103087. /**
  103088. * Y subdivisions
  103089. */
  103090. get subdivisionsY(): number;
  103091. /**
  103092. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  103093. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  103094. * @param chunksCount the number of subdivisions for x and y
  103095. * @param octreeBlocksSize (Default: 32)
  103096. */
  103097. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  103098. /**
  103099. * Returns a height (y) value in the Worl system :
  103100. * the ground altitude at the coordinates (x, z) expressed in the World system.
  103101. * @param x x coordinate
  103102. * @param z z coordinate
  103103. * @returns the ground y position if (x, z) are outside the ground surface.
  103104. */
  103105. getHeightAtCoordinates(x: number, z: number): number;
  103106. /**
  103107. * Returns a normalized vector (Vector3) orthogonal to the ground
  103108. * at the ground coordinates (x, z) expressed in the World system.
  103109. * @param x x coordinate
  103110. * @param z z coordinate
  103111. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  103112. */
  103113. getNormalAtCoordinates(x: number, z: number): Vector3;
  103114. /**
  103115. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  103116. * at the ground coordinates (x, z) expressed in the World system.
  103117. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  103118. * @param x x coordinate
  103119. * @param z z coordinate
  103120. * @param ref vector to store the result
  103121. * @returns the GroundMesh.
  103122. */
  103123. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  103124. /**
  103125. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  103126. * if the ground has been updated.
  103127. * This can be used in the render loop.
  103128. * @returns the GroundMesh.
  103129. */
  103130. updateCoordinateHeights(): GroundMesh;
  103131. private _getFacetAt;
  103132. private _initHeightQuads;
  103133. private _computeHeightQuads;
  103134. /**
  103135. * Serializes this ground mesh
  103136. * @param serializationObject object to write serialization to
  103137. */
  103138. serialize(serializationObject: any): void;
  103139. /**
  103140. * Parses a serialized ground mesh
  103141. * @param parsedMesh the serialized mesh
  103142. * @param scene the scene to create the ground mesh in
  103143. * @returns the created ground mesh
  103144. */
  103145. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  103146. }
  103147. }
  103148. declare module BABYLON {
  103149. /**
  103150. * Interface for Physics-Joint data
  103151. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103152. */
  103153. export interface PhysicsJointData {
  103154. /**
  103155. * The main pivot of the joint
  103156. */
  103157. mainPivot?: Vector3;
  103158. /**
  103159. * The connected pivot of the joint
  103160. */
  103161. connectedPivot?: Vector3;
  103162. /**
  103163. * The main axis of the joint
  103164. */
  103165. mainAxis?: Vector3;
  103166. /**
  103167. * The connected axis of the joint
  103168. */
  103169. connectedAxis?: Vector3;
  103170. /**
  103171. * The collision of the joint
  103172. */
  103173. collision?: boolean;
  103174. /**
  103175. * Native Oimo/Cannon/Energy data
  103176. */
  103177. nativeParams?: any;
  103178. }
  103179. /**
  103180. * This is a holder class for the physics joint created by the physics plugin
  103181. * It holds a set of functions to control the underlying joint
  103182. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103183. */
  103184. export class PhysicsJoint {
  103185. /**
  103186. * The type of the physics joint
  103187. */
  103188. type: number;
  103189. /**
  103190. * The data for the physics joint
  103191. */
  103192. jointData: PhysicsJointData;
  103193. private _physicsJoint;
  103194. protected _physicsPlugin: IPhysicsEnginePlugin;
  103195. /**
  103196. * Initializes the physics joint
  103197. * @param type The type of the physics joint
  103198. * @param jointData The data for the physics joint
  103199. */
  103200. constructor(
  103201. /**
  103202. * The type of the physics joint
  103203. */
  103204. type: number,
  103205. /**
  103206. * The data for the physics joint
  103207. */
  103208. jointData: PhysicsJointData);
  103209. /**
  103210. * Gets the physics joint
  103211. */
  103212. get physicsJoint(): any;
  103213. /**
  103214. * Sets the physics joint
  103215. */
  103216. set physicsJoint(newJoint: any);
  103217. /**
  103218. * Sets the physics plugin
  103219. */
  103220. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  103221. /**
  103222. * Execute a function that is physics-plugin specific.
  103223. * @param {Function} func the function that will be executed.
  103224. * It accepts two parameters: the physics world and the physics joint
  103225. */
  103226. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  103227. /**
  103228. * Distance-Joint type
  103229. */
  103230. static DistanceJoint: number;
  103231. /**
  103232. * Hinge-Joint type
  103233. */
  103234. static HingeJoint: number;
  103235. /**
  103236. * Ball-and-Socket joint type
  103237. */
  103238. static BallAndSocketJoint: number;
  103239. /**
  103240. * Wheel-Joint type
  103241. */
  103242. static WheelJoint: number;
  103243. /**
  103244. * Slider-Joint type
  103245. */
  103246. static SliderJoint: number;
  103247. /**
  103248. * Prismatic-Joint type
  103249. */
  103250. static PrismaticJoint: number;
  103251. /**
  103252. * Universal-Joint type
  103253. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  103254. */
  103255. static UniversalJoint: number;
  103256. /**
  103257. * Hinge-Joint 2 type
  103258. */
  103259. static Hinge2Joint: number;
  103260. /**
  103261. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  103262. */
  103263. static PointToPointJoint: number;
  103264. /**
  103265. * Spring-Joint type
  103266. */
  103267. static SpringJoint: number;
  103268. /**
  103269. * Lock-Joint type
  103270. */
  103271. static LockJoint: number;
  103272. }
  103273. /**
  103274. * A class representing a physics distance joint
  103275. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103276. */
  103277. export class DistanceJoint extends PhysicsJoint {
  103278. /**
  103279. *
  103280. * @param jointData The data for the Distance-Joint
  103281. */
  103282. constructor(jointData: DistanceJointData);
  103283. /**
  103284. * Update the predefined distance.
  103285. * @param maxDistance The maximum preferred distance
  103286. * @param minDistance The minimum preferred distance
  103287. */
  103288. updateDistance(maxDistance: number, minDistance?: number): void;
  103289. }
  103290. /**
  103291. * Represents a Motor-Enabled Joint
  103292. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103293. */
  103294. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  103295. /**
  103296. * Initializes the Motor-Enabled Joint
  103297. * @param type The type of the joint
  103298. * @param jointData The physica joint data for the joint
  103299. */
  103300. constructor(type: number, jointData: PhysicsJointData);
  103301. /**
  103302. * Set the motor values.
  103303. * Attention, this function is plugin specific. Engines won't react 100% the same.
  103304. * @param force the force to apply
  103305. * @param maxForce max force for this motor.
  103306. */
  103307. setMotor(force?: number, maxForce?: number): void;
  103308. /**
  103309. * Set the motor's limits.
  103310. * Attention, this function is plugin specific. Engines won't react 100% the same.
  103311. * @param upperLimit The upper limit of the motor
  103312. * @param lowerLimit The lower limit of the motor
  103313. */
  103314. setLimit(upperLimit: number, lowerLimit?: number): void;
  103315. }
  103316. /**
  103317. * This class represents a single physics Hinge-Joint
  103318. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103319. */
  103320. export class HingeJoint extends MotorEnabledJoint {
  103321. /**
  103322. * Initializes the Hinge-Joint
  103323. * @param jointData The joint data for the Hinge-Joint
  103324. */
  103325. constructor(jointData: PhysicsJointData);
  103326. /**
  103327. * Set the motor values.
  103328. * Attention, this function is plugin specific. Engines won't react 100% the same.
  103329. * @param {number} force the force to apply
  103330. * @param {number} maxForce max force for this motor.
  103331. */
  103332. setMotor(force?: number, maxForce?: number): void;
  103333. /**
  103334. * Set the motor's limits.
  103335. * Attention, this function is plugin specific. Engines won't react 100% the same.
  103336. * @param upperLimit The upper limit of the motor
  103337. * @param lowerLimit The lower limit of the motor
  103338. */
  103339. setLimit(upperLimit: number, lowerLimit?: number): void;
  103340. }
  103341. /**
  103342. * This class represents a dual hinge physics joint (same as wheel joint)
  103343. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103344. */
  103345. export class Hinge2Joint extends MotorEnabledJoint {
  103346. /**
  103347. * Initializes the Hinge2-Joint
  103348. * @param jointData The joint data for the Hinge2-Joint
  103349. */
  103350. constructor(jointData: PhysicsJointData);
  103351. /**
  103352. * Set the motor values.
  103353. * Attention, this function is plugin specific. Engines won't react 100% the same.
  103354. * @param {number} targetSpeed the speed the motor is to reach
  103355. * @param {number} maxForce max force for this motor.
  103356. * @param {motorIndex} the motor's index, 0 or 1.
  103357. */
  103358. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  103359. /**
  103360. * Set the motor limits.
  103361. * Attention, this function is plugin specific. Engines won't react 100% the same.
  103362. * @param {number} upperLimit the upper limit
  103363. * @param {number} lowerLimit lower limit
  103364. * @param {motorIndex} the motor's index, 0 or 1.
  103365. */
  103366. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  103367. }
  103368. /**
  103369. * Interface for a motor enabled joint
  103370. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103371. */
  103372. export interface IMotorEnabledJoint {
  103373. /**
  103374. * Physics joint
  103375. */
  103376. physicsJoint: any;
  103377. /**
  103378. * Sets the motor of the motor-enabled joint
  103379. * @param force The force of the motor
  103380. * @param maxForce The maximum force of the motor
  103381. * @param motorIndex The index of the motor
  103382. */
  103383. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  103384. /**
  103385. * Sets the limit of the motor
  103386. * @param upperLimit The upper limit of the motor
  103387. * @param lowerLimit The lower limit of the motor
  103388. * @param motorIndex The index of the motor
  103389. */
  103390. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  103391. }
  103392. /**
  103393. * Joint data for a Distance-Joint
  103394. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103395. */
  103396. export interface DistanceJointData extends PhysicsJointData {
  103397. /**
  103398. * Max distance the 2 joint objects can be apart
  103399. */
  103400. maxDistance: number;
  103401. }
  103402. /**
  103403. * Joint data from a spring joint
  103404. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103405. */
  103406. export interface SpringJointData extends PhysicsJointData {
  103407. /**
  103408. * Length of the spring
  103409. */
  103410. length: number;
  103411. /**
  103412. * Stiffness of the spring
  103413. */
  103414. stiffness: number;
  103415. /**
  103416. * Damping of the spring
  103417. */
  103418. damping: number;
  103419. /** this callback will be called when applying the force to the impostors. */
  103420. forceApplicationCallback: () => void;
  103421. }
  103422. }
  103423. declare module BABYLON {
  103424. /**
  103425. * Holds the data for the raycast result
  103426. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103427. */
  103428. export class PhysicsRaycastResult {
  103429. private _hasHit;
  103430. private _hitDistance;
  103431. private _hitNormalWorld;
  103432. private _hitPointWorld;
  103433. private _rayFromWorld;
  103434. private _rayToWorld;
  103435. /**
  103436. * Gets if there was a hit
  103437. */
  103438. get hasHit(): boolean;
  103439. /**
  103440. * Gets the distance from the hit
  103441. */
  103442. get hitDistance(): number;
  103443. /**
  103444. * Gets the hit normal/direction in the world
  103445. */
  103446. get hitNormalWorld(): Vector3;
  103447. /**
  103448. * Gets the hit point in the world
  103449. */
  103450. get hitPointWorld(): Vector3;
  103451. /**
  103452. * Gets the ray "start point" of the ray in the world
  103453. */
  103454. get rayFromWorld(): Vector3;
  103455. /**
  103456. * Gets the ray "end point" of the ray in the world
  103457. */
  103458. get rayToWorld(): Vector3;
  103459. /**
  103460. * Sets the hit data (normal & point in world space)
  103461. * @param hitNormalWorld defines the normal in world space
  103462. * @param hitPointWorld defines the point in world space
  103463. */
  103464. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  103465. /**
  103466. * Sets the distance from the start point to the hit point
  103467. * @param distance
  103468. */
  103469. setHitDistance(distance: number): void;
  103470. /**
  103471. * Calculates the distance manually
  103472. */
  103473. calculateHitDistance(): void;
  103474. /**
  103475. * Resets all the values to default
  103476. * @param from The from point on world space
  103477. * @param to The to point on world space
  103478. */
  103479. reset(from?: Vector3, to?: Vector3): void;
  103480. }
  103481. /**
  103482. * Interface for the size containing width and height
  103483. */
  103484. interface IXYZ {
  103485. /**
  103486. * X
  103487. */
  103488. x: number;
  103489. /**
  103490. * Y
  103491. */
  103492. y: number;
  103493. /**
  103494. * Z
  103495. */
  103496. z: number;
  103497. }
  103498. }
  103499. declare module BABYLON {
  103500. /**
  103501. * Interface used to describe a physics joint
  103502. */
  103503. export interface PhysicsImpostorJoint {
  103504. /** Defines the main impostor to which the joint is linked */
  103505. mainImpostor: PhysicsImpostor;
  103506. /** Defines the impostor that is connected to the main impostor using this joint */
  103507. connectedImpostor: PhysicsImpostor;
  103508. /** Defines the joint itself */
  103509. joint: PhysicsJoint;
  103510. }
  103511. /** @hidden */
  103512. export interface IPhysicsEnginePlugin {
  103513. world: any;
  103514. name: string;
  103515. setGravity(gravity: Vector3): void;
  103516. setTimeStep(timeStep: number): void;
  103517. getTimeStep(): number;
  103518. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  103519. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  103520. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  103521. generatePhysicsBody(impostor: PhysicsImpostor): void;
  103522. removePhysicsBody(impostor: PhysicsImpostor): void;
  103523. generateJoint(joint: PhysicsImpostorJoint): void;
  103524. removeJoint(joint: PhysicsImpostorJoint): void;
  103525. isSupported(): boolean;
  103526. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  103527. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  103528. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  103529. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  103530. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  103531. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  103532. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  103533. getBodyMass(impostor: PhysicsImpostor): number;
  103534. getBodyFriction(impostor: PhysicsImpostor): number;
  103535. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  103536. getBodyRestitution(impostor: PhysicsImpostor): number;
  103537. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  103538. getBodyPressure?(impostor: PhysicsImpostor): number;
  103539. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  103540. getBodyStiffness?(impostor: PhysicsImpostor): number;
  103541. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  103542. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  103543. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  103544. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  103545. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  103546. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  103547. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  103548. sleepBody(impostor: PhysicsImpostor): void;
  103549. wakeUpBody(impostor: PhysicsImpostor): void;
  103550. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  103551. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  103552. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  103553. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  103554. getRadius(impostor: PhysicsImpostor): number;
  103555. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  103556. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  103557. dispose(): void;
  103558. }
  103559. /**
  103560. * Interface used to define a physics engine
  103561. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  103562. */
  103563. export interface IPhysicsEngine {
  103564. /**
  103565. * Gets the gravity vector used by the simulation
  103566. */
  103567. gravity: Vector3;
  103568. /**
  103569. * Sets the gravity vector used by the simulation
  103570. * @param gravity defines the gravity vector to use
  103571. */
  103572. setGravity(gravity: Vector3): void;
  103573. /**
  103574. * Set the time step of the physics engine.
  103575. * Default is 1/60.
  103576. * To slow it down, enter 1/600 for example.
  103577. * To speed it up, 1/30
  103578. * @param newTimeStep the new timestep to apply to this world.
  103579. */
  103580. setTimeStep(newTimeStep: number): void;
  103581. /**
  103582. * Get the time step of the physics engine.
  103583. * @returns the current time step
  103584. */
  103585. getTimeStep(): number;
  103586. /**
  103587. * Set the sub time step of the physics engine.
  103588. * Default is 0 meaning there is no sub steps
  103589. * To increase physics resolution precision, set a small value (like 1 ms)
  103590. * @param subTimeStep defines the new sub timestep used for physics resolution.
  103591. */
  103592. setSubTimeStep(subTimeStep: number): void;
  103593. /**
  103594. * Get the sub time step of the physics engine.
  103595. * @returns the current sub time step
  103596. */
  103597. getSubTimeStep(): number;
  103598. /**
  103599. * Release all resources
  103600. */
  103601. dispose(): void;
  103602. /**
  103603. * Gets the name of the current physics plugin
  103604. * @returns the name of the plugin
  103605. */
  103606. getPhysicsPluginName(): string;
  103607. /**
  103608. * Adding a new impostor for the impostor tracking.
  103609. * This will be done by the impostor itself.
  103610. * @param impostor the impostor to add
  103611. */
  103612. addImpostor(impostor: PhysicsImpostor): void;
  103613. /**
  103614. * Remove an impostor from the engine.
  103615. * This impostor and its mesh will not longer be updated by the physics engine.
  103616. * @param impostor the impostor to remove
  103617. */
  103618. removeImpostor(impostor: PhysicsImpostor): void;
  103619. /**
  103620. * Add a joint to the physics engine
  103621. * @param mainImpostor defines the main impostor to which the joint is added.
  103622. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  103623. * @param joint defines the joint that will connect both impostors.
  103624. */
  103625. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  103626. /**
  103627. * Removes a joint from the simulation
  103628. * @param mainImpostor defines the impostor used with the joint
  103629. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  103630. * @param joint defines the joint to remove
  103631. */
  103632. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  103633. /**
  103634. * Gets the current plugin used to run the simulation
  103635. * @returns current plugin
  103636. */
  103637. getPhysicsPlugin(): IPhysicsEnginePlugin;
  103638. /**
  103639. * Gets the list of physic impostors
  103640. * @returns an array of PhysicsImpostor
  103641. */
  103642. getImpostors(): Array<PhysicsImpostor>;
  103643. /**
  103644. * Gets the impostor for a physics enabled object
  103645. * @param object defines the object impersonated by the impostor
  103646. * @returns the PhysicsImpostor or null if not found
  103647. */
  103648. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  103649. /**
  103650. * Gets the impostor for a physics body object
  103651. * @param body defines physics body used by the impostor
  103652. * @returns the PhysicsImpostor or null if not found
  103653. */
  103654. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  103655. /**
  103656. * Does a raycast in the physics world
  103657. * @param from when should the ray start?
  103658. * @param to when should the ray end?
  103659. * @returns PhysicsRaycastResult
  103660. */
  103661. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  103662. /**
  103663. * Called by the scene. No need to call it.
  103664. * @param delta defines the timespam between frames
  103665. */
  103666. _step(delta: number): void;
  103667. }
  103668. }
  103669. declare module BABYLON {
  103670. /**
  103671. * The interface for the physics imposter parameters
  103672. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103673. */
  103674. export interface PhysicsImpostorParameters {
  103675. /**
  103676. * The mass of the physics imposter
  103677. */
  103678. mass: number;
  103679. /**
  103680. * The friction of the physics imposter
  103681. */
  103682. friction?: number;
  103683. /**
  103684. * The coefficient of restitution of the physics imposter
  103685. */
  103686. restitution?: number;
  103687. /**
  103688. * The native options of the physics imposter
  103689. */
  103690. nativeOptions?: any;
  103691. /**
  103692. * Specifies if the parent should be ignored
  103693. */
  103694. ignoreParent?: boolean;
  103695. /**
  103696. * Specifies if bi-directional transformations should be disabled
  103697. */
  103698. disableBidirectionalTransformation?: boolean;
  103699. /**
  103700. * The pressure inside the physics imposter, soft object only
  103701. */
  103702. pressure?: number;
  103703. /**
  103704. * The stiffness the physics imposter, soft object only
  103705. */
  103706. stiffness?: number;
  103707. /**
  103708. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  103709. */
  103710. velocityIterations?: number;
  103711. /**
  103712. * The number of iterations used in maintaining consistent vertex positions, soft object only
  103713. */
  103714. positionIterations?: number;
  103715. /**
  103716. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  103717. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  103718. * Add to fix multiple points
  103719. */
  103720. fixedPoints?: number;
  103721. /**
  103722. * The collision margin around a soft object
  103723. */
  103724. margin?: number;
  103725. /**
  103726. * The collision margin around a soft object
  103727. */
  103728. damping?: number;
  103729. /**
  103730. * The path for a rope based on an extrusion
  103731. */
  103732. path?: any;
  103733. /**
  103734. * The shape of an extrusion used for a rope based on an extrusion
  103735. */
  103736. shape?: any;
  103737. }
  103738. /**
  103739. * Interface for a physics-enabled object
  103740. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103741. */
  103742. export interface IPhysicsEnabledObject {
  103743. /**
  103744. * The position of the physics-enabled object
  103745. */
  103746. position: Vector3;
  103747. /**
  103748. * The rotation of the physics-enabled object
  103749. */
  103750. rotationQuaternion: Nullable<Quaternion>;
  103751. /**
  103752. * The scale of the physics-enabled object
  103753. */
  103754. scaling: Vector3;
  103755. /**
  103756. * The rotation of the physics-enabled object
  103757. */
  103758. rotation?: Vector3;
  103759. /**
  103760. * The parent of the physics-enabled object
  103761. */
  103762. parent?: any;
  103763. /**
  103764. * The bounding info of the physics-enabled object
  103765. * @returns The bounding info of the physics-enabled object
  103766. */
  103767. getBoundingInfo(): BoundingInfo;
  103768. /**
  103769. * Computes the world matrix
  103770. * @param force Specifies if the world matrix should be computed by force
  103771. * @returns A world matrix
  103772. */
  103773. computeWorldMatrix(force: boolean): Matrix;
  103774. /**
  103775. * Gets the world matrix
  103776. * @returns A world matrix
  103777. */
  103778. getWorldMatrix?(): Matrix;
  103779. /**
  103780. * Gets the child meshes
  103781. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  103782. * @returns An array of abstract meshes
  103783. */
  103784. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  103785. /**
  103786. * Gets the vertex data
  103787. * @param kind The type of vertex data
  103788. * @returns A nullable array of numbers, or a float32 array
  103789. */
  103790. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  103791. /**
  103792. * Gets the indices from the mesh
  103793. * @returns A nullable array of index arrays
  103794. */
  103795. getIndices?(): Nullable<IndicesArray>;
  103796. /**
  103797. * Gets the scene from the mesh
  103798. * @returns the indices array or null
  103799. */
  103800. getScene?(): Scene;
  103801. /**
  103802. * Gets the absolute position from the mesh
  103803. * @returns the absolute position
  103804. */
  103805. getAbsolutePosition(): Vector3;
  103806. /**
  103807. * Gets the absolute pivot point from the mesh
  103808. * @returns the absolute pivot point
  103809. */
  103810. getAbsolutePivotPoint(): Vector3;
  103811. /**
  103812. * Rotates the mesh
  103813. * @param axis The axis of rotation
  103814. * @param amount The amount of rotation
  103815. * @param space The space of the rotation
  103816. * @returns The rotation transform node
  103817. */
  103818. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  103819. /**
  103820. * Translates the mesh
  103821. * @param axis The axis of translation
  103822. * @param distance The distance of translation
  103823. * @param space The space of the translation
  103824. * @returns The transform node
  103825. */
  103826. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  103827. /**
  103828. * Sets the absolute position of the mesh
  103829. * @param absolutePosition The absolute position of the mesh
  103830. * @returns The transform node
  103831. */
  103832. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  103833. /**
  103834. * Gets the class name of the mesh
  103835. * @returns The class name
  103836. */
  103837. getClassName(): string;
  103838. }
  103839. /**
  103840. * Represents a physics imposter
  103841. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103842. */
  103843. export class PhysicsImpostor {
  103844. /**
  103845. * The physics-enabled object used as the physics imposter
  103846. */
  103847. object: IPhysicsEnabledObject;
  103848. /**
  103849. * The type of the physics imposter
  103850. */
  103851. type: number;
  103852. private _options;
  103853. private _scene?;
  103854. /**
  103855. * The default object size of the imposter
  103856. */
  103857. static DEFAULT_OBJECT_SIZE: Vector3;
  103858. /**
  103859. * The identity quaternion of the imposter
  103860. */
  103861. static IDENTITY_QUATERNION: Quaternion;
  103862. /** @hidden */
  103863. _pluginData: any;
  103864. private _physicsEngine;
  103865. private _physicsBody;
  103866. private _bodyUpdateRequired;
  103867. private _onBeforePhysicsStepCallbacks;
  103868. private _onAfterPhysicsStepCallbacks;
  103869. /** @hidden */
  103870. _onPhysicsCollideCallbacks: Array<{
  103871. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  103872. otherImpostors: Array<PhysicsImpostor>;
  103873. }>;
  103874. private _deltaPosition;
  103875. private _deltaRotation;
  103876. private _deltaRotationConjugated;
  103877. /** @hidden */
  103878. _isFromLine: boolean;
  103879. private _parent;
  103880. private _isDisposed;
  103881. private static _tmpVecs;
  103882. private static _tmpQuat;
  103883. /**
  103884. * Specifies if the physics imposter is disposed
  103885. */
  103886. get isDisposed(): boolean;
  103887. /**
  103888. * Gets the mass of the physics imposter
  103889. */
  103890. get mass(): number;
  103891. set mass(value: number);
  103892. /**
  103893. * Gets the coefficient of friction
  103894. */
  103895. get friction(): number;
  103896. /**
  103897. * Sets the coefficient of friction
  103898. */
  103899. set friction(value: number);
  103900. /**
  103901. * Gets the coefficient of restitution
  103902. */
  103903. get restitution(): number;
  103904. /**
  103905. * Sets the coefficient of restitution
  103906. */
  103907. set restitution(value: number);
  103908. /**
  103909. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  103910. */
  103911. get pressure(): number;
  103912. /**
  103913. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  103914. */
  103915. set pressure(value: number);
  103916. /**
  103917. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  103918. */
  103919. get stiffness(): number;
  103920. /**
  103921. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  103922. */
  103923. set stiffness(value: number);
  103924. /**
  103925. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  103926. */
  103927. get velocityIterations(): number;
  103928. /**
  103929. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  103930. */
  103931. set velocityIterations(value: number);
  103932. /**
  103933. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  103934. */
  103935. get positionIterations(): number;
  103936. /**
  103937. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  103938. */
  103939. set positionIterations(value: number);
  103940. /**
  103941. * The unique id of the physics imposter
  103942. * set by the physics engine when adding this impostor to the array
  103943. */
  103944. uniqueId: number;
  103945. /**
  103946. * @hidden
  103947. */
  103948. soft: boolean;
  103949. /**
  103950. * @hidden
  103951. */
  103952. segments: number;
  103953. private _joints;
  103954. /**
  103955. * Initializes the physics imposter
  103956. * @param object The physics-enabled object used as the physics imposter
  103957. * @param type The type of the physics imposter
  103958. * @param _options The options for the physics imposter
  103959. * @param _scene The Babylon scene
  103960. */
  103961. constructor(
  103962. /**
  103963. * The physics-enabled object used as the physics imposter
  103964. */
  103965. object: IPhysicsEnabledObject,
  103966. /**
  103967. * The type of the physics imposter
  103968. */
  103969. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  103970. /**
  103971. * This function will completly initialize this impostor.
  103972. * It will create a new body - but only if this mesh has no parent.
  103973. * If it has, this impostor will not be used other than to define the impostor
  103974. * of the child mesh.
  103975. * @hidden
  103976. */
  103977. _init(): void;
  103978. private _getPhysicsParent;
  103979. /**
  103980. * Should a new body be generated.
  103981. * @returns boolean specifying if body initialization is required
  103982. */
  103983. isBodyInitRequired(): boolean;
  103984. /**
  103985. * Sets the updated scaling
  103986. * @param updated Specifies if the scaling is updated
  103987. */
  103988. setScalingUpdated(): void;
  103989. /**
  103990. * Force a regeneration of this or the parent's impostor's body.
  103991. * Use under cautious - This will remove all joints already implemented.
  103992. */
  103993. forceUpdate(): void;
  103994. /**
  103995. * Gets the body that holds this impostor. Either its own, or its parent.
  103996. */
  103997. get physicsBody(): any;
  103998. /**
  103999. * Get the parent of the physics imposter
  104000. * @returns Physics imposter or null
  104001. */
  104002. get parent(): Nullable<PhysicsImpostor>;
  104003. /**
  104004. * Sets the parent of the physics imposter
  104005. */
  104006. set parent(value: Nullable<PhysicsImpostor>);
  104007. /**
  104008. * Set the physics body. Used mainly by the physics engine/plugin
  104009. */
  104010. set physicsBody(physicsBody: any);
  104011. /**
  104012. * Resets the update flags
  104013. */
  104014. resetUpdateFlags(): void;
  104015. /**
  104016. * Gets the object extend size
  104017. * @returns the object extend size
  104018. */
  104019. getObjectExtendSize(): Vector3;
  104020. /**
  104021. * Gets the object center
  104022. * @returns The object center
  104023. */
  104024. getObjectCenter(): Vector3;
  104025. /**
  104026. * Get a specific parameter from the options parameters
  104027. * @param paramName The object parameter name
  104028. * @returns The object parameter
  104029. */
  104030. getParam(paramName: string): any;
  104031. /**
  104032. * Sets a specific parameter in the options given to the physics plugin
  104033. * @param paramName The parameter name
  104034. * @param value The value of the parameter
  104035. */
  104036. setParam(paramName: string, value: number): void;
  104037. /**
  104038. * Specifically change the body's mass option. Won't recreate the physics body object
  104039. * @param mass The mass of the physics imposter
  104040. */
  104041. setMass(mass: number): void;
  104042. /**
  104043. * Gets the linear velocity
  104044. * @returns linear velocity or null
  104045. */
  104046. getLinearVelocity(): Nullable<Vector3>;
  104047. /**
  104048. * Sets the linear velocity
  104049. * @param velocity linear velocity or null
  104050. */
  104051. setLinearVelocity(velocity: Nullable<Vector3>): void;
  104052. /**
  104053. * Gets the angular velocity
  104054. * @returns angular velocity or null
  104055. */
  104056. getAngularVelocity(): Nullable<Vector3>;
  104057. /**
  104058. * Sets the angular velocity
  104059. * @param velocity The velocity or null
  104060. */
  104061. setAngularVelocity(velocity: Nullable<Vector3>): void;
  104062. /**
  104063. * Execute a function with the physics plugin native code
  104064. * Provide a function the will have two variables - the world object and the physics body object
  104065. * @param func The function to execute with the physics plugin native code
  104066. */
  104067. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  104068. /**
  104069. * Register a function that will be executed before the physics world is stepping forward
  104070. * @param func The function to execute before the physics world is stepped forward
  104071. */
  104072. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  104073. /**
  104074. * Unregister a function that will be executed before the physics world is stepping forward
  104075. * @param func The function to execute before the physics world is stepped forward
  104076. */
  104077. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  104078. /**
  104079. * Register a function that will be executed after the physics step
  104080. * @param func The function to execute after physics step
  104081. */
  104082. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  104083. /**
  104084. * Unregisters a function that will be executed after the physics step
  104085. * @param func The function to execute after physics step
  104086. */
  104087. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  104088. /**
  104089. * register a function that will be executed when this impostor collides against a different body
  104090. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  104091. * @param func Callback that is executed on collision
  104092. */
  104093. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  104094. /**
  104095. * Unregisters the physics imposter on contact
  104096. * @param collideAgainst The physics object to collide against
  104097. * @param func Callback to execute on collision
  104098. */
  104099. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  104100. private _tmpQuat;
  104101. private _tmpQuat2;
  104102. /**
  104103. * Get the parent rotation
  104104. * @returns The parent rotation
  104105. */
  104106. getParentsRotation(): Quaternion;
  104107. /**
  104108. * this function is executed by the physics engine.
  104109. */
  104110. beforeStep: () => void;
  104111. /**
  104112. * this function is executed by the physics engine
  104113. */
  104114. afterStep: () => void;
  104115. /**
  104116. * Legacy collision detection event support
  104117. */
  104118. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  104119. /**
  104120. * event and body object due to cannon's event-based architecture.
  104121. */
  104122. onCollide: (e: {
  104123. body: any;
  104124. }) => void;
  104125. /**
  104126. * Apply a force
  104127. * @param force The force to apply
  104128. * @param contactPoint The contact point for the force
  104129. * @returns The physics imposter
  104130. */
  104131. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  104132. /**
  104133. * Apply an impulse
  104134. * @param force The impulse force
  104135. * @param contactPoint The contact point for the impulse force
  104136. * @returns The physics imposter
  104137. */
  104138. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  104139. /**
  104140. * A help function to create a joint
  104141. * @param otherImpostor A physics imposter used to create a joint
  104142. * @param jointType The type of joint
  104143. * @param jointData The data for the joint
  104144. * @returns The physics imposter
  104145. */
  104146. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  104147. /**
  104148. * Add a joint to this impostor with a different impostor
  104149. * @param otherImpostor A physics imposter used to add a joint
  104150. * @param joint The joint to add
  104151. * @returns The physics imposter
  104152. */
  104153. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  104154. /**
  104155. * Add an anchor to a cloth impostor
  104156. * @param otherImpostor rigid impostor to anchor to
  104157. * @param width ratio across width from 0 to 1
  104158. * @param height ratio up height from 0 to 1
  104159. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  104160. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  104161. * @returns impostor the soft imposter
  104162. */
  104163. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  104164. /**
  104165. * Add a hook to a rope impostor
  104166. * @param otherImpostor rigid impostor to anchor to
  104167. * @param length ratio across rope from 0 to 1
  104168. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  104169. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  104170. * @returns impostor the rope imposter
  104171. */
  104172. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  104173. /**
  104174. * Will keep this body still, in a sleep mode.
  104175. * @returns the physics imposter
  104176. */
  104177. sleep(): PhysicsImpostor;
  104178. /**
  104179. * Wake the body up.
  104180. * @returns The physics imposter
  104181. */
  104182. wakeUp(): PhysicsImpostor;
  104183. /**
  104184. * Clones the physics imposter
  104185. * @param newObject The physics imposter clones to this physics-enabled object
  104186. * @returns A nullable physics imposter
  104187. */
  104188. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  104189. /**
  104190. * Disposes the physics imposter
  104191. */
  104192. dispose(): void;
  104193. /**
  104194. * Sets the delta position
  104195. * @param position The delta position amount
  104196. */
  104197. setDeltaPosition(position: Vector3): void;
  104198. /**
  104199. * Sets the delta rotation
  104200. * @param rotation The delta rotation amount
  104201. */
  104202. setDeltaRotation(rotation: Quaternion): void;
  104203. /**
  104204. * Gets the box size of the physics imposter and stores the result in the input parameter
  104205. * @param result Stores the box size
  104206. * @returns The physics imposter
  104207. */
  104208. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  104209. /**
  104210. * Gets the radius of the physics imposter
  104211. * @returns Radius of the physics imposter
  104212. */
  104213. getRadius(): number;
  104214. /**
  104215. * Sync a bone with this impostor
  104216. * @param bone The bone to sync to the impostor.
  104217. * @param boneMesh The mesh that the bone is influencing.
  104218. * @param jointPivot The pivot of the joint / bone in local space.
  104219. * @param distToJoint Optional distance from the impostor to the joint.
  104220. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  104221. */
  104222. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  104223. /**
  104224. * Sync impostor to a bone
  104225. * @param bone The bone that the impostor will be synced to.
  104226. * @param boneMesh The mesh that the bone is influencing.
  104227. * @param jointPivot The pivot of the joint / bone in local space.
  104228. * @param distToJoint Optional distance from the impostor to the joint.
  104229. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  104230. * @param boneAxis Optional vector3 axis the bone is aligned with
  104231. */
  104232. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  104233. /**
  104234. * No-Imposter type
  104235. */
  104236. static NoImpostor: number;
  104237. /**
  104238. * Sphere-Imposter type
  104239. */
  104240. static SphereImpostor: number;
  104241. /**
  104242. * Box-Imposter type
  104243. */
  104244. static BoxImpostor: number;
  104245. /**
  104246. * Plane-Imposter type
  104247. */
  104248. static PlaneImpostor: number;
  104249. /**
  104250. * Mesh-imposter type
  104251. */
  104252. static MeshImpostor: number;
  104253. /**
  104254. * Capsule-Impostor type (Ammo.js plugin only)
  104255. */
  104256. static CapsuleImpostor: number;
  104257. /**
  104258. * Cylinder-Imposter type
  104259. */
  104260. static CylinderImpostor: number;
  104261. /**
  104262. * Particle-Imposter type
  104263. */
  104264. static ParticleImpostor: number;
  104265. /**
  104266. * Heightmap-Imposter type
  104267. */
  104268. static HeightmapImpostor: number;
  104269. /**
  104270. * ConvexHull-Impostor type (Ammo.js plugin only)
  104271. */
  104272. static ConvexHullImpostor: number;
  104273. /**
  104274. * Custom-Imposter type (Ammo.js plugin only)
  104275. */
  104276. static CustomImpostor: number;
  104277. /**
  104278. * Rope-Imposter type
  104279. */
  104280. static RopeImpostor: number;
  104281. /**
  104282. * Cloth-Imposter type
  104283. */
  104284. static ClothImpostor: number;
  104285. /**
  104286. * Softbody-Imposter type
  104287. */
  104288. static SoftbodyImpostor: number;
  104289. }
  104290. }
  104291. declare module BABYLON {
  104292. /**
  104293. * @hidden
  104294. **/
  104295. export class _CreationDataStorage {
  104296. closePath?: boolean;
  104297. closeArray?: boolean;
  104298. idx: number[];
  104299. dashSize: number;
  104300. gapSize: number;
  104301. path3D: Path3D;
  104302. pathArray: Vector3[][];
  104303. arc: number;
  104304. radius: number;
  104305. cap: number;
  104306. tessellation: number;
  104307. }
  104308. /**
  104309. * @hidden
  104310. **/
  104311. class _InstanceDataStorage {
  104312. visibleInstances: any;
  104313. batchCache: _InstancesBatch;
  104314. instancesBufferSize: number;
  104315. instancesBuffer: Nullable<Buffer>;
  104316. instancesData: Float32Array;
  104317. overridenInstanceCount: number;
  104318. isFrozen: boolean;
  104319. previousBatch: Nullable<_InstancesBatch>;
  104320. hardwareInstancedRendering: boolean;
  104321. sideOrientation: number;
  104322. manualUpdate: boolean;
  104323. }
  104324. /**
  104325. * @hidden
  104326. **/
  104327. export class _InstancesBatch {
  104328. mustReturn: boolean;
  104329. visibleInstances: Nullable<InstancedMesh[]>[];
  104330. renderSelf: boolean[];
  104331. hardwareInstancedRendering: boolean[];
  104332. }
  104333. /**
  104334. * @hidden
  104335. **/
  104336. class _ThinInstanceDataStorage {
  104337. instancesCount: number;
  104338. matrixBuffer: Nullable<Buffer>;
  104339. matrixBufferSize: number;
  104340. matrixData: Nullable<Float32Array>;
  104341. boundingVectors: Array<Vector3>;
  104342. }
  104343. /**
  104344. * Class used to represent renderable models
  104345. */
  104346. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  104347. /**
  104348. * Mesh side orientation : usually the external or front surface
  104349. */
  104350. static readonly FRONTSIDE: number;
  104351. /**
  104352. * Mesh side orientation : usually the internal or back surface
  104353. */
  104354. static readonly BACKSIDE: number;
  104355. /**
  104356. * Mesh side orientation : both internal and external or front and back surfaces
  104357. */
  104358. static readonly DOUBLESIDE: number;
  104359. /**
  104360. * Mesh side orientation : by default, `FRONTSIDE`
  104361. */
  104362. static readonly DEFAULTSIDE: number;
  104363. /**
  104364. * Mesh cap setting : no cap
  104365. */
  104366. static readonly NO_CAP: number;
  104367. /**
  104368. * Mesh cap setting : one cap at the beginning of the mesh
  104369. */
  104370. static readonly CAP_START: number;
  104371. /**
  104372. * Mesh cap setting : one cap at the end of the mesh
  104373. */
  104374. static readonly CAP_END: number;
  104375. /**
  104376. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  104377. */
  104378. static readonly CAP_ALL: number;
  104379. /**
  104380. * Mesh pattern setting : no flip or rotate
  104381. */
  104382. static readonly NO_FLIP: number;
  104383. /**
  104384. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  104385. */
  104386. static readonly FLIP_TILE: number;
  104387. /**
  104388. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  104389. */
  104390. static readonly ROTATE_TILE: number;
  104391. /**
  104392. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  104393. */
  104394. static readonly FLIP_ROW: number;
  104395. /**
  104396. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  104397. */
  104398. static readonly ROTATE_ROW: number;
  104399. /**
  104400. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  104401. */
  104402. static readonly FLIP_N_ROTATE_TILE: number;
  104403. /**
  104404. * Mesh pattern setting : rotate pattern and rotate
  104405. */
  104406. static readonly FLIP_N_ROTATE_ROW: number;
  104407. /**
  104408. * Mesh tile positioning : part tiles same on left/right or top/bottom
  104409. */
  104410. static readonly CENTER: number;
  104411. /**
  104412. * Mesh tile positioning : part tiles on left
  104413. */
  104414. static readonly LEFT: number;
  104415. /**
  104416. * Mesh tile positioning : part tiles on right
  104417. */
  104418. static readonly RIGHT: number;
  104419. /**
  104420. * Mesh tile positioning : part tiles on top
  104421. */
  104422. static readonly TOP: number;
  104423. /**
  104424. * Mesh tile positioning : part tiles on bottom
  104425. */
  104426. static readonly BOTTOM: number;
  104427. /**
  104428. * Gets the default side orientation.
  104429. * @param orientation the orientation to value to attempt to get
  104430. * @returns the default orientation
  104431. * @hidden
  104432. */
  104433. static _GetDefaultSideOrientation(orientation?: number): number;
  104434. private _internalMeshDataInfo;
  104435. /**
  104436. * An event triggered before rendering the mesh
  104437. */
  104438. get onBeforeRenderObservable(): Observable<Mesh>;
  104439. /**
  104440. * An event triggered before binding the mesh
  104441. */
  104442. get onBeforeBindObservable(): Observable<Mesh>;
  104443. /**
  104444. * An event triggered after rendering the mesh
  104445. */
  104446. get onAfterRenderObservable(): Observable<Mesh>;
  104447. /**
  104448. * An event triggered before drawing the mesh
  104449. */
  104450. get onBeforeDrawObservable(): Observable<Mesh>;
  104451. private _onBeforeDrawObserver;
  104452. /**
  104453. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  104454. */
  104455. set onBeforeDraw(callback: () => void);
  104456. get hasInstances(): boolean;
  104457. get hasThinInstances(): boolean;
  104458. /**
  104459. * Gets the delay loading state of the mesh (when delay loading is turned on)
  104460. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  104461. */
  104462. delayLoadState: number;
  104463. /**
  104464. * Gets the list of instances created from this mesh
  104465. * it is not supposed to be modified manually.
  104466. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  104467. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  104468. */
  104469. instances: InstancedMesh[];
  104470. /**
  104471. * Gets the file containing delay loading data for this mesh
  104472. */
  104473. delayLoadingFile: string;
  104474. /** @hidden */
  104475. _binaryInfo: any;
  104476. /**
  104477. * User defined function used to change how LOD level selection is done
  104478. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  104479. */
  104480. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  104481. /**
  104482. * Gets or sets the morph target manager
  104483. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  104484. */
  104485. get morphTargetManager(): Nullable<MorphTargetManager>;
  104486. set morphTargetManager(value: Nullable<MorphTargetManager>);
  104487. /** @hidden */
  104488. _creationDataStorage: Nullable<_CreationDataStorage>;
  104489. /** @hidden */
  104490. _geometry: Nullable<Geometry>;
  104491. /** @hidden */
  104492. _delayInfo: Array<string>;
  104493. /** @hidden */
  104494. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  104495. /** @hidden */
  104496. _instanceDataStorage: _InstanceDataStorage;
  104497. /** @hidden */
  104498. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  104499. private _effectiveMaterial;
  104500. /** @hidden */
  104501. _shouldGenerateFlatShading: boolean;
  104502. /** @hidden */
  104503. _originalBuilderSideOrientation: number;
  104504. /**
  104505. * Use this property to change the original side orientation defined at construction time
  104506. */
  104507. overrideMaterialSideOrientation: Nullable<number>;
  104508. /**
  104509. * Gets the source mesh (the one used to clone this one from)
  104510. */
  104511. get source(): Nullable<Mesh>;
  104512. /**
  104513. * Gets or sets a boolean indicating that this mesh does not use index buffer
  104514. */
  104515. get isUnIndexed(): boolean;
  104516. set isUnIndexed(value: boolean);
  104517. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  104518. get worldMatrixInstancedBuffer(): Float32Array;
  104519. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  104520. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  104521. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  104522. /**
  104523. * @constructor
  104524. * @param name The value used by scene.getMeshByName() to do a lookup.
  104525. * @param scene The scene to add this mesh to.
  104526. * @param parent The parent of this mesh, if it has one
  104527. * @param source An optional Mesh from which geometry is shared, cloned.
  104528. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  104529. * When false, achieved by calling a clone(), also passing False.
  104530. * This will make creation of children, recursive.
  104531. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  104532. */
  104533. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  104534. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  104535. doNotInstantiate: boolean;
  104536. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  104537. /**
  104538. * Gets the class name
  104539. * @returns the string "Mesh".
  104540. */
  104541. getClassName(): string;
  104542. /** @hidden */
  104543. get _isMesh(): boolean;
  104544. /**
  104545. * Returns a description of this mesh
  104546. * @param fullDetails define if full details about this mesh must be used
  104547. * @returns a descriptive string representing this mesh
  104548. */
  104549. toString(fullDetails?: boolean): string;
  104550. /** @hidden */
  104551. _unBindEffect(): void;
  104552. /**
  104553. * Gets a boolean indicating if this mesh has LOD
  104554. */
  104555. get hasLODLevels(): boolean;
  104556. /**
  104557. * Gets the list of MeshLODLevel associated with the current mesh
  104558. * @returns an array of MeshLODLevel
  104559. */
  104560. getLODLevels(): MeshLODLevel[];
  104561. private _sortLODLevels;
  104562. /**
  104563. * Add a mesh as LOD level triggered at the given distance.
  104564. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  104565. * @param distance The distance from the center of the object to show this level
  104566. * @param mesh The mesh to be added as LOD level (can be null)
  104567. * @return This mesh (for chaining)
  104568. */
  104569. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  104570. /**
  104571. * Returns the LOD level mesh at the passed distance or null if not found.
  104572. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  104573. * @param distance The distance from the center of the object to show this level
  104574. * @returns a Mesh or `null`
  104575. */
  104576. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  104577. /**
  104578. * Remove a mesh from the LOD array
  104579. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  104580. * @param mesh defines the mesh to be removed
  104581. * @return This mesh (for chaining)
  104582. */
  104583. removeLODLevel(mesh: Mesh): Mesh;
  104584. /**
  104585. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  104586. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  104587. * @param camera defines the camera to use to compute distance
  104588. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  104589. * @return This mesh (for chaining)
  104590. */
  104591. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  104592. /**
  104593. * Gets the mesh internal Geometry object
  104594. */
  104595. get geometry(): Nullable<Geometry>;
  104596. /**
  104597. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  104598. * @returns the total number of vertices
  104599. */
  104600. getTotalVertices(): number;
  104601. /**
  104602. * Returns the content of an associated vertex buffer
  104603. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  104604. * - VertexBuffer.PositionKind
  104605. * - VertexBuffer.UVKind
  104606. * - VertexBuffer.UV2Kind
  104607. * - VertexBuffer.UV3Kind
  104608. * - VertexBuffer.UV4Kind
  104609. * - VertexBuffer.UV5Kind
  104610. * - VertexBuffer.UV6Kind
  104611. * - VertexBuffer.ColorKind
  104612. * - VertexBuffer.MatricesIndicesKind
  104613. * - VertexBuffer.MatricesIndicesExtraKind
  104614. * - VertexBuffer.MatricesWeightsKind
  104615. * - VertexBuffer.MatricesWeightsExtraKind
  104616. * @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
  104617. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  104618. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  104619. */
  104620. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  104621. /**
  104622. * Returns the mesh VertexBuffer object from the requested `kind`
  104623. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  104624. * - VertexBuffer.PositionKind
  104625. * - VertexBuffer.NormalKind
  104626. * - VertexBuffer.UVKind
  104627. * - VertexBuffer.UV2Kind
  104628. * - VertexBuffer.UV3Kind
  104629. * - VertexBuffer.UV4Kind
  104630. * - VertexBuffer.UV5Kind
  104631. * - VertexBuffer.UV6Kind
  104632. * - VertexBuffer.ColorKind
  104633. * - VertexBuffer.MatricesIndicesKind
  104634. * - VertexBuffer.MatricesIndicesExtraKind
  104635. * - VertexBuffer.MatricesWeightsKind
  104636. * - VertexBuffer.MatricesWeightsExtraKind
  104637. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  104638. */
  104639. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  104640. /**
  104641. * Tests if a specific vertex buffer is associated with this mesh
  104642. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  104643. * - VertexBuffer.PositionKind
  104644. * - VertexBuffer.NormalKind
  104645. * - VertexBuffer.UVKind
  104646. * - VertexBuffer.UV2Kind
  104647. * - VertexBuffer.UV3Kind
  104648. * - VertexBuffer.UV4Kind
  104649. * - VertexBuffer.UV5Kind
  104650. * - VertexBuffer.UV6Kind
  104651. * - VertexBuffer.ColorKind
  104652. * - VertexBuffer.MatricesIndicesKind
  104653. * - VertexBuffer.MatricesIndicesExtraKind
  104654. * - VertexBuffer.MatricesWeightsKind
  104655. * - VertexBuffer.MatricesWeightsExtraKind
  104656. * @returns a boolean
  104657. */
  104658. isVerticesDataPresent(kind: string): boolean;
  104659. /**
  104660. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  104661. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  104662. * - VertexBuffer.PositionKind
  104663. * - VertexBuffer.UVKind
  104664. * - VertexBuffer.UV2Kind
  104665. * - VertexBuffer.UV3Kind
  104666. * - VertexBuffer.UV4Kind
  104667. * - VertexBuffer.UV5Kind
  104668. * - VertexBuffer.UV6Kind
  104669. * - VertexBuffer.ColorKind
  104670. * - VertexBuffer.MatricesIndicesKind
  104671. * - VertexBuffer.MatricesIndicesExtraKind
  104672. * - VertexBuffer.MatricesWeightsKind
  104673. * - VertexBuffer.MatricesWeightsExtraKind
  104674. * @returns a boolean
  104675. */
  104676. isVertexBufferUpdatable(kind: string): boolean;
  104677. /**
  104678. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  104679. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  104680. * - VertexBuffer.PositionKind
  104681. * - VertexBuffer.NormalKind
  104682. * - VertexBuffer.UVKind
  104683. * - VertexBuffer.UV2Kind
  104684. * - VertexBuffer.UV3Kind
  104685. * - VertexBuffer.UV4Kind
  104686. * - VertexBuffer.UV5Kind
  104687. * - VertexBuffer.UV6Kind
  104688. * - VertexBuffer.ColorKind
  104689. * - VertexBuffer.MatricesIndicesKind
  104690. * - VertexBuffer.MatricesIndicesExtraKind
  104691. * - VertexBuffer.MatricesWeightsKind
  104692. * - VertexBuffer.MatricesWeightsExtraKind
  104693. * @returns an array of strings
  104694. */
  104695. getVerticesDataKinds(): string[];
  104696. /**
  104697. * Returns a positive integer : the total number of indices in this mesh geometry.
  104698. * @returns the numner of indices or zero if the mesh has no geometry.
  104699. */
  104700. getTotalIndices(): number;
  104701. /**
  104702. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  104703. * @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.
  104704. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  104705. * @returns the indices array or an empty array if the mesh has no geometry
  104706. */
  104707. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  104708. get isBlocked(): boolean;
  104709. /**
  104710. * Determine if the current mesh is ready to be rendered
  104711. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  104712. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  104713. * @returns true if all associated assets are ready (material, textures, shaders)
  104714. */
  104715. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  104716. /**
  104717. * 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.
  104718. */
  104719. get areNormalsFrozen(): boolean;
  104720. /**
  104721. * 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.
  104722. * @returns the current mesh
  104723. */
  104724. freezeNormals(): Mesh;
  104725. /**
  104726. * 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
  104727. * @returns the current mesh
  104728. */
  104729. unfreezeNormals(): Mesh;
  104730. /**
  104731. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  104732. */
  104733. set overridenInstanceCount(count: number);
  104734. /** @hidden */
  104735. _preActivate(): Mesh;
  104736. /** @hidden */
  104737. _preActivateForIntermediateRendering(renderId: number): Mesh;
  104738. /** @hidden */
  104739. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  104740. protected _afterComputeWorldMatrix(): void;
  104741. /**
  104742. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  104743. * This means the mesh underlying bounding box and sphere are recomputed.
  104744. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  104745. * @returns the current mesh
  104746. */
  104747. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  104748. /** @hidden */
  104749. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  104750. /**
  104751. * This function will subdivide the mesh into multiple submeshes
  104752. * @param count defines the expected number of submeshes
  104753. */
  104754. subdivide(count: number): void;
  104755. /**
  104756. * Copy a FloatArray into a specific associated vertex buffer
  104757. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  104758. * - VertexBuffer.PositionKind
  104759. * - VertexBuffer.UVKind
  104760. * - VertexBuffer.UV2Kind
  104761. * - VertexBuffer.UV3Kind
  104762. * - VertexBuffer.UV4Kind
  104763. * - VertexBuffer.UV5Kind
  104764. * - VertexBuffer.UV6Kind
  104765. * - VertexBuffer.ColorKind
  104766. * - VertexBuffer.MatricesIndicesKind
  104767. * - VertexBuffer.MatricesIndicesExtraKind
  104768. * - VertexBuffer.MatricesWeightsKind
  104769. * - VertexBuffer.MatricesWeightsExtraKind
  104770. * @param data defines the data source
  104771. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  104772. * @param stride defines the data stride size (can be null)
  104773. * @returns the current mesh
  104774. */
  104775. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  104776. /**
  104777. * Delete a vertex buffer associated with this mesh
  104778. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  104779. * - VertexBuffer.PositionKind
  104780. * - VertexBuffer.UVKind
  104781. * - VertexBuffer.UV2Kind
  104782. * - VertexBuffer.UV3Kind
  104783. * - VertexBuffer.UV4Kind
  104784. * - VertexBuffer.UV5Kind
  104785. * - VertexBuffer.UV6Kind
  104786. * - VertexBuffer.ColorKind
  104787. * - VertexBuffer.MatricesIndicesKind
  104788. * - VertexBuffer.MatricesIndicesExtraKind
  104789. * - VertexBuffer.MatricesWeightsKind
  104790. * - VertexBuffer.MatricesWeightsExtraKind
  104791. */
  104792. removeVerticesData(kind: string): void;
  104793. /**
  104794. * Flags an associated vertex buffer as updatable
  104795. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  104796. * - VertexBuffer.PositionKind
  104797. * - VertexBuffer.UVKind
  104798. * - VertexBuffer.UV2Kind
  104799. * - VertexBuffer.UV3Kind
  104800. * - VertexBuffer.UV4Kind
  104801. * - VertexBuffer.UV5Kind
  104802. * - VertexBuffer.UV6Kind
  104803. * - VertexBuffer.ColorKind
  104804. * - VertexBuffer.MatricesIndicesKind
  104805. * - VertexBuffer.MatricesIndicesExtraKind
  104806. * - VertexBuffer.MatricesWeightsKind
  104807. * - VertexBuffer.MatricesWeightsExtraKind
  104808. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  104809. */
  104810. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  104811. /**
  104812. * Sets the mesh global Vertex Buffer
  104813. * @param buffer defines the buffer to use
  104814. * @returns the current mesh
  104815. */
  104816. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  104817. /**
  104818. * Update a specific associated vertex buffer
  104819. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  104820. * - VertexBuffer.PositionKind
  104821. * - VertexBuffer.UVKind
  104822. * - VertexBuffer.UV2Kind
  104823. * - VertexBuffer.UV3Kind
  104824. * - VertexBuffer.UV4Kind
  104825. * - VertexBuffer.UV5Kind
  104826. * - VertexBuffer.UV6Kind
  104827. * - VertexBuffer.ColorKind
  104828. * - VertexBuffer.MatricesIndicesKind
  104829. * - VertexBuffer.MatricesIndicesExtraKind
  104830. * - VertexBuffer.MatricesWeightsKind
  104831. * - VertexBuffer.MatricesWeightsExtraKind
  104832. * @param data defines the data source
  104833. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  104834. * @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)
  104835. * @returns the current mesh
  104836. */
  104837. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  104838. /**
  104839. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  104840. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  104841. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  104842. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  104843. * @returns the current mesh
  104844. */
  104845. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  104846. /**
  104847. * Creates a un-shared specific occurence of the geometry for the mesh.
  104848. * @returns the current mesh
  104849. */
  104850. makeGeometryUnique(): Mesh;
  104851. /**
  104852. * Set the index buffer of this mesh
  104853. * @param indices defines the source data
  104854. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  104855. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  104856. * @returns the current mesh
  104857. */
  104858. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  104859. /**
  104860. * Update the current index buffer
  104861. * @param indices defines the source data
  104862. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  104863. * @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)
  104864. * @returns the current mesh
  104865. */
  104866. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  104867. /**
  104868. * Invert the geometry to move from a right handed system to a left handed one.
  104869. * @returns the current mesh
  104870. */
  104871. toLeftHanded(): Mesh;
  104872. /** @hidden */
  104873. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  104874. /** @hidden */
  104875. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  104876. /**
  104877. * Registers for this mesh a javascript function called just before the rendering process
  104878. * @param func defines the function to call before rendering this mesh
  104879. * @returns the current mesh
  104880. */
  104881. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  104882. /**
  104883. * Disposes a previously registered javascript function called before the rendering
  104884. * @param func defines the function to remove
  104885. * @returns the current mesh
  104886. */
  104887. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  104888. /**
  104889. * Registers for this mesh a javascript function called just after the rendering is complete
  104890. * @param func defines the function to call after rendering this mesh
  104891. * @returns the current mesh
  104892. */
  104893. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  104894. /**
  104895. * Disposes a previously registered javascript function called after the rendering.
  104896. * @param func defines the function to remove
  104897. * @returns the current mesh
  104898. */
  104899. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  104900. /** @hidden */
  104901. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  104902. /** @hidden */
  104903. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  104904. /** @hidden */
  104905. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  104906. /** @hidden */
  104907. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  104908. /** @hidden */
  104909. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  104910. /** @hidden */
  104911. _rebuild(): void;
  104912. /** @hidden */
  104913. _freeze(): void;
  104914. /** @hidden */
  104915. _unFreeze(): void;
  104916. /**
  104917. * 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
  104918. * @param subMesh defines the subMesh to render
  104919. * @param enableAlphaMode defines if alpha mode can be changed
  104920. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  104921. * @returns the current mesh
  104922. */
  104923. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  104924. private _onBeforeDraw;
  104925. /**
  104926. * Renormalize the mesh and patch it up if there are no weights
  104927. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  104928. * However in the case of zero weights then we set just a single influence to 1.
  104929. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  104930. */
  104931. cleanMatrixWeights(): void;
  104932. private normalizeSkinFourWeights;
  104933. private normalizeSkinWeightsAndExtra;
  104934. /**
  104935. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  104936. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  104937. * the user know there was an issue with importing the mesh
  104938. * @returns a validation object with skinned, valid and report string
  104939. */
  104940. validateSkinning(): {
  104941. skinned: boolean;
  104942. valid: boolean;
  104943. report: string;
  104944. };
  104945. /** @hidden */
  104946. _checkDelayState(): Mesh;
  104947. private _queueLoad;
  104948. /**
  104949. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  104950. * A mesh is in the frustum if its bounding box intersects the frustum
  104951. * @param frustumPlanes defines the frustum to test
  104952. * @returns true if the mesh is in the frustum planes
  104953. */
  104954. isInFrustum(frustumPlanes: Plane[]): boolean;
  104955. /**
  104956. * Sets the mesh material by the material or multiMaterial `id` property
  104957. * @param id is a string identifying the material or the multiMaterial
  104958. * @returns the current mesh
  104959. */
  104960. setMaterialByID(id: string): Mesh;
  104961. /**
  104962. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  104963. * @returns an array of IAnimatable
  104964. */
  104965. getAnimatables(): IAnimatable[];
  104966. /**
  104967. * Modifies the mesh geometry according to the passed transformation matrix.
  104968. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  104969. * The mesh normals are modified using the same transformation.
  104970. * Note that, under the hood, this method sets a new VertexBuffer each call.
  104971. * @param transform defines the transform matrix to use
  104972. * @see http://doc.babylonjs.com/resources/baking_transformations
  104973. * @returns the current mesh
  104974. */
  104975. bakeTransformIntoVertices(transform: Matrix): Mesh;
  104976. /**
  104977. * Modifies the mesh geometry according to its own current World Matrix.
  104978. * The mesh World Matrix is then reset.
  104979. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  104980. * Note that, under the hood, this method sets a new VertexBuffer each call.
  104981. * @see http://doc.babylonjs.com/resources/baking_transformations
  104982. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  104983. * @returns the current mesh
  104984. */
  104985. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  104986. /** @hidden */
  104987. get _positions(): Nullable<Vector3[]>;
  104988. /** @hidden */
  104989. _resetPointsArrayCache(): Mesh;
  104990. /** @hidden */
  104991. _generatePointsArray(): boolean;
  104992. /**
  104993. * Returns a new Mesh object generated from the current mesh properties.
  104994. * This method must not get confused with createInstance()
  104995. * @param name is a string, the name given to the new mesh
  104996. * @param newParent can be any Node object (default `null`)
  104997. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  104998. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  104999. * @returns a new mesh
  105000. */
  105001. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  105002. /**
  105003. * Releases resources associated with this mesh.
  105004. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  105005. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  105006. */
  105007. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  105008. /** @hidden */
  105009. _disposeInstanceSpecificData(): void;
  105010. /** @hidden */
  105011. _disposeThinInstanceSpecificData(): void;
  105012. /**
  105013. * Modifies the mesh geometry according to a displacement map.
  105014. * 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.
  105015. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  105016. * @param url is a string, the URL from the image file is to be downloaded.
  105017. * @param minHeight is the lower limit of the displacement.
  105018. * @param maxHeight is the upper limit of the displacement.
  105019. * @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.
  105020. * @param uvOffset is an optional vector2 used to offset UV.
  105021. * @param uvScale is an optional vector2 used to scale UV.
  105022. * @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.
  105023. * @returns the Mesh.
  105024. */
  105025. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  105026. /**
  105027. * Modifies the mesh geometry according to a displacementMap buffer.
  105028. * 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.
  105029. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  105030. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  105031. * @param heightMapWidth is the width of the buffer image.
  105032. * @param heightMapHeight is the height of the buffer image.
  105033. * @param minHeight is the lower limit of the displacement.
  105034. * @param maxHeight is the upper limit of the displacement.
  105035. * @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.
  105036. * @param uvOffset is an optional vector2 used to offset UV.
  105037. * @param uvScale is an optional vector2 used to scale UV.
  105038. * @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.
  105039. * @returns the Mesh.
  105040. */
  105041. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  105042. /**
  105043. * Modify the mesh to get a flat shading rendering.
  105044. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  105045. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  105046. * @returns current mesh
  105047. */
  105048. convertToFlatShadedMesh(): Mesh;
  105049. /**
  105050. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  105051. * In other words, more vertices, no more indices and a single bigger VBO.
  105052. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  105053. * @returns current mesh
  105054. */
  105055. convertToUnIndexedMesh(): Mesh;
  105056. /**
  105057. * Inverses facet orientations.
  105058. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  105059. * @param flipNormals will also inverts the normals
  105060. * @returns current mesh
  105061. */
  105062. flipFaces(flipNormals?: boolean): Mesh;
  105063. /**
  105064. * Increase the number of facets and hence vertices in a mesh
  105065. * Vertex normals are interpolated from existing vertex normals
  105066. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  105067. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  105068. */
  105069. increaseVertices(numberPerEdge: number): void;
  105070. /**
  105071. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  105072. * This will undo any application of covertToFlatShadedMesh
  105073. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  105074. */
  105075. forceSharedVertices(): void;
  105076. /** @hidden */
  105077. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  105078. /** @hidden */
  105079. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  105080. /**
  105081. * Creates a new InstancedMesh object from the mesh model.
  105082. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  105083. * @param name defines the name of the new instance
  105084. * @returns a new InstancedMesh
  105085. */
  105086. createInstance(name: string): InstancedMesh;
  105087. /**
  105088. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  105089. * After this call, all the mesh instances have the same submeshes than the current mesh.
  105090. * @returns the current mesh
  105091. */
  105092. synchronizeInstances(): Mesh;
  105093. /**
  105094. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  105095. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  105096. * This should be used together with the simplification to avoid disappearing triangles.
  105097. * @param successCallback an optional success callback to be called after the optimization finished.
  105098. * @returns the current mesh
  105099. */
  105100. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  105101. /**
  105102. * Serialize current mesh
  105103. * @param serializationObject defines the object which will receive the serialization data
  105104. */
  105105. serialize(serializationObject: any): void;
  105106. /** @hidden */
  105107. _syncGeometryWithMorphTargetManager(): void;
  105108. /** @hidden */
  105109. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  105110. /**
  105111. * Returns a new Mesh object parsed from the source provided.
  105112. * @param parsedMesh is the source
  105113. * @param scene defines the hosting scene
  105114. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  105115. * @returns a new Mesh
  105116. */
  105117. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  105118. /**
  105119. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  105120. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  105121. * @param name defines the name of the mesh to create
  105122. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  105123. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  105124. * @param closePath creates a seam between the first and the last points of each path of the path array
  105125. * @param offset is taken in account only if the `pathArray` is containing a single path
  105126. * @param scene defines the hosting scene
  105127. * @param updatable defines if the mesh must be flagged as updatable
  105128. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105129. * @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)
  105130. * @returns a new Mesh
  105131. */
  105132. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  105133. /**
  105134. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  105135. * @param name defines the name of the mesh to create
  105136. * @param radius sets the radius size (float) of the polygon (default 0.5)
  105137. * @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
  105138. * @param scene defines the hosting scene
  105139. * @param updatable defines if the mesh must be flagged as updatable
  105140. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105141. * @returns a new Mesh
  105142. */
  105143. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  105144. /**
  105145. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  105146. * @param name defines the name of the mesh to create
  105147. * @param size sets the size (float) of each box side (default 1)
  105148. * @param scene defines the hosting scene
  105149. * @param updatable defines if the mesh must be flagged as updatable
  105150. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105151. * @returns a new Mesh
  105152. */
  105153. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  105154. /**
  105155. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  105156. * @param name defines the name of the mesh to create
  105157. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  105158. * @param diameter sets the diameter size (float) of the sphere (default 1)
  105159. * @param scene defines the hosting scene
  105160. * @param updatable defines if the mesh must be flagged as updatable
  105161. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105162. * @returns a new Mesh
  105163. */
  105164. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  105165. /**
  105166. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  105167. * @param name defines the name of the mesh to create
  105168. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  105169. * @param diameter sets the diameter size (float) of the sphere (default 1)
  105170. * @param scene defines the hosting scene
  105171. * @returns a new Mesh
  105172. */
  105173. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  105174. /**
  105175. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  105176. * @param name defines the name of the mesh to create
  105177. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  105178. * @param diameterTop set the top cap diameter (floats, default 1)
  105179. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  105180. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  105181. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  105182. * @param scene defines the hosting scene
  105183. * @param updatable defines if the mesh must be flagged as updatable
  105184. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105185. * @returns a new Mesh
  105186. */
  105187. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  105188. /**
  105189. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  105190. * @param name defines the name of the mesh to create
  105191. * @param diameter sets the diameter size (float) of the torus (default 1)
  105192. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  105193. * @param tessellation sets the number of torus sides (postive integer, default 16)
  105194. * @param scene defines the hosting scene
  105195. * @param updatable defines if the mesh must be flagged as updatable
  105196. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105197. * @returns a new Mesh
  105198. */
  105199. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  105200. /**
  105201. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  105202. * @param name defines the name of the mesh to create
  105203. * @param radius sets the global radius size (float) of the torus knot (default 2)
  105204. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  105205. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  105206. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  105207. * @param p the number of windings on X axis (positive integers, default 2)
  105208. * @param q the number of windings on Y axis (positive integers, default 3)
  105209. * @param scene defines the hosting scene
  105210. * @param updatable defines if the mesh must be flagged as updatable
  105211. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105212. * @returns a new Mesh
  105213. */
  105214. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  105215. /**
  105216. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  105217. * @param name defines the name of the mesh to create
  105218. * @param points is an array successive Vector3
  105219. * @param scene defines the hosting scene
  105220. * @param updatable defines if the mesh must be flagged as updatable
  105221. * @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).
  105222. * @returns a new Mesh
  105223. */
  105224. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  105225. /**
  105226. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  105227. * @param name defines the name of the mesh to create
  105228. * @param points is an array successive Vector3
  105229. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  105230. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  105231. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  105232. * @param scene defines the hosting scene
  105233. * @param updatable defines if the mesh must be flagged as updatable
  105234. * @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)
  105235. * @returns a new Mesh
  105236. */
  105237. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  105238. /**
  105239. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  105240. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  105241. * 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.
  105242. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105243. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105244. * Remember you can only change the shape positions, not their number when updating a polygon.
  105245. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  105246. * @param name defines the name of the mesh to create
  105247. * @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
  105248. * @param scene defines the hosting scene
  105249. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  105250. * @param updatable defines if the mesh must be flagged as updatable
  105251. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105252. * @param earcutInjection can be used to inject your own earcut reference
  105253. * @returns a new Mesh
  105254. */
  105255. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  105256. /**
  105257. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  105258. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  105259. * @param name defines the name of the mesh to create
  105260. * @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
  105261. * @param depth defines the height of extrusion
  105262. * @param scene defines the hosting scene
  105263. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  105264. * @param updatable defines if the mesh must be flagged as updatable
  105265. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105266. * @param earcutInjection can be used to inject your own earcut reference
  105267. * @returns a new Mesh
  105268. */
  105269. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  105270. /**
  105271. * Creates an extruded shape mesh.
  105272. * 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
  105273. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  105274. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  105275. * @param name defines the name of the mesh to create
  105276. * @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
  105277. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  105278. * @param scale is the value to scale the shape
  105279. * @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
  105280. * @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
  105281. * @param scene defines the hosting scene
  105282. * @param updatable defines if the mesh must be flagged as updatable
  105283. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105284. * @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)
  105285. * @returns a new Mesh
  105286. */
  105287. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  105288. /**
  105289. * Creates an custom extruded shape mesh.
  105290. * The custom extrusion is a parametric shape.
  105291. * It has no predefined shape. Its final shape will depend on the input parameters.
  105292. * Please consider using the same method from the MeshBuilder class instead
  105293. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  105294. * @param name defines the name of the mesh to create
  105295. * @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
  105296. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  105297. * @param scaleFunction is a custom Javascript function called on each path point
  105298. * @param rotationFunction is a custom Javascript function called on each path point
  105299. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  105300. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  105301. * @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
  105302. * @param scene defines the hosting scene
  105303. * @param updatable defines if the mesh must be flagged as updatable
  105304. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105305. * @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)
  105306. * @returns a new Mesh
  105307. */
  105308. 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;
  105309. /**
  105310. * Creates lathe mesh.
  105311. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  105312. * Please consider using the same method from the MeshBuilder class instead
  105313. * @param name defines the name of the mesh to create
  105314. * @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
  105315. * @param radius is the radius value of the lathe
  105316. * @param tessellation is the side number of the lathe.
  105317. * @param scene defines the hosting scene
  105318. * @param updatable defines if the mesh must be flagged as updatable
  105319. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105320. * @returns a new Mesh
  105321. */
  105322. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  105323. /**
  105324. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  105325. * @param name defines the name of the mesh to create
  105326. * @param size sets the size (float) of both sides of the plane at once (default 1)
  105327. * @param scene defines the hosting scene
  105328. * @param updatable defines if the mesh must be flagged as updatable
  105329. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105330. * @returns a new Mesh
  105331. */
  105332. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  105333. /**
  105334. * Creates a ground mesh.
  105335. * Please consider using the same method from the MeshBuilder class instead
  105336. * @param name defines the name of the mesh to create
  105337. * @param width set the width of the ground
  105338. * @param height set the height of the ground
  105339. * @param subdivisions sets the number of subdivisions per side
  105340. * @param scene defines the hosting scene
  105341. * @param updatable defines if the mesh must be flagged as updatable
  105342. * @returns a new Mesh
  105343. */
  105344. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  105345. /**
  105346. * Creates a tiled ground mesh.
  105347. * Please consider using the same method from the MeshBuilder class instead
  105348. * @param name defines the name of the mesh to create
  105349. * @param xmin set the ground minimum X coordinate
  105350. * @param zmin set the ground minimum Y coordinate
  105351. * @param xmax set the ground maximum X coordinate
  105352. * @param zmax set the ground maximum Z coordinate
  105353. * @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
  105354. * @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
  105355. * @param scene defines the hosting scene
  105356. * @param updatable defines if the mesh must be flagged as updatable
  105357. * @returns a new Mesh
  105358. */
  105359. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  105360. w: number;
  105361. h: number;
  105362. }, precision: {
  105363. w: number;
  105364. h: number;
  105365. }, scene: Scene, updatable?: boolean): Mesh;
  105366. /**
  105367. * Creates a ground mesh from a height map.
  105368. * Please consider using the same method from the MeshBuilder class instead
  105369. * @see http://doc.babylonjs.com/babylon101/height_map
  105370. * @param name defines the name of the mesh to create
  105371. * @param url sets the URL of the height map image resource
  105372. * @param width set the ground width size
  105373. * @param height set the ground height size
  105374. * @param subdivisions sets the number of subdivision per side
  105375. * @param minHeight is the minimum altitude on the ground
  105376. * @param maxHeight is the maximum altitude on the ground
  105377. * @param scene defines the hosting scene
  105378. * @param updatable defines if the mesh must be flagged as updatable
  105379. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  105380. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  105381. * @returns a new Mesh
  105382. */
  105383. 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;
  105384. /**
  105385. * Creates a tube mesh.
  105386. * The tube is a parametric shape.
  105387. * It has no predefined shape. Its final shape will depend on the input parameters.
  105388. * Please consider using the same method from the MeshBuilder class instead
  105389. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  105390. * @param name defines the name of the mesh to create
  105391. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  105392. * @param radius sets the tube radius size
  105393. * @param tessellation is the number of sides on the tubular surface
  105394. * @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
  105395. * @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
  105396. * @param scene defines the hosting scene
  105397. * @param updatable defines if the mesh must be flagged as updatable
  105398. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105399. * @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)
  105400. * @returns a new Mesh
  105401. */
  105402. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  105403. (i: number, distance: number): number;
  105404. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  105405. /**
  105406. * Creates a polyhedron mesh.
  105407. * Please consider using the same method from the MeshBuilder class instead.
  105408. * * 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
  105409. * * The parameter `size` (positive float, default 1) sets the polygon size
  105410. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  105411. * * 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`
  105412. * * 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
  105413. * * 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)`)
  105414. * * 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
  105415. * * 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
  105416. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105417. * * If you create a double-sided mesh, you can choose what parts of 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
  105418. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105419. * @param name defines the name of the mesh to create
  105420. * @param options defines the options used to create the mesh
  105421. * @param scene defines the hosting scene
  105422. * @returns a new Mesh
  105423. */
  105424. static CreatePolyhedron(name: string, options: {
  105425. type?: number;
  105426. size?: number;
  105427. sizeX?: number;
  105428. sizeY?: number;
  105429. sizeZ?: number;
  105430. custom?: any;
  105431. faceUV?: Vector4[];
  105432. faceColors?: Color4[];
  105433. updatable?: boolean;
  105434. sideOrientation?: number;
  105435. }, scene: Scene): Mesh;
  105436. /**
  105437. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  105438. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  105439. * * 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`)
  105440. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  105441. * * 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
  105442. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105443. * * If you create a double-sided mesh, you can choose what parts of 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
  105444. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105445. * @param name defines the name of the mesh
  105446. * @param options defines the options used to create the mesh
  105447. * @param scene defines the hosting scene
  105448. * @returns a new Mesh
  105449. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  105450. */
  105451. static CreateIcoSphere(name: string, options: {
  105452. radius?: number;
  105453. flat?: boolean;
  105454. subdivisions?: number;
  105455. sideOrientation?: number;
  105456. updatable?: boolean;
  105457. }, scene: Scene): Mesh;
  105458. /**
  105459. * Creates a decal mesh.
  105460. * Please consider using the same method from the MeshBuilder class instead.
  105461. * A decal is a mesh usually applied as a model onto the surface of another mesh
  105462. * @param name defines the name of the mesh
  105463. * @param sourceMesh defines the mesh receiving the decal
  105464. * @param position sets the position of the decal in world coordinates
  105465. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  105466. * @param size sets the decal scaling
  105467. * @param angle sets the angle to rotate the decal
  105468. * @returns a new Mesh
  105469. */
  105470. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  105471. /**
  105472. * Prepare internal position array for software CPU skinning
  105473. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  105474. */
  105475. setPositionsForCPUSkinning(): Float32Array;
  105476. /**
  105477. * Prepare internal normal array for software CPU skinning
  105478. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  105479. */
  105480. setNormalsForCPUSkinning(): Float32Array;
  105481. /**
  105482. * Updates the vertex buffer by applying transformation from the bones
  105483. * @param skeleton defines the skeleton to apply to current mesh
  105484. * @returns the current mesh
  105485. */
  105486. applySkeleton(skeleton: Skeleton): Mesh;
  105487. /**
  105488. * 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
  105489. * @param meshes defines the list of meshes to scan
  105490. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  105491. */
  105492. static MinMax(meshes: AbstractMesh[]): {
  105493. min: Vector3;
  105494. max: Vector3;
  105495. };
  105496. /**
  105497. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  105498. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  105499. * @returns a vector3
  105500. */
  105501. static Center(meshesOrMinMaxVector: {
  105502. min: Vector3;
  105503. max: Vector3;
  105504. } | AbstractMesh[]): Vector3;
  105505. /**
  105506. * Merge the array of meshes into a single mesh for performance reasons.
  105507. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  105508. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  105509. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  105510. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  105511. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  105512. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  105513. * @returns a new mesh
  105514. */
  105515. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  105516. /** @hidden */
  105517. addInstance(instance: InstancedMesh): void;
  105518. /** @hidden */
  105519. removeInstance(instance: InstancedMesh): void;
  105520. }
  105521. }
  105522. declare module BABYLON {
  105523. /**
  105524. * This is the base class of all the camera used in the application.
  105525. * @see http://doc.babylonjs.com/features/cameras
  105526. */
  105527. export class Camera extends Node {
  105528. /** @hidden */
  105529. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  105530. /**
  105531. * This is the default projection mode used by the cameras.
  105532. * It helps recreating a feeling of perspective and better appreciate depth.
  105533. * This is the best way to simulate real life cameras.
  105534. */
  105535. static readonly PERSPECTIVE_CAMERA: number;
  105536. /**
  105537. * This helps creating camera with an orthographic mode.
  105538. * 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.
  105539. */
  105540. static readonly ORTHOGRAPHIC_CAMERA: number;
  105541. /**
  105542. * This is the default FOV mode for perspective cameras.
  105543. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  105544. */
  105545. static readonly FOVMODE_VERTICAL_FIXED: number;
  105546. /**
  105547. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  105548. */
  105549. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  105550. /**
  105551. * This specifies ther is no need for a camera rig.
  105552. * Basically only one eye is rendered corresponding to the camera.
  105553. */
  105554. static readonly RIG_MODE_NONE: number;
  105555. /**
  105556. * Simulates a camera Rig with one blue eye and one red eye.
  105557. * This can be use with 3d blue and red glasses.
  105558. */
  105559. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  105560. /**
  105561. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  105562. */
  105563. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  105564. /**
  105565. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  105566. */
  105567. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  105568. /**
  105569. * Defines that both eyes of the camera will be rendered over under each other.
  105570. */
  105571. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  105572. /**
  105573. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  105574. */
  105575. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  105576. /**
  105577. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  105578. */
  105579. static readonly RIG_MODE_VR: number;
  105580. /**
  105581. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  105582. */
  105583. static readonly RIG_MODE_WEBVR: number;
  105584. /**
  105585. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  105586. */
  105587. static readonly RIG_MODE_CUSTOM: number;
  105588. /**
  105589. * Defines if by default attaching controls should prevent the default javascript event to continue.
  105590. */
  105591. static ForceAttachControlToAlwaysPreventDefault: boolean;
  105592. /**
  105593. * Define the input manager associated with the camera.
  105594. */
  105595. inputs: CameraInputsManager<Camera>;
  105596. /** @hidden */
  105597. _position: Vector3;
  105598. /**
  105599. * Define the current local position of the camera in the scene
  105600. */
  105601. get position(): Vector3;
  105602. set position(newPosition: Vector3);
  105603. /**
  105604. * The vector the camera should consider as up.
  105605. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  105606. */
  105607. upVector: Vector3;
  105608. /**
  105609. * Define the current limit on the left side for an orthographic camera
  105610. * In scene unit
  105611. */
  105612. orthoLeft: Nullable<number>;
  105613. /**
  105614. * Define the current limit on the right side for an orthographic camera
  105615. * In scene unit
  105616. */
  105617. orthoRight: Nullable<number>;
  105618. /**
  105619. * Define the current limit on the bottom side for an orthographic camera
  105620. * In scene unit
  105621. */
  105622. orthoBottom: Nullable<number>;
  105623. /**
  105624. * Define the current limit on the top side for an orthographic camera
  105625. * In scene unit
  105626. */
  105627. orthoTop: Nullable<number>;
  105628. /**
  105629. * Field Of View is set in Radians. (default is 0.8)
  105630. */
  105631. fov: number;
  105632. /**
  105633. * Define the minimum distance the camera can see from.
  105634. * This is important to note that the depth buffer are not infinite and the closer it starts
  105635. * the more your scene might encounter depth fighting issue.
  105636. */
  105637. minZ: number;
  105638. /**
  105639. * Define the maximum distance the camera can see to.
  105640. * This is important to note that the depth buffer are not infinite and the further it end
  105641. * the more your scene might encounter depth fighting issue.
  105642. */
  105643. maxZ: number;
  105644. /**
  105645. * Define the default inertia of the camera.
  105646. * This helps giving a smooth feeling to the camera movement.
  105647. */
  105648. inertia: number;
  105649. /**
  105650. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  105651. */
  105652. mode: number;
  105653. /**
  105654. * Define whether the camera is intermediate.
  105655. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  105656. */
  105657. isIntermediate: boolean;
  105658. /**
  105659. * Define the viewport of the camera.
  105660. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  105661. */
  105662. viewport: Viewport;
  105663. /**
  105664. * Restricts the camera to viewing objects with the same layerMask.
  105665. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  105666. */
  105667. layerMask: number;
  105668. /**
  105669. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  105670. */
  105671. fovMode: number;
  105672. /**
  105673. * Rig mode of the camera.
  105674. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  105675. * This is normally controlled byt the camera themselves as internal use.
  105676. */
  105677. cameraRigMode: number;
  105678. /**
  105679. * Defines the distance between both "eyes" in case of a RIG
  105680. */
  105681. interaxialDistance: number;
  105682. /**
  105683. * Defines if stereoscopic rendering is done side by side or over under.
  105684. */
  105685. isStereoscopicSideBySide: boolean;
  105686. /**
  105687. * 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
  105688. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  105689. * else in the scene. (Eg. security camera)
  105690. *
  105691. * 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)
  105692. */
  105693. customRenderTargets: RenderTargetTexture[];
  105694. /**
  105695. * When set, the camera will render to this render target instead of the default canvas
  105696. *
  105697. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  105698. */
  105699. outputRenderTarget: Nullable<RenderTargetTexture>;
  105700. /**
  105701. * Observable triggered when the camera view matrix has changed.
  105702. */
  105703. onViewMatrixChangedObservable: Observable<Camera>;
  105704. /**
  105705. * Observable triggered when the camera Projection matrix has changed.
  105706. */
  105707. onProjectionMatrixChangedObservable: Observable<Camera>;
  105708. /**
  105709. * Observable triggered when the inputs have been processed.
  105710. */
  105711. onAfterCheckInputsObservable: Observable<Camera>;
  105712. /**
  105713. * Observable triggered when reset has been called and applied to the camera.
  105714. */
  105715. onRestoreStateObservable: Observable<Camera>;
  105716. /**
  105717. * Is this camera a part of a rig system?
  105718. */
  105719. isRigCamera: boolean;
  105720. /**
  105721. * If isRigCamera set to true this will be set with the parent camera.
  105722. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  105723. */
  105724. rigParent?: Camera;
  105725. /** @hidden */
  105726. _cameraRigParams: any;
  105727. /** @hidden */
  105728. _rigCameras: Camera[];
  105729. /** @hidden */
  105730. _rigPostProcess: Nullable<PostProcess>;
  105731. protected _webvrViewMatrix: Matrix;
  105732. /** @hidden */
  105733. _skipRendering: boolean;
  105734. /** @hidden */
  105735. _projectionMatrix: Matrix;
  105736. /** @hidden */
  105737. _postProcesses: Nullable<PostProcess>[];
  105738. /** @hidden */
  105739. _activeMeshes: SmartArray<AbstractMesh>;
  105740. protected _globalPosition: Vector3;
  105741. /** @hidden */
  105742. _computedViewMatrix: Matrix;
  105743. private _doNotComputeProjectionMatrix;
  105744. private _transformMatrix;
  105745. private _frustumPlanes;
  105746. private _refreshFrustumPlanes;
  105747. private _storedFov;
  105748. private _stateStored;
  105749. /**
  105750. * Instantiates a new camera object.
  105751. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  105752. * @see http://doc.babylonjs.com/features/cameras
  105753. * @param name Defines the name of the camera in the scene
  105754. * @param position Defines the position of the camera
  105755. * @param scene Defines the scene the camera belongs too
  105756. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  105757. */
  105758. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  105759. /**
  105760. * Store current camera state (fov, position, etc..)
  105761. * @returns the camera
  105762. */
  105763. storeState(): Camera;
  105764. /**
  105765. * Restores the camera state values if it has been stored. You must call storeState() first
  105766. */
  105767. protected _restoreStateValues(): boolean;
  105768. /**
  105769. * Restored camera state. You must call storeState() first.
  105770. * @returns true if restored and false otherwise
  105771. */
  105772. restoreState(): boolean;
  105773. /**
  105774. * Gets the class name of the camera.
  105775. * @returns the class name
  105776. */
  105777. getClassName(): string;
  105778. /** @hidden */
  105779. readonly _isCamera: boolean;
  105780. /**
  105781. * Gets a string representation of the camera useful for debug purpose.
  105782. * @param fullDetails Defines that a more verboe level of logging is required
  105783. * @returns the string representation
  105784. */
  105785. toString(fullDetails?: boolean): string;
  105786. /**
  105787. * Gets the current world space position of the camera.
  105788. */
  105789. get globalPosition(): Vector3;
  105790. /**
  105791. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  105792. * @returns the active meshe list
  105793. */
  105794. getActiveMeshes(): SmartArray<AbstractMesh>;
  105795. /**
  105796. * Check whether a mesh is part of the current active mesh list of the camera
  105797. * @param mesh Defines the mesh to check
  105798. * @returns true if active, false otherwise
  105799. */
  105800. isActiveMesh(mesh: Mesh): boolean;
  105801. /**
  105802. * Is this camera ready to be used/rendered
  105803. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  105804. * @return true if the camera is ready
  105805. */
  105806. isReady(completeCheck?: boolean): boolean;
  105807. /** @hidden */
  105808. _initCache(): void;
  105809. /** @hidden */
  105810. _updateCache(ignoreParentClass?: boolean): void;
  105811. /** @hidden */
  105812. _isSynchronized(): boolean;
  105813. /** @hidden */
  105814. _isSynchronizedViewMatrix(): boolean;
  105815. /** @hidden */
  105816. _isSynchronizedProjectionMatrix(): boolean;
  105817. /**
  105818. * Attach the input controls to a specific dom element to get the input from.
  105819. * @param element Defines the element the controls should be listened from
  105820. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105821. */
  105822. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105823. /**
  105824. * Detach the current controls from the specified dom element.
  105825. * @param element Defines the element to stop listening the inputs from
  105826. */
  105827. detachControl(element: HTMLElement): void;
  105828. /**
  105829. * Update the camera state according to the different inputs gathered during the frame.
  105830. */
  105831. update(): void;
  105832. /** @hidden */
  105833. _checkInputs(): void;
  105834. /** @hidden */
  105835. get rigCameras(): Camera[];
  105836. /**
  105837. * Gets the post process used by the rig cameras
  105838. */
  105839. get rigPostProcess(): Nullable<PostProcess>;
  105840. /**
  105841. * Internal, gets the first post proces.
  105842. * @returns the first post process to be run on this camera.
  105843. */
  105844. _getFirstPostProcess(): Nullable<PostProcess>;
  105845. private _cascadePostProcessesToRigCams;
  105846. /**
  105847. * Attach a post process to the camera.
  105848. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  105849. * @param postProcess The post process to attach to the camera
  105850. * @param insertAt The position of the post process in case several of them are in use in the scene
  105851. * @returns the position the post process has been inserted at
  105852. */
  105853. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  105854. /**
  105855. * Detach a post process to the camera.
  105856. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  105857. * @param postProcess The post process to detach from the camera
  105858. */
  105859. detachPostProcess(postProcess: PostProcess): void;
  105860. /**
  105861. * Gets the current world matrix of the camera
  105862. */
  105863. getWorldMatrix(): Matrix;
  105864. /** @hidden */
  105865. _getViewMatrix(): Matrix;
  105866. /**
  105867. * Gets the current view matrix of the camera.
  105868. * @param force forces the camera to recompute the matrix without looking at the cached state
  105869. * @returns the view matrix
  105870. */
  105871. getViewMatrix(force?: boolean): Matrix;
  105872. /**
  105873. * Freeze the projection matrix.
  105874. * It will prevent the cache check of the camera projection compute and can speed up perf
  105875. * if no parameter of the camera are meant to change
  105876. * @param projection Defines manually a projection if necessary
  105877. */
  105878. freezeProjectionMatrix(projection?: Matrix): void;
  105879. /**
  105880. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  105881. */
  105882. unfreezeProjectionMatrix(): void;
  105883. /**
  105884. * Gets the current projection matrix of the camera.
  105885. * @param force forces the camera to recompute the matrix without looking at the cached state
  105886. * @returns the projection matrix
  105887. */
  105888. getProjectionMatrix(force?: boolean): Matrix;
  105889. /**
  105890. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  105891. * @returns a Matrix
  105892. */
  105893. getTransformationMatrix(): Matrix;
  105894. private _updateFrustumPlanes;
  105895. /**
  105896. * Checks if a cullable object (mesh...) is in the camera frustum
  105897. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  105898. * @param target The object to check
  105899. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  105900. * @returns true if the object is in frustum otherwise false
  105901. */
  105902. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  105903. /**
  105904. * Checks if a cullable object (mesh...) is in the camera frustum
  105905. * Unlike isInFrustum this cheks the full bounding box
  105906. * @param target The object to check
  105907. * @returns true if the object is in frustum otherwise false
  105908. */
  105909. isCompletelyInFrustum(target: ICullable): boolean;
  105910. /**
  105911. * Gets a ray in the forward direction from the camera.
  105912. * @param length Defines the length of the ray to create
  105913. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  105914. * @param origin Defines the start point of the ray which defaults to the camera position
  105915. * @returns the forward ray
  105916. */
  105917. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  105918. /**
  105919. * Releases resources associated with this node.
  105920. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  105921. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  105922. */
  105923. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  105924. /** @hidden */
  105925. _isLeftCamera: boolean;
  105926. /**
  105927. * Gets the left camera of a rig setup in case of Rigged Camera
  105928. */
  105929. get isLeftCamera(): boolean;
  105930. /** @hidden */
  105931. _isRightCamera: boolean;
  105932. /**
  105933. * Gets the right camera of a rig setup in case of Rigged Camera
  105934. */
  105935. get isRightCamera(): boolean;
  105936. /**
  105937. * Gets the left camera of a rig setup in case of Rigged Camera
  105938. */
  105939. get leftCamera(): Nullable<FreeCamera>;
  105940. /**
  105941. * Gets the right camera of a rig setup in case of Rigged Camera
  105942. */
  105943. get rightCamera(): Nullable<FreeCamera>;
  105944. /**
  105945. * Gets the left camera target of a rig setup in case of Rigged Camera
  105946. * @returns the target position
  105947. */
  105948. getLeftTarget(): Nullable<Vector3>;
  105949. /**
  105950. * Gets the right camera target of a rig setup in case of Rigged Camera
  105951. * @returns the target position
  105952. */
  105953. getRightTarget(): Nullable<Vector3>;
  105954. /**
  105955. * @hidden
  105956. */
  105957. setCameraRigMode(mode: number, rigParams: any): void;
  105958. /** @hidden */
  105959. static _setStereoscopicRigMode(camera: Camera): void;
  105960. /** @hidden */
  105961. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  105962. /** @hidden */
  105963. static _setVRRigMode(camera: Camera, rigParams: any): void;
  105964. /** @hidden */
  105965. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  105966. /** @hidden */
  105967. _getVRProjectionMatrix(): Matrix;
  105968. protected _updateCameraRotationMatrix(): void;
  105969. protected _updateWebVRCameraRotationMatrix(): void;
  105970. /**
  105971. * This function MUST be overwritten by the different WebVR cameras available.
  105972. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  105973. * @hidden
  105974. */
  105975. _getWebVRProjectionMatrix(): Matrix;
  105976. /**
  105977. * This function MUST be overwritten by the different WebVR cameras available.
  105978. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  105979. * @hidden
  105980. */
  105981. _getWebVRViewMatrix(): Matrix;
  105982. /** @hidden */
  105983. setCameraRigParameter(name: string, value: any): void;
  105984. /**
  105985. * needs to be overridden by children so sub has required properties to be copied
  105986. * @hidden
  105987. */
  105988. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  105989. /**
  105990. * May need to be overridden by children
  105991. * @hidden
  105992. */
  105993. _updateRigCameras(): void;
  105994. /** @hidden */
  105995. _setupInputs(): void;
  105996. /**
  105997. * Serialiaze the camera setup to a json represention
  105998. * @returns the JSON representation
  105999. */
  106000. serialize(): any;
  106001. /**
  106002. * Clones the current camera.
  106003. * @param name The cloned camera name
  106004. * @returns the cloned camera
  106005. */
  106006. clone(name: string): Camera;
  106007. /**
  106008. * Gets the direction of the camera relative to a given local axis.
  106009. * @param localAxis Defines the reference axis to provide a relative direction.
  106010. * @return the direction
  106011. */
  106012. getDirection(localAxis: Vector3): Vector3;
  106013. /**
  106014. * Returns the current camera absolute rotation
  106015. */
  106016. get absoluteRotation(): Quaternion;
  106017. /**
  106018. * Gets the direction of the camera relative to a given local axis into a passed vector.
  106019. * @param localAxis Defines the reference axis to provide a relative direction.
  106020. * @param result Defines the vector to store the result in
  106021. */
  106022. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  106023. /**
  106024. * Gets a camera constructor for a given camera type
  106025. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  106026. * @param name The name of the camera the result will be able to instantiate
  106027. * @param scene The scene the result will construct the camera in
  106028. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  106029. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  106030. * @returns a factory method to construc the camera
  106031. */
  106032. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  106033. /**
  106034. * Compute the world matrix of the camera.
  106035. * @returns the camera world matrix
  106036. */
  106037. computeWorldMatrix(): Matrix;
  106038. /**
  106039. * Parse a JSON and creates the camera from the parsed information
  106040. * @param parsedCamera The JSON to parse
  106041. * @param scene The scene to instantiate the camera in
  106042. * @returns the newly constructed camera
  106043. */
  106044. static Parse(parsedCamera: any, scene: Scene): Camera;
  106045. }
  106046. }
  106047. declare module BABYLON {
  106048. /**
  106049. * Class containing static functions to help procedurally build meshes
  106050. */
  106051. export class DiscBuilder {
  106052. /**
  106053. * Creates a plane polygonal mesh. By default, this is a disc
  106054. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  106055. * * 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
  106056. * * 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
  106057. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106058. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106059. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106060. * @param name defines the name of the mesh
  106061. * @param options defines the options used to create the mesh
  106062. * @param scene defines the hosting scene
  106063. * @returns the plane polygonal mesh
  106064. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  106065. */
  106066. static CreateDisc(name: string, options: {
  106067. radius?: number;
  106068. tessellation?: number;
  106069. arc?: number;
  106070. updatable?: boolean;
  106071. sideOrientation?: number;
  106072. frontUVs?: Vector4;
  106073. backUVs?: Vector4;
  106074. }, scene?: Nullable<Scene>): Mesh;
  106075. }
  106076. }
  106077. declare module BABYLON {
  106078. /**
  106079. * Options to be used when creating a FresnelParameters.
  106080. */
  106081. export type IFresnelParametersCreationOptions = {
  106082. /**
  106083. * Define the color used on edges (grazing angle)
  106084. */
  106085. leftColor?: Color3;
  106086. /**
  106087. * Define the color used on center
  106088. */
  106089. rightColor?: Color3;
  106090. /**
  106091. * Define bias applied to computed fresnel term
  106092. */
  106093. bias?: number;
  106094. /**
  106095. * Defined the power exponent applied to fresnel term
  106096. */
  106097. power?: number;
  106098. /**
  106099. * Define if the fresnel effect is enable or not.
  106100. */
  106101. isEnabled?: boolean;
  106102. };
  106103. /**
  106104. * Serialized format for FresnelParameters.
  106105. */
  106106. export type IFresnelParametersSerialized = {
  106107. /**
  106108. * Define the color used on edges (grazing angle) [as an array]
  106109. */
  106110. leftColor: number[];
  106111. /**
  106112. * Define the color used on center [as an array]
  106113. */
  106114. rightColor: number[];
  106115. /**
  106116. * Define bias applied to computed fresnel term
  106117. */
  106118. bias: number;
  106119. /**
  106120. * Defined the power exponent applied to fresnel term
  106121. */
  106122. power?: number;
  106123. /**
  106124. * Define if the fresnel effect is enable or not.
  106125. */
  106126. isEnabled: boolean;
  106127. };
  106128. /**
  106129. * This represents all the required information to add a fresnel effect on a material:
  106130. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106131. */
  106132. export class FresnelParameters {
  106133. private _isEnabled;
  106134. /**
  106135. * Define if the fresnel effect is enable or not.
  106136. */
  106137. get isEnabled(): boolean;
  106138. set isEnabled(value: boolean);
  106139. /**
  106140. * Define the color used on edges (grazing angle)
  106141. */
  106142. leftColor: Color3;
  106143. /**
  106144. * Define the color used on center
  106145. */
  106146. rightColor: Color3;
  106147. /**
  106148. * Define bias applied to computed fresnel term
  106149. */
  106150. bias: number;
  106151. /**
  106152. * Defined the power exponent applied to fresnel term
  106153. */
  106154. power: number;
  106155. /**
  106156. * Creates a new FresnelParameters object.
  106157. *
  106158. * @param options provide your own settings to optionally to override defaults
  106159. */
  106160. constructor(options?: IFresnelParametersCreationOptions);
  106161. /**
  106162. * Clones the current fresnel and its valuues
  106163. * @returns a clone fresnel configuration
  106164. */
  106165. clone(): FresnelParameters;
  106166. /**
  106167. * Determines equality between FresnelParameters objects
  106168. * @param otherFresnelParameters defines the second operand
  106169. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  106170. */
  106171. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  106172. /**
  106173. * Serializes the current fresnel parameters to a JSON representation.
  106174. * @return the JSON serialization
  106175. */
  106176. serialize(): IFresnelParametersSerialized;
  106177. /**
  106178. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  106179. * @param parsedFresnelParameters Define the JSON representation
  106180. * @returns the parsed parameters
  106181. */
  106182. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  106183. }
  106184. }
  106185. declare module BABYLON {
  106186. /**
  106187. * This groups all the flags used to control the materials channel.
  106188. */
  106189. export class MaterialFlags {
  106190. private static _DiffuseTextureEnabled;
  106191. /**
  106192. * Are diffuse textures enabled in the application.
  106193. */
  106194. static get DiffuseTextureEnabled(): boolean;
  106195. static set DiffuseTextureEnabled(value: boolean);
  106196. private static _AmbientTextureEnabled;
  106197. /**
  106198. * Are ambient textures enabled in the application.
  106199. */
  106200. static get AmbientTextureEnabled(): boolean;
  106201. static set AmbientTextureEnabled(value: boolean);
  106202. private static _OpacityTextureEnabled;
  106203. /**
  106204. * Are opacity textures enabled in the application.
  106205. */
  106206. static get OpacityTextureEnabled(): boolean;
  106207. static set OpacityTextureEnabled(value: boolean);
  106208. private static _ReflectionTextureEnabled;
  106209. /**
  106210. * Are reflection textures enabled in the application.
  106211. */
  106212. static get ReflectionTextureEnabled(): boolean;
  106213. static set ReflectionTextureEnabled(value: boolean);
  106214. private static _EmissiveTextureEnabled;
  106215. /**
  106216. * Are emissive textures enabled in the application.
  106217. */
  106218. static get EmissiveTextureEnabled(): boolean;
  106219. static set EmissiveTextureEnabled(value: boolean);
  106220. private static _SpecularTextureEnabled;
  106221. /**
  106222. * Are specular textures enabled in the application.
  106223. */
  106224. static get SpecularTextureEnabled(): boolean;
  106225. static set SpecularTextureEnabled(value: boolean);
  106226. private static _BumpTextureEnabled;
  106227. /**
  106228. * Are bump textures enabled in the application.
  106229. */
  106230. static get BumpTextureEnabled(): boolean;
  106231. static set BumpTextureEnabled(value: boolean);
  106232. private static _LightmapTextureEnabled;
  106233. /**
  106234. * Are lightmap textures enabled in the application.
  106235. */
  106236. static get LightmapTextureEnabled(): boolean;
  106237. static set LightmapTextureEnabled(value: boolean);
  106238. private static _RefractionTextureEnabled;
  106239. /**
  106240. * Are refraction textures enabled in the application.
  106241. */
  106242. static get RefractionTextureEnabled(): boolean;
  106243. static set RefractionTextureEnabled(value: boolean);
  106244. private static _ColorGradingTextureEnabled;
  106245. /**
  106246. * Are color grading textures enabled in the application.
  106247. */
  106248. static get ColorGradingTextureEnabled(): boolean;
  106249. static set ColorGradingTextureEnabled(value: boolean);
  106250. private static _FresnelEnabled;
  106251. /**
  106252. * Are fresnels enabled in the application.
  106253. */
  106254. static get FresnelEnabled(): boolean;
  106255. static set FresnelEnabled(value: boolean);
  106256. private static _ClearCoatTextureEnabled;
  106257. /**
  106258. * Are clear coat textures enabled in the application.
  106259. */
  106260. static get ClearCoatTextureEnabled(): boolean;
  106261. static set ClearCoatTextureEnabled(value: boolean);
  106262. private static _ClearCoatBumpTextureEnabled;
  106263. /**
  106264. * Are clear coat bump textures enabled in the application.
  106265. */
  106266. static get ClearCoatBumpTextureEnabled(): boolean;
  106267. static set ClearCoatBumpTextureEnabled(value: boolean);
  106268. private static _ClearCoatTintTextureEnabled;
  106269. /**
  106270. * Are clear coat tint textures enabled in the application.
  106271. */
  106272. static get ClearCoatTintTextureEnabled(): boolean;
  106273. static set ClearCoatTintTextureEnabled(value: boolean);
  106274. private static _SheenTextureEnabled;
  106275. /**
  106276. * Are sheen textures enabled in the application.
  106277. */
  106278. static get SheenTextureEnabled(): boolean;
  106279. static set SheenTextureEnabled(value: boolean);
  106280. private static _AnisotropicTextureEnabled;
  106281. /**
  106282. * Are anisotropic textures enabled in the application.
  106283. */
  106284. static get AnisotropicTextureEnabled(): boolean;
  106285. static set AnisotropicTextureEnabled(value: boolean);
  106286. private static _ThicknessTextureEnabled;
  106287. /**
  106288. * Are thickness textures enabled in the application.
  106289. */
  106290. static get ThicknessTextureEnabled(): boolean;
  106291. static set ThicknessTextureEnabled(value: boolean);
  106292. }
  106293. }
  106294. declare module BABYLON {
  106295. /** @hidden */
  106296. export var defaultFragmentDeclaration: {
  106297. name: string;
  106298. shader: string;
  106299. };
  106300. }
  106301. declare module BABYLON {
  106302. /** @hidden */
  106303. export var defaultUboDeclaration: {
  106304. name: string;
  106305. shader: string;
  106306. };
  106307. }
  106308. declare module BABYLON {
  106309. /** @hidden */
  106310. export var lightFragmentDeclaration: {
  106311. name: string;
  106312. shader: string;
  106313. };
  106314. }
  106315. declare module BABYLON {
  106316. /** @hidden */
  106317. export var lightUboDeclaration: {
  106318. name: string;
  106319. shader: string;
  106320. };
  106321. }
  106322. declare module BABYLON {
  106323. /** @hidden */
  106324. export var lightsFragmentFunctions: {
  106325. name: string;
  106326. shader: string;
  106327. };
  106328. }
  106329. declare module BABYLON {
  106330. /** @hidden */
  106331. export var shadowsFragmentFunctions: {
  106332. name: string;
  106333. shader: string;
  106334. };
  106335. }
  106336. declare module BABYLON {
  106337. /** @hidden */
  106338. export var fresnelFunction: {
  106339. name: string;
  106340. shader: string;
  106341. };
  106342. }
  106343. declare module BABYLON {
  106344. /** @hidden */
  106345. export var bumpFragmentMainFunctions: {
  106346. name: string;
  106347. shader: string;
  106348. };
  106349. }
  106350. declare module BABYLON {
  106351. /** @hidden */
  106352. export var bumpFragmentFunctions: {
  106353. name: string;
  106354. shader: string;
  106355. };
  106356. }
  106357. declare module BABYLON {
  106358. /** @hidden */
  106359. export var logDepthDeclaration: {
  106360. name: string;
  106361. shader: string;
  106362. };
  106363. }
  106364. declare module BABYLON {
  106365. /** @hidden */
  106366. export var bumpFragment: {
  106367. name: string;
  106368. shader: string;
  106369. };
  106370. }
  106371. declare module BABYLON {
  106372. /** @hidden */
  106373. export var depthPrePass: {
  106374. name: string;
  106375. shader: string;
  106376. };
  106377. }
  106378. declare module BABYLON {
  106379. /** @hidden */
  106380. export var lightFragment: {
  106381. name: string;
  106382. shader: string;
  106383. };
  106384. }
  106385. declare module BABYLON {
  106386. /** @hidden */
  106387. export var logDepthFragment: {
  106388. name: string;
  106389. shader: string;
  106390. };
  106391. }
  106392. declare module BABYLON {
  106393. /** @hidden */
  106394. export var defaultPixelShader: {
  106395. name: string;
  106396. shader: string;
  106397. };
  106398. }
  106399. declare module BABYLON {
  106400. /** @hidden */
  106401. export var defaultVertexDeclaration: {
  106402. name: string;
  106403. shader: string;
  106404. };
  106405. }
  106406. declare module BABYLON {
  106407. /** @hidden */
  106408. export var bumpVertexDeclaration: {
  106409. name: string;
  106410. shader: string;
  106411. };
  106412. }
  106413. declare module BABYLON {
  106414. /** @hidden */
  106415. export var bumpVertex: {
  106416. name: string;
  106417. shader: string;
  106418. };
  106419. }
  106420. declare module BABYLON {
  106421. /** @hidden */
  106422. export var fogVertex: {
  106423. name: string;
  106424. shader: string;
  106425. };
  106426. }
  106427. declare module BABYLON {
  106428. /** @hidden */
  106429. export var shadowsVertex: {
  106430. name: string;
  106431. shader: string;
  106432. };
  106433. }
  106434. declare module BABYLON {
  106435. /** @hidden */
  106436. export var pointCloudVertex: {
  106437. name: string;
  106438. shader: string;
  106439. };
  106440. }
  106441. declare module BABYLON {
  106442. /** @hidden */
  106443. export var logDepthVertex: {
  106444. name: string;
  106445. shader: string;
  106446. };
  106447. }
  106448. declare module BABYLON {
  106449. /** @hidden */
  106450. export var defaultVertexShader: {
  106451. name: string;
  106452. shader: string;
  106453. };
  106454. }
  106455. declare module BABYLON {
  106456. /** @hidden */
  106457. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  106458. MAINUV1: boolean;
  106459. MAINUV2: boolean;
  106460. DIFFUSE: boolean;
  106461. DIFFUSEDIRECTUV: number;
  106462. AMBIENT: boolean;
  106463. AMBIENTDIRECTUV: number;
  106464. OPACITY: boolean;
  106465. OPACITYDIRECTUV: number;
  106466. OPACITYRGB: boolean;
  106467. REFLECTION: boolean;
  106468. EMISSIVE: boolean;
  106469. EMISSIVEDIRECTUV: number;
  106470. SPECULAR: boolean;
  106471. SPECULARDIRECTUV: number;
  106472. BUMP: boolean;
  106473. BUMPDIRECTUV: number;
  106474. PARALLAX: boolean;
  106475. PARALLAXOCCLUSION: boolean;
  106476. SPECULAROVERALPHA: boolean;
  106477. CLIPPLANE: boolean;
  106478. CLIPPLANE2: boolean;
  106479. CLIPPLANE3: boolean;
  106480. CLIPPLANE4: boolean;
  106481. CLIPPLANE5: boolean;
  106482. CLIPPLANE6: boolean;
  106483. ALPHATEST: boolean;
  106484. DEPTHPREPASS: boolean;
  106485. ALPHAFROMDIFFUSE: boolean;
  106486. POINTSIZE: boolean;
  106487. FOG: boolean;
  106488. SPECULARTERM: boolean;
  106489. DIFFUSEFRESNEL: boolean;
  106490. OPACITYFRESNEL: boolean;
  106491. REFLECTIONFRESNEL: boolean;
  106492. REFRACTIONFRESNEL: boolean;
  106493. EMISSIVEFRESNEL: boolean;
  106494. FRESNEL: boolean;
  106495. NORMAL: boolean;
  106496. UV1: boolean;
  106497. UV2: boolean;
  106498. VERTEXCOLOR: boolean;
  106499. VERTEXALPHA: boolean;
  106500. NUM_BONE_INFLUENCERS: number;
  106501. BonesPerMesh: number;
  106502. BONETEXTURE: boolean;
  106503. INSTANCES: boolean;
  106504. THIN_INSTANCES: boolean;
  106505. GLOSSINESS: boolean;
  106506. ROUGHNESS: boolean;
  106507. EMISSIVEASILLUMINATION: boolean;
  106508. LINKEMISSIVEWITHDIFFUSE: boolean;
  106509. REFLECTIONFRESNELFROMSPECULAR: boolean;
  106510. LIGHTMAP: boolean;
  106511. LIGHTMAPDIRECTUV: number;
  106512. OBJECTSPACE_NORMALMAP: boolean;
  106513. USELIGHTMAPASSHADOWMAP: boolean;
  106514. REFLECTIONMAP_3D: boolean;
  106515. REFLECTIONMAP_SPHERICAL: boolean;
  106516. REFLECTIONMAP_PLANAR: boolean;
  106517. REFLECTIONMAP_CUBIC: boolean;
  106518. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  106519. REFLECTIONMAP_PROJECTION: boolean;
  106520. REFLECTIONMAP_SKYBOX: boolean;
  106521. REFLECTIONMAP_EXPLICIT: boolean;
  106522. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  106523. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  106524. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  106525. INVERTCUBICMAP: boolean;
  106526. LOGARITHMICDEPTH: boolean;
  106527. REFRACTION: boolean;
  106528. REFRACTIONMAP_3D: boolean;
  106529. REFLECTIONOVERALPHA: boolean;
  106530. TWOSIDEDLIGHTING: boolean;
  106531. SHADOWFLOAT: boolean;
  106532. MORPHTARGETS: boolean;
  106533. MORPHTARGETS_NORMAL: boolean;
  106534. MORPHTARGETS_TANGENT: boolean;
  106535. MORPHTARGETS_UV: boolean;
  106536. NUM_MORPH_INFLUENCERS: number;
  106537. NONUNIFORMSCALING: boolean;
  106538. PREMULTIPLYALPHA: boolean;
  106539. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  106540. ALPHABLEND: boolean;
  106541. RGBDLIGHTMAP: boolean;
  106542. RGBDREFLECTION: boolean;
  106543. RGBDREFRACTION: boolean;
  106544. IMAGEPROCESSING: boolean;
  106545. VIGNETTE: boolean;
  106546. VIGNETTEBLENDMODEMULTIPLY: boolean;
  106547. VIGNETTEBLENDMODEOPAQUE: boolean;
  106548. TONEMAPPING: boolean;
  106549. TONEMAPPING_ACES: boolean;
  106550. CONTRAST: boolean;
  106551. COLORCURVES: boolean;
  106552. COLORGRADING: boolean;
  106553. COLORGRADING3D: boolean;
  106554. SAMPLER3DGREENDEPTH: boolean;
  106555. SAMPLER3DBGRMAP: boolean;
  106556. IMAGEPROCESSINGPOSTPROCESS: boolean;
  106557. MULTIVIEW: boolean;
  106558. /**
  106559. * If the reflection texture on this material is in linear color space
  106560. * @hidden
  106561. */
  106562. IS_REFLECTION_LINEAR: boolean;
  106563. /**
  106564. * If the refraction texture on this material is in linear color space
  106565. * @hidden
  106566. */
  106567. IS_REFRACTION_LINEAR: boolean;
  106568. EXPOSURE: boolean;
  106569. constructor();
  106570. setReflectionMode(modeToEnable: string): void;
  106571. }
  106572. /**
  106573. * This is the default material used in Babylon. It is the best trade off between quality
  106574. * and performances.
  106575. * @see http://doc.babylonjs.com/babylon101/materials
  106576. */
  106577. export class StandardMaterial extends PushMaterial {
  106578. private _diffuseTexture;
  106579. /**
  106580. * The basic texture of the material as viewed under a light.
  106581. */
  106582. diffuseTexture: Nullable<BaseTexture>;
  106583. private _ambientTexture;
  106584. /**
  106585. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  106586. */
  106587. ambientTexture: Nullable<BaseTexture>;
  106588. private _opacityTexture;
  106589. /**
  106590. * Define the transparency of the material from a texture.
  106591. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  106592. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  106593. */
  106594. opacityTexture: Nullable<BaseTexture>;
  106595. private _reflectionTexture;
  106596. /**
  106597. * Define the texture used to display the reflection.
  106598. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  106599. */
  106600. reflectionTexture: Nullable<BaseTexture>;
  106601. private _emissiveTexture;
  106602. /**
  106603. * Define texture of the material as if self lit.
  106604. * This will be mixed in the final result even in the absence of light.
  106605. */
  106606. emissiveTexture: Nullable<BaseTexture>;
  106607. private _specularTexture;
  106608. /**
  106609. * Define how the color and intensity of the highlight given by the light in the material.
  106610. */
  106611. specularTexture: Nullable<BaseTexture>;
  106612. private _bumpTexture;
  106613. /**
  106614. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  106615. * 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.
  106616. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  106617. */
  106618. bumpTexture: Nullable<BaseTexture>;
  106619. private _lightmapTexture;
  106620. /**
  106621. * Complex lighting can be computationally expensive to compute at runtime.
  106622. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  106623. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  106624. */
  106625. lightmapTexture: Nullable<BaseTexture>;
  106626. private _refractionTexture;
  106627. /**
  106628. * Define the texture used to display the refraction.
  106629. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  106630. */
  106631. refractionTexture: Nullable<BaseTexture>;
  106632. /**
  106633. * The color of the material lit by the environmental background lighting.
  106634. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  106635. */
  106636. ambientColor: Color3;
  106637. /**
  106638. * The basic color of the material as viewed under a light.
  106639. */
  106640. diffuseColor: Color3;
  106641. /**
  106642. * Define how the color and intensity of the highlight given by the light in the material.
  106643. */
  106644. specularColor: Color3;
  106645. /**
  106646. * Define the color of the material as if self lit.
  106647. * This will be mixed in the final result even in the absence of light.
  106648. */
  106649. emissiveColor: Color3;
  106650. /**
  106651. * Defines how sharp are the highlights in the material.
  106652. * The bigger the value the sharper giving a more glossy feeling to the result.
  106653. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  106654. */
  106655. specularPower: number;
  106656. private _useAlphaFromDiffuseTexture;
  106657. /**
  106658. * Does the transparency come from the diffuse texture alpha channel.
  106659. */
  106660. useAlphaFromDiffuseTexture: boolean;
  106661. private _useEmissiveAsIllumination;
  106662. /**
  106663. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  106664. */
  106665. useEmissiveAsIllumination: boolean;
  106666. private _linkEmissiveWithDiffuse;
  106667. /**
  106668. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  106669. * the emissive level when the final color is close to one.
  106670. */
  106671. linkEmissiveWithDiffuse: boolean;
  106672. private _useSpecularOverAlpha;
  106673. /**
  106674. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  106675. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  106676. */
  106677. useSpecularOverAlpha: boolean;
  106678. private _useReflectionOverAlpha;
  106679. /**
  106680. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  106681. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  106682. */
  106683. useReflectionOverAlpha: boolean;
  106684. private _disableLighting;
  106685. /**
  106686. * Does lights from the scene impacts this material.
  106687. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  106688. */
  106689. disableLighting: boolean;
  106690. private _useObjectSpaceNormalMap;
  106691. /**
  106692. * Allows using an object space normal map (instead of tangent space).
  106693. */
  106694. useObjectSpaceNormalMap: boolean;
  106695. private _useParallax;
  106696. /**
  106697. * Is parallax enabled or not.
  106698. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  106699. */
  106700. useParallax: boolean;
  106701. private _useParallaxOcclusion;
  106702. /**
  106703. * Is parallax occlusion enabled or not.
  106704. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  106705. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  106706. */
  106707. useParallaxOcclusion: boolean;
  106708. /**
  106709. * 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.
  106710. */
  106711. parallaxScaleBias: number;
  106712. private _roughness;
  106713. /**
  106714. * Helps to define how blurry the reflections should appears in the material.
  106715. */
  106716. roughness: number;
  106717. /**
  106718. * In case of refraction, define the value of the index of refraction.
  106719. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  106720. */
  106721. indexOfRefraction: number;
  106722. /**
  106723. * Invert the refraction texture alongside the y axis.
  106724. * It can be useful with procedural textures or probe for instance.
  106725. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  106726. */
  106727. invertRefractionY: boolean;
  106728. /**
  106729. * Defines the alpha limits in alpha test mode.
  106730. */
  106731. alphaCutOff: number;
  106732. private _useLightmapAsShadowmap;
  106733. /**
  106734. * In case of light mapping, define whether the map contains light or shadow informations.
  106735. */
  106736. useLightmapAsShadowmap: boolean;
  106737. private _diffuseFresnelParameters;
  106738. /**
  106739. * Define the diffuse fresnel parameters of the material.
  106740. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106741. */
  106742. diffuseFresnelParameters: FresnelParameters;
  106743. private _opacityFresnelParameters;
  106744. /**
  106745. * Define the opacity fresnel parameters of the material.
  106746. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106747. */
  106748. opacityFresnelParameters: FresnelParameters;
  106749. private _reflectionFresnelParameters;
  106750. /**
  106751. * Define the reflection fresnel parameters of the material.
  106752. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106753. */
  106754. reflectionFresnelParameters: FresnelParameters;
  106755. private _refractionFresnelParameters;
  106756. /**
  106757. * Define the refraction fresnel parameters of the material.
  106758. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106759. */
  106760. refractionFresnelParameters: FresnelParameters;
  106761. private _emissiveFresnelParameters;
  106762. /**
  106763. * Define the emissive fresnel parameters of the material.
  106764. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106765. */
  106766. emissiveFresnelParameters: FresnelParameters;
  106767. private _useReflectionFresnelFromSpecular;
  106768. /**
  106769. * If true automatically deducts the fresnels values from the material specularity.
  106770. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106771. */
  106772. useReflectionFresnelFromSpecular: boolean;
  106773. private _useGlossinessFromSpecularMapAlpha;
  106774. /**
  106775. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  106776. */
  106777. useGlossinessFromSpecularMapAlpha: boolean;
  106778. private _maxSimultaneousLights;
  106779. /**
  106780. * Defines the maximum number of lights that can be used in the material
  106781. */
  106782. maxSimultaneousLights: number;
  106783. private _invertNormalMapX;
  106784. /**
  106785. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  106786. */
  106787. invertNormalMapX: boolean;
  106788. private _invertNormalMapY;
  106789. /**
  106790. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  106791. */
  106792. invertNormalMapY: boolean;
  106793. private _twoSidedLighting;
  106794. /**
  106795. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  106796. */
  106797. twoSidedLighting: boolean;
  106798. /**
  106799. * Default configuration related to image processing available in the standard Material.
  106800. */
  106801. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  106802. /**
  106803. * Gets the image processing configuration used either in this material.
  106804. */
  106805. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  106806. /**
  106807. * Sets the Default image processing configuration used either in the this material.
  106808. *
  106809. * If sets to null, the scene one is in use.
  106810. */
  106811. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  106812. /**
  106813. * Keep track of the image processing observer to allow dispose and replace.
  106814. */
  106815. private _imageProcessingObserver;
  106816. /**
  106817. * Attaches a new image processing configuration to the Standard Material.
  106818. * @param configuration
  106819. */
  106820. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  106821. /**
  106822. * Gets wether the color curves effect is enabled.
  106823. */
  106824. get cameraColorCurvesEnabled(): boolean;
  106825. /**
  106826. * Sets wether the color curves effect is enabled.
  106827. */
  106828. set cameraColorCurvesEnabled(value: boolean);
  106829. /**
  106830. * Gets wether the color grading effect is enabled.
  106831. */
  106832. get cameraColorGradingEnabled(): boolean;
  106833. /**
  106834. * Gets wether the color grading effect is enabled.
  106835. */
  106836. set cameraColorGradingEnabled(value: boolean);
  106837. /**
  106838. * Gets wether tonemapping is enabled or not.
  106839. */
  106840. get cameraToneMappingEnabled(): boolean;
  106841. /**
  106842. * Sets wether tonemapping is enabled or not
  106843. */
  106844. set cameraToneMappingEnabled(value: boolean);
  106845. /**
  106846. * The camera exposure used on this material.
  106847. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  106848. * This corresponds to a photographic exposure.
  106849. */
  106850. get cameraExposure(): number;
  106851. /**
  106852. * The camera exposure used on this material.
  106853. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  106854. * This corresponds to a photographic exposure.
  106855. */
  106856. set cameraExposure(value: number);
  106857. /**
  106858. * Gets The camera contrast used on this material.
  106859. */
  106860. get cameraContrast(): number;
  106861. /**
  106862. * Sets The camera contrast used on this material.
  106863. */
  106864. set cameraContrast(value: number);
  106865. /**
  106866. * Gets the Color Grading 2D Lookup Texture.
  106867. */
  106868. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  106869. /**
  106870. * Sets the Color Grading 2D Lookup Texture.
  106871. */
  106872. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  106873. /**
  106874. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  106875. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  106876. * 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;
  106877. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  106878. */
  106879. get cameraColorCurves(): Nullable<ColorCurves>;
  106880. /**
  106881. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  106882. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  106883. * 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;
  106884. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  106885. */
  106886. set cameraColorCurves(value: Nullable<ColorCurves>);
  106887. protected _renderTargets: SmartArray<RenderTargetTexture>;
  106888. protected _worldViewProjectionMatrix: Matrix;
  106889. protected _globalAmbientColor: Color3;
  106890. protected _useLogarithmicDepth: boolean;
  106891. protected _rebuildInParallel: boolean;
  106892. /**
  106893. * Instantiates a new standard material.
  106894. * This is the default material used in Babylon. It is the best trade off between quality
  106895. * and performances.
  106896. * @see http://doc.babylonjs.com/babylon101/materials
  106897. * @param name Define the name of the material in the scene
  106898. * @param scene Define the scene the material belong to
  106899. */
  106900. constructor(name: string, scene: Scene);
  106901. /**
  106902. * Gets a boolean indicating that current material needs to register RTT
  106903. */
  106904. get hasRenderTargetTextures(): boolean;
  106905. /**
  106906. * Gets the current class name of the material e.g. "StandardMaterial"
  106907. * Mainly use in serialization.
  106908. * @returns the class name
  106909. */
  106910. getClassName(): string;
  106911. /**
  106912. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  106913. * You can try switching to logarithmic depth.
  106914. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  106915. */
  106916. get useLogarithmicDepth(): boolean;
  106917. set useLogarithmicDepth(value: boolean);
  106918. /**
  106919. * Specifies if the material will require alpha blending
  106920. * @returns a boolean specifying if alpha blending is needed
  106921. */
  106922. needAlphaBlending(): boolean;
  106923. /**
  106924. * Specifies if this material should be rendered in alpha test mode
  106925. * @returns a boolean specifying if an alpha test is needed.
  106926. */
  106927. needAlphaTesting(): boolean;
  106928. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  106929. /**
  106930. * Get the texture used for alpha test purpose.
  106931. * @returns the diffuse texture in case of the standard material.
  106932. */
  106933. getAlphaTestTexture(): Nullable<BaseTexture>;
  106934. /**
  106935. * Get if the submesh is ready to be used and all its information available.
  106936. * Child classes can use it to update shaders
  106937. * @param mesh defines the mesh to check
  106938. * @param subMesh defines which submesh to check
  106939. * @param useInstances specifies that instances should be used
  106940. * @returns a boolean indicating that the submesh is ready or not
  106941. */
  106942. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  106943. /**
  106944. * Builds the material UBO layouts.
  106945. * Used internally during the effect preparation.
  106946. */
  106947. buildUniformLayout(): void;
  106948. /**
  106949. * Unbinds the material from the mesh
  106950. */
  106951. unbind(): void;
  106952. /**
  106953. * Binds the submesh to this material by preparing the effect and shader to draw
  106954. * @param world defines the world transformation matrix
  106955. * @param mesh defines the mesh containing the submesh
  106956. * @param subMesh defines the submesh to bind the material to
  106957. */
  106958. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  106959. /**
  106960. * Get the list of animatables in the material.
  106961. * @returns the list of animatables object used in the material
  106962. */
  106963. getAnimatables(): IAnimatable[];
  106964. /**
  106965. * Gets the active textures from the material
  106966. * @returns an array of textures
  106967. */
  106968. getActiveTextures(): BaseTexture[];
  106969. /**
  106970. * Specifies if the material uses a texture
  106971. * @param texture defines the texture to check against the material
  106972. * @returns a boolean specifying if the material uses the texture
  106973. */
  106974. hasTexture(texture: BaseTexture): boolean;
  106975. /**
  106976. * Disposes the material
  106977. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  106978. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  106979. */
  106980. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  106981. /**
  106982. * Makes a duplicate of the material, and gives it a new name
  106983. * @param name defines the new name for the duplicated material
  106984. * @returns the cloned material
  106985. */
  106986. clone(name: string): StandardMaterial;
  106987. /**
  106988. * Serializes this material in a JSON representation
  106989. * @returns the serialized material object
  106990. */
  106991. serialize(): any;
  106992. /**
  106993. * Creates a standard material from parsed material data
  106994. * @param source defines the JSON representation of the material
  106995. * @param scene defines the hosting scene
  106996. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  106997. * @returns a new standard material
  106998. */
  106999. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  107000. /**
  107001. * Are diffuse textures enabled in the application.
  107002. */
  107003. static get DiffuseTextureEnabled(): boolean;
  107004. static set DiffuseTextureEnabled(value: boolean);
  107005. /**
  107006. * Are ambient textures enabled in the application.
  107007. */
  107008. static get AmbientTextureEnabled(): boolean;
  107009. static set AmbientTextureEnabled(value: boolean);
  107010. /**
  107011. * Are opacity textures enabled in the application.
  107012. */
  107013. static get OpacityTextureEnabled(): boolean;
  107014. static set OpacityTextureEnabled(value: boolean);
  107015. /**
  107016. * Are reflection textures enabled in the application.
  107017. */
  107018. static get ReflectionTextureEnabled(): boolean;
  107019. static set ReflectionTextureEnabled(value: boolean);
  107020. /**
  107021. * Are emissive textures enabled in the application.
  107022. */
  107023. static get EmissiveTextureEnabled(): boolean;
  107024. static set EmissiveTextureEnabled(value: boolean);
  107025. /**
  107026. * Are specular textures enabled in the application.
  107027. */
  107028. static get SpecularTextureEnabled(): boolean;
  107029. static set SpecularTextureEnabled(value: boolean);
  107030. /**
  107031. * Are bump textures enabled in the application.
  107032. */
  107033. static get BumpTextureEnabled(): boolean;
  107034. static set BumpTextureEnabled(value: boolean);
  107035. /**
  107036. * Are lightmap textures enabled in the application.
  107037. */
  107038. static get LightmapTextureEnabled(): boolean;
  107039. static set LightmapTextureEnabled(value: boolean);
  107040. /**
  107041. * Are refraction textures enabled in the application.
  107042. */
  107043. static get RefractionTextureEnabled(): boolean;
  107044. static set RefractionTextureEnabled(value: boolean);
  107045. /**
  107046. * Are color grading textures enabled in the application.
  107047. */
  107048. static get ColorGradingTextureEnabled(): boolean;
  107049. static set ColorGradingTextureEnabled(value: boolean);
  107050. /**
  107051. * Are fresnels enabled in the application.
  107052. */
  107053. static get FresnelEnabled(): boolean;
  107054. static set FresnelEnabled(value: boolean);
  107055. }
  107056. }
  107057. declare module BABYLON {
  107058. /**
  107059. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  107060. *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.
  107061. * The SPS is also a particle system. It provides some methods to manage the particles.
  107062. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  107063. *
  107064. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  107065. */
  107066. export class SolidParticleSystem implements IDisposable {
  107067. /**
  107068. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  107069. * Example : var p = SPS.particles[i];
  107070. */
  107071. particles: SolidParticle[];
  107072. /**
  107073. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  107074. */
  107075. nbParticles: number;
  107076. /**
  107077. * If the particles must ever face the camera (default false). Useful for planar particles.
  107078. */
  107079. billboard: boolean;
  107080. /**
  107081. * Recompute normals when adding a shape
  107082. */
  107083. recomputeNormals: boolean;
  107084. /**
  107085. * This a counter ofr your own usage. It's not set by any SPS functions.
  107086. */
  107087. counter: number;
  107088. /**
  107089. * The SPS name. This name is also given to the underlying mesh.
  107090. */
  107091. name: string;
  107092. /**
  107093. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  107094. */
  107095. mesh: Mesh;
  107096. /**
  107097. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  107098. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  107099. */
  107100. vars: any;
  107101. /**
  107102. * This array is populated when the SPS is set as 'pickable'.
  107103. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  107104. * Each element of this array is an object `{idx: int, faceId: int}`.
  107105. * `idx` is the picked particle index in the `SPS.particles` array
  107106. * `faceId` is the picked face index counted within this particle.
  107107. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  107108. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  107109. * Use the method SPS.pickedParticle(pickingInfo) instead.
  107110. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  107111. */
  107112. pickedParticles: {
  107113. idx: number;
  107114. faceId: number;
  107115. }[];
  107116. /**
  107117. * This array is populated when the SPS is set as 'pickable'
  107118. * Each key of this array is a submesh index.
  107119. * Each element of this array is a second array defined like this :
  107120. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  107121. * Each element of this second array is an object `{idx: int, faceId: int}`.
  107122. * `idx` is the picked particle index in the `SPS.particles` array
  107123. * `faceId` is the picked face index counted within this particle.
  107124. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  107125. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  107126. */
  107127. pickedBySubMesh: {
  107128. idx: number;
  107129. faceId: number;
  107130. }[][];
  107131. /**
  107132. * This array is populated when `enableDepthSort` is set to true.
  107133. * Each element of this array is an instance of the class DepthSortedParticle.
  107134. */
  107135. depthSortedParticles: DepthSortedParticle[];
  107136. /**
  107137. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  107138. * @hidden
  107139. */
  107140. _bSphereOnly: boolean;
  107141. /**
  107142. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  107143. * @hidden
  107144. */
  107145. _bSphereRadiusFactor: number;
  107146. private _scene;
  107147. private _positions;
  107148. private _indices;
  107149. private _normals;
  107150. private _colors;
  107151. private _uvs;
  107152. private _indices32;
  107153. private _positions32;
  107154. private _normals32;
  107155. private _fixedNormal32;
  107156. private _colors32;
  107157. private _uvs32;
  107158. private _index;
  107159. private _updatable;
  107160. private _pickable;
  107161. private _isVisibilityBoxLocked;
  107162. private _alwaysVisible;
  107163. private _depthSort;
  107164. private _expandable;
  107165. private _shapeCounter;
  107166. private _copy;
  107167. private _color;
  107168. private _computeParticleColor;
  107169. private _computeParticleTexture;
  107170. private _computeParticleRotation;
  107171. private _computeParticleVertex;
  107172. private _computeBoundingBox;
  107173. private _depthSortParticles;
  107174. private _camera;
  107175. private _mustUnrotateFixedNormals;
  107176. private _particlesIntersect;
  107177. private _needs32Bits;
  107178. private _isNotBuilt;
  107179. private _lastParticleId;
  107180. private _idxOfId;
  107181. private _multimaterialEnabled;
  107182. private _useModelMaterial;
  107183. private _indicesByMaterial;
  107184. private _materialIndexes;
  107185. private _depthSortFunction;
  107186. private _materialSortFunction;
  107187. private _materials;
  107188. private _multimaterial;
  107189. private _materialIndexesById;
  107190. private _defaultMaterial;
  107191. private _autoUpdateSubMeshes;
  107192. private _tmpVertex;
  107193. /**
  107194. * Creates a SPS (Solid Particle System) object.
  107195. * @param name (String) is the SPS name, this will be the underlying mesh name.
  107196. * @param scene (Scene) is the scene in which the SPS is added.
  107197. * @param options defines the options of the sps e.g.
  107198. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  107199. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  107200. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  107201. * * 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.
  107202. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  107203. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  107204. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  107205. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  107206. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  107207. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  107208. */
  107209. constructor(name: string, scene: Scene, options?: {
  107210. updatable?: boolean;
  107211. isPickable?: boolean;
  107212. enableDepthSort?: boolean;
  107213. particleIntersection?: boolean;
  107214. boundingSphereOnly?: boolean;
  107215. bSphereRadiusFactor?: number;
  107216. expandable?: boolean;
  107217. useModelMaterial?: boolean;
  107218. enableMultiMaterial?: boolean;
  107219. });
  107220. /**
  107221. * Builds the SPS underlying mesh. Returns a standard Mesh.
  107222. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  107223. * @returns the created mesh
  107224. */
  107225. buildMesh(): Mesh;
  107226. /**
  107227. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  107228. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  107229. * Thus the particles generated from `digest()` have their property `position` set yet.
  107230. * @param mesh ( Mesh ) is the mesh to be digested
  107231. * @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
  107232. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  107233. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  107234. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  107235. * @returns the current SPS
  107236. */
  107237. digest(mesh: Mesh, options?: {
  107238. facetNb?: number;
  107239. number?: number;
  107240. delta?: number;
  107241. storage?: [];
  107242. }): SolidParticleSystem;
  107243. /**
  107244. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  107245. * @hidden
  107246. */
  107247. private _unrotateFixedNormals;
  107248. /**
  107249. * Resets the temporary working copy particle
  107250. * @hidden
  107251. */
  107252. private _resetCopy;
  107253. /**
  107254. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  107255. * @param p the current index in the positions array to be updated
  107256. * @param ind the current index in the indices array
  107257. * @param shape a Vector3 array, the shape geometry
  107258. * @param positions the positions array to be updated
  107259. * @param meshInd the shape indices array
  107260. * @param indices the indices array to be updated
  107261. * @param meshUV the shape uv array
  107262. * @param uvs the uv array to be updated
  107263. * @param meshCol the shape color array
  107264. * @param colors the color array to be updated
  107265. * @param meshNor the shape normals array
  107266. * @param normals the normals array to be updated
  107267. * @param idx the particle index
  107268. * @param idxInShape the particle index in its shape
  107269. * @param options the addShape() method passed options
  107270. * @model the particle model
  107271. * @hidden
  107272. */
  107273. private _meshBuilder;
  107274. /**
  107275. * Returns a shape Vector3 array from positions float array
  107276. * @param positions float array
  107277. * @returns a vector3 array
  107278. * @hidden
  107279. */
  107280. private _posToShape;
  107281. /**
  107282. * Returns a shapeUV array from a float uvs (array deep copy)
  107283. * @param uvs as a float array
  107284. * @returns a shapeUV array
  107285. * @hidden
  107286. */
  107287. private _uvsToShapeUV;
  107288. /**
  107289. * Adds a new particle object in the particles array
  107290. * @param idx particle index in particles array
  107291. * @param id particle id
  107292. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  107293. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  107294. * @param model particle ModelShape object
  107295. * @param shapeId model shape identifier
  107296. * @param idxInShape index of the particle in the current model
  107297. * @param bInfo model bounding info object
  107298. * @param storage target storage array, if any
  107299. * @hidden
  107300. */
  107301. private _addParticle;
  107302. /**
  107303. * Adds some particles to the SPS from the model shape. Returns the shape id.
  107304. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  107305. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  107306. * @param nb (positive integer) the number of particles to be created from this model
  107307. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  107308. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  107309. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  107310. * @returns the number of shapes in the system
  107311. */
  107312. addShape(mesh: Mesh, nb: number, options?: {
  107313. positionFunction?: any;
  107314. vertexFunction?: any;
  107315. storage?: [];
  107316. }): number;
  107317. /**
  107318. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  107319. * @hidden
  107320. */
  107321. private _rebuildParticle;
  107322. /**
  107323. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  107324. * @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.
  107325. * @returns the SPS.
  107326. */
  107327. rebuildMesh(reset?: boolean): SolidParticleSystem;
  107328. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  107329. * Returns an array with the removed particles.
  107330. * 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.
  107331. * The SPS can't be empty so at least one particle needs to remain in place.
  107332. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  107333. * @param start index of the first particle to remove
  107334. * @param end index of the last particle to remove (included)
  107335. * @returns an array populated with the removed particles
  107336. */
  107337. removeParticles(start: number, end: number): SolidParticle[];
  107338. /**
  107339. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  107340. * @param solidParticleArray an array populated with Solid Particles objects
  107341. * @returns the SPS
  107342. */
  107343. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  107344. /**
  107345. * Creates a new particle and modifies the SPS mesh geometry :
  107346. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  107347. * - calls _addParticle() to populate the particle array
  107348. * factorized code from addShape() and insertParticlesFromArray()
  107349. * @param idx particle index in the particles array
  107350. * @param i particle index in its shape
  107351. * @param modelShape particle ModelShape object
  107352. * @param shape shape vertex array
  107353. * @param meshInd shape indices array
  107354. * @param meshUV shape uv array
  107355. * @param meshCol shape color array
  107356. * @param meshNor shape normals array
  107357. * @param bbInfo shape bounding info
  107358. * @param storage target particle storage
  107359. * @options addShape() passed options
  107360. * @hidden
  107361. */
  107362. private _insertNewParticle;
  107363. /**
  107364. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  107365. * This method calls `updateParticle()` for each particle of the SPS.
  107366. * For an animated SPS, it is usually called within the render loop.
  107367. * 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.
  107368. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  107369. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  107370. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  107371. * @returns the SPS.
  107372. */
  107373. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  107374. /**
  107375. * Disposes the SPS.
  107376. */
  107377. dispose(): void;
  107378. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  107379. * idx is the particle index in the SPS
  107380. * faceId is the picked face index counted within this particle.
  107381. * Returns null if the pickInfo can't identify a picked particle.
  107382. * @param pickingInfo (PickingInfo object)
  107383. * @returns {idx: number, faceId: number} or null
  107384. */
  107385. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  107386. idx: number;
  107387. faceId: number;
  107388. }>;
  107389. /**
  107390. * Returns a SolidParticle object from its identifier : particle.id
  107391. * @param id (integer) the particle Id
  107392. * @returns the searched particle or null if not found in the SPS.
  107393. */
  107394. getParticleById(id: number): Nullable<SolidParticle>;
  107395. /**
  107396. * Returns a new array populated with the particles having the passed shapeId.
  107397. * @param shapeId (integer) the shape identifier
  107398. * @returns a new solid particle array
  107399. */
  107400. getParticlesByShapeId(shapeId: number): SolidParticle[];
  107401. /**
  107402. * Populates the passed array "ref" with the particles having the passed shapeId.
  107403. * @param shapeId the shape identifier
  107404. * @returns the SPS
  107405. * @param ref
  107406. */
  107407. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  107408. /**
  107409. * Computes the required SubMeshes according the materials assigned to the particles.
  107410. * @returns the solid particle system.
  107411. * Does nothing if called before the SPS mesh is built.
  107412. */
  107413. computeSubMeshes(): SolidParticleSystem;
  107414. /**
  107415. * Sorts the solid particles by material when MultiMaterial is enabled.
  107416. * Updates the indices32 array.
  107417. * Updates the indicesByMaterial array.
  107418. * Updates the mesh indices array.
  107419. * @returns the SPS
  107420. * @hidden
  107421. */
  107422. private _sortParticlesByMaterial;
  107423. /**
  107424. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  107425. * @hidden
  107426. */
  107427. private _setMaterialIndexesById;
  107428. /**
  107429. * Returns an array with unique values of Materials from the passed array
  107430. * @param array the material array to be checked and filtered
  107431. * @hidden
  107432. */
  107433. private _filterUniqueMaterialId;
  107434. /**
  107435. * Sets a new Standard Material as _defaultMaterial if not already set.
  107436. * @hidden
  107437. */
  107438. private _setDefaultMaterial;
  107439. /**
  107440. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  107441. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  107442. * @returns the SPS.
  107443. */
  107444. refreshVisibleSize(): SolidParticleSystem;
  107445. /**
  107446. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  107447. * @param size the size (float) of the visibility box
  107448. * note : this doesn't lock the SPS mesh bounding box.
  107449. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  107450. */
  107451. setVisibilityBox(size: number): void;
  107452. /**
  107453. * Gets whether the SPS as always visible or not
  107454. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  107455. */
  107456. get isAlwaysVisible(): boolean;
  107457. /**
  107458. * Sets the SPS as always visible or not
  107459. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  107460. */
  107461. set isAlwaysVisible(val: boolean);
  107462. /**
  107463. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  107464. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  107465. */
  107466. set isVisibilityBoxLocked(val: boolean);
  107467. /**
  107468. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  107469. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  107470. */
  107471. get isVisibilityBoxLocked(): boolean;
  107472. /**
  107473. * Tells to `setParticles()` to compute the particle rotations or not.
  107474. * Default value : true. The SPS is faster when it's set to false.
  107475. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  107476. */
  107477. set computeParticleRotation(val: boolean);
  107478. /**
  107479. * Tells to `setParticles()` to compute the particle colors or not.
  107480. * Default value : true. The SPS is faster when it's set to false.
  107481. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  107482. */
  107483. set computeParticleColor(val: boolean);
  107484. set computeParticleTexture(val: boolean);
  107485. /**
  107486. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  107487. * Default value : false. The SPS is faster when it's set to false.
  107488. * Note : the particle custom vertex positions aren't stored values.
  107489. */
  107490. set computeParticleVertex(val: boolean);
  107491. /**
  107492. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  107493. */
  107494. set computeBoundingBox(val: boolean);
  107495. /**
  107496. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  107497. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  107498. * Default : `true`
  107499. */
  107500. set depthSortParticles(val: boolean);
  107501. /**
  107502. * Gets if `setParticles()` computes the particle rotations or not.
  107503. * Default value : true. The SPS is faster when it's set to false.
  107504. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  107505. */
  107506. get computeParticleRotation(): boolean;
  107507. /**
  107508. * Gets if `setParticles()` computes the particle colors or not.
  107509. * Default value : true. The SPS is faster when it's set to false.
  107510. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  107511. */
  107512. get computeParticleColor(): boolean;
  107513. /**
  107514. * Gets if `setParticles()` computes the particle textures or not.
  107515. * Default value : true. The SPS is faster when it's set to false.
  107516. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  107517. */
  107518. get computeParticleTexture(): boolean;
  107519. /**
  107520. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  107521. * Default value : false. The SPS is faster when it's set to false.
  107522. * Note : the particle custom vertex positions aren't stored values.
  107523. */
  107524. get computeParticleVertex(): boolean;
  107525. /**
  107526. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  107527. */
  107528. get computeBoundingBox(): boolean;
  107529. /**
  107530. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  107531. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  107532. * Default : `true`
  107533. */
  107534. get depthSortParticles(): boolean;
  107535. /**
  107536. * Gets if the SPS is created as expandable at construction time.
  107537. * Default : `false`
  107538. */
  107539. get expandable(): boolean;
  107540. /**
  107541. * Gets if the SPS supports the Multi Materials
  107542. */
  107543. get multimaterialEnabled(): boolean;
  107544. /**
  107545. * Gets if the SPS uses the model materials for its own multimaterial.
  107546. */
  107547. get useModelMaterial(): boolean;
  107548. /**
  107549. * The SPS used material array.
  107550. */
  107551. get materials(): Material[];
  107552. /**
  107553. * Sets the SPS MultiMaterial from the passed materials.
  107554. * Note : the passed array is internally copied and not used then by reference.
  107555. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  107556. */
  107557. setMultiMaterial(materials: Material[]): void;
  107558. /**
  107559. * The SPS computed multimaterial object
  107560. */
  107561. get multimaterial(): MultiMaterial;
  107562. set multimaterial(mm: MultiMaterial);
  107563. /**
  107564. * If the subMeshes must be updated on the next call to setParticles()
  107565. */
  107566. get autoUpdateSubMeshes(): boolean;
  107567. set autoUpdateSubMeshes(val: boolean);
  107568. /**
  107569. * This function does nothing. It may be overwritten to set all the particle first values.
  107570. * The SPS doesn't call this function, you may have to call it by your own.
  107571. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  107572. */
  107573. initParticles(): void;
  107574. /**
  107575. * This function does nothing. It may be overwritten to recycle a particle.
  107576. * The SPS doesn't call this function, you may have to call it by your own.
  107577. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  107578. * @param particle The particle to recycle
  107579. * @returns the recycled particle
  107580. */
  107581. recycleParticle(particle: SolidParticle): SolidParticle;
  107582. /**
  107583. * Updates a particle : this function should be overwritten by the user.
  107584. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  107585. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  107586. * @example : just set a particle position or velocity and recycle conditions
  107587. * @param particle The particle to update
  107588. * @returns the updated particle
  107589. */
  107590. updateParticle(particle: SolidParticle): SolidParticle;
  107591. /**
  107592. * Updates a vertex of a particle : it can be overwritten by the user.
  107593. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  107594. * @param particle the current particle
  107595. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  107596. * @param pt the index of the current vertex in the particle shape
  107597. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  107598. * @example : just set a vertex particle position or color
  107599. * @returns the sps
  107600. */
  107601. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  107602. /**
  107603. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  107604. * This does nothing and may be overwritten by the user.
  107605. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  107606. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  107607. * @param update the boolean update value actually passed to setParticles()
  107608. */
  107609. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  107610. /**
  107611. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  107612. * This will be passed three parameters.
  107613. * This does nothing and may be overwritten by the user.
  107614. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  107615. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  107616. * @param update the boolean update value actually passed to setParticles()
  107617. */
  107618. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  107619. }
  107620. }
  107621. declare module BABYLON {
  107622. /**
  107623. * Represents one particle of a solid particle system.
  107624. */
  107625. export class SolidParticle {
  107626. /**
  107627. * particle global index
  107628. */
  107629. idx: number;
  107630. /**
  107631. * particle identifier
  107632. */
  107633. id: number;
  107634. /**
  107635. * The color of the particle
  107636. */
  107637. color: Nullable<Color4>;
  107638. /**
  107639. * The world space position of the particle.
  107640. */
  107641. position: Vector3;
  107642. /**
  107643. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  107644. */
  107645. rotation: Vector3;
  107646. /**
  107647. * The world space rotation quaternion of the particle.
  107648. */
  107649. rotationQuaternion: Nullable<Quaternion>;
  107650. /**
  107651. * The scaling of the particle.
  107652. */
  107653. scaling: Vector3;
  107654. /**
  107655. * The uvs of the particle.
  107656. */
  107657. uvs: Vector4;
  107658. /**
  107659. * The current speed of the particle.
  107660. */
  107661. velocity: Vector3;
  107662. /**
  107663. * The pivot point in the particle local space.
  107664. */
  107665. pivot: Vector3;
  107666. /**
  107667. * Must the particle be translated from its pivot point in its local space ?
  107668. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  107669. * Default : false
  107670. */
  107671. translateFromPivot: boolean;
  107672. /**
  107673. * Is the particle active or not ?
  107674. */
  107675. alive: boolean;
  107676. /**
  107677. * Is the particle visible or not ?
  107678. */
  107679. isVisible: boolean;
  107680. /**
  107681. * Index of this particle in the global "positions" array (Internal use)
  107682. * @hidden
  107683. */
  107684. _pos: number;
  107685. /**
  107686. * @hidden Index of this particle in the global "indices" array (Internal use)
  107687. */
  107688. _ind: number;
  107689. /**
  107690. * @hidden ModelShape of this particle (Internal use)
  107691. */
  107692. _model: ModelShape;
  107693. /**
  107694. * ModelShape id of this particle
  107695. */
  107696. shapeId: number;
  107697. /**
  107698. * Index of the particle in its shape id
  107699. */
  107700. idxInShape: number;
  107701. /**
  107702. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  107703. */
  107704. _modelBoundingInfo: BoundingInfo;
  107705. /**
  107706. * @hidden Particle BoundingInfo object (Internal use)
  107707. */
  107708. _boundingInfo: BoundingInfo;
  107709. /**
  107710. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  107711. */
  107712. _sps: SolidParticleSystem;
  107713. /**
  107714. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  107715. */
  107716. _stillInvisible: boolean;
  107717. /**
  107718. * @hidden Last computed particle rotation matrix
  107719. */
  107720. _rotationMatrix: number[];
  107721. /**
  107722. * Parent particle Id, if any.
  107723. * Default null.
  107724. */
  107725. parentId: Nullable<number>;
  107726. /**
  107727. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  107728. */
  107729. materialIndex: Nullable<number>;
  107730. /**
  107731. * Custom object or properties.
  107732. */
  107733. props: Nullable<any>;
  107734. /**
  107735. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  107736. * The possible values are :
  107737. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  107738. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  107739. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  107740. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  107741. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  107742. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  107743. * */
  107744. cullingStrategy: number;
  107745. /**
  107746. * @hidden Internal global position in the SPS.
  107747. */
  107748. _globalPosition: Vector3;
  107749. /**
  107750. * Creates a Solid Particle object.
  107751. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  107752. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  107753. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  107754. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  107755. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  107756. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  107757. * @param shapeId (integer) is the model shape identifier in the SPS.
  107758. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  107759. * @param sps defines the sps it is associated to
  107760. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  107761. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  107762. */
  107763. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  107764. /**
  107765. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  107766. * @param target the particle target
  107767. * @returns the current particle
  107768. */
  107769. copyToRef(target: SolidParticle): SolidParticle;
  107770. /**
  107771. * Legacy support, changed scale to scaling
  107772. */
  107773. get scale(): Vector3;
  107774. /**
  107775. * Legacy support, changed scale to scaling
  107776. */
  107777. set scale(scale: Vector3);
  107778. /**
  107779. * Legacy support, changed quaternion to rotationQuaternion
  107780. */
  107781. get quaternion(): Nullable<Quaternion>;
  107782. /**
  107783. * Legacy support, changed quaternion to rotationQuaternion
  107784. */
  107785. set quaternion(q: Nullable<Quaternion>);
  107786. /**
  107787. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  107788. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  107789. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  107790. * @returns true if it intersects
  107791. */
  107792. intersectsMesh(target: Mesh | SolidParticle): boolean;
  107793. /**
  107794. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  107795. * A particle is in the frustum if its bounding box intersects the frustum
  107796. * @param frustumPlanes defines the frustum to test
  107797. * @returns true if the particle is in the frustum planes
  107798. */
  107799. isInFrustum(frustumPlanes: Plane[]): boolean;
  107800. /**
  107801. * get the rotation matrix of the particle
  107802. * @hidden
  107803. */
  107804. getRotationMatrix(m: Matrix): void;
  107805. }
  107806. /**
  107807. * Represents the shape of the model used by one particle of a solid particle system.
  107808. * SPS internal tool, don't use it manually.
  107809. */
  107810. export class ModelShape {
  107811. /**
  107812. * The shape id
  107813. * @hidden
  107814. */
  107815. shapeID: number;
  107816. /**
  107817. * flat array of model positions (internal use)
  107818. * @hidden
  107819. */
  107820. _shape: Vector3[];
  107821. /**
  107822. * flat array of model UVs (internal use)
  107823. * @hidden
  107824. */
  107825. _shapeUV: number[];
  107826. /**
  107827. * color array of the model
  107828. * @hidden
  107829. */
  107830. _shapeColors: number[];
  107831. /**
  107832. * indices array of the model
  107833. * @hidden
  107834. */
  107835. _indices: number[];
  107836. /**
  107837. * normals array of the model
  107838. * @hidden
  107839. */
  107840. _normals: number[];
  107841. /**
  107842. * length of the shape in the model indices array (internal use)
  107843. * @hidden
  107844. */
  107845. _indicesLength: number;
  107846. /**
  107847. * Custom position function (internal use)
  107848. * @hidden
  107849. */
  107850. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  107851. /**
  107852. * Custom vertex function (internal use)
  107853. * @hidden
  107854. */
  107855. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  107856. /**
  107857. * Model material (internal use)
  107858. * @hidden
  107859. */
  107860. _material: Nullable<Material>;
  107861. /**
  107862. * 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.
  107863. * SPS internal tool, don't use it manually.
  107864. * @hidden
  107865. */
  107866. 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>);
  107867. }
  107868. /**
  107869. * Represents a Depth Sorted Particle in the solid particle system.
  107870. * @hidden
  107871. */
  107872. export class DepthSortedParticle {
  107873. /**
  107874. * Particle index
  107875. */
  107876. idx: number;
  107877. /**
  107878. * Index of the particle in the "indices" array
  107879. */
  107880. ind: number;
  107881. /**
  107882. * Length of the particle shape in the "indices" array
  107883. */
  107884. indicesLength: number;
  107885. /**
  107886. * Squared distance from the particle to the camera
  107887. */
  107888. sqDistance: number;
  107889. /**
  107890. * Material index when used with MultiMaterials
  107891. */
  107892. materialIndex: number;
  107893. /**
  107894. * Creates a new sorted particle
  107895. * @param materialIndex
  107896. */
  107897. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  107898. }
  107899. /**
  107900. * Represents a solid particle vertex
  107901. */
  107902. export class SolidParticleVertex {
  107903. /**
  107904. * Vertex position
  107905. */
  107906. position: Vector3;
  107907. /**
  107908. * Vertex color
  107909. */
  107910. color: Color4;
  107911. /**
  107912. * Vertex UV
  107913. */
  107914. uv: Vector2;
  107915. /**
  107916. * Creates a new solid particle vertex
  107917. */
  107918. constructor();
  107919. /** Vertex x coordinate */
  107920. get x(): number;
  107921. set x(val: number);
  107922. /** Vertex y coordinate */
  107923. get y(): number;
  107924. set y(val: number);
  107925. /** Vertex z coordinate */
  107926. get z(): number;
  107927. set z(val: number);
  107928. }
  107929. }
  107930. declare module BABYLON {
  107931. /**
  107932. * @hidden
  107933. */
  107934. export class _MeshCollisionData {
  107935. _checkCollisions: boolean;
  107936. _collisionMask: number;
  107937. _collisionGroup: number;
  107938. _surroundingMeshes: Nullable<AbstractMesh[]>;
  107939. _collider: Nullable<Collider>;
  107940. _oldPositionForCollisions: Vector3;
  107941. _diffPositionForCollisions: Vector3;
  107942. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  107943. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  107944. }
  107945. }
  107946. declare module BABYLON {
  107947. /** @hidden */
  107948. class _FacetDataStorage {
  107949. facetPositions: Vector3[];
  107950. facetNormals: Vector3[];
  107951. facetPartitioning: number[][];
  107952. facetNb: number;
  107953. partitioningSubdivisions: number;
  107954. partitioningBBoxRatio: number;
  107955. facetDataEnabled: boolean;
  107956. facetParameters: any;
  107957. bbSize: Vector3;
  107958. subDiv: {
  107959. max: number;
  107960. X: number;
  107961. Y: number;
  107962. Z: number;
  107963. };
  107964. facetDepthSort: boolean;
  107965. facetDepthSortEnabled: boolean;
  107966. depthSortedIndices: IndicesArray;
  107967. depthSortedFacets: {
  107968. ind: number;
  107969. sqDistance: number;
  107970. }[];
  107971. facetDepthSortFunction: (f1: {
  107972. ind: number;
  107973. sqDistance: number;
  107974. }, f2: {
  107975. ind: number;
  107976. sqDistance: number;
  107977. }) => number;
  107978. facetDepthSortFrom: Vector3;
  107979. facetDepthSortOrigin: Vector3;
  107980. invertedMatrix: Matrix;
  107981. }
  107982. /**
  107983. * @hidden
  107984. **/
  107985. class _InternalAbstractMeshDataInfo {
  107986. _hasVertexAlpha: boolean;
  107987. _useVertexColors: boolean;
  107988. _numBoneInfluencers: number;
  107989. _applyFog: boolean;
  107990. _receiveShadows: boolean;
  107991. _facetData: _FacetDataStorage;
  107992. _visibility: number;
  107993. _skeleton: Nullable<Skeleton>;
  107994. _layerMask: number;
  107995. _computeBonesUsingShaders: boolean;
  107996. _isActive: boolean;
  107997. _onlyForInstances: boolean;
  107998. _isActiveIntermediate: boolean;
  107999. _onlyForInstancesIntermediate: boolean;
  108000. _actAsRegularMesh: boolean;
  108001. }
  108002. /**
  108003. * Class used to store all common mesh properties
  108004. */
  108005. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  108006. /** No occlusion */
  108007. static OCCLUSION_TYPE_NONE: number;
  108008. /** Occlusion set to optimisitic */
  108009. static OCCLUSION_TYPE_OPTIMISTIC: number;
  108010. /** Occlusion set to strict */
  108011. static OCCLUSION_TYPE_STRICT: number;
  108012. /** Use an accurante occlusion algorithm */
  108013. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  108014. /** Use a conservative occlusion algorithm */
  108015. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  108016. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  108017. * Test order :
  108018. * Is the bounding sphere outside the frustum ?
  108019. * If not, are the bounding box vertices outside the frustum ?
  108020. * It not, then the cullable object is in the frustum.
  108021. */
  108022. static readonly CULLINGSTRATEGY_STANDARD: number;
  108023. /** Culling strategy : Bounding Sphere Only.
  108024. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  108025. * It's also less accurate than the standard because some not visible objects can still be selected.
  108026. * Test : is the bounding sphere outside the frustum ?
  108027. * If not, then the cullable object is in the frustum.
  108028. */
  108029. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  108030. /** Culling strategy : Optimistic Inclusion.
  108031. * This in an inclusion test first, then the standard exclusion test.
  108032. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  108033. * 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.
  108034. * Anyway, it's as accurate as the standard strategy.
  108035. * Test :
  108036. * Is the cullable object bounding sphere center in the frustum ?
  108037. * If not, apply the default culling strategy.
  108038. */
  108039. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  108040. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  108041. * This in an inclusion test first, then the bounding sphere only exclusion test.
  108042. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  108043. * 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.
  108044. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  108045. * Test :
  108046. * Is the cullable object bounding sphere center in the frustum ?
  108047. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  108048. */
  108049. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  108050. /**
  108051. * No billboard
  108052. */
  108053. static get BILLBOARDMODE_NONE(): number;
  108054. /** Billboard on X axis */
  108055. static get BILLBOARDMODE_X(): number;
  108056. /** Billboard on Y axis */
  108057. static get BILLBOARDMODE_Y(): number;
  108058. /** Billboard on Z axis */
  108059. static get BILLBOARDMODE_Z(): number;
  108060. /** Billboard on all axes */
  108061. static get BILLBOARDMODE_ALL(): number;
  108062. /** Billboard on using position instead of orientation */
  108063. static get BILLBOARDMODE_USE_POSITION(): number;
  108064. /** @hidden */
  108065. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  108066. /**
  108067. * The culling strategy to use to check whether the mesh must be rendered or not.
  108068. * This value can be changed at any time and will be used on the next render mesh selection.
  108069. * The possible values are :
  108070. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  108071. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  108072. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  108073. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  108074. * Please read each static variable documentation to get details about the culling process.
  108075. * */
  108076. cullingStrategy: number;
  108077. /**
  108078. * Gets the number of facets in the mesh
  108079. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  108080. */
  108081. get facetNb(): number;
  108082. /**
  108083. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  108084. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  108085. */
  108086. get partitioningSubdivisions(): number;
  108087. set partitioningSubdivisions(nb: number);
  108088. /**
  108089. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  108090. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  108091. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  108092. */
  108093. get partitioningBBoxRatio(): number;
  108094. set partitioningBBoxRatio(ratio: number);
  108095. /**
  108096. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  108097. * Works only for updatable meshes.
  108098. * Doesn't work with multi-materials
  108099. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  108100. */
  108101. get mustDepthSortFacets(): boolean;
  108102. set mustDepthSortFacets(sort: boolean);
  108103. /**
  108104. * The location (Vector3) where the facet depth sort must be computed from.
  108105. * By default, the active camera position.
  108106. * Used only when facet depth sort is enabled
  108107. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  108108. */
  108109. get facetDepthSortFrom(): Vector3;
  108110. set facetDepthSortFrom(location: Vector3);
  108111. /**
  108112. * gets a boolean indicating if facetData is enabled
  108113. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  108114. */
  108115. get isFacetDataEnabled(): boolean;
  108116. /** @hidden */
  108117. _updateNonUniformScalingState(value: boolean): boolean;
  108118. /**
  108119. * An event triggered when this mesh collides with another one
  108120. */
  108121. onCollideObservable: Observable<AbstractMesh>;
  108122. /** Set a function to call when this mesh collides with another one */
  108123. set onCollide(callback: () => void);
  108124. /**
  108125. * An event triggered when the collision's position changes
  108126. */
  108127. onCollisionPositionChangeObservable: Observable<Vector3>;
  108128. /** Set a function to call when the collision's position changes */
  108129. set onCollisionPositionChange(callback: () => void);
  108130. /**
  108131. * An event triggered when material is changed
  108132. */
  108133. onMaterialChangedObservable: Observable<AbstractMesh>;
  108134. /**
  108135. * Gets or sets the orientation for POV movement & rotation
  108136. */
  108137. definedFacingForward: boolean;
  108138. /** @hidden */
  108139. _occlusionQuery: Nullable<WebGLQuery>;
  108140. /** @hidden */
  108141. _renderingGroup: Nullable<RenderingGroup>;
  108142. /**
  108143. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  108144. */
  108145. get visibility(): number;
  108146. /**
  108147. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  108148. */
  108149. set visibility(value: number);
  108150. /** Gets or sets the alpha index used to sort transparent meshes
  108151. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  108152. */
  108153. alphaIndex: number;
  108154. /**
  108155. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  108156. */
  108157. isVisible: boolean;
  108158. /**
  108159. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  108160. */
  108161. isPickable: boolean;
  108162. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  108163. showSubMeshesBoundingBox: boolean;
  108164. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  108165. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  108166. */
  108167. isBlocker: boolean;
  108168. /**
  108169. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  108170. */
  108171. enablePointerMoveEvents: boolean;
  108172. /**
  108173. * Specifies the rendering group id for this mesh (0 by default)
  108174. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  108175. */
  108176. renderingGroupId: number;
  108177. private _material;
  108178. /** Gets or sets current material */
  108179. get material(): Nullable<Material>;
  108180. set material(value: Nullable<Material>);
  108181. /**
  108182. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  108183. * @see http://doc.babylonjs.com/babylon101/shadows
  108184. */
  108185. get receiveShadows(): boolean;
  108186. set receiveShadows(value: boolean);
  108187. /** Defines color to use when rendering outline */
  108188. outlineColor: Color3;
  108189. /** Define width to use when rendering outline */
  108190. outlineWidth: number;
  108191. /** Defines color to use when rendering overlay */
  108192. overlayColor: Color3;
  108193. /** Defines alpha to use when rendering overlay */
  108194. overlayAlpha: number;
  108195. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  108196. get hasVertexAlpha(): boolean;
  108197. set hasVertexAlpha(value: boolean);
  108198. /** 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) */
  108199. get useVertexColors(): boolean;
  108200. set useVertexColors(value: boolean);
  108201. /**
  108202. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  108203. */
  108204. get computeBonesUsingShaders(): boolean;
  108205. set computeBonesUsingShaders(value: boolean);
  108206. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  108207. get numBoneInfluencers(): number;
  108208. set numBoneInfluencers(value: number);
  108209. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  108210. get applyFog(): boolean;
  108211. set applyFog(value: boolean);
  108212. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  108213. useOctreeForRenderingSelection: boolean;
  108214. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  108215. useOctreeForPicking: boolean;
  108216. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  108217. useOctreeForCollisions: boolean;
  108218. /**
  108219. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  108220. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  108221. */
  108222. get layerMask(): number;
  108223. set layerMask(value: number);
  108224. /**
  108225. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  108226. */
  108227. alwaysSelectAsActiveMesh: boolean;
  108228. /**
  108229. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  108230. */
  108231. doNotSyncBoundingInfo: boolean;
  108232. /**
  108233. * Gets or sets the current action manager
  108234. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  108235. */
  108236. actionManager: Nullable<AbstractActionManager>;
  108237. private _meshCollisionData;
  108238. /**
  108239. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  108240. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  108241. */
  108242. ellipsoid: Vector3;
  108243. /**
  108244. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  108245. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  108246. */
  108247. ellipsoidOffset: Vector3;
  108248. /**
  108249. * Gets or sets a collision mask used to mask collisions (default is -1).
  108250. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  108251. */
  108252. get collisionMask(): number;
  108253. set collisionMask(mask: number);
  108254. /**
  108255. * Gets or sets the current collision group mask (-1 by default).
  108256. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  108257. */
  108258. get collisionGroup(): number;
  108259. set collisionGroup(mask: number);
  108260. /**
  108261. * Gets or sets current surrounding meshes (null by default).
  108262. *
  108263. * By default collision detection is tested against every mesh in the scene.
  108264. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  108265. * meshes will be tested for the collision.
  108266. *
  108267. * Note: if set to an empty array no collision will happen when this mesh is moved.
  108268. */
  108269. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  108270. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  108271. /**
  108272. * Defines edge width used when edgesRenderer is enabled
  108273. * @see https://www.babylonjs-playground.com/#10OJSG#13
  108274. */
  108275. edgesWidth: number;
  108276. /**
  108277. * Defines edge color used when edgesRenderer is enabled
  108278. * @see https://www.babylonjs-playground.com/#10OJSG#13
  108279. */
  108280. edgesColor: Color4;
  108281. /** @hidden */
  108282. _edgesRenderer: Nullable<IEdgesRenderer>;
  108283. /** @hidden */
  108284. _masterMesh: Nullable<AbstractMesh>;
  108285. /** @hidden */
  108286. _boundingInfo: Nullable<BoundingInfo>;
  108287. /** @hidden */
  108288. _renderId: number;
  108289. /**
  108290. * Gets or sets the list of subMeshes
  108291. * @see http://doc.babylonjs.com/how_to/multi_materials
  108292. */
  108293. subMeshes: SubMesh[];
  108294. /** @hidden */
  108295. _intersectionsInProgress: AbstractMesh[];
  108296. /** @hidden */
  108297. _unIndexed: boolean;
  108298. /** @hidden */
  108299. _lightSources: Light[];
  108300. /** Gets the list of lights affecting that mesh */
  108301. get lightSources(): Light[];
  108302. /** @hidden */
  108303. get _positions(): Nullable<Vector3[]>;
  108304. /** @hidden */
  108305. _waitingData: {
  108306. lods: Nullable<any>;
  108307. actions: Nullable<any>;
  108308. freezeWorldMatrix: Nullable<boolean>;
  108309. };
  108310. /** @hidden */
  108311. _bonesTransformMatrices: Nullable<Float32Array>;
  108312. /** @hidden */
  108313. _transformMatrixTexture: Nullable<RawTexture>;
  108314. /**
  108315. * Gets or sets a skeleton to apply skining transformations
  108316. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  108317. */
  108318. set skeleton(value: Nullable<Skeleton>);
  108319. get skeleton(): Nullable<Skeleton>;
  108320. /**
  108321. * An event triggered when the mesh is rebuilt.
  108322. */
  108323. onRebuildObservable: Observable<AbstractMesh>;
  108324. /**
  108325. * Creates a new AbstractMesh
  108326. * @param name defines the name of the mesh
  108327. * @param scene defines the hosting scene
  108328. */
  108329. constructor(name: string, scene?: Nullable<Scene>);
  108330. /**
  108331. * Returns the string "AbstractMesh"
  108332. * @returns "AbstractMesh"
  108333. */
  108334. getClassName(): string;
  108335. /**
  108336. * Gets a string representation of the current mesh
  108337. * @param fullDetails defines a boolean indicating if full details must be included
  108338. * @returns a string representation of the current mesh
  108339. */
  108340. toString(fullDetails?: boolean): string;
  108341. /**
  108342. * @hidden
  108343. */
  108344. protected _getEffectiveParent(): Nullable<Node>;
  108345. /** @hidden */
  108346. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  108347. /** @hidden */
  108348. _rebuild(): void;
  108349. /** @hidden */
  108350. _resyncLightSources(): void;
  108351. /** @hidden */
  108352. _resyncLightSource(light: Light): void;
  108353. /** @hidden */
  108354. _unBindEffect(): void;
  108355. /** @hidden */
  108356. _removeLightSource(light: Light, dispose: boolean): void;
  108357. private _markSubMeshesAsDirty;
  108358. /** @hidden */
  108359. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  108360. /** @hidden */
  108361. _markSubMeshesAsAttributesDirty(): void;
  108362. /** @hidden */
  108363. _markSubMeshesAsMiscDirty(): void;
  108364. /**
  108365. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  108366. */
  108367. get scaling(): Vector3;
  108368. set scaling(newScaling: Vector3);
  108369. /**
  108370. * Returns true if the mesh is blocked. Implemented by child classes
  108371. */
  108372. get isBlocked(): boolean;
  108373. /**
  108374. * Returns the mesh itself by default. Implemented by child classes
  108375. * @param camera defines the camera to use to pick the right LOD level
  108376. * @returns the currentAbstractMesh
  108377. */
  108378. getLOD(camera: Camera): Nullable<AbstractMesh>;
  108379. /**
  108380. * Returns 0 by default. Implemented by child classes
  108381. * @returns an integer
  108382. */
  108383. getTotalVertices(): number;
  108384. /**
  108385. * Returns a positive integer : the total number of indices in this mesh geometry.
  108386. * @returns the numner of indices or zero if the mesh has no geometry.
  108387. */
  108388. getTotalIndices(): number;
  108389. /**
  108390. * Returns null by default. Implemented by child classes
  108391. * @returns null
  108392. */
  108393. getIndices(): Nullable<IndicesArray>;
  108394. /**
  108395. * Returns the array of the requested vertex data kind. Implemented by child classes
  108396. * @param kind defines the vertex data kind to use
  108397. * @returns null
  108398. */
  108399. getVerticesData(kind: string): Nullable<FloatArray>;
  108400. /**
  108401. * Sets the vertex data of the mesh geometry for the requested `kind`.
  108402. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  108403. * Note that a new underlying VertexBuffer object is created each call.
  108404. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  108405. * @param kind defines vertex data kind:
  108406. * * VertexBuffer.PositionKind
  108407. * * VertexBuffer.UVKind
  108408. * * VertexBuffer.UV2Kind
  108409. * * VertexBuffer.UV3Kind
  108410. * * VertexBuffer.UV4Kind
  108411. * * VertexBuffer.UV5Kind
  108412. * * VertexBuffer.UV6Kind
  108413. * * VertexBuffer.ColorKind
  108414. * * VertexBuffer.MatricesIndicesKind
  108415. * * VertexBuffer.MatricesIndicesExtraKind
  108416. * * VertexBuffer.MatricesWeightsKind
  108417. * * VertexBuffer.MatricesWeightsExtraKind
  108418. * @param data defines the data source
  108419. * @param updatable defines if the data must be flagged as updatable (or static)
  108420. * @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
  108421. * @returns the current mesh
  108422. */
  108423. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  108424. /**
  108425. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  108426. * If the mesh has no geometry, it is simply returned as it is.
  108427. * @param kind defines vertex data kind:
  108428. * * VertexBuffer.PositionKind
  108429. * * VertexBuffer.UVKind
  108430. * * VertexBuffer.UV2Kind
  108431. * * VertexBuffer.UV3Kind
  108432. * * VertexBuffer.UV4Kind
  108433. * * VertexBuffer.UV5Kind
  108434. * * VertexBuffer.UV6Kind
  108435. * * VertexBuffer.ColorKind
  108436. * * VertexBuffer.MatricesIndicesKind
  108437. * * VertexBuffer.MatricesIndicesExtraKind
  108438. * * VertexBuffer.MatricesWeightsKind
  108439. * * VertexBuffer.MatricesWeightsExtraKind
  108440. * @param data defines the data source
  108441. * @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
  108442. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  108443. * @returns the current mesh
  108444. */
  108445. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  108446. /**
  108447. * Sets the mesh indices,
  108448. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  108449. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  108450. * @param totalVertices Defines the total number of vertices
  108451. * @returns the current mesh
  108452. */
  108453. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  108454. /**
  108455. * Gets a boolean indicating if specific vertex data is present
  108456. * @param kind defines the vertex data kind to use
  108457. * @returns true is data kind is present
  108458. */
  108459. isVerticesDataPresent(kind: string): boolean;
  108460. /**
  108461. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  108462. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  108463. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  108464. * @returns a BoundingInfo
  108465. */
  108466. getBoundingInfo(): BoundingInfo;
  108467. /**
  108468. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  108469. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  108470. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  108471. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  108472. * @returns the current mesh
  108473. */
  108474. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  108475. /**
  108476. * Overwrite the current bounding info
  108477. * @param boundingInfo defines the new bounding info
  108478. * @returns the current mesh
  108479. */
  108480. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  108481. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  108482. get useBones(): boolean;
  108483. /** @hidden */
  108484. _preActivate(): void;
  108485. /** @hidden */
  108486. _preActivateForIntermediateRendering(renderId: number): void;
  108487. /** @hidden */
  108488. _activate(renderId: number, intermediateRendering: boolean): boolean;
  108489. /** @hidden */
  108490. _postActivate(): void;
  108491. /** @hidden */
  108492. _freeze(): void;
  108493. /** @hidden */
  108494. _unFreeze(): void;
  108495. /**
  108496. * Gets the current world matrix
  108497. * @returns a Matrix
  108498. */
  108499. getWorldMatrix(): Matrix;
  108500. /** @hidden */
  108501. _getWorldMatrixDeterminant(): number;
  108502. /**
  108503. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  108504. */
  108505. get isAnInstance(): boolean;
  108506. /**
  108507. * Gets a boolean indicating if this mesh has instances
  108508. */
  108509. get hasInstances(): boolean;
  108510. /**
  108511. * Gets a boolean indicating if this mesh has thin instances
  108512. */
  108513. get hasThinInstances(): boolean;
  108514. /**
  108515. * Perform relative position change from the point of view of behind the front of the mesh.
  108516. * This is performed taking into account the meshes current rotation, so you do not have to care.
  108517. * Supports definition of mesh facing forward or backward
  108518. * @param amountRight defines the distance on the right axis
  108519. * @param amountUp defines the distance on the up axis
  108520. * @param amountForward defines the distance on the forward axis
  108521. * @returns the current mesh
  108522. */
  108523. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  108524. /**
  108525. * Calculate relative position change from the point of view of behind the front of the mesh.
  108526. * This is performed taking into account the meshes current rotation, so you do not have to care.
  108527. * Supports definition of mesh facing forward or backward
  108528. * @param amountRight defines the distance on the right axis
  108529. * @param amountUp defines the distance on the up axis
  108530. * @param amountForward defines the distance on the forward axis
  108531. * @returns the new displacement vector
  108532. */
  108533. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  108534. /**
  108535. * Perform relative rotation change from the point of view of behind the front of the mesh.
  108536. * Supports definition of mesh facing forward or backward
  108537. * @param flipBack defines the flip
  108538. * @param twirlClockwise defines the twirl
  108539. * @param tiltRight defines the tilt
  108540. * @returns the current mesh
  108541. */
  108542. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  108543. /**
  108544. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  108545. * Supports definition of mesh facing forward or backward.
  108546. * @param flipBack defines the flip
  108547. * @param twirlClockwise defines the twirl
  108548. * @param tiltRight defines the tilt
  108549. * @returns the new rotation vector
  108550. */
  108551. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  108552. /**
  108553. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  108554. * This means the mesh underlying bounding box and sphere are recomputed.
  108555. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  108556. * @returns the current mesh
  108557. */
  108558. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  108559. /** @hidden */
  108560. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  108561. /** @hidden */
  108562. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  108563. /** @hidden */
  108564. _updateBoundingInfo(): AbstractMesh;
  108565. /** @hidden */
  108566. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  108567. /** @hidden */
  108568. protected _afterComputeWorldMatrix(): void;
  108569. /** @hidden */
  108570. get _effectiveMesh(): AbstractMesh;
  108571. /**
  108572. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  108573. * A mesh is in the frustum if its bounding box intersects the frustum
  108574. * @param frustumPlanes defines the frustum to test
  108575. * @returns true if the mesh is in the frustum planes
  108576. */
  108577. isInFrustum(frustumPlanes: Plane[]): boolean;
  108578. /**
  108579. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  108580. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  108581. * @param frustumPlanes defines the frustum to test
  108582. * @returns true if the mesh is completely in the frustum planes
  108583. */
  108584. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  108585. /**
  108586. * True if the mesh intersects another mesh or a SolidParticle object
  108587. * @param mesh defines a target mesh or SolidParticle to test
  108588. * @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)
  108589. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  108590. * @returns true if there is an intersection
  108591. */
  108592. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  108593. /**
  108594. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  108595. * @param point defines the point to test
  108596. * @returns true if there is an intersection
  108597. */
  108598. intersectsPoint(point: Vector3): boolean;
  108599. /**
  108600. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  108601. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  108602. */
  108603. get checkCollisions(): boolean;
  108604. set checkCollisions(collisionEnabled: boolean);
  108605. /**
  108606. * Gets Collider object used to compute collisions (not physics)
  108607. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  108608. */
  108609. get collider(): Nullable<Collider>;
  108610. /**
  108611. * Move the mesh using collision engine
  108612. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  108613. * @param displacement defines the requested displacement vector
  108614. * @returns the current mesh
  108615. */
  108616. moveWithCollisions(displacement: Vector3): AbstractMesh;
  108617. private _onCollisionPositionChange;
  108618. /** @hidden */
  108619. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  108620. /** @hidden */
  108621. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  108622. /** @hidden */
  108623. _checkCollision(collider: Collider): AbstractMesh;
  108624. /** @hidden */
  108625. _generatePointsArray(): boolean;
  108626. /**
  108627. * Checks if the passed Ray intersects with the mesh
  108628. * @param ray defines the ray to use
  108629. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  108630. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  108631. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  108632. * @returns the picking info
  108633. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  108634. */
  108635. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  108636. /**
  108637. * Clones the current mesh
  108638. * @param name defines the mesh name
  108639. * @param newParent defines the new mesh parent
  108640. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  108641. * @returns the new mesh
  108642. */
  108643. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  108644. /**
  108645. * Disposes all the submeshes of the current meshnp
  108646. * @returns the current mesh
  108647. */
  108648. releaseSubMeshes(): AbstractMesh;
  108649. /**
  108650. * Releases resources associated with this abstract mesh.
  108651. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  108652. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  108653. */
  108654. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  108655. /**
  108656. * Adds the passed mesh as a child to the current mesh
  108657. * @param mesh defines the child mesh
  108658. * @returns the current mesh
  108659. */
  108660. addChild(mesh: AbstractMesh): AbstractMesh;
  108661. /**
  108662. * Removes the passed mesh from the current mesh children list
  108663. * @param mesh defines the child mesh
  108664. * @returns the current mesh
  108665. */
  108666. removeChild(mesh: AbstractMesh): AbstractMesh;
  108667. /** @hidden */
  108668. private _initFacetData;
  108669. /**
  108670. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  108671. * This method can be called within the render loop.
  108672. * 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
  108673. * @returns the current mesh
  108674. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  108675. */
  108676. updateFacetData(): AbstractMesh;
  108677. /**
  108678. * Returns the facetLocalNormals array.
  108679. * The normals are expressed in the mesh local spac
  108680. * @returns an array of Vector3
  108681. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  108682. */
  108683. getFacetLocalNormals(): Vector3[];
  108684. /**
  108685. * Returns the facetLocalPositions array.
  108686. * The facet positions are expressed in the mesh local space
  108687. * @returns an array of Vector3
  108688. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  108689. */
  108690. getFacetLocalPositions(): Vector3[];
  108691. /**
  108692. * Returns the facetLocalPartioning array
  108693. * @returns an array of array of numbers
  108694. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  108695. */
  108696. getFacetLocalPartitioning(): number[][];
  108697. /**
  108698. * Returns the i-th facet position in the world system.
  108699. * This method allocates a new Vector3 per call
  108700. * @param i defines the facet index
  108701. * @returns a new Vector3
  108702. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  108703. */
  108704. getFacetPosition(i: number): Vector3;
  108705. /**
  108706. * Sets the reference Vector3 with the i-th facet position in the world system
  108707. * @param i defines the facet index
  108708. * @param ref defines the target vector
  108709. * @returns the current mesh
  108710. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  108711. */
  108712. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  108713. /**
  108714. * Returns the i-th facet normal in the world system.
  108715. * This method allocates a new Vector3 per call
  108716. * @param i defines the facet index
  108717. * @returns a new Vector3
  108718. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  108719. */
  108720. getFacetNormal(i: number): Vector3;
  108721. /**
  108722. * Sets the reference Vector3 with the i-th facet normal in the world system
  108723. * @param i defines the facet index
  108724. * @param ref defines the target vector
  108725. * @returns the current mesh
  108726. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  108727. */
  108728. getFacetNormalToRef(i: number, ref: Vector3): this;
  108729. /**
  108730. * 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)
  108731. * @param x defines x coordinate
  108732. * @param y defines y coordinate
  108733. * @param z defines z coordinate
  108734. * @returns the array of facet indexes
  108735. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  108736. */
  108737. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  108738. /**
  108739. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  108740. * @param projected sets as the (x,y,z) world projection on the facet
  108741. * @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
  108742. * @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
  108743. * @param x defines x coordinate
  108744. * @param y defines y coordinate
  108745. * @param z defines z coordinate
  108746. * @returns the face index if found (or null instead)
  108747. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  108748. */
  108749. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  108750. /**
  108751. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  108752. * @param projected sets as the (x,y,z) local projection on the facet
  108753. * @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
  108754. * @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
  108755. * @param x defines x coordinate
  108756. * @param y defines y coordinate
  108757. * @param z defines z coordinate
  108758. * @returns the face index if found (or null instead)
  108759. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  108760. */
  108761. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  108762. /**
  108763. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  108764. * @returns the parameters
  108765. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  108766. */
  108767. getFacetDataParameters(): any;
  108768. /**
  108769. * Disables the feature FacetData and frees the related memory
  108770. * @returns the current mesh
  108771. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  108772. */
  108773. disableFacetData(): AbstractMesh;
  108774. /**
  108775. * Updates the AbstractMesh indices array
  108776. * @param indices defines the data source
  108777. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  108778. * @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)
  108779. * @returns the current mesh
  108780. */
  108781. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  108782. /**
  108783. * Creates new normals data for the mesh
  108784. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  108785. * @returns the current mesh
  108786. */
  108787. createNormals(updatable: boolean): AbstractMesh;
  108788. /**
  108789. * Align the mesh with a normal
  108790. * @param normal defines the normal to use
  108791. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  108792. * @returns the current mesh
  108793. */
  108794. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  108795. /** @hidden */
  108796. _checkOcclusionQuery(): boolean;
  108797. /**
  108798. * Disables the mesh edge rendering mode
  108799. * @returns the currentAbstractMesh
  108800. */
  108801. disableEdgesRendering(): AbstractMesh;
  108802. /**
  108803. * Enables the edge rendering mode on the mesh.
  108804. * This mode makes the mesh edges visible
  108805. * @param epsilon defines the maximal distance between two angles to detect a face
  108806. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  108807. * @returns the currentAbstractMesh
  108808. * @see https://www.babylonjs-playground.com/#19O9TU#0
  108809. */
  108810. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  108811. }
  108812. }
  108813. declare module BABYLON {
  108814. /**
  108815. * Interface used to define ActionEvent
  108816. */
  108817. export interface IActionEvent {
  108818. /** The mesh or sprite that triggered the action */
  108819. source: any;
  108820. /** The X mouse cursor position at the time of the event */
  108821. pointerX: number;
  108822. /** The Y mouse cursor position at the time of the event */
  108823. pointerY: number;
  108824. /** The mesh that is currently pointed at (can be null) */
  108825. meshUnderPointer: Nullable<AbstractMesh>;
  108826. /** the original (browser) event that triggered the ActionEvent */
  108827. sourceEvent?: any;
  108828. /** additional data for the event */
  108829. additionalData?: any;
  108830. }
  108831. /**
  108832. * ActionEvent is the event being sent when an action is triggered.
  108833. */
  108834. export class ActionEvent implements IActionEvent {
  108835. /** The mesh or sprite that triggered the action */
  108836. source: any;
  108837. /** The X mouse cursor position at the time of the event */
  108838. pointerX: number;
  108839. /** The Y mouse cursor position at the time of the event */
  108840. pointerY: number;
  108841. /** The mesh that is currently pointed at (can be null) */
  108842. meshUnderPointer: Nullable<AbstractMesh>;
  108843. /** the original (browser) event that triggered the ActionEvent */
  108844. sourceEvent?: any;
  108845. /** additional data for the event */
  108846. additionalData?: any;
  108847. /**
  108848. * Creates a new ActionEvent
  108849. * @param source The mesh or sprite that triggered the action
  108850. * @param pointerX The X mouse cursor position at the time of the event
  108851. * @param pointerY The Y mouse cursor position at the time of the event
  108852. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  108853. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  108854. * @param additionalData additional data for the event
  108855. */
  108856. constructor(
  108857. /** The mesh or sprite that triggered the action */
  108858. source: any,
  108859. /** The X mouse cursor position at the time of the event */
  108860. pointerX: number,
  108861. /** The Y mouse cursor position at the time of the event */
  108862. pointerY: number,
  108863. /** The mesh that is currently pointed at (can be null) */
  108864. meshUnderPointer: Nullable<AbstractMesh>,
  108865. /** the original (browser) event that triggered the ActionEvent */
  108866. sourceEvent?: any,
  108867. /** additional data for the event */
  108868. additionalData?: any);
  108869. /**
  108870. * Helper function to auto-create an ActionEvent from a source mesh.
  108871. * @param source The source mesh that triggered the event
  108872. * @param evt The original (browser) event
  108873. * @param additionalData additional data for the event
  108874. * @returns the new ActionEvent
  108875. */
  108876. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  108877. /**
  108878. * Helper function to auto-create an ActionEvent from a source sprite
  108879. * @param source The source sprite that triggered the event
  108880. * @param scene Scene associated with the sprite
  108881. * @param evt The original (browser) event
  108882. * @param additionalData additional data for the event
  108883. * @returns the new ActionEvent
  108884. */
  108885. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  108886. /**
  108887. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  108888. * @param scene the scene where the event occurred
  108889. * @param evt The original (browser) event
  108890. * @returns the new ActionEvent
  108891. */
  108892. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  108893. /**
  108894. * Helper function to auto-create an ActionEvent from a primitive
  108895. * @param prim defines the target primitive
  108896. * @param pointerPos defines the pointer position
  108897. * @param evt The original (browser) event
  108898. * @param additionalData additional data for the event
  108899. * @returns the new ActionEvent
  108900. */
  108901. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  108902. }
  108903. }
  108904. declare module BABYLON {
  108905. /**
  108906. * Abstract class used to decouple action Manager from scene and meshes.
  108907. * Do not instantiate.
  108908. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  108909. */
  108910. export abstract class AbstractActionManager implements IDisposable {
  108911. /** Gets the list of active triggers */
  108912. static Triggers: {
  108913. [key: string]: number;
  108914. };
  108915. /** Gets the cursor to use when hovering items */
  108916. hoverCursor: string;
  108917. /** Gets the list of actions */
  108918. actions: IAction[];
  108919. /**
  108920. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  108921. */
  108922. isRecursive: boolean;
  108923. /**
  108924. * Releases all associated resources
  108925. */
  108926. abstract dispose(): void;
  108927. /**
  108928. * Does this action manager has pointer triggers
  108929. */
  108930. abstract get hasPointerTriggers(): boolean;
  108931. /**
  108932. * Does this action manager has pick triggers
  108933. */
  108934. abstract get hasPickTriggers(): boolean;
  108935. /**
  108936. * Process a specific trigger
  108937. * @param trigger defines the trigger to process
  108938. * @param evt defines the event details to be processed
  108939. */
  108940. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  108941. /**
  108942. * Does this action manager handles actions of any of the given triggers
  108943. * @param triggers defines the triggers to be tested
  108944. * @return a boolean indicating whether one (or more) of the triggers is handled
  108945. */
  108946. abstract hasSpecificTriggers(triggers: number[]): boolean;
  108947. /**
  108948. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  108949. * speed.
  108950. * @param triggerA defines the trigger to be tested
  108951. * @param triggerB defines the trigger to be tested
  108952. * @return a boolean indicating whether one (or more) of the triggers is handled
  108953. */
  108954. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  108955. /**
  108956. * Does this action manager handles actions of a given trigger
  108957. * @param trigger defines the trigger to be tested
  108958. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  108959. * @return whether the trigger is handled
  108960. */
  108961. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  108962. /**
  108963. * Serialize this manager to a JSON object
  108964. * @param name defines the property name to store this manager
  108965. * @returns a JSON representation of this manager
  108966. */
  108967. abstract serialize(name: string): any;
  108968. /**
  108969. * Registers an action to this action manager
  108970. * @param action defines the action to be registered
  108971. * @return the action amended (prepared) after registration
  108972. */
  108973. abstract registerAction(action: IAction): Nullable<IAction>;
  108974. /**
  108975. * Unregisters an action to this action manager
  108976. * @param action defines the action to be unregistered
  108977. * @return a boolean indicating whether the action has been unregistered
  108978. */
  108979. abstract unregisterAction(action: IAction): Boolean;
  108980. /**
  108981. * Does exist one action manager with at least one trigger
  108982. **/
  108983. static get HasTriggers(): boolean;
  108984. /**
  108985. * Does exist one action manager with at least one pick trigger
  108986. **/
  108987. static get HasPickTriggers(): boolean;
  108988. /**
  108989. * Does exist one action manager that handles actions of a given trigger
  108990. * @param trigger defines the trigger to be tested
  108991. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  108992. **/
  108993. static HasSpecificTrigger(trigger: number): boolean;
  108994. }
  108995. }
  108996. declare module BABYLON {
  108997. /**
  108998. * Defines how a node can be built from a string name.
  108999. */
  109000. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  109001. /**
  109002. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  109003. */
  109004. export class Node implements IBehaviorAware<Node> {
  109005. /** @hidden */
  109006. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  109007. private static _NodeConstructors;
  109008. /**
  109009. * Add a new node constructor
  109010. * @param type defines the type name of the node to construct
  109011. * @param constructorFunc defines the constructor function
  109012. */
  109013. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  109014. /**
  109015. * Returns a node constructor based on type name
  109016. * @param type defines the type name
  109017. * @param name defines the new node name
  109018. * @param scene defines the hosting scene
  109019. * @param options defines optional options to transmit to constructors
  109020. * @returns the new constructor or null
  109021. */
  109022. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  109023. /**
  109024. * Gets or sets the name of the node
  109025. */
  109026. name: string;
  109027. /**
  109028. * Gets or sets the id of the node
  109029. */
  109030. id: string;
  109031. /**
  109032. * Gets or sets the unique id of the node
  109033. */
  109034. uniqueId: number;
  109035. /**
  109036. * Gets or sets a string used to store user defined state for the node
  109037. */
  109038. state: string;
  109039. /**
  109040. * Gets or sets an object used to store user defined information for the node
  109041. */
  109042. metadata: any;
  109043. /**
  109044. * For internal use only. Please do not use.
  109045. */
  109046. reservedDataStore: any;
  109047. /**
  109048. * List of inspectable custom properties (used by the Inspector)
  109049. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  109050. */
  109051. inspectableCustomProperties: IInspectable[];
  109052. private _doNotSerialize;
  109053. /**
  109054. * Gets or sets a boolean used to define if the node must be serialized
  109055. */
  109056. get doNotSerialize(): boolean;
  109057. set doNotSerialize(value: boolean);
  109058. /** @hidden */
  109059. _isDisposed: boolean;
  109060. /**
  109061. * Gets a list of Animations associated with the node
  109062. */
  109063. animations: Animation[];
  109064. protected _ranges: {
  109065. [name: string]: Nullable<AnimationRange>;
  109066. };
  109067. /**
  109068. * Callback raised when the node is ready to be used
  109069. */
  109070. onReady: Nullable<(node: Node) => void>;
  109071. private _isEnabled;
  109072. private _isParentEnabled;
  109073. private _isReady;
  109074. /** @hidden */
  109075. _currentRenderId: number;
  109076. private _parentUpdateId;
  109077. /** @hidden */
  109078. _childUpdateId: number;
  109079. /** @hidden */
  109080. _waitingParentId: Nullable<string>;
  109081. /** @hidden */
  109082. _scene: Scene;
  109083. /** @hidden */
  109084. _cache: any;
  109085. private _parentNode;
  109086. private _children;
  109087. /** @hidden */
  109088. _worldMatrix: Matrix;
  109089. /** @hidden */
  109090. _worldMatrixDeterminant: number;
  109091. /** @hidden */
  109092. _worldMatrixDeterminantIsDirty: boolean;
  109093. /** @hidden */
  109094. private _sceneRootNodesIndex;
  109095. /**
  109096. * Gets a boolean indicating if the node has been disposed
  109097. * @returns true if the node was disposed
  109098. */
  109099. isDisposed(): boolean;
  109100. /**
  109101. * Gets or sets the parent of the node (without keeping the current position in the scene)
  109102. * @see https://doc.babylonjs.com/how_to/parenting
  109103. */
  109104. set parent(parent: Nullable<Node>);
  109105. get parent(): Nullable<Node>;
  109106. /** @hidden */
  109107. _addToSceneRootNodes(): void;
  109108. /** @hidden */
  109109. _removeFromSceneRootNodes(): void;
  109110. private _animationPropertiesOverride;
  109111. /**
  109112. * Gets or sets the animation properties override
  109113. */
  109114. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  109115. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  109116. /**
  109117. * Gets a string idenfifying the name of the class
  109118. * @returns "Node" string
  109119. */
  109120. getClassName(): string;
  109121. /** @hidden */
  109122. readonly _isNode: boolean;
  109123. /**
  109124. * An event triggered when the mesh is disposed
  109125. */
  109126. onDisposeObservable: Observable<Node>;
  109127. private _onDisposeObserver;
  109128. /**
  109129. * Sets a callback that will be raised when the node will be disposed
  109130. */
  109131. set onDispose(callback: () => void);
  109132. /**
  109133. * Creates a new Node
  109134. * @param name the name and id to be given to this node
  109135. * @param scene the scene this node will be added to
  109136. */
  109137. constructor(name: string, scene?: Nullable<Scene>);
  109138. /**
  109139. * Gets the scene of the node
  109140. * @returns a scene
  109141. */
  109142. getScene(): Scene;
  109143. /**
  109144. * Gets the engine of the node
  109145. * @returns a Engine
  109146. */
  109147. getEngine(): Engine;
  109148. private _behaviors;
  109149. /**
  109150. * Attach a behavior to the node
  109151. * @see http://doc.babylonjs.com/features/behaviour
  109152. * @param behavior defines the behavior to attach
  109153. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  109154. * @returns the current Node
  109155. */
  109156. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  109157. /**
  109158. * Remove an attached behavior
  109159. * @see http://doc.babylonjs.com/features/behaviour
  109160. * @param behavior defines the behavior to attach
  109161. * @returns the current Node
  109162. */
  109163. removeBehavior(behavior: Behavior<Node>): Node;
  109164. /**
  109165. * Gets the list of attached behaviors
  109166. * @see http://doc.babylonjs.com/features/behaviour
  109167. */
  109168. get behaviors(): Behavior<Node>[];
  109169. /**
  109170. * Gets an attached behavior by name
  109171. * @param name defines the name of the behavior to look for
  109172. * @see http://doc.babylonjs.com/features/behaviour
  109173. * @returns null if behavior was not found else the requested behavior
  109174. */
  109175. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  109176. /**
  109177. * Returns the latest update of the World matrix
  109178. * @returns a Matrix
  109179. */
  109180. getWorldMatrix(): Matrix;
  109181. /** @hidden */
  109182. _getWorldMatrixDeterminant(): number;
  109183. /**
  109184. * Returns directly the latest state of the mesh World matrix.
  109185. * A Matrix is returned.
  109186. */
  109187. get worldMatrixFromCache(): Matrix;
  109188. /** @hidden */
  109189. _initCache(): void;
  109190. /** @hidden */
  109191. updateCache(force?: boolean): void;
  109192. /** @hidden */
  109193. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  109194. /** @hidden */
  109195. _updateCache(ignoreParentClass?: boolean): void;
  109196. /** @hidden */
  109197. _isSynchronized(): boolean;
  109198. /** @hidden */
  109199. _markSyncedWithParent(): void;
  109200. /** @hidden */
  109201. isSynchronizedWithParent(): boolean;
  109202. /** @hidden */
  109203. isSynchronized(): boolean;
  109204. /**
  109205. * Is this node ready to be used/rendered
  109206. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  109207. * @return true if the node is ready
  109208. */
  109209. isReady(completeCheck?: boolean): boolean;
  109210. /**
  109211. * Is this node enabled?
  109212. * 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
  109213. * @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
  109214. * @return whether this node (and its parent) is enabled
  109215. */
  109216. isEnabled(checkAncestors?: boolean): boolean;
  109217. /** @hidden */
  109218. protected _syncParentEnabledState(): void;
  109219. /**
  109220. * Set the enabled state of this node
  109221. * @param value defines the new enabled state
  109222. */
  109223. setEnabled(value: boolean): void;
  109224. /**
  109225. * Is this node a descendant of the given node?
  109226. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  109227. * @param ancestor defines the parent node to inspect
  109228. * @returns a boolean indicating if this node is a descendant of the given node
  109229. */
  109230. isDescendantOf(ancestor: Node): boolean;
  109231. /** @hidden */
  109232. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  109233. /**
  109234. * Will return all nodes that have this node as ascendant
  109235. * @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
  109236. * @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
  109237. * @return all children nodes of all types
  109238. */
  109239. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  109240. /**
  109241. * Get all child-meshes of this node
  109242. * @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)
  109243. * @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
  109244. * @returns an array of AbstractMesh
  109245. */
  109246. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  109247. /**
  109248. * Get all direct children of this node
  109249. * @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
  109250. * @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)
  109251. * @returns an array of Node
  109252. */
  109253. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  109254. /** @hidden */
  109255. _setReady(state: boolean): void;
  109256. /**
  109257. * Get an animation by name
  109258. * @param name defines the name of the animation to look for
  109259. * @returns null if not found else the requested animation
  109260. */
  109261. getAnimationByName(name: string): Nullable<Animation>;
  109262. /**
  109263. * Creates an animation range for this node
  109264. * @param name defines the name of the range
  109265. * @param from defines the starting key
  109266. * @param to defines the end key
  109267. */
  109268. createAnimationRange(name: string, from: number, to: number): void;
  109269. /**
  109270. * Delete a specific animation range
  109271. * @param name defines the name of the range to delete
  109272. * @param deleteFrames defines if animation frames from the range must be deleted as well
  109273. */
  109274. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  109275. /**
  109276. * Get an animation range by name
  109277. * @param name defines the name of the animation range to look for
  109278. * @returns null if not found else the requested animation range
  109279. */
  109280. getAnimationRange(name: string): Nullable<AnimationRange>;
  109281. /**
  109282. * Gets the list of all animation ranges defined on this node
  109283. * @returns an array
  109284. */
  109285. getAnimationRanges(): Nullable<AnimationRange>[];
  109286. /**
  109287. * Will start the animation sequence
  109288. * @param name defines the range frames for animation sequence
  109289. * @param loop defines if the animation should loop (false by default)
  109290. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  109291. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  109292. * @returns the object created for this animation. If range does not exist, it will return null
  109293. */
  109294. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  109295. /**
  109296. * Serialize animation ranges into a JSON compatible object
  109297. * @returns serialization object
  109298. */
  109299. serializeAnimationRanges(): any;
  109300. /**
  109301. * Computes the world matrix of the node
  109302. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  109303. * @returns the world matrix
  109304. */
  109305. computeWorldMatrix(force?: boolean): Matrix;
  109306. /**
  109307. * Releases resources associated with this node.
  109308. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  109309. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  109310. */
  109311. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  109312. /**
  109313. * Parse animation range data from a serialization object and store them into a given node
  109314. * @param node defines where to store the animation ranges
  109315. * @param parsedNode defines the serialization object to read data from
  109316. * @param scene defines the hosting scene
  109317. */
  109318. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  109319. /**
  109320. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  109321. * @param includeDescendants Include bounding info from descendants as well (true by default)
  109322. * @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
  109323. * @returns the new bounding vectors
  109324. */
  109325. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  109326. min: Vector3;
  109327. max: Vector3;
  109328. };
  109329. }
  109330. }
  109331. declare module BABYLON {
  109332. /**
  109333. * @hidden
  109334. */
  109335. export class _IAnimationState {
  109336. key: number;
  109337. repeatCount: number;
  109338. workValue?: any;
  109339. loopMode?: number;
  109340. offsetValue?: any;
  109341. highLimitValue?: any;
  109342. }
  109343. /**
  109344. * Class used to store any kind of animation
  109345. */
  109346. export class Animation {
  109347. /**Name of the animation */
  109348. name: string;
  109349. /**Property to animate */
  109350. targetProperty: string;
  109351. /**The frames per second of the animation */
  109352. framePerSecond: number;
  109353. /**The data type of the animation */
  109354. dataType: number;
  109355. /**The loop mode of the animation */
  109356. loopMode?: number | undefined;
  109357. /**Specifies if blending should be enabled */
  109358. enableBlending?: boolean | undefined;
  109359. /**
  109360. * Use matrix interpolation instead of using direct key value when animating matrices
  109361. */
  109362. static AllowMatricesInterpolation: boolean;
  109363. /**
  109364. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  109365. */
  109366. static AllowMatrixDecomposeForInterpolation: boolean;
  109367. /**
  109368. * Stores the key frames of the animation
  109369. */
  109370. private _keys;
  109371. /**
  109372. * Stores the easing function of the animation
  109373. */
  109374. private _easingFunction;
  109375. /**
  109376. * @hidden Internal use only
  109377. */
  109378. _runtimeAnimations: RuntimeAnimation[];
  109379. /**
  109380. * The set of event that will be linked to this animation
  109381. */
  109382. private _events;
  109383. /**
  109384. * Stores an array of target property paths
  109385. */
  109386. targetPropertyPath: string[];
  109387. /**
  109388. * Stores the blending speed of the animation
  109389. */
  109390. blendingSpeed: number;
  109391. /**
  109392. * Stores the animation ranges for the animation
  109393. */
  109394. private _ranges;
  109395. /**
  109396. * @hidden Internal use
  109397. */
  109398. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  109399. /**
  109400. * Sets up an animation
  109401. * @param property The property to animate
  109402. * @param animationType The animation type to apply
  109403. * @param framePerSecond The frames per second of the animation
  109404. * @param easingFunction The easing function used in the animation
  109405. * @returns The created animation
  109406. */
  109407. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  109408. /**
  109409. * Create and start an animation on a node
  109410. * @param name defines the name of the global animation that will be run on all nodes
  109411. * @param node defines the root node where the animation will take place
  109412. * @param targetProperty defines property to animate
  109413. * @param framePerSecond defines the number of frame per second yo use
  109414. * @param totalFrame defines the number of frames in total
  109415. * @param from defines the initial value
  109416. * @param to defines the final value
  109417. * @param loopMode defines which loop mode you want to use (off by default)
  109418. * @param easingFunction defines the easing function to use (linear by default)
  109419. * @param onAnimationEnd defines the callback to call when animation end
  109420. * @returns the animatable created for this animation
  109421. */
  109422. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  109423. /**
  109424. * Create and start an animation on a node and its descendants
  109425. * @param name defines the name of the global animation that will be run on all nodes
  109426. * @param node defines the root node where the animation will take place
  109427. * @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
  109428. * @param targetProperty defines property to animate
  109429. * @param framePerSecond defines the number of frame per second to use
  109430. * @param totalFrame defines the number of frames in total
  109431. * @param from defines the initial value
  109432. * @param to defines the final value
  109433. * @param loopMode defines which loop mode you want to use (off by default)
  109434. * @param easingFunction defines the easing function to use (linear by default)
  109435. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  109436. * @returns the list of animatables created for all nodes
  109437. * @example https://www.babylonjs-playground.com/#MH0VLI
  109438. */
  109439. 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[]>;
  109440. /**
  109441. * Creates a new animation, merges it with the existing animations and starts it
  109442. * @param name Name of the animation
  109443. * @param node Node which contains the scene that begins the animations
  109444. * @param targetProperty Specifies which property to animate
  109445. * @param framePerSecond The frames per second of the animation
  109446. * @param totalFrame The total number of frames
  109447. * @param from The frame at the beginning of the animation
  109448. * @param to The frame at the end of the animation
  109449. * @param loopMode Specifies the loop mode of the animation
  109450. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  109451. * @param onAnimationEnd Callback to run once the animation is complete
  109452. * @returns Nullable animation
  109453. */
  109454. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  109455. /**
  109456. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  109457. * @param sourceAnimation defines the Animation containing keyframes to convert
  109458. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  109459. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  109460. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  109461. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  109462. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  109463. */
  109464. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  109465. /**
  109466. * Transition property of an host to the target Value
  109467. * @param property The property to transition
  109468. * @param targetValue The target Value of the property
  109469. * @param host The object where the property to animate belongs
  109470. * @param scene Scene used to run the animation
  109471. * @param frameRate Framerate (in frame/s) to use
  109472. * @param transition The transition type we want to use
  109473. * @param duration The duration of the animation, in milliseconds
  109474. * @param onAnimationEnd Callback trigger at the end of the animation
  109475. * @returns Nullable animation
  109476. */
  109477. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  109478. /**
  109479. * Return the array of runtime animations currently using this animation
  109480. */
  109481. get runtimeAnimations(): RuntimeAnimation[];
  109482. /**
  109483. * Specifies if any of the runtime animations are currently running
  109484. */
  109485. get hasRunningRuntimeAnimations(): boolean;
  109486. /**
  109487. * Initializes the animation
  109488. * @param name Name of the animation
  109489. * @param targetProperty Property to animate
  109490. * @param framePerSecond The frames per second of the animation
  109491. * @param dataType The data type of the animation
  109492. * @param loopMode The loop mode of the animation
  109493. * @param enableBlending Specifies if blending should be enabled
  109494. */
  109495. constructor(
  109496. /**Name of the animation */
  109497. name: string,
  109498. /**Property to animate */
  109499. targetProperty: string,
  109500. /**The frames per second of the animation */
  109501. framePerSecond: number,
  109502. /**The data type of the animation */
  109503. dataType: number,
  109504. /**The loop mode of the animation */
  109505. loopMode?: number | undefined,
  109506. /**Specifies if blending should be enabled */
  109507. enableBlending?: boolean | undefined);
  109508. /**
  109509. * Converts the animation to a string
  109510. * @param fullDetails support for multiple levels of logging within scene loading
  109511. * @returns String form of the animation
  109512. */
  109513. toString(fullDetails?: boolean): string;
  109514. /**
  109515. * Add an event to this animation
  109516. * @param event Event to add
  109517. */
  109518. addEvent(event: AnimationEvent): void;
  109519. /**
  109520. * Remove all events found at the given frame
  109521. * @param frame The frame to remove events from
  109522. */
  109523. removeEvents(frame: number): void;
  109524. /**
  109525. * Retrieves all the events from the animation
  109526. * @returns Events from the animation
  109527. */
  109528. getEvents(): AnimationEvent[];
  109529. /**
  109530. * Creates an animation range
  109531. * @param name Name of the animation range
  109532. * @param from Starting frame of the animation range
  109533. * @param to Ending frame of the animation
  109534. */
  109535. createRange(name: string, from: number, to: number): void;
  109536. /**
  109537. * Deletes an animation range by name
  109538. * @param name Name of the animation range to delete
  109539. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  109540. */
  109541. deleteRange(name: string, deleteFrames?: boolean): void;
  109542. /**
  109543. * Gets the animation range by name, or null if not defined
  109544. * @param name Name of the animation range
  109545. * @returns Nullable animation range
  109546. */
  109547. getRange(name: string): Nullable<AnimationRange>;
  109548. /**
  109549. * Gets the key frames from the animation
  109550. * @returns The key frames of the animation
  109551. */
  109552. getKeys(): Array<IAnimationKey>;
  109553. /**
  109554. * Gets the highest frame rate of the animation
  109555. * @returns Highest frame rate of the animation
  109556. */
  109557. getHighestFrame(): number;
  109558. /**
  109559. * Gets the easing function of the animation
  109560. * @returns Easing function of the animation
  109561. */
  109562. getEasingFunction(): IEasingFunction;
  109563. /**
  109564. * Sets the easing function of the animation
  109565. * @param easingFunction A custom mathematical formula for animation
  109566. */
  109567. setEasingFunction(easingFunction: EasingFunction): void;
  109568. /**
  109569. * Interpolates a scalar linearly
  109570. * @param startValue Start value of the animation curve
  109571. * @param endValue End value of the animation curve
  109572. * @param gradient Scalar amount to interpolate
  109573. * @returns Interpolated scalar value
  109574. */
  109575. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  109576. /**
  109577. * Interpolates a scalar cubically
  109578. * @param startValue Start value of the animation curve
  109579. * @param outTangent End tangent of the animation
  109580. * @param endValue End value of the animation curve
  109581. * @param inTangent Start tangent of the animation curve
  109582. * @param gradient Scalar amount to interpolate
  109583. * @returns Interpolated scalar value
  109584. */
  109585. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  109586. /**
  109587. * Interpolates a quaternion using a spherical linear interpolation
  109588. * @param startValue Start value of the animation curve
  109589. * @param endValue End value of the animation curve
  109590. * @param gradient Scalar amount to interpolate
  109591. * @returns Interpolated quaternion value
  109592. */
  109593. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  109594. /**
  109595. * Interpolates a quaternion cubically
  109596. * @param startValue Start value of the animation curve
  109597. * @param outTangent End tangent of the animation curve
  109598. * @param endValue End value of the animation curve
  109599. * @param inTangent Start tangent of the animation curve
  109600. * @param gradient Scalar amount to interpolate
  109601. * @returns Interpolated quaternion value
  109602. */
  109603. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  109604. /**
  109605. * Interpolates a Vector3 linearl
  109606. * @param startValue Start value of the animation curve
  109607. * @param endValue End value of the animation curve
  109608. * @param gradient Scalar amount to interpolate
  109609. * @returns Interpolated scalar value
  109610. */
  109611. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  109612. /**
  109613. * Interpolates a Vector3 cubically
  109614. * @param startValue Start value of the animation curve
  109615. * @param outTangent End tangent of the animation
  109616. * @param endValue End value of the animation curve
  109617. * @param inTangent Start tangent of the animation curve
  109618. * @param gradient Scalar amount to interpolate
  109619. * @returns InterpolatedVector3 value
  109620. */
  109621. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  109622. /**
  109623. * Interpolates a Vector2 linearly
  109624. * @param startValue Start value of the animation curve
  109625. * @param endValue End value of the animation curve
  109626. * @param gradient Scalar amount to interpolate
  109627. * @returns Interpolated Vector2 value
  109628. */
  109629. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  109630. /**
  109631. * Interpolates a Vector2 cubically
  109632. * @param startValue Start value of the animation curve
  109633. * @param outTangent End tangent of the animation
  109634. * @param endValue End value of the animation curve
  109635. * @param inTangent Start tangent of the animation curve
  109636. * @param gradient Scalar amount to interpolate
  109637. * @returns Interpolated Vector2 value
  109638. */
  109639. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  109640. /**
  109641. * Interpolates a size linearly
  109642. * @param startValue Start value of the animation curve
  109643. * @param endValue End value of the animation curve
  109644. * @param gradient Scalar amount to interpolate
  109645. * @returns Interpolated Size value
  109646. */
  109647. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  109648. /**
  109649. * Interpolates a Color3 linearly
  109650. * @param startValue Start value of the animation curve
  109651. * @param endValue End value of the animation curve
  109652. * @param gradient Scalar amount to interpolate
  109653. * @returns Interpolated Color3 value
  109654. */
  109655. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  109656. /**
  109657. * Interpolates a Color4 linearly
  109658. * @param startValue Start value of the animation curve
  109659. * @param endValue End value of the animation curve
  109660. * @param gradient Scalar amount to interpolate
  109661. * @returns Interpolated Color3 value
  109662. */
  109663. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  109664. /**
  109665. * @hidden Internal use only
  109666. */
  109667. _getKeyValue(value: any): any;
  109668. /**
  109669. * @hidden Internal use only
  109670. */
  109671. _interpolate(currentFrame: number, state: _IAnimationState): any;
  109672. /**
  109673. * Defines the function to use to interpolate matrices
  109674. * @param startValue defines the start matrix
  109675. * @param endValue defines the end matrix
  109676. * @param gradient defines the gradient between both matrices
  109677. * @param result defines an optional target matrix where to store the interpolation
  109678. * @returns the interpolated matrix
  109679. */
  109680. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  109681. /**
  109682. * Makes a copy of the animation
  109683. * @returns Cloned animation
  109684. */
  109685. clone(): Animation;
  109686. /**
  109687. * Sets the key frames of the animation
  109688. * @param values The animation key frames to set
  109689. */
  109690. setKeys(values: Array<IAnimationKey>): void;
  109691. /**
  109692. * Serializes the animation to an object
  109693. * @returns Serialized object
  109694. */
  109695. serialize(): any;
  109696. /**
  109697. * Float animation type
  109698. */
  109699. static readonly ANIMATIONTYPE_FLOAT: number;
  109700. /**
  109701. * Vector3 animation type
  109702. */
  109703. static readonly ANIMATIONTYPE_VECTOR3: number;
  109704. /**
  109705. * Quaternion animation type
  109706. */
  109707. static readonly ANIMATIONTYPE_QUATERNION: number;
  109708. /**
  109709. * Matrix animation type
  109710. */
  109711. static readonly ANIMATIONTYPE_MATRIX: number;
  109712. /**
  109713. * Color3 animation type
  109714. */
  109715. static readonly ANIMATIONTYPE_COLOR3: number;
  109716. /**
  109717. * Color3 animation type
  109718. */
  109719. static readonly ANIMATIONTYPE_COLOR4: number;
  109720. /**
  109721. * Vector2 animation type
  109722. */
  109723. static readonly ANIMATIONTYPE_VECTOR2: number;
  109724. /**
  109725. * Size animation type
  109726. */
  109727. static readonly ANIMATIONTYPE_SIZE: number;
  109728. /**
  109729. * Relative Loop Mode
  109730. */
  109731. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  109732. /**
  109733. * Cycle Loop Mode
  109734. */
  109735. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  109736. /**
  109737. * Constant Loop Mode
  109738. */
  109739. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  109740. /** @hidden */
  109741. static _UniversalLerp(left: any, right: any, amount: number): any;
  109742. /**
  109743. * Parses an animation object and creates an animation
  109744. * @param parsedAnimation Parsed animation object
  109745. * @returns Animation object
  109746. */
  109747. static Parse(parsedAnimation: any): Animation;
  109748. /**
  109749. * Appends the serialized animations from the source animations
  109750. * @param source Source containing the animations
  109751. * @param destination Target to store the animations
  109752. */
  109753. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  109754. }
  109755. }
  109756. declare module BABYLON {
  109757. /**
  109758. * Interface containing an array of animations
  109759. */
  109760. export interface IAnimatable {
  109761. /**
  109762. * Array of animations
  109763. */
  109764. animations: Nullable<Array<Animation>>;
  109765. }
  109766. }
  109767. declare module BABYLON {
  109768. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  109769. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  109770. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  109771. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  109772. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  109773. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  109774. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  109775. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  109776. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  109777. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  109778. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  109779. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  109780. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  109781. /**
  109782. * Decorator used to define property that can be serialized as reference to a camera
  109783. * @param sourceName defines the name of the property to decorate
  109784. */
  109785. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  109786. /**
  109787. * Class used to help serialization objects
  109788. */
  109789. export class SerializationHelper {
  109790. /** @hidden */
  109791. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  109792. /** @hidden */
  109793. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  109794. /** @hidden */
  109795. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  109796. /** @hidden */
  109797. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  109798. /**
  109799. * Appends the serialized animations from the source animations
  109800. * @param source Source containing the animations
  109801. * @param destination Target to store the animations
  109802. */
  109803. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  109804. /**
  109805. * Static function used to serialized a specific entity
  109806. * @param entity defines the entity to serialize
  109807. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  109808. * @returns a JSON compatible object representing the serialization of the entity
  109809. */
  109810. static Serialize<T>(entity: T, serializationObject?: any): any;
  109811. /**
  109812. * Creates a new entity from a serialization data object
  109813. * @param creationFunction defines a function used to instanciated the new entity
  109814. * @param source defines the source serialization data
  109815. * @param scene defines the hosting scene
  109816. * @param rootUrl defines the root url for resources
  109817. * @returns a new entity
  109818. */
  109819. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  109820. /**
  109821. * Clones an object
  109822. * @param creationFunction defines the function used to instanciate the new object
  109823. * @param source defines the source object
  109824. * @returns the cloned object
  109825. */
  109826. static Clone<T>(creationFunction: () => T, source: T): T;
  109827. /**
  109828. * Instanciates a new object based on a source one (some data will be shared between both object)
  109829. * @param creationFunction defines the function used to instanciate the new object
  109830. * @param source defines the source object
  109831. * @returns the new object
  109832. */
  109833. static Instanciate<T>(creationFunction: () => T, source: T): T;
  109834. }
  109835. }
  109836. declare module BABYLON {
  109837. /**
  109838. * Base class of all the textures in babylon.
  109839. * It groups all the common properties the materials, post process, lights... might need
  109840. * in order to make a correct use of the texture.
  109841. */
  109842. export class BaseTexture implements IAnimatable {
  109843. /**
  109844. * Default anisotropic filtering level for the application.
  109845. * It is set to 4 as a good tradeoff between perf and quality.
  109846. */
  109847. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  109848. /**
  109849. * Gets or sets the unique id of the texture
  109850. */
  109851. uniqueId: number;
  109852. /**
  109853. * Define the name of the texture.
  109854. */
  109855. name: string;
  109856. /**
  109857. * Gets or sets an object used to store user defined information.
  109858. */
  109859. metadata: any;
  109860. /**
  109861. * For internal use only. Please do not use.
  109862. */
  109863. reservedDataStore: any;
  109864. private _hasAlpha;
  109865. /**
  109866. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  109867. */
  109868. set hasAlpha(value: boolean);
  109869. get hasAlpha(): boolean;
  109870. /**
  109871. * Defines if the alpha value should be determined via the rgb values.
  109872. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  109873. */
  109874. getAlphaFromRGB: boolean;
  109875. /**
  109876. * Intensity or strength of the texture.
  109877. * It is commonly used by materials to fine tune the intensity of the texture
  109878. */
  109879. level: number;
  109880. /**
  109881. * Define the UV chanel to use starting from 0 and defaulting to 0.
  109882. * This is part of the texture as textures usually maps to one uv set.
  109883. */
  109884. coordinatesIndex: number;
  109885. private _coordinatesMode;
  109886. /**
  109887. * How a texture is mapped.
  109888. *
  109889. * | Value | Type | Description |
  109890. * | ----- | ----------------------------------- | ----------- |
  109891. * | 0 | EXPLICIT_MODE | |
  109892. * | 1 | SPHERICAL_MODE | |
  109893. * | 2 | PLANAR_MODE | |
  109894. * | 3 | CUBIC_MODE | |
  109895. * | 4 | PROJECTION_MODE | |
  109896. * | 5 | SKYBOX_MODE | |
  109897. * | 6 | INVCUBIC_MODE | |
  109898. * | 7 | EQUIRECTANGULAR_MODE | |
  109899. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  109900. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  109901. */
  109902. set coordinatesMode(value: number);
  109903. get coordinatesMode(): number;
  109904. /**
  109905. * | Value | Type | Description |
  109906. * | ----- | ------------------ | ----------- |
  109907. * | 0 | CLAMP_ADDRESSMODE | |
  109908. * | 1 | WRAP_ADDRESSMODE | |
  109909. * | 2 | MIRROR_ADDRESSMODE | |
  109910. */
  109911. wrapU: number;
  109912. /**
  109913. * | Value | Type | Description |
  109914. * | ----- | ------------------ | ----------- |
  109915. * | 0 | CLAMP_ADDRESSMODE | |
  109916. * | 1 | WRAP_ADDRESSMODE | |
  109917. * | 2 | MIRROR_ADDRESSMODE | |
  109918. */
  109919. wrapV: number;
  109920. /**
  109921. * | Value | Type | Description |
  109922. * | ----- | ------------------ | ----------- |
  109923. * | 0 | CLAMP_ADDRESSMODE | |
  109924. * | 1 | WRAP_ADDRESSMODE | |
  109925. * | 2 | MIRROR_ADDRESSMODE | |
  109926. */
  109927. wrapR: number;
  109928. /**
  109929. * With compliant hardware and browser (supporting anisotropic filtering)
  109930. * this defines the level of anisotropic filtering in the texture.
  109931. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  109932. */
  109933. anisotropicFilteringLevel: number;
  109934. /**
  109935. * Define if the texture is a cube texture or if false a 2d texture.
  109936. */
  109937. get isCube(): boolean;
  109938. set isCube(value: boolean);
  109939. /**
  109940. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  109941. */
  109942. get is3D(): boolean;
  109943. set is3D(value: boolean);
  109944. /**
  109945. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  109946. */
  109947. get is2DArray(): boolean;
  109948. set is2DArray(value: boolean);
  109949. /**
  109950. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  109951. * HDR texture are usually stored in linear space.
  109952. * This only impacts the PBR and Background materials
  109953. */
  109954. gammaSpace: boolean;
  109955. /**
  109956. * Gets or sets whether or not the texture contains RGBD data.
  109957. */
  109958. get isRGBD(): boolean;
  109959. set isRGBD(value: boolean);
  109960. /**
  109961. * Is Z inverted in the texture (useful in a cube texture).
  109962. */
  109963. invertZ: boolean;
  109964. /**
  109965. * Are mip maps generated for this texture or not.
  109966. */
  109967. get noMipmap(): boolean;
  109968. /**
  109969. * @hidden
  109970. */
  109971. lodLevelInAlpha: boolean;
  109972. /**
  109973. * With prefiltered texture, defined the offset used during the prefiltering steps.
  109974. */
  109975. get lodGenerationOffset(): number;
  109976. set lodGenerationOffset(value: number);
  109977. /**
  109978. * With prefiltered texture, defined the scale used during the prefiltering steps.
  109979. */
  109980. get lodGenerationScale(): number;
  109981. set lodGenerationScale(value: number);
  109982. /**
  109983. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  109984. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  109985. * average roughness values.
  109986. */
  109987. get linearSpecularLOD(): boolean;
  109988. set linearSpecularLOD(value: boolean);
  109989. /**
  109990. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  109991. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  109992. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  109993. */
  109994. get irradianceTexture(): Nullable<BaseTexture>;
  109995. set irradianceTexture(value: Nullable<BaseTexture>);
  109996. /**
  109997. * Define if the texture is a render target.
  109998. */
  109999. isRenderTarget: boolean;
  110000. /**
  110001. * Define the unique id of the texture in the scene.
  110002. */
  110003. get uid(): string;
  110004. /** @hidden */
  110005. _prefiltered: boolean;
  110006. /**
  110007. * Return a string representation of the texture.
  110008. * @returns the texture as a string
  110009. */
  110010. toString(): string;
  110011. /**
  110012. * Get the class name of the texture.
  110013. * @returns "BaseTexture"
  110014. */
  110015. getClassName(): string;
  110016. /**
  110017. * Define the list of animation attached to the texture.
  110018. */
  110019. animations: Animation[];
  110020. /**
  110021. * An event triggered when the texture is disposed.
  110022. */
  110023. onDisposeObservable: Observable<BaseTexture>;
  110024. private _onDisposeObserver;
  110025. /**
  110026. * Callback triggered when the texture has been disposed.
  110027. * Kept for back compatibility, you can use the onDisposeObservable instead.
  110028. */
  110029. set onDispose(callback: () => void);
  110030. /**
  110031. * Define the current state of the loading sequence when in delayed load mode.
  110032. */
  110033. delayLoadState: number;
  110034. private _scene;
  110035. private _engine;
  110036. /** @hidden */
  110037. _texture: Nullable<InternalTexture>;
  110038. private _uid;
  110039. /**
  110040. * Define if the texture is preventinga material to render or not.
  110041. * If not and the texture is not ready, the engine will use a default black texture instead.
  110042. */
  110043. get isBlocking(): boolean;
  110044. /**
  110045. * Instantiates a new BaseTexture.
  110046. * Base class of all the textures in babylon.
  110047. * It groups all the common properties the materials, post process, lights... might need
  110048. * in order to make a correct use of the texture.
  110049. * @param sceneOrEngine Define the scene or engine the texture blongs to
  110050. */
  110051. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  110052. /**
  110053. * Get the scene the texture belongs to.
  110054. * @returns the scene or null if undefined
  110055. */
  110056. getScene(): Nullable<Scene>;
  110057. /** @hidden */
  110058. protected _getEngine(): Nullable<ThinEngine>;
  110059. /**
  110060. * Get the texture transform matrix used to offset tile the texture for istance.
  110061. * @returns the transformation matrix
  110062. */
  110063. getTextureMatrix(): Matrix;
  110064. /**
  110065. * Get the texture reflection matrix used to rotate/transform the reflection.
  110066. * @returns the reflection matrix
  110067. */
  110068. getReflectionTextureMatrix(): Matrix;
  110069. /**
  110070. * Get the underlying lower level texture from Babylon.
  110071. * @returns the insternal texture
  110072. */
  110073. getInternalTexture(): Nullable<InternalTexture>;
  110074. /**
  110075. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  110076. * @returns true if ready or not blocking
  110077. */
  110078. isReadyOrNotBlocking(): boolean;
  110079. /**
  110080. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  110081. * @returns true if fully ready
  110082. */
  110083. isReady(): boolean;
  110084. private _cachedSize;
  110085. /**
  110086. * Get the size of the texture.
  110087. * @returns the texture size.
  110088. */
  110089. getSize(): ISize;
  110090. /**
  110091. * Get the base size of the texture.
  110092. * It can be different from the size if the texture has been resized for POT for instance
  110093. * @returns the base size
  110094. */
  110095. getBaseSize(): ISize;
  110096. /**
  110097. * Update the sampling mode of the texture.
  110098. * Default is Trilinear mode.
  110099. *
  110100. * | Value | Type | Description |
  110101. * | ----- | ------------------ | ----------- |
  110102. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  110103. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  110104. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  110105. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  110106. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  110107. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  110108. * | 7 | NEAREST_LINEAR | |
  110109. * | 8 | NEAREST_NEAREST | |
  110110. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  110111. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  110112. * | 11 | LINEAR_LINEAR | |
  110113. * | 12 | LINEAR_NEAREST | |
  110114. *
  110115. * > _mag_: magnification filter (close to the viewer)
  110116. * > _min_: minification filter (far from the viewer)
  110117. * > _mip_: filter used between mip map levels
  110118. *@param samplingMode Define the new sampling mode of the texture
  110119. */
  110120. updateSamplingMode(samplingMode: number): void;
  110121. /**
  110122. * Scales the texture if is `canRescale()`
  110123. * @param ratio the resize factor we want to use to rescale
  110124. */
  110125. scale(ratio: number): void;
  110126. /**
  110127. * Get if the texture can rescale.
  110128. */
  110129. get canRescale(): boolean;
  110130. /** @hidden */
  110131. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  110132. /** @hidden */
  110133. _rebuild(): void;
  110134. /**
  110135. * Triggers the load sequence in delayed load mode.
  110136. */
  110137. delayLoad(): void;
  110138. /**
  110139. * Clones the texture.
  110140. * @returns the cloned texture
  110141. */
  110142. clone(): Nullable<BaseTexture>;
  110143. /**
  110144. * Get the texture underlying type (INT, FLOAT...)
  110145. */
  110146. get textureType(): number;
  110147. /**
  110148. * Get the texture underlying format (RGB, RGBA...)
  110149. */
  110150. get textureFormat(): number;
  110151. /**
  110152. * Indicates that textures need to be re-calculated for all materials
  110153. */
  110154. protected _markAllSubMeshesAsTexturesDirty(): void;
  110155. /**
  110156. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  110157. * This will returns an RGBA array buffer containing either in values (0-255) or
  110158. * float values (0-1) depending of the underlying buffer type.
  110159. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  110160. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  110161. * @param buffer defines a user defined buffer to fill with data (can be null)
  110162. * @returns The Array buffer containing the pixels data.
  110163. */
  110164. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  110165. /**
  110166. * Release and destroy the underlying lower level texture aka internalTexture.
  110167. */
  110168. releaseInternalTexture(): void;
  110169. /** @hidden */
  110170. get _lodTextureHigh(): Nullable<BaseTexture>;
  110171. /** @hidden */
  110172. get _lodTextureMid(): Nullable<BaseTexture>;
  110173. /** @hidden */
  110174. get _lodTextureLow(): Nullable<BaseTexture>;
  110175. /**
  110176. * Dispose the texture and release its associated resources.
  110177. */
  110178. dispose(): void;
  110179. /**
  110180. * Serialize the texture into a JSON representation that can be parsed later on.
  110181. * @returns the JSON representation of the texture
  110182. */
  110183. serialize(): any;
  110184. /**
  110185. * Helper function to be called back once a list of texture contains only ready textures.
  110186. * @param textures Define the list of textures to wait for
  110187. * @param callback Define the callback triggered once the entire list will be ready
  110188. */
  110189. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  110190. private static _isScene;
  110191. }
  110192. }
  110193. declare module BABYLON {
  110194. /**
  110195. * Options to be used when creating an effect.
  110196. */
  110197. export interface IEffectCreationOptions {
  110198. /**
  110199. * Atrributes that will be used in the shader.
  110200. */
  110201. attributes: string[];
  110202. /**
  110203. * Uniform varible names that will be set in the shader.
  110204. */
  110205. uniformsNames: string[];
  110206. /**
  110207. * Uniform buffer variable names that will be set in the shader.
  110208. */
  110209. uniformBuffersNames: string[];
  110210. /**
  110211. * Sampler texture variable names that will be set in the shader.
  110212. */
  110213. samplers: string[];
  110214. /**
  110215. * Define statements that will be set in the shader.
  110216. */
  110217. defines: any;
  110218. /**
  110219. * Possible fallbacks for this effect to improve performance when needed.
  110220. */
  110221. fallbacks: Nullable<IEffectFallbacks>;
  110222. /**
  110223. * Callback that will be called when the shader is compiled.
  110224. */
  110225. onCompiled: Nullable<(effect: Effect) => void>;
  110226. /**
  110227. * Callback that will be called if an error occurs during shader compilation.
  110228. */
  110229. onError: Nullable<(effect: Effect, errors: string) => void>;
  110230. /**
  110231. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  110232. */
  110233. indexParameters?: any;
  110234. /**
  110235. * Max number of lights that can be used in the shader.
  110236. */
  110237. maxSimultaneousLights?: number;
  110238. /**
  110239. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  110240. */
  110241. transformFeedbackVaryings?: Nullable<string[]>;
  110242. /**
  110243. * 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
  110244. */
  110245. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  110246. }
  110247. /**
  110248. * Effect containing vertex and fragment shader that can be executed on an object.
  110249. */
  110250. export class Effect implements IDisposable {
  110251. /**
  110252. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  110253. */
  110254. static ShadersRepository: string;
  110255. /**
  110256. * Enable logging of the shader code when a compilation error occurs
  110257. */
  110258. static LogShaderCodeOnCompilationError: boolean;
  110259. /**
  110260. * Name of the effect.
  110261. */
  110262. name: any;
  110263. /**
  110264. * String container all the define statements that should be set on the shader.
  110265. */
  110266. defines: string;
  110267. /**
  110268. * Callback that will be called when the shader is compiled.
  110269. */
  110270. onCompiled: Nullable<(effect: Effect) => void>;
  110271. /**
  110272. * Callback that will be called if an error occurs during shader compilation.
  110273. */
  110274. onError: Nullable<(effect: Effect, errors: string) => void>;
  110275. /**
  110276. * Callback that will be called when effect is bound.
  110277. */
  110278. onBind: Nullable<(effect: Effect) => void>;
  110279. /**
  110280. * Unique ID of the effect.
  110281. */
  110282. uniqueId: number;
  110283. /**
  110284. * Observable that will be called when the shader is compiled.
  110285. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  110286. */
  110287. onCompileObservable: Observable<Effect>;
  110288. /**
  110289. * Observable that will be called if an error occurs during shader compilation.
  110290. */
  110291. onErrorObservable: Observable<Effect>;
  110292. /** @hidden */
  110293. _onBindObservable: Nullable<Observable<Effect>>;
  110294. /**
  110295. * @hidden
  110296. * Specifies if the effect was previously ready
  110297. */
  110298. _wasPreviouslyReady: boolean;
  110299. /**
  110300. * Observable that will be called when effect is bound.
  110301. */
  110302. get onBindObservable(): Observable<Effect>;
  110303. /** @hidden */
  110304. _bonesComputationForcedToCPU: boolean;
  110305. private static _uniqueIdSeed;
  110306. private _engine;
  110307. private _uniformBuffersNames;
  110308. private _uniformBuffersNamesList;
  110309. private _uniformsNames;
  110310. private _samplerList;
  110311. private _samplers;
  110312. private _isReady;
  110313. private _compilationError;
  110314. private _allFallbacksProcessed;
  110315. private _attributesNames;
  110316. private _attributes;
  110317. private _attributeLocationByName;
  110318. private _uniforms;
  110319. /**
  110320. * Key for the effect.
  110321. * @hidden
  110322. */
  110323. _key: string;
  110324. private _indexParameters;
  110325. private _fallbacks;
  110326. private _vertexSourceCode;
  110327. private _fragmentSourceCode;
  110328. private _vertexSourceCodeOverride;
  110329. private _fragmentSourceCodeOverride;
  110330. private _transformFeedbackVaryings;
  110331. /**
  110332. * Compiled shader to webGL program.
  110333. * @hidden
  110334. */
  110335. _pipelineContext: Nullable<IPipelineContext>;
  110336. private _valueCache;
  110337. private static _baseCache;
  110338. /**
  110339. * Instantiates an effect.
  110340. * An effect can be used to create/manage/execute vertex and fragment shaders.
  110341. * @param baseName Name of the effect.
  110342. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  110343. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  110344. * @param samplers List of sampler variables that will be passed to the shader.
  110345. * @param engine Engine to be used to render the effect
  110346. * @param defines Define statements to be added to the shader.
  110347. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  110348. * @param onCompiled Callback that will be called when the shader is compiled.
  110349. * @param onError Callback that will be called if an error occurs during shader compilation.
  110350. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  110351. */
  110352. 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);
  110353. private _useFinalCode;
  110354. /**
  110355. * Unique key for this effect
  110356. */
  110357. get key(): string;
  110358. /**
  110359. * If the effect has been compiled and prepared.
  110360. * @returns if the effect is compiled and prepared.
  110361. */
  110362. isReady(): boolean;
  110363. private _isReadyInternal;
  110364. /**
  110365. * The engine the effect was initialized with.
  110366. * @returns the engine.
  110367. */
  110368. getEngine(): Engine;
  110369. /**
  110370. * The pipeline context for this effect
  110371. * @returns the associated pipeline context
  110372. */
  110373. getPipelineContext(): Nullable<IPipelineContext>;
  110374. /**
  110375. * The set of names of attribute variables for the shader.
  110376. * @returns An array of attribute names.
  110377. */
  110378. getAttributesNames(): string[];
  110379. /**
  110380. * Returns the attribute at the given index.
  110381. * @param index The index of the attribute.
  110382. * @returns The location of the attribute.
  110383. */
  110384. getAttributeLocation(index: number): number;
  110385. /**
  110386. * Returns the attribute based on the name of the variable.
  110387. * @param name of the attribute to look up.
  110388. * @returns the attribute location.
  110389. */
  110390. getAttributeLocationByName(name: string): number;
  110391. /**
  110392. * The number of attributes.
  110393. * @returns the numnber of attributes.
  110394. */
  110395. getAttributesCount(): number;
  110396. /**
  110397. * Gets the index of a uniform variable.
  110398. * @param uniformName of the uniform to look up.
  110399. * @returns the index.
  110400. */
  110401. getUniformIndex(uniformName: string): number;
  110402. /**
  110403. * Returns the attribute based on the name of the variable.
  110404. * @param uniformName of the uniform to look up.
  110405. * @returns the location of the uniform.
  110406. */
  110407. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  110408. /**
  110409. * Returns an array of sampler variable names
  110410. * @returns The array of sampler variable names.
  110411. */
  110412. getSamplers(): string[];
  110413. /**
  110414. * Returns an array of uniform variable names
  110415. * @returns The array of uniform variable names.
  110416. */
  110417. getUniformNames(): string[];
  110418. /**
  110419. * Returns an array of uniform buffer variable names
  110420. * @returns The array of uniform buffer variable names.
  110421. */
  110422. getUniformBuffersNames(): string[];
  110423. /**
  110424. * Returns the index parameters used to create the effect
  110425. * @returns The index parameters object
  110426. */
  110427. getIndexParameters(): any;
  110428. /**
  110429. * The error from the last compilation.
  110430. * @returns the error string.
  110431. */
  110432. getCompilationError(): string;
  110433. /**
  110434. * Gets a boolean indicating that all fallbacks were used during compilation
  110435. * @returns true if all fallbacks were used
  110436. */
  110437. allFallbacksProcessed(): boolean;
  110438. /**
  110439. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  110440. * @param func The callback to be used.
  110441. */
  110442. executeWhenCompiled(func: (effect: Effect) => void): void;
  110443. private _checkIsReady;
  110444. private _loadShader;
  110445. /**
  110446. * Gets the vertex shader source code of this effect
  110447. */
  110448. get vertexSourceCode(): string;
  110449. /**
  110450. * Gets the fragment shader source code of this effect
  110451. */
  110452. get fragmentSourceCode(): string;
  110453. /**
  110454. * Recompiles the webGL program
  110455. * @param vertexSourceCode The source code for the vertex shader.
  110456. * @param fragmentSourceCode The source code for the fragment shader.
  110457. * @param onCompiled Callback called when completed.
  110458. * @param onError Callback called on error.
  110459. * @hidden
  110460. */
  110461. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  110462. /**
  110463. * Prepares the effect
  110464. * @hidden
  110465. */
  110466. _prepareEffect(): void;
  110467. private _getShaderCodeAndErrorLine;
  110468. private _processCompilationErrors;
  110469. /**
  110470. * Checks if the effect is supported. (Must be called after compilation)
  110471. */
  110472. get isSupported(): boolean;
  110473. /**
  110474. * Binds a texture to the engine to be used as output of the shader.
  110475. * @param channel Name of the output variable.
  110476. * @param texture Texture to bind.
  110477. * @hidden
  110478. */
  110479. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  110480. /**
  110481. * Sets a texture on the engine to be used in the shader.
  110482. * @param channel Name of the sampler variable.
  110483. * @param texture Texture to set.
  110484. */
  110485. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  110486. /**
  110487. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  110488. * @param channel Name of the sampler variable.
  110489. * @param texture Texture to set.
  110490. */
  110491. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  110492. /**
  110493. * Sets an array of textures on the engine to be used in the shader.
  110494. * @param channel Name of the variable.
  110495. * @param textures Textures to set.
  110496. */
  110497. setTextureArray(channel: string, textures: BaseTexture[]): void;
  110498. /**
  110499. * 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)
  110500. * @param channel Name of the sampler variable.
  110501. * @param postProcess Post process to get the input texture from.
  110502. */
  110503. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  110504. /**
  110505. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  110506. * 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)
  110507. * @param channel Name of the sampler variable.
  110508. * @param postProcess Post process to get the output texture from.
  110509. */
  110510. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  110511. /** @hidden */
  110512. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  110513. /** @hidden */
  110514. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  110515. /** @hidden */
  110516. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  110517. /** @hidden */
  110518. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  110519. /**
  110520. * Binds a buffer to a uniform.
  110521. * @param buffer Buffer to bind.
  110522. * @param name Name of the uniform variable to bind to.
  110523. */
  110524. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  110525. /**
  110526. * Binds block to a uniform.
  110527. * @param blockName Name of the block to bind.
  110528. * @param index Index to bind.
  110529. */
  110530. bindUniformBlock(blockName: string, index: number): void;
  110531. /**
  110532. * Sets an interger value on a uniform variable.
  110533. * @param uniformName Name of the variable.
  110534. * @param value Value to be set.
  110535. * @returns this effect.
  110536. */
  110537. setInt(uniformName: string, value: number): Effect;
  110538. /**
  110539. * Sets an int array on a uniform variable.
  110540. * @param uniformName Name of the variable.
  110541. * @param array array to be set.
  110542. * @returns this effect.
  110543. */
  110544. setIntArray(uniformName: string, array: Int32Array): Effect;
  110545. /**
  110546. * 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)
  110547. * @param uniformName Name of the variable.
  110548. * @param array array to be set.
  110549. * @returns this effect.
  110550. */
  110551. setIntArray2(uniformName: string, array: Int32Array): Effect;
  110552. /**
  110553. * 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)
  110554. * @param uniformName Name of the variable.
  110555. * @param array array to be set.
  110556. * @returns this effect.
  110557. */
  110558. setIntArray3(uniformName: string, array: Int32Array): Effect;
  110559. /**
  110560. * 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)
  110561. * @param uniformName Name of the variable.
  110562. * @param array array to be set.
  110563. * @returns this effect.
  110564. */
  110565. setIntArray4(uniformName: string, array: Int32Array): Effect;
  110566. /**
  110567. * Sets an float array on a uniform variable.
  110568. * @param uniformName Name of the variable.
  110569. * @param array array to be set.
  110570. * @returns this effect.
  110571. */
  110572. setFloatArray(uniformName: string, array: Float32Array): Effect;
  110573. /**
  110574. * 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)
  110575. * @param uniformName Name of the variable.
  110576. * @param array array to be set.
  110577. * @returns this effect.
  110578. */
  110579. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  110580. /**
  110581. * 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)
  110582. * @param uniformName Name of the variable.
  110583. * @param array array to be set.
  110584. * @returns this effect.
  110585. */
  110586. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  110587. /**
  110588. * 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)
  110589. * @param uniformName Name of the variable.
  110590. * @param array array to be set.
  110591. * @returns this effect.
  110592. */
  110593. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  110594. /**
  110595. * Sets an array on a uniform variable.
  110596. * @param uniformName Name of the variable.
  110597. * @param array array to be set.
  110598. * @returns this effect.
  110599. */
  110600. setArray(uniformName: string, array: number[]): Effect;
  110601. /**
  110602. * 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)
  110603. * @param uniformName Name of the variable.
  110604. * @param array array to be set.
  110605. * @returns this effect.
  110606. */
  110607. setArray2(uniformName: string, array: number[]): Effect;
  110608. /**
  110609. * 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)
  110610. * @param uniformName Name of the variable.
  110611. * @param array array to be set.
  110612. * @returns this effect.
  110613. */
  110614. setArray3(uniformName: string, array: number[]): Effect;
  110615. /**
  110616. * 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)
  110617. * @param uniformName Name of the variable.
  110618. * @param array array to be set.
  110619. * @returns this effect.
  110620. */
  110621. setArray4(uniformName: string, array: number[]): Effect;
  110622. /**
  110623. * Sets matrices on a uniform variable.
  110624. * @param uniformName Name of the variable.
  110625. * @param matrices matrices to be set.
  110626. * @returns this effect.
  110627. */
  110628. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  110629. /**
  110630. * Sets matrix on a uniform variable.
  110631. * @param uniformName Name of the variable.
  110632. * @param matrix matrix to be set.
  110633. * @returns this effect.
  110634. */
  110635. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  110636. /**
  110637. * 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)
  110638. * @param uniformName Name of the variable.
  110639. * @param matrix matrix to be set.
  110640. * @returns this effect.
  110641. */
  110642. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  110643. /**
  110644. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  110645. * @param uniformName Name of the variable.
  110646. * @param matrix matrix to be set.
  110647. * @returns this effect.
  110648. */
  110649. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  110650. /**
  110651. * Sets a float on a uniform variable.
  110652. * @param uniformName Name of the variable.
  110653. * @param value value to be set.
  110654. * @returns this effect.
  110655. */
  110656. setFloat(uniformName: string, value: number): Effect;
  110657. /**
  110658. * Sets a boolean on a uniform variable.
  110659. * @param uniformName Name of the variable.
  110660. * @param bool value to be set.
  110661. * @returns this effect.
  110662. */
  110663. setBool(uniformName: string, bool: boolean): Effect;
  110664. /**
  110665. * Sets a Vector2 on a uniform variable.
  110666. * @param uniformName Name of the variable.
  110667. * @param vector2 vector2 to be set.
  110668. * @returns this effect.
  110669. */
  110670. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  110671. /**
  110672. * Sets a float2 on a uniform variable.
  110673. * @param uniformName Name of the variable.
  110674. * @param x First float in float2.
  110675. * @param y Second float in float2.
  110676. * @returns this effect.
  110677. */
  110678. setFloat2(uniformName: string, x: number, y: number): Effect;
  110679. /**
  110680. * Sets a Vector3 on a uniform variable.
  110681. * @param uniformName Name of the variable.
  110682. * @param vector3 Value to be set.
  110683. * @returns this effect.
  110684. */
  110685. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  110686. /**
  110687. * Sets a float3 on a uniform variable.
  110688. * @param uniformName Name of the variable.
  110689. * @param x First float in float3.
  110690. * @param y Second float in float3.
  110691. * @param z Third float in float3.
  110692. * @returns this effect.
  110693. */
  110694. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  110695. /**
  110696. * Sets a Vector4 on a uniform variable.
  110697. * @param uniformName Name of the variable.
  110698. * @param vector4 Value to be set.
  110699. * @returns this effect.
  110700. */
  110701. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  110702. /**
  110703. * Sets a float4 on a uniform variable.
  110704. * @param uniformName Name of the variable.
  110705. * @param x First float in float4.
  110706. * @param y Second float in float4.
  110707. * @param z Third float in float4.
  110708. * @param w Fourth float in float4.
  110709. * @returns this effect.
  110710. */
  110711. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  110712. /**
  110713. * Sets a Color3 on a uniform variable.
  110714. * @param uniformName Name of the variable.
  110715. * @param color3 Value to be set.
  110716. * @returns this effect.
  110717. */
  110718. setColor3(uniformName: string, color3: IColor3Like): Effect;
  110719. /**
  110720. * Sets a Color4 on a uniform variable.
  110721. * @param uniformName Name of the variable.
  110722. * @param color3 Value to be set.
  110723. * @param alpha Alpha value to be set.
  110724. * @returns this effect.
  110725. */
  110726. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  110727. /**
  110728. * Sets a Color4 on a uniform variable
  110729. * @param uniformName defines the name of the variable
  110730. * @param color4 defines the value to be set
  110731. * @returns this effect.
  110732. */
  110733. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  110734. /** Release all associated resources */
  110735. dispose(): void;
  110736. /**
  110737. * This function will add a new shader to the shader store
  110738. * @param name the name of the shader
  110739. * @param pixelShader optional pixel shader content
  110740. * @param vertexShader optional vertex shader content
  110741. */
  110742. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  110743. /**
  110744. * Store of each shader (The can be looked up using effect.key)
  110745. */
  110746. static ShadersStore: {
  110747. [key: string]: string;
  110748. };
  110749. /**
  110750. * Store of each included file for a shader (The can be looked up using effect.key)
  110751. */
  110752. static IncludesShadersStore: {
  110753. [key: string]: string;
  110754. };
  110755. /**
  110756. * Resets the cache of effects.
  110757. */
  110758. static ResetCache(): void;
  110759. }
  110760. }
  110761. declare module BABYLON {
  110762. /**
  110763. * Interface used to describe the capabilities of the engine relatively to the current browser
  110764. */
  110765. export interface EngineCapabilities {
  110766. /** Maximum textures units per fragment shader */
  110767. maxTexturesImageUnits: number;
  110768. /** Maximum texture units per vertex shader */
  110769. maxVertexTextureImageUnits: number;
  110770. /** Maximum textures units in the entire pipeline */
  110771. maxCombinedTexturesImageUnits: number;
  110772. /** Maximum texture size */
  110773. maxTextureSize: number;
  110774. /** Maximum texture samples */
  110775. maxSamples?: number;
  110776. /** Maximum cube texture size */
  110777. maxCubemapTextureSize: number;
  110778. /** Maximum render texture size */
  110779. maxRenderTextureSize: number;
  110780. /** Maximum number of vertex attributes */
  110781. maxVertexAttribs: number;
  110782. /** Maximum number of varyings */
  110783. maxVaryingVectors: number;
  110784. /** Maximum number of uniforms per vertex shader */
  110785. maxVertexUniformVectors: number;
  110786. /** Maximum number of uniforms per fragment shader */
  110787. maxFragmentUniformVectors: number;
  110788. /** Defines if standard derivates (dx/dy) are supported */
  110789. standardDerivatives: boolean;
  110790. /** Defines if s3tc texture compression is supported */
  110791. s3tc?: WEBGL_compressed_texture_s3tc;
  110792. /** Defines if pvrtc texture compression is supported */
  110793. pvrtc: any;
  110794. /** Defines if etc1 texture compression is supported */
  110795. etc1: any;
  110796. /** Defines if etc2 texture compression is supported */
  110797. etc2: any;
  110798. /** Defines if astc texture compression is supported */
  110799. astc: any;
  110800. /** Defines if float textures are supported */
  110801. textureFloat: boolean;
  110802. /** Defines if vertex array objects are supported */
  110803. vertexArrayObject: boolean;
  110804. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  110805. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  110806. /** Gets the maximum level of anisotropy supported */
  110807. maxAnisotropy: number;
  110808. /** Defines if instancing is supported */
  110809. instancedArrays: boolean;
  110810. /** Defines if 32 bits indices are supported */
  110811. uintIndices: boolean;
  110812. /** Defines if high precision shaders are supported */
  110813. highPrecisionShaderSupported: boolean;
  110814. /** Defines if depth reading in the fragment shader is supported */
  110815. fragmentDepthSupported: boolean;
  110816. /** Defines if float texture linear filtering is supported*/
  110817. textureFloatLinearFiltering: boolean;
  110818. /** Defines if rendering to float textures is supported */
  110819. textureFloatRender: boolean;
  110820. /** Defines if half float textures are supported*/
  110821. textureHalfFloat: boolean;
  110822. /** Defines if half float texture linear filtering is supported*/
  110823. textureHalfFloatLinearFiltering: boolean;
  110824. /** Defines if rendering to half float textures is supported */
  110825. textureHalfFloatRender: boolean;
  110826. /** Defines if textureLOD shader command is supported */
  110827. textureLOD: boolean;
  110828. /** Defines if draw buffers extension is supported */
  110829. drawBuffersExtension: boolean;
  110830. /** Defines if depth textures are supported */
  110831. depthTextureExtension: boolean;
  110832. /** Defines if float color buffer are supported */
  110833. colorBufferFloat: boolean;
  110834. /** Gets disjoint timer query extension (null if not supported) */
  110835. timerQuery?: EXT_disjoint_timer_query;
  110836. /** Defines if timestamp can be used with timer query */
  110837. canUseTimestampForTimerQuery: boolean;
  110838. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  110839. multiview?: any;
  110840. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  110841. oculusMultiview?: any;
  110842. /** Function used to let the system compiles shaders in background */
  110843. parallelShaderCompile?: {
  110844. COMPLETION_STATUS_KHR: number;
  110845. };
  110846. /** Max number of texture samples for MSAA */
  110847. maxMSAASamples: number;
  110848. /** Defines if the blend min max extension is supported */
  110849. blendMinMax: boolean;
  110850. }
  110851. }
  110852. declare module BABYLON {
  110853. /**
  110854. * @hidden
  110855. **/
  110856. export class DepthCullingState {
  110857. private _isDepthTestDirty;
  110858. private _isDepthMaskDirty;
  110859. private _isDepthFuncDirty;
  110860. private _isCullFaceDirty;
  110861. private _isCullDirty;
  110862. private _isZOffsetDirty;
  110863. private _isFrontFaceDirty;
  110864. private _depthTest;
  110865. private _depthMask;
  110866. private _depthFunc;
  110867. private _cull;
  110868. private _cullFace;
  110869. private _zOffset;
  110870. private _frontFace;
  110871. /**
  110872. * Initializes the state.
  110873. */
  110874. constructor();
  110875. get isDirty(): boolean;
  110876. get zOffset(): number;
  110877. set zOffset(value: number);
  110878. get cullFace(): Nullable<number>;
  110879. set cullFace(value: Nullable<number>);
  110880. get cull(): Nullable<boolean>;
  110881. set cull(value: Nullable<boolean>);
  110882. get depthFunc(): Nullable<number>;
  110883. set depthFunc(value: Nullable<number>);
  110884. get depthMask(): boolean;
  110885. set depthMask(value: boolean);
  110886. get depthTest(): boolean;
  110887. set depthTest(value: boolean);
  110888. get frontFace(): Nullable<number>;
  110889. set frontFace(value: Nullable<number>);
  110890. reset(): void;
  110891. apply(gl: WebGLRenderingContext): void;
  110892. }
  110893. }
  110894. declare module BABYLON {
  110895. /**
  110896. * @hidden
  110897. **/
  110898. export class StencilState {
  110899. /** 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 */
  110900. static readonly ALWAYS: number;
  110901. /** Passed to stencilOperation to specify that stencil value must be kept */
  110902. static readonly KEEP: number;
  110903. /** Passed to stencilOperation to specify that stencil value must be replaced */
  110904. static readonly REPLACE: number;
  110905. private _isStencilTestDirty;
  110906. private _isStencilMaskDirty;
  110907. private _isStencilFuncDirty;
  110908. private _isStencilOpDirty;
  110909. private _stencilTest;
  110910. private _stencilMask;
  110911. private _stencilFunc;
  110912. private _stencilFuncRef;
  110913. private _stencilFuncMask;
  110914. private _stencilOpStencilFail;
  110915. private _stencilOpDepthFail;
  110916. private _stencilOpStencilDepthPass;
  110917. get isDirty(): boolean;
  110918. get stencilFunc(): number;
  110919. set stencilFunc(value: number);
  110920. get stencilFuncRef(): number;
  110921. set stencilFuncRef(value: number);
  110922. get stencilFuncMask(): number;
  110923. set stencilFuncMask(value: number);
  110924. get stencilOpStencilFail(): number;
  110925. set stencilOpStencilFail(value: number);
  110926. get stencilOpDepthFail(): number;
  110927. set stencilOpDepthFail(value: number);
  110928. get stencilOpStencilDepthPass(): number;
  110929. set stencilOpStencilDepthPass(value: number);
  110930. get stencilMask(): number;
  110931. set stencilMask(value: number);
  110932. get stencilTest(): boolean;
  110933. set stencilTest(value: boolean);
  110934. constructor();
  110935. reset(): void;
  110936. apply(gl: WebGLRenderingContext): void;
  110937. }
  110938. }
  110939. declare module BABYLON {
  110940. /**
  110941. * @hidden
  110942. **/
  110943. export class AlphaState {
  110944. private _isAlphaBlendDirty;
  110945. private _isBlendFunctionParametersDirty;
  110946. private _isBlendEquationParametersDirty;
  110947. private _isBlendConstantsDirty;
  110948. private _alphaBlend;
  110949. private _blendFunctionParameters;
  110950. private _blendEquationParameters;
  110951. private _blendConstants;
  110952. /**
  110953. * Initializes the state.
  110954. */
  110955. constructor();
  110956. get isDirty(): boolean;
  110957. get alphaBlend(): boolean;
  110958. set alphaBlend(value: boolean);
  110959. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  110960. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  110961. setAlphaEquationParameters(rgb: number, alpha: number): void;
  110962. reset(): void;
  110963. apply(gl: WebGLRenderingContext): void;
  110964. }
  110965. }
  110966. declare module BABYLON {
  110967. /** @hidden */
  110968. export class WebGL2ShaderProcessor implements IShaderProcessor {
  110969. attributeProcessor(attribute: string): string;
  110970. varyingProcessor(varying: string, isFragment: boolean): string;
  110971. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  110972. }
  110973. }
  110974. declare module BABYLON {
  110975. /**
  110976. * Interface for attribute information associated with buffer instanciation
  110977. */
  110978. export interface InstancingAttributeInfo {
  110979. /**
  110980. * Name of the GLSL attribute
  110981. * if attribute index is not specified, this is used to retrieve the index from the effect
  110982. */
  110983. attributeName: string;
  110984. /**
  110985. * Index/offset of the attribute in the vertex shader
  110986. * if not specified, this will be computes from the name.
  110987. */
  110988. index?: number;
  110989. /**
  110990. * size of the attribute, 1, 2, 3 or 4
  110991. */
  110992. attributeSize: number;
  110993. /**
  110994. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  110995. */
  110996. offset: number;
  110997. /**
  110998. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  110999. * default to 1
  111000. */
  111001. divisor?: number;
  111002. /**
  111003. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  111004. * default is FLOAT
  111005. */
  111006. attributeType?: number;
  111007. /**
  111008. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  111009. */
  111010. normalized?: boolean;
  111011. }
  111012. }
  111013. declare module BABYLON {
  111014. interface ThinEngine {
  111015. /**
  111016. * Update a video texture
  111017. * @param texture defines the texture to update
  111018. * @param video defines the video element to use
  111019. * @param invertY defines if data must be stored with Y axis inverted
  111020. */
  111021. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  111022. }
  111023. }
  111024. declare module BABYLON {
  111025. /**
  111026. * Settings for finer control over video usage
  111027. */
  111028. export interface VideoTextureSettings {
  111029. /**
  111030. * Applies `autoplay` to video, if specified
  111031. */
  111032. autoPlay?: boolean;
  111033. /**
  111034. * Applies `loop` to video, if specified
  111035. */
  111036. loop?: boolean;
  111037. /**
  111038. * Automatically updates internal texture from video at every frame in the render loop
  111039. */
  111040. autoUpdateTexture: boolean;
  111041. /**
  111042. * Image src displayed during the video loading or until the user interacts with the video.
  111043. */
  111044. poster?: string;
  111045. }
  111046. /**
  111047. * If you want to display a video in your scene, this is the special texture for that.
  111048. * This special texture works similar to other textures, with the exception of a few parameters.
  111049. * @see https://doc.babylonjs.com/how_to/video_texture
  111050. */
  111051. export class VideoTexture extends Texture {
  111052. /**
  111053. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  111054. */
  111055. readonly autoUpdateTexture: boolean;
  111056. /**
  111057. * The video instance used by the texture internally
  111058. */
  111059. readonly video: HTMLVideoElement;
  111060. private _onUserActionRequestedObservable;
  111061. /**
  111062. * Event triggerd when a dom action is required by the user to play the video.
  111063. * This happens due to recent changes in browser policies preventing video to auto start.
  111064. */
  111065. get onUserActionRequestedObservable(): Observable<Texture>;
  111066. private _generateMipMaps;
  111067. private _stillImageCaptured;
  111068. private _displayingPosterTexture;
  111069. private _settings;
  111070. private _createInternalTextureOnEvent;
  111071. private _frameId;
  111072. private _currentSrc;
  111073. /**
  111074. * Creates a video texture.
  111075. * If you want to display a video in your scene, this is the special texture for that.
  111076. * This special texture works similar to other textures, with the exception of a few parameters.
  111077. * @see https://doc.babylonjs.com/how_to/video_texture
  111078. * @param name optional name, will detect from video source, if not defined
  111079. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  111080. * @param scene is obviously the current scene.
  111081. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  111082. * @param invertY is false by default but can be used to invert video on Y axis
  111083. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  111084. * @param settings allows finer control over video usage
  111085. */
  111086. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  111087. private _getName;
  111088. private _getVideo;
  111089. private _createInternalTexture;
  111090. private reset;
  111091. /**
  111092. * @hidden Internal method to initiate `update`.
  111093. */
  111094. _rebuild(): void;
  111095. /**
  111096. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  111097. */
  111098. update(): void;
  111099. /**
  111100. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  111101. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  111102. */
  111103. updateTexture(isVisible: boolean): void;
  111104. protected _updateInternalTexture: () => void;
  111105. /**
  111106. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  111107. * @param url New url.
  111108. */
  111109. updateURL(url: string): void;
  111110. /**
  111111. * Clones the texture.
  111112. * @returns the cloned texture
  111113. */
  111114. clone(): VideoTexture;
  111115. /**
  111116. * Dispose the texture and release its associated resources.
  111117. */
  111118. dispose(): void;
  111119. /**
  111120. * Creates a video texture straight from a stream.
  111121. * @param scene Define the scene the texture should be created in
  111122. * @param stream Define the stream the texture should be created from
  111123. * @returns The created video texture as a promise
  111124. */
  111125. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  111126. /**
  111127. * Creates a video texture straight from your WebCam video feed.
  111128. * @param scene Define the scene the texture should be created in
  111129. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  111130. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  111131. * @returns The created video texture as a promise
  111132. */
  111133. static CreateFromWebCamAsync(scene: Scene, constraints: {
  111134. minWidth: number;
  111135. maxWidth: number;
  111136. minHeight: number;
  111137. maxHeight: number;
  111138. deviceId: string;
  111139. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  111140. /**
  111141. * Creates a video texture straight from your WebCam video feed.
  111142. * @param scene Define the scene the texture should be created in
  111143. * @param onReady Define a callback to triggered once the texture will be ready
  111144. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  111145. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  111146. */
  111147. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  111148. minWidth: number;
  111149. maxWidth: number;
  111150. minHeight: number;
  111151. maxHeight: number;
  111152. deviceId: string;
  111153. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  111154. }
  111155. }
  111156. declare module BABYLON {
  111157. /**
  111158. * Defines the interface used by objects working like Scene
  111159. * @hidden
  111160. */
  111161. export interface ISceneLike {
  111162. _addPendingData(data: any): void;
  111163. _removePendingData(data: any): void;
  111164. offlineProvider: IOfflineProvider;
  111165. }
  111166. /** Interface defining initialization parameters for Engine class */
  111167. export interface EngineOptions extends WebGLContextAttributes {
  111168. /**
  111169. * Defines if the engine should no exceed a specified device ratio
  111170. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  111171. */
  111172. limitDeviceRatio?: number;
  111173. /**
  111174. * Defines if webvr should be enabled automatically
  111175. * @see http://doc.babylonjs.com/how_to/webvr_camera
  111176. */
  111177. autoEnableWebVR?: boolean;
  111178. /**
  111179. * Defines if webgl2 should be turned off even if supported
  111180. * @see http://doc.babylonjs.com/features/webgl2
  111181. */
  111182. disableWebGL2Support?: boolean;
  111183. /**
  111184. * Defines if webaudio should be initialized as well
  111185. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  111186. */
  111187. audioEngine?: boolean;
  111188. /**
  111189. * Defines if animations should run using a deterministic lock step
  111190. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  111191. */
  111192. deterministicLockstep?: boolean;
  111193. /** Defines the maximum steps to use with deterministic lock step mode */
  111194. lockstepMaxSteps?: number;
  111195. /** Defines the seconds between each deterministic lock step */
  111196. timeStep?: number;
  111197. /**
  111198. * Defines that engine should ignore context lost events
  111199. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  111200. */
  111201. doNotHandleContextLost?: boolean;
  111202. /**
  111203. * Defines that engine should ignore modifying touch action attribute and style
  111204. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  111205. */
  111206. doNotHandleTouchAction?: boolean;
  111207. /**
  111208. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  111209. */
  111210. useHighPrecisionFloats?: boolean;
  111211. }
  111212. /**
  111213. * The base engine class (root of all engines)
  111214. */
  111215. export class ThinEngine {
  111216. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  111217. static ExceptionList: ({
  111218. key: string;
  111219. capture: string;
  111220. captureConstraint: number;
  111221. targets: string[];
  111222. } | {
  111223. key: string;
  111224. capture: null;
  111225. captureConstraint: null;
  111226. targets: string[];
  111227. })[];
  111228. /** @hidden */
  111229. static _TextureLoaders: IInternalTextureLoader[];
  111230. /**
  111231. * Returns the current npm package of the sdk
  111232. */
  111233. static get NpmPackage(): string;
  111234. /**
  111235. * Returns the current version of the framework
  111236. */
  111237. static get Version(): string;
  111238. /**
  111239. * Returns a string describing the current engine
  111240. */
  111241. get description(): string;
  111242. /**
  111243. * Gets or sets the epsilon value used by collision engine
  111244. */
  111245. static CollisionsEpsilon: number;
  111246. /**
  111247. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  111248. */
  111249. static get ShadersRepository(): string;
  111250. static set ShadersRepository(value: string);
  111251. /** @hidden */
  111252. _shaderProcessor: IShaderProcessor;
  111253. /**
  111254. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  111255. */
  111256. forcePOTTextures: boolean;
  111257. /**
  111258. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  111259. */
  111260. isFullscreen: boolean;
  111261. /**
  111262. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  111263. */
  111264. cullBackFaces: boolean;
  111265. /**
  111266. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  111267. */
  111268. renderEvenInBackground: boolean;
  111269. /**
  111270. * Gets or sets a boolean indicating that cache can be kept between frames
  111271. */
  111272. preventCacheWipeBetweenFrames: boolean;
  111273. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  111274. validateShaderPrograms: boolean;
  111275. /**
  111276. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  111277. * This can provide greater z depth for distant objects.
  111278. */
  111279. useReverseDepthBuffer: boolean;
  111280. /**
  111281. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  111282. */
  111283. disableUniformBuffers: boolean;
  111284. /** @hidden */
  111285. _uniformBuffers: UniformBuffer[];
  111286. /**
  111287. * Gets a boolean indicating that the engine supports uniform buffers
  111288. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  111289. */
  111290. get supportsUniformBuffers(): boolean;
  111291. /** @hidden */
  111292. _gl: WebGLRenderingContext;
  111293. /** @hidden */
  111294. _webGLVersion: number;
  111295. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  111296. protected _windowIsBackground: boolean;
  111297. protected _creationOptions: EngineOptions;
  111298. protected _highPrecisionShadersAllowed: boolean;
  111299. /** @hidden */
  111300. get _shouldUseHighPrecisionShader(): boolean;
  111301. /**
  111302. * Gets a boolean indicating that only power of 2 textures are supported
  111303. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  111304. */
  111305. get needPOTTextures(): boolean;
  111306. /** @hidden */
  111307. _badOS: boolean;
  111308. /** @hidden */
  111309. _badDesktopOS: boolean;
  111310. private _hardwareScalingLevel;
  111311. /** @hidden */
  111312. _caps: EngineCapabilities;
  111313. private _isStencilEnable;
  111314. private _glVersion;
  111315. private _glRenderer;
  111316. private _glVendor;
  111317. /** @hidden */
  111318. _videoTextureSupported: boolean;
  111319. protected _renderingQueueLaunched: boolean;
  111320. protected _activeRenderLoops: (() => void)[];
  111321. /**
  111322. * Observable signaled when a context lost event is raised
  111323. */
  111324. onContextLostObservable: Observable<ThinEngine>;
  111325. /**
  111326. * Observable signaled when a context restored event is raised
  111327. */
  111328. onContextRestoredObservable: Observable<ThinEngine>;
  111329. private _onContextLost;
  111330. private _onContextRestored;
  111331. protected _contextWasLost: boolean;
  111332. /** @hidden */
  111333. _doNotHandleContextLost: boolean;
  111334. /**
  111335. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  111336. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  111337. */
  111338. get doNotHandleContextLost(): boolean;
  111339. set doNotHandleContextLost(value: boolean);
  111340. /**
  111341. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  111342. */
  111343. disableVertexArrayObjects: boolean;
  111344. /** @hidden */
  111345. protected _colorWrite: boolean;
  111346. /** @hidden */
  111347. protected _colorWriteChanged: boolean;
  111348. /** @hidden */
  111349. protected _depthCullingState: DepthCullingState;
  111350. /** @hidden */
  111351. protected _stencilState: StencilState;
  111352. /** @hidden */
  111353. _alphaState: AlphaState;
  111354. /** @hidden */
  111355. _alphaMode: number;
  111356. /** @hidden */
  111357. _alphaEquation: number;
  111358. /** @hidden */
  111359. _internalTexturesCache: InternalTexture[];
  111360. /** @hidden */
  111361. protected _activeChannel: number;
  111362. private _currentTextureChannel;
  111363. /** @hidden */
  111364. protected _boundTexturesCache: {
  111365. [key: string]: Nullable<InternalTexture>;
  111366. };
  111367. /** @hidden */
  111368. protected _currentEffect: Nullable<Effect>;
  111369. /** @hidden */
  111370. protected _currentProgram: Nullable<WebGLProgram>;
  111371. private _compiledEffects;
  111372. private _vertexAttribArraysEnabled;
  111373. /** @hidden */
  111374. protected _cachedViewport: Nullable<IViewportLike>;
  111375. private _cachedVertexArrayObject;
  111376. /** @hidden */
  111377. protected _cachedVertexBuffers: any;
  111378. /** @hidden */
  111379. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  111380. /** @hidden */
  111381. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  111382. /** @hidden */
  111383. _currentRenderTarget: Nullable<InternalTexture>;
  111384. private _uintIndicesCurrentlySet;
  111385. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  111386. /** @hidden */
  111387. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  111388. /** @hidden */
  111389. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  111390. private _currentBufferPointers;
  111391. private _currentInstanceLocations;
  111392. private _currentInstanceBuffers;
  111393. private _textureUnits;
  111394. /** @hidden */
  111395. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  111396. /** @hidden */
  111397. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  111398. /** @hidden */
  111399. _boundRenderFunction: any;
  111400. private _vaoRecordInProgress;
  111401. private _mustWipeVertexAttributes;
  111402. private _emptyTexture;
  111403. private _emptyCubeTexture;
  111404. private _emptyTexture3D;
  111405. private _emptyTexture2DArray;
  111406. /** @hidden */
  111407. _frameHandler: number;
  111408. private _nextFreeTextureSlots;
  111409. private _maxSimultaneousTextures;
  111410. private _activeRequests;
  111411. /** @hidden */
  111412. _transformTextureUrl: Nullable<(url: string) => string>;
  111413. protected get _supportsHardwareTextureRescaling(): boolean;
  111414. private _framebufferDimensionsObject;
  111415. /**
  111416. * sets the object from which width and height will be taken from when getting render width and height
  111417. * Will fallback to the gl object
  111418. * @param dimensions the framebuffer width and height that will be used.
  111419. */
  111420. set framebufferDimensionsObject(dimensions: Nullable<{
  111421. framebufferWidth: number;
  111422. framebufferHeight: number;
  111423. }>);
  111424. /**
  111425. * Gets the current viewport
  111426. */
  111427. get currentViewport(): Nullable<IViewportLike>;
  111428. /**
  111429. * Gets the default empty texture
  111430. */
  111431. get emptyTexture(): InternalTexture;
  111432. /**
  111433. * Gets the default empty 3D texture
  111434. */
  111435. get emptyTexture3D(): InternalTexture;
  111436. /**
  111437. * Gets the default empty 2D array texture
  111438. */
  111439. get emptyTexture2DArray(): InternalTexture;
  111440. /**
  111441. * Gets the default empty cube texture
  111442. */
  111443. get emptyCubeTexture(): InternalTexture;
  111444. /**
  111445. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  111446. */
  111447. readonly premultipliedAlpha: boolean;
  111448. /**
  111449. * Observable event triggered before each texture is initialized
  111450. */
  111451. onBeforeTextureInitObservable: Observable<Texture>;
  111452. /**
  111453. * Creates a new engine
  111454. * @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
  111455. * @param antialias defines enable antialiasing (default: false)
  111456. * @param options defines further options to be sent to the getContext() function
  111457. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  111458. */
  111459. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  111460. private _rebuildInternalTextures;
  111461. private _rebuildEffects;
  111462. /**
  111463. * Gets a boolean indicating if all created effects are ready
  111464. * @returns true if all effects are ready
  111465. */
  111466. areAllEffectsReady(): boolean;
  111467. protected _rebuildBuffers(): void;
  111468. protected _initGLContext(): void;
  111469. /**
  111470. * Gets version of the current webGL context
  111471. */
  111472. get webGLVersion(): number;
  111473. /**
  111474. * Gets a string idenfifying the name of the class
  111475. * @returns "Engine" string
  111476. */
  111477. getClassName(): string;
  111478. /**
  111479. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  111480. */
  111481. get isStencilEnable(): boolean;
  111482. /** @hidden */
  111483. _prepareWorkingCanvas(): void;
  111484. /**
  111485. * Reset the texture cache to empty state
  111486. */
  111487. resetTextureCache(): void;
  111488. /**
  111489. * Gets an object containing information about the current webGL context
  111490. * @returns an object containing the vender, the renderer and the version of the current webGL context
  111491. */
  111492. getGlInfo(): {
  111493. vendor: string;
  111494. renderer: string;
  111495. version: string;
  111496. };
  111497. /**
  111498. * Defines the hardware scaling level.
  111499. * By default the hardware scaling level is computed from the window device ratio.
  111500. * 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.
  111501. * @param level defines the level to use
  111502. */
  111503. setHardwareScalingLevel(level: number): void;
  111504. /**
  111505. * Gets the current hardware scaling level.
  111506. * By default the hardware scaling level is computed from the window device ratio.
  111507. * 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.
  111508. * @returns a number indicating the current hardware scaling level
  111509. */
  111510. getHardwareScalingLevel(): number;
  111511. /**
  111512. * Gets the list of loaded textures
  111513. * @returns an array containing all loaded textures
  111514. */
  111515. getLoadedTexturesCache(): InternalTexture[];
  111516. /**
  111517. * Gets the object containing all engine capabilities
  111518. * @returns the EngineCapabilities object
  111519. */
  111520. getCaps(): EngineCapabilities;
  111521. /**
  111522. * stop executing a render loop function and remove it from the execution array
  111523. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  111524. */
  111525. stopRenderLoop(renderFunction?: () => void): void;
  111526. /** @hidden */
  111527. _renderLoop(): void;
  111528. /**
  111529. * Gets the HTML canvas attached with the current webGL context
  111530. * @returns a HTML canvas
  111531. */
  111532. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  111533. /**
  111534. * Gets host window
  111535. * @returns the host window object
  111536. */
  111537. getHostWindow(): Nullable<Window>;
  111538. /**
  111539. * Gets the current render width
  111540. * @param useScreen defines if screen size must be used (or the current render target if any)
  111541. * @returns a number defining the current render width
  111542. */
  111543. getRenderWidth(useScreen?: boolean): number;
  111544. /**
  111545. * Gets the current render height
  111546. * @param useScreen defines if screen size must be used (or the current render target if any)
  111547. * @returns a number defining the current render height
  111548. */
  111549. getRenderHeight(useScreen?: boolean): number;
  111550. /**
  111551. * Can be used to override the current requestAnimationFrame requester.
  111552. * @hidden
  111553. */
  111554. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  111555. /**
  111556. * Register and execute a render loop. The engine can have more than one render function
  111557. * @param renderFunction defines the function to continuously execute
  111558. */
  111559. runRenderLoop(renderFunction: () => void): void;
  111560. /**
  111561. * Clear the current render buffer or the current render target (if any is set up)
  111562. * @param color defines the color to use
  111563. * @param backBuffer defines if the back buffer must be cleared
  111564. * @param depth defines if the depth buffer must be cleared
  111565. * @param stencil defines if the stencil buffer must be cleared
  111566. */
  111567. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  111568. private _viewportCached;
  111569. /** @hidden */
  111570. _viewport(x: number, y: number, width: number, height: number): void;
  111571. /**
  111572. * Set the WebGL's viewport
  111573. * @param viewport defines the viewport element to be used
  111574. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  111575. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  111576. */
  111577. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  111578. /**
  111579. * Begin a new frame
  111580. */
  111581. beginFrame(): void;
  111582. /**
  111583. * Enf the current frame
  111584. */
  111585. endFrame(): void;
  111586. /**
  111587. * Resize the view according to the canvas' size
  111588. */
  111589. resize(): void;
  111590. /**
  111591. * Force a specific size of the canvas
  111592. * @param width defines the new canvas' width
  111593. * @param height defines the new canvas' height
  111594. */
  111595. setSize(width: number, height: number): void;
  111596. /**
  111597. * Binds the frame buffer to the specified texture.
  111598. * @param texture The texture to render to or null for the default canvas
  111599. * @param faceIndex The face of the texture to render to in case of cube texture
  111600. * @param requiredWidth The width of the target to render to
  111601. * @param requiredHeight The height of the target to render to
  111602. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  111603. * @param lodLevel defines the lod level to bind to the frame buffer
  111604. * @param layer defines the 2d array index to bind to frame buffer to
  111605. */
  111606. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  111607. /** @hidden */
  111608. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  111609. /**
  111610. * Unbind the current render target texture from the webGL context
  111611. * @param texture defines the render target texture to unbind
  111612. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  111613. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  111614. */
  111615. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  111616. /**
  111617. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  111618. */
  111619. flushFramebuffer(): void;
  111620. /**
  111621. * Unbind the current render target and bind the default framebuffer
  111622. */
  111623. restoreDefaultFramebuffer(): void;
  111624. /** @hidden */
  111625. protected _resetVertexBufferBinding(): void;
  111626. /**
  111627. * Creates a vertex buffer
  111628. * @param data the data for the vertex buffer
  111629. * @returns the new WebGL static buffer
  111630. */
  111631. createVertexBuffer(data: DataArray): DataBuffer;
  111632. private _createVertexBuffer;
  111633. /**
  111634. * Creates a dynamic vertex buffer
  111635. * @param data the data for the dynamic vertex buffer
  111636. * @returns the new WebGL dynamic buffer
  111637. */
  111638. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  111639. protected _resetIndexBufferBinding(): void;
  111640. /**
  111641. * Creates a new index buffer
  111642. * @param indices defines the content of the index buffer
  111643. * @param updatable defines if the index buffer must be updatable
  111644. * @returns a new webGL buffer
  111645. */
  111646. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  111647. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  111648. /**
  111649. * Bind a webGL buffer to the webGL context
  111650. * @param buffer defines the buffer to bind
  111651. */
  111652. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  111653. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  111654. private bindBuffer;
  111655. /**
  111656. * update the bound buffer with the given data
  111657. * @param data defines the data to update
  111658. */
  111659. updateArrayBuffer(data: Float32Array): void;
  111660. private _vertexAttribPointer;
  111661. /** @hidden */
  111662. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  111663. private _bindVertexBuffersAttributes;
  111664. /**
  111665. * Records a vertex array object
  111666. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  111667. * @param vertexBuffers defines the list of vertex buffers to store
  111668. * @param indexBuffer defines the index buffer to store
  111669. * @param effect defines the effect to store
  111670. * @returns the new vertex array object
  111671. */
  111672. recordVertexArrayObject(vertexBuffers: {
  111673. [key: string]: VertexBuffer;
  111674. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  111675. /**
  111676. * Bind a specific vertex array object
  111677. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  111678. * @param vertexArrayObject defines the vertex array object to bind
  111679. * @param indexBuffer defines the index buffer to bind
  111680. */
  111681. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  111682. /**
  111683. * Bind webGl buffers directly to the webGL context
  111684. * @param vertexBuffer defines the vertex buffer to bind
  111685. * @param indexBuffer defines the index buffer to bind
  111686. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  111687. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  111688. * @param effect defines the effect associated with the vertex buffer
  111689. */
  111690. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  111691. private _unbindVertexArrayObject;
  111692. /**
  111693. * Bind a list of vertex buffers to the webGL context
  111694. * @param vertexBuffers defines the list of vertex buffers to bind
  111695. * @param indexBuffer defines the index buffer to bind
  111696. * @param effect defines the effect associated with the vertex buffers
  111697. */
  111698. bindBuffers(vertexBuffers: {
  111699. [key: string]: Nullable<VertexBuffer>;
  111700. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  111701. /**
  111702. * Unbind all instance attributes
  111703. */
  111704. unbindInstanceAttributes(): void;
  111705. /**
  111706. * Release and free the memory of a vertex array object
  111707. * @param vao defines the vertex array object to delete
  111708. */
  111709. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  111710. /** @hidden */
  111711. _releaseBuffer(buffer: DataBuffer): boolean;
  111712. protected _deleteBuffer(buffer: DataBuffer): void;
  111713. /**
  111714. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  111715. * @param instancesBuffer defines the webGL buffer to update and bind
  111716. * @param data defines the data to store in the buffer
  111717. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  111718. */
  111719. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  111720. /**
  111721. * Bind the content of a webGL buffer used with instantiation
  111722. * @param instancesBuffer defines the webGL buffer to bind
  111723. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  111724. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  111725. */
  111726. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  111727. /**
  111728. * Disable the instance attribute corresponding to the name in parameter
  111729. * @param name defines the name of the attribute to disable
  111730. */
  111731. disableInstanceAttributeByName(name: string): void;
  111732. /**
  111733. * Disable the instance attribute corresponding to the location in parameter
  111734. * @param attributeLocation defines the attribute location of the attribute to disable
  111735. */
  111736. disableInstanceAttribute(attributeLocation: number): void;
  111737. /**
  111738. * Disable the attribute corresponding to the location in parameter
  111739. * @param attributeLocation defines the attribute location of the attribute to disable
  111740. */
  111741. disableAttributeByIndex(attributeLocation: number): void;
  111742. /**
  111743. * Send a draw order
  111744. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  111745. * @param indexStart defines the starting index
  111746. * @param indexCount defines the number of index to draw
  111747. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  111748. */
  111749. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  111750. /**
  111751. * Draw a list of points
  111752. * @param verticesStart defines the index of first vertex to draw
  111753. * @param verticesCount defines the count of vertices to draw
  111754. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  111755. */
  111756. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  111757. /**
  111758. * Draw a list of unindexed primitives
  111759. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  111760. * @param verticesStart defines the index of first vertex to draw
  111761. * @param verticesCount defines the count of vertices to draw
  111762. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  111763. */
  111764. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  111765. /**
  111766. * Draw a list of indexed primitives
  111767. * @param fillMode defines the primitive to use
  111768. * @param indexStart defines the starting index
  111769. * @param indexCount defines the number of index to draw
  111770. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  111771. */
  111772. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  111773. /**
  111774. * Draw a list of unindexed primitives
  111775. * @param fillMode defines the primitive to use
  111776. * @param verticesStart defines the index of first vertex to draw
  111777. * @param verticesCount defines the count of vertices to draw
  111778. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  111779. */
  111780. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  111781. private _drawMode;
  111782. /** @hidden */
  111783. protected _reportDrawCall(): void;
  111784. /** @hidden */
  111785. _releaseEffect(effect: Effect): void;
  111786. /** @hidden */
  111787. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  111788. /**
  111789. * Create a new effect (used to store vertex/fragment shaders)
  111790. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  111791. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  111792. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  111793. * @param samplers defines an array of string used to represent textures
  111794. * @param defines defines the string containing the defines to use to compile the shaders
  111795. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  111796. * @param onCompiled defines a function to call when the effect creation is successful
  111797. * @param onError defines a function to call when the effect creation has failed
  111798. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  111799. * @returns the new Effect
  111800. */
  111801. 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;
  111802. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  111803. private _compileShader;
  111804. private _compileRawShader;
  111805. /** @hidden */
  111806. _getShaderSource(shader: WebGLShader): Nullable<string>;
  111807. /**
  111808. * Directly creates a webGL program
  111809. * @param pipelineContext defines the pipeline context to attach to
  111810. * @param vertexCode defines the vertex shader code to use
  111811. * @param fragmentCode defines the fragment shader code to use
  111812. * @param context defines the webGL context to use (if not set, the current one will be used)
  111813. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  111814. * @returns the new webGL program
  111815. */
  111816. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  111817. /**
  111818. * Creates a webGL program
  111819. * @param pipelineContext defines the pipeline context to attach to
  111820. * @param vertexCode defines the vertex shader code to use
  111821. * @param fragmentCode defines the fragment shader code to use
  111822. * @param defines defines the string containing the defines to use to compile the shaders
  111823. * @param context defines the webGL context to use (if not set, the current one will be used)
  111824. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  111825. * @returns the new webGL program
  111826. */
  111827. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  111828. /**
  111829. * Creates a new pipeline context
  111830. * @returns the new pipeline
  111831. */
  111832. createPipelineContext(): IPipelineContext;
  111833. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  111834. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  111835. /** @hidden */
  111836. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  111837. /** @hidden */
  111838. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  111839. /** @hidden */
  111840. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  111841. /**
  111842. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  111843. * @param pipelineContext defines the pipeline context to use
  111844. * @param uniformsNames defines the list of uniform names
  111845. * @returns an array of webGL uniform locations
  111846. */
  111847. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  111848. /**
  111849. * Gets the lsit of active attributes for a given webGL program
  111850. * @param pipelineContext defines the pipeline context to use
  111851. * @param attributesNames defines the list of attribute names to get
  111852. * @returns an array of indices indicating the offset of each attribute
  111853. */
  111854. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  111855. /**
  111856. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  111857. * @param effect defines the effect to activate
  111858. */
  111859. enableEffect(effect: Nullable<Effect>): void;
  111860. /**
  111861. * Set the value of an uniform to a number (int)
  111862. * @param uniform defines the webGL uniform location where to store the value
  111863. * @param value defines the int number to store
  111864. */
  111865. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  111866. /**
  111867. * Set the value of an uniform to an array of int32
  111868. * @param uniform defines the webGL uniform location where to store the value
  111869. * @param array defines the array of int32 to store
  111870. */
  111871. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  111872. /**
  111873. * Set the value of an uniform to an array of int32 (stored as vec2)
  111874. * @param uniform defines the webGL uniform location where to store the value
  111875. * @param array defines the array of int32 to store
  111876. */
  111877. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  111878. /**
  111879. * Set the value of an uniform to an array of int32 (stored as vec3)
  111880. * @param uniform defines the webGL uniform location where to store the value
  111881. * @param array defines the array of int32 to store
  111882. */
  111883. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  111884. /**
  111885. * Set the value of an uniform to an array of int32 (stored as vec4)
  111886. * @param uniform defines the webGL uniform location where to store the value
  111887. * @param array defines the array of int32 to store
  111888. */
  111889. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  111890. /**
  111891. * Set the value of an uniform to an array of number
  111892. * @param uniform defines the webGL uniform location where to store the value
  111893. * @param array defines the array of number to store
  111894. */
  111895. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  111896. /**
  111897. * Set the value of an uniform to an array of number (stored as vec2)
  111898. * @param uniform defines the webGL uniform location where to store the value
  111899. * @param array defines the array of number to store
  111900. */
  111901. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  111902. /**
  111903. * Set the value of an uniform to an array of number (stored as vec3)
  111904. * @param uniform defines the webGL uniform location where to store the value
  111905. * @param array defines the array of number to store
  111906. */
  111907. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  111908. /**
  111909. * Set the value of an uniform to an array of number (stored as vec4)
  111910. * @param uniform defines the webGL uniform location where to store the value
  111911. * @param array defines the array of number to store
  111912. */
  111913. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  111914. /**
  111915. * Set the value of an uniform to an array of float32 (stored as matrices)
  111916. * @param uniform defines the webGL uniform location where to store the value
  111917. * @param matrices defines the array of float32 to store
  111918. */
  111919. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  111920. /**
  111921. * Set the value of an uniform to a matrix (3x3)
  111922. * @param uniform defines the webGL uniform location where to store the value
  111923. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  111924. */
  111925. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  111926. /**
  111927. * Set the value of an uniform to a matrix (2x2)
  111928. * @param uniform defines the webGL uniform location where to store the value
  111929. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  111930. */
  111931. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  111932. /**
  111933. * Set the value of an uniform to a number (float)
  111934. * @param uniform defines the webGL uniform location where to store the value
  111935. * @param value defines the float number to store
  111936. */
  111937. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  111938. /**
  111939. * Set the value of an uniform to a vec2
  111940. * @param uniform defines the webGL uniform location where to store the value
  111941. * @param x defines the 1st component of the value
  111942. * @param y defines the 2nd component of the value
  111943. */
  111944. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  111945. /**
  111946. * Set the value of an uniform to a vec3
  111947. * @param uniform defines the webGL uniform location where to store the value
  111948. * @param x defines the 1st component of the value
  111949. * @param y defines the 2nd component of the value
  111950. * @param z defines the 3rd component of the value
  111951. */
  111952. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  111953. /**
  111954. * Set the value of an uniform to a vec4
  111955. * @param uniform defines the webGL uniform location where to store the value
  111956. * @param x defines the 1st component of the value
  111957. * @param y defines the 2nd component of the value
  111958. * @param z defines the 3rd component of the value
  111959. * @param w defines the 4th component of the value
  111960. */
  111961. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  111962. /**
  111963. * Apply all cached states (depth, culling, stencil and alpha)
  111964. */
  111965. applyStates(): void;
  111966. /**
  111967. * Enable or disable color writing
  111968. * @param enable defines the state to set
  111969. */
  111970. setColorWrite(enable: boolean): void;
  111971. /**
  111972. * Gets a boolean indicating if color writing is enabled
  111973. * @returns the current color writing state
  111974. */
  111975. getColorWrite(): boolean;
  111976. /**
  111977. * Gets the depth culling state manager
  111978. */
  111979. get depthCullingState(): DepthCullingState;
  111980. /**
  111981. * Gets the alpha state manager
  111982. */
  111983. get alphaState(): AlphaState;
  111984. /**
  111985. * Gets the stencil state manager
  111986. */
  111987. get stencilState(): StencilState;
  111988. /**
  111989. * Clears the list of texture accessible through engine.
  111990. * This can help preventing texture load conflict due to name collision.
  111991. */
  111992. clearInternalTexturesCache(): void;
  111993. /**
  111994. * Force the entire cache to be cleared
  111995. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  111996. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  111997. */
  111998. wipeCaches(bruteForce?: boolean): void;
  111999. /** @hidden */
  112000. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  112001. min: number;
  112002. mag: number;
  112003. };
  112004. /** @hidden */
  112005. _createTexture(): WebGLTexture;
  112006. /**
  112007. * Usually called from Texture.ts.
  112008. * Passed information to create a WebGLTexture
  112009. * @param url defines a value which contains one of the following:
  112010. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  112011. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  112012. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  112013. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  112014. * @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)
  112015. * @param scene needed for loading to the correct scene
  112016. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  112017. * @param onLoad optional callback to be called upon successful completion
  112018. * @param onError optional callback to be called upon failure
  112019. * @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
  112020. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  112021. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  112022. * @param forcedExtension defines the extension to use to pick the right loader
  112023. * @param mimeType defines an optional mime type
  112024. * @returns a InternalTexture for assignment back into BABYLON.Texture
  112025. */
  112026. 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;
  112027. /**
  112028. * Loads an image as an HTMLImageElement.
  112029. * @param input url string, ArrayBuffer, or Blob to load
  112030. * @param onLoad callback called when the image successfully loads
  112031. * @param onError callback called when the image fails to load
  112032. * @param offlineProvider offline provider for caching
  112033. * @param mimeType optional mime type
  112034. * @returns the HTMLImageElement of the loaded image
  112035. * @hidden
  112036. */
  112037. 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>;
  112038. /**
  112039. * @hidden
  112040. */
  112041. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  112042. private _unpackFlipYCached;
  112043. /**
  112044. * In case you are sharing the context with other applications, it might
  112045. * be interested to not cache the unpack flip y state to ensure a consistent
  112046. * value would be set.
  112047. */
  112048. enableUnpackFlipYCached: boolean;
  112049. /** @hidden */
  112050. _unpackFlipY(value: boolean): void;
  112051. /** @hidden */
  112052. _getUnpackAlignement(): number;
  112053. private _getTextureTarget;
  112054. /**
  112055. * Update the sampling mode of a given texture
  112056. * @param samplingMode defines the required sampling mode
  112057. * @param texture defines the texture to update
  112058. * @param generateMipMaps defines whether to generate mipmaps for the texture
  112059. */
  112060. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  112061. /**
  112062. * Update the sampling mode of a given texture
  112063. * @param texture defines the texture to update
  112064. * @param wrapU defines the texture wrap mode of the u coordinates
  112065. * @param wrapV defines the texture wrap mode of the v coordinates
  112066. * @param wrapR defines the texture wrap mode of the r coordinates
  112067. */
  112068. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  112069. /** @hidden */
  112070. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  112071. width: number;
  112072. height: number;
  112073. layers?: number;
  112074. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  112075. /** @hidden */
  112076. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  112077. /** @hidden */
  112078. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  112079. /**
  112080. * Update a portion of an internal texture
  112081. * @param texture defines the texture to update
  112082. * @param imageData defines the data to store into the texture
  112083. * @param xOffset defines the x coordinates of the update rectangle
  112084. * @param yOffset defines the y coordinates of the update rectangle
  112085. * @param width defines the width of the update rectangle
  112086. * @param height defines the height of the update rectangle
  112087. * @param faceIndex defines the face index if texture is a cube (0 by default)
  112088. * @param lod defines the lod level to update (0 by default)
  112089. */
  112090. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  112091. /** @hidden */
  112092. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  112093. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  112094. private _prepareWebGLTexture;
  112095. /** @hidden */
  112096. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  112097. private _getDepthStencilBuffer;
  112098. /** @hidden */
  112099. _releaseFramebufferObjects(texture: InternalTexture): void;
  112100. /** @hidden */
  112101. _releaseTexture(texture: InternalTexture): void;
  112102. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  112103. protected _setProgram(program: WebGLProgram): void;
  112104. protected _boundUniforms: {
  112105. [key: number]: WebGLUniformLocation;
  112106. };
  112107. /**
  112108. * Binds an effect to the webGL context
  112109. * @param effect defines the effect to bind
  112110. */
  112111. bindSamplers(effect: Effect): void;
  112112. private _activateCurrentTexture;
  112113. /** @hidden */
  112114. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  112115. /** @hidden */
  112116. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  112117. /**
  112118. * Unbind all textures from the webGL context
  112119. */
  112120. unbindAllTextures(): void;
  112121. /**
  112122. * Sets a texture to the according uniform.
  112123. * @param channel The texture channel
  112124. * @param uniform The uniform to set
  112125. * @param texture The texture to apply
  112126. */
  112127. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  112128. private _bindSamplerUniformToChannel;
  112129. private _getTextureWrapMode;
  112130. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  112131. /**
  112132. * Sets an array of texture to the webGL context
  112133. * @param channel defines the channel where the texture array must be set
  112134. * @param uniform defines the associated uniform location
  112135. * @param textures defines the array of textures to bind
  112136. */
  112137. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  112138. /** @hidden */
  112139. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  112140. private _setTextureParameterFloat;
  112141. private _setTextureParameterInteger;
  112142. /**
  112143. * Unbind all vertex attributes from the webGL context
  112144. */
  112145. unbindAllAttributes(): void;
  112146. /**
  112147. * 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
  112148. */
  112149. releaseEffects(): void;
  112150. /**
  112151. * Dispose and release all associated resources
  112152. */
  112153. dispose(): void;
  112154. /**
  112155. * Attach a new callback raised when context lost event is fired
  112156. * @param callback defines the callback to call
  112157. */
  112158. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  112159. /**
  112160. * Attach a new callback raised when context restored event is fired
  112161. * @param callback defines the callback to call
  112162. */
  112163. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  112164. /**
  112165. * Get the current error code of the webGL context
  112166. * @returns the error code
  112167. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  112168. */
  112169. getError(): number;
  112170. private _canRenderToFloatFramebuffer;
  112171. private _canRenderToHalfFloatFramebuffer;
  112172. private _canRenderToFramebuffer;
  112173. /** @hidden */
  112174. _getWebGLTextureType(type: number): number;
  112175. /** @hidden */
  112176. _getInternalFormat(format: number): number;
  112177. /** @hidden */
  112178. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  112179. /** @hidden */
  112180. _getRGBAMultiSampleBufferFormat(type: number): number;
  112181. /** @hidden */
  112182. _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;
  112183. /**
  112184. * Loads a file from a url
  112185. * @param url url to load
  112186. * @param onSuccess callback called when the file successfully loads
  112187. * @param onProgress callback called while file is loading (if the server supports this mode)
  112188. * @param offlineProvider defines the offline provider for caching
  112189. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  112190. * @param onError callback called when the file fails to load
  112191. * @returns a file request object
  112192. * @hidden
  112193. */
  112194. 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;
  112195. /**
  112196. * Reads pixels from the current frame buffer. Please note that this function can be slow
  112197. * @param x defines the x coordinate of the rectangle where pixels must be read
  112198. * @param y defines the y coordinate of the rectangle where pixels must be read
  112199. * @param width defines the width of the rectangle where pixels must be read
  112200. * @param height defines the height of the rectangle where pixels must be read
  112201. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  112202. * @returns a Uint8Array containing RGBA colors
  112203. */
  112204. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  112205. private static _isSupported;
  112206. /**
  112207. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  112208. * @returns true if the engine can be created
  112209. * @ignorenaming
  112210. */
  112211. static isSupported(): boolean;
  112212. /**
  112213. * Find the next highest power of two.
  112214. * @param x Number to start search from.
  112215. * @return Next highest power of two.
  112216. */
  112217. static CeilingPOT(x: number): number;
  112218. /**
  112219. * Find the next lowest power of two.
  112220. * @param x Number to start search from.
  112221. * @return Next lowest power of two.
  112222. */
  112223. static FloorPOT(x: number): number;
  112224. /**
  112225. * Find the nearest power of two.
  112226. * @param x Number to start search from.
  112227. * @return Next nearest power of two.
  112228. */
  112229. static NearestPOT(x: number): number;
  112230. /**
  112231. * Get the closest exponent of two
  112232. * @param value defines the value to approximate
  112233. * @param max defines the maximum value to return
  112234. * @param mode defines how to define the closest value
  112235. * @returns closest exponent of two of the given value
  112236. */
  112237. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  112238. /**
  112239. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  112240. * @param func - the function to be called
  112241. * @param requester - the object that will request the next frame. Falls back to window.
  112242. * @returns frame number
  112243. */
  112244. static QueueNewFrame(func: () => void, requester?: any): number;
  112245. /**
  112246. * Gets host document
  112247. * @returns the host document object
  112248. */
  112249. getHostDocument(): Nullable<Document>;
  112250. }
  112251. }
  112252. declare module BABYLON {
  112253. /**
  112254. * Class representing spherical harmonics coefficients to the 3rd degree
  112255. */
  112256. export class SphericalHarmonics {
  112257. /**
  112258. * Defines whether or not the harmonics have been prescaled for rendering.
  112259. */
  112260. preScaled: boolean;
  112261. /**
  112262. * The l0,0 coefficients of the spherical harmonics
  112263. */
  112264. l00: Vector3;
  112265. /**
  112266. * The l1,-1 coefficients of the spherical harmonics
  112267. */
  112268. l1_1: Vector3;
  112269. /**
  112270. * The l1,0 coefficients of the spherical harmonics
  112271. */
  112272. l10: Vector3;
  112273. /**
  112274. * The l1,1 coefficients of the spherical harmonics
  112275. */
  112276. l11: Vector3;
  112277. /**
  112278. * The l2,-2 coefficients of the spherical harmonics
  112279. */
  112280. l2_2: Vector3;
  112281. /**
  112282. * The l2,-1 coefficients of the spherical harmonics
  112283. */
  112284. l2_1: Vector3;
  112285. /**
  112286. * The l2,0 coefficients of the spherical harmonics
  112287. */
  112288. l20: Vector3;
  112289. /**
  112290. * The l2,1 coefficients of the spherical harmonics
  112291. */
  112292. l21: Vector3;
  112293. /**
  112294. * The l2,2 coefficients of the spherical harmonics
  112295. */
  112296. l22: Vector3;
  112297. /**
  112298. * Adds a light to the spherical harmonics
  112299. * @param direction the direction of the light
  112300. * @param color the color of the light
  112301. * @param deltaSolidAngle the delta solid angle of the light
  112302. */
  112303. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  112304. /**
  112305. * Scales the spherical harmonics by the given amount
  112306. * @param scale the amount to scale
  112307. */
  112308. scaleInPlace(scale: number): void;
  112309. /**
  112310. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  112311. *
  112312. * ```
  112313. * E_lm = A_l * L_lm
  112314. * ```
  112315. *
  112316. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  112317. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  112318. * the scaling factors are given in equation 9.
  112319. */
  112320. convertIncidentRadianceToIrradiance(): void;
  112321. /**
  112322. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  112323. *
  112324. * ```
  112325. * L = (1/pi) * E * rho
  112326. * ```
  112327. *
  112328. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  112329. */
  112330. convertIrradianceToLambertianRadiance(): void;
  112331. /**
  112332. * Integrates the reconstruction coefficients directly in to the SH preventing further
  112333. * required operations at run time.
  112334. *
  112335. * This is simply done by scaling back the SH with Ylm constants parameter.
  112336. * The trigonometric part being applied by the shader at run time.
  112337. */
  112338. preScaleForRendering(): void;
  112339. /**
  112340. * Constructs a spherical harmonics from an array.
  112341. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  112342. * @returns the spherical harmonics
  112343. */
  112344. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  112345. /**
  112346. * Gets the spherical harmonics from polynomial
  112347. * @param polynomial the spherical polynomial
  112348. * @returns the spherical harmonics
  112349. */
  112350. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  112351. }
  112352. /**
  112353. * Class representing spherical polynomial coefficients to the 3rd degree
  112354. */
  112355. export class SphericalPolynomial {
  112356. private _harmonics;
  112357. /**
  112358. * The spherical harmonics used to create the polynomials.
  112359. */
  112360. get preScaledHarmonics(): SphericalHarmonics;
  112361. /**
  112362. * The x coefficients of the spherical polynomial
  112363. */
  112364. x: Vector3;
  112365. /**
  112366. * The y coefficients of the spherical polynomial
  112367. */
  112368. y: Vector3;
  112369. /**
  112370. * The z coefficients of the spherical polynomial
  112371. */
  112372. z: Vector3;
  112373. /**
  112374. * The xx coefficients of the spherical polynomial
  112375. */
  112376. xx: Vector3;
  112377. /**
  112378. * The yy coefficients of the spherical polynomial
  112379. */
  112380. yy: Vector3;
  112381. /**
  112382. * The zz coefficients of the spherical polynomial
  112383. */
  112384. zz: Vector3;
  112385. /**
  112386. * The xy coefficients of the spherical polynomial
  112387. */
  112388. xy: Vector3;
  112389. /**
  112390. * The yz coefficients of the spherical polynomial
  112391. */
  112392. yz: Vector3;
  112393. /**
  112394. * The zx coefficients of the spherical polynomial
  112395. */
  112396. zx: Vector3;
  112397. /**
  112398. * Adds an ambient color to the spherical polynomial
  112399. * @param color the color to add
  112400. */
  112401. addAmbient(color: Color3): void;
  112402. /**
  112403. * Scales the spherical polynomial by the given amount
  112404. * @param scale the amount to scale
  112405. */
  112406. scaleInPlace(scale: number): void;
  112407. /**
  112408. * Gets the spherical polynomial from harmonics
  112409. * @param harmonics the spherical harmonics
  112410. * @returns the spherical polynomial
  112411. */
  112412. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  112413. /**
  112414. * Constructs a spherical polynomial from an array.
  112415. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  112416. * @returns the spherical polynomial
  112417. */
  112418. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  112419. }
  112420. }
  112421. declare module BABYLON {
  112422. /**
  112423. * Defines the source of the internal texture
  112424. */
  112425. export enum InternalTextureSource {
  112426. /**
  112427. * The source of the texture data is unknown
  112428. */
  112429. Unknown = 0,
  112430. /**
  112431. * Texture data comes from an URL
  112432. */
  112433. Url = 1,
  112434. /**
  112435. * Texture data is only used for temporary storage
  112436. */
  112437. Temp = 2,
  112438. /**
  112439. * Texture data comes from raw data (ArrayBuffer)
  112440. */
  112441. Raw = 3,
  112442. /**
  112443. * Texture content is dynamic (video or dynamic texture)
  112444. */
  112445. Dynamic = 4,
  112446. /**
  112447. * Texture content is generated by rendering to it
  112448. */
  112449. RenderTarget = 5,
  112450. /**
  112451. * Texture content is part of a multi render target process
  112452. */
  112453. MultiRenderTarget = 6,
  112454. /**
  112455. * Texture data comes from a cube data file
  112456. */
  112457. Cube = 7,
  112458. /**
  112459. * Texture data comes from a raw cube data
  112460. */
  112461. CubeRaw = 8,
  112462. /**
  112463. * Texture data come from a prefiltered cube data file
  112464. */
  112465. CubePrefiltered = 9,
  112466. /**
  112467. * Texture content is raw 3D data
  112468. */
  112469. Raw3D = 10,
  112470. /**
  112471. * Texture content is raw 2D array data
  112472. */
  112473. Raw2DArray = 11,
  112474. /**
  112475. * Texture content is a depth texture
  112476. */
  112477. Depth = 12,
  112478. /**
  112479. * Texture data comes from a raw cube data encoded with RGBD
  112480. */
  112481. CubeRawRGBD = 13
  112482. }
  112483. /**
  112484. * Class used to store data associated with WebGL texture data for the engine
  112485. * This class should not be used directly
  112486. */
  112487. export class InternalTexture {
  112488. /** @hidden */
  112489. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  112490. /**
  112491. * Defines if the texture is ready
  112492. */
  112493. isReady: boolean;
  112494. /**
  112495. * Defines if the texture is a cube texture
  112496. */
  112497. isCube: boolean;
  112498. /**
  112499. * Defines if the texture contains 3D data
  112500. */
  112501. is3D: boolean;
  112502. /**
  112503. * Defines if the texture contains 2D array data
  112504. */
  112505. is2DArray: boolean;
  112506. /**
  112507. * Defines if the texture contains multiview data
  112508. */
  112509. isMultiview: boolean;
  112510. /**
  112511. * Gets the URL used to load this texture
  112512. */
  112513. url: string;
  112514. /**
  112515. * Gets the sampling mode of the texture
  112516. */
  112517. samplingMode: number;
  112518. /**
  112519. * Gets a boolean indicating if the texture needs mipmaps generation
  112520. */
  112521. generateMipMaps: boolean;
  112522. /**
  112523. * Gets the number of samples used by the texture (WebGL2+ only)
  112524. */
  112525. samples: number;
  112526. /**
  112527. * Gets the type of the texture (int, float...)
  112528. */
  112529. type: number;
  112530. /**
  112531. * Gets the format of the texture (RGB, RGBA...)
  112532. */
  112533. format: number;
  112534. /**
  112535. * Observable called when the texture is loaded
  112536. */
  112537. onLoadedObservable: Observable<InternalTexture>;
  112538. /**
  112539. * Gets the width of the texture
  112540. */
  112541. width: number;
  112542. /**
  112543. * Gets the height of the texture
  112544. */
  112545. height: number;
  112546. /**
  112547. * Gets the depth of the texture
  112548. */
  112549. depth: number;
  112550. /**
  112551. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  112552. */
  112553. baseWidth: number;
  112554. /**
  112555. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  112556. */
  112557. baseHeight: number;
  112558. /**
  112559. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  112560. */
  112561. baseDepth: number;
  112562. /**
  112563. * Gets a boolean indicating if the texture is inverted on Y axis
  112564. */
  112565. invertY: boolean;
  112566. /** @hidden */
  112567. _invertVScale: boolean;
  112568. /** @hidden */
  112569. _associatedChannel: number;
  112570. /** @hidden */
  112571. _source: InternalTextureSource;
  112572. /** @hidden */
  112573. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  112574. /** @hidden */
  112575. _bufferView: Nullable<ArrayBufferView>;
  112576. /** @hidden */
  112577. _bufferViewArray: Nullable<ArrayBufferView[]>;
  112578. /** @hidden */
  112579. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  112580. /** @hidden */
  112581. _size: number;
  112582. /** @hidden */
  112583. _extension: string;
  112584. /** @hidden */
  112585. _files: Nullable<string[]>;
  112586. /** @hidden */
  112587. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  112588. /** @hidden */
  112589. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  112590. /** @hidden */
  112591. _framebuffer: Nullable<WebGLFramebuffer>;
  112592. /** @hidden */
  112593. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  112594. /** @hidden */
  112595. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  112596. /** @hidden */
  112597. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  112598. /** @hidden */
  112599. _attachments: Nullable<number[]>;
  112600. /** @hidden */
  112601. _cachedCoordinatesMode: Nullable<number>;
  112602. /** @hidden */
  112603. _cachedWrapU: Nullable<number>;
  112604. /** @hidden */
  112605. _cachedWrapV: Nullable<number>;
  112606. /** @hidden */
  112607. _cachedWrapR: Nullable<number>;
  112608. /** @hidden */
  112609. _cachedAnisotropicFilteringLevel: Nullable<number>;
  112610. /** @hidden */
  112611. _isDisabled: boolean;
  112612. /** @hidden */
  112613. _compression: Nullable<string>;
  112614. /** @hidden */
  112615. _generateStencilBuffer: boolean;
  112616. /** @hidden */
  112617. _generateDepthBuffer: boolean;
  112618. /** @hidden */
  112619. _comparisonFunction: number;
  112620. /** @hidden */
  112621. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  112622. /** @hidden */
  112623. _lodGenerationScale: number;
  112624. /** @hidden */
  112625. _lodGenerationOffset: number;
  112626. /** @hidden */
  112627. _depthStencilTexture: Nullable<InternalTexture>;
  112628. /** @hidden */
  112629. _colorTextureArray: Nullable<WebGLTexture>;
  112630. /** @hidden */
  112631. _depthStencilTextureArray: Nullable<WebGLTexture>;
  112632. /** @hidden */
  112633. _lodTextureHigh: Nullable<BaseTexture>;
  112634. /** @hidden */
  112635. _lodTextureMid: Nullable<BaseTexture>;
  112636. /** @hidden */
  112637. _lodTextureLow: Nullable<BaseTexture>;
  112638. /** @hidden */
  112639. _isRGBD: boolean;
  112640. /** @hidden */
  112641. _linearSpecularLOD: boolean;
  112642. /** @hidden */
  112643. _irradianceTexture: Nullable<BaseTexture>;
  112644. /** @hidden */
  112645. _webGLTexture: Nullable<WebGLTexture>;
  112646. /** @hidden */
  112647. _references: number;
  112648. private _engine;
  112649. /**
  112650. * Gets the Engine the texture belongs to.
  112651. * @returns The babylon engine
  112652. */
  112653. getEngine(): ThinEngine;
  112654. /**
  112655. * Gets the data source type of the texture
  112656. */
  112657. get source(): InternalTextureSource;
  112658. /**
  112659. * Creates a new InternalTexture
  112660. * @param engine defines the engine to use
  112661. * @param source defines the type of data that will be used
  112662. * @param delayAllocation if the texture allocation should be delayed (default: false)
  112663. */
  112664. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  112665. /**
  112666. * Increments the number of references (ie. the number of Texture that point to it)
  112667. */
  112668. incrementReferences(): void;
  112669. /**
  112670. * Change the size of the texture (not the size of the content)
  112671. * @param width defines the new width
  112672. * @param height defines the new height
  112673. * @param depth defines the new depth (1 by default)
  112674. */
  112675. updateSize(width: int, height: int, depth?: int): void;
  112676. /** @hidden */
  112677. _rebuild(): void;
  112678. /** @hidden */
  112679. _swapAndDie(target: InternalTexture): void;
  112680. /**
  112681. * Dispose the current allocated resources
  112682. */
  112683. dispose(): void;
  112684. }
  112685. }
  112686. declare module BABYLON {
  112687. /**
  112688. * Class used to work with sound analyzer using fast fourier transform (FFT)
  112689. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  112690. */
  112691. export class Analyser {
  112692. /**
  112693. * Gets or sets the smoothing
  112694. * @ignorenaming
  112695. */
  112696. SMOOTHING: number;
  112697. /**
  112698. * Gets or sets the FFT table size
  112699. * @ignorenaming
  112700. */
  112701. FFT_SIZE: number;
  112702. /**
  112703. * Gets or sets the bar graph amplitude
  112704. * @ignorenaming
  112705. */
  112706. BARGRAPHAMPLITUDE: number;
  112707. /**
  112708. * Gets or sets the position of the debug canvas
  112709. * @ignorenaming
  112710. */
  112711. DEBUGCANVASPOS: {
  112712. x: number;
  112713. y: number;
  112714. };
  112715. /**
  112716. * Gets or sets the debug canvas size
  112717. * @ignorenaming
  112718. */
  112719. DEBUGCANVASSIZE: {
  112720. width: number;
  112721. height: number;
  112722. };
  112723. private _byteFreqs;
  112724. private _byteTime;
  112725. private _floatFreqs;
  112726. private _webAudioAnalyser;
  112727. private _debugCanvas;
  112728. private _debugCanvasContext;
  112729. private _scene;
  112730. private _registerFunc;
  112731. private _audioEngine;
  112732. /**
  112733. * Creates a new analyser
  112734. * @param scene defines hosting scene
  112735. */
  112736. constructor(scene: Scene);
  112737. /**
  112738. * Get the number of data values you will have to play with for the visualization
  112739. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  112740. * @returns a number
  112741. */
  112742. getFrequencyBinCount(): number;
  112743. /**
  112744. * Gets the current frequency data as a byte array
  112745. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  112746. * @returns a Uint8Array
  112747. */
  112748. getByteFrequencyData(): Uint8Array;
  112749. /**
  112750. * Gets the current waveform as a byte array
  112751. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  112752. * @returns a Uint8Array
  112753. */
  112754. getByteTimeDomainData(): Uint8Array;
  112755. /**
  112756. * Gets the current frequency data as a float array
  112757. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  112758. * @returns a Float32Array
  112759. */
  112760. getFloatFrequencyData(): Float32Array;
  112761. /**
  112762. * Renders the debug canvas
  112763. */
  112764. drawDebugCanvas(): void;
  112765. /**
  112766. * Stops rendering the debug canvas and removes it
  112767. */
  112768. stopDebugCanvas(): void;
  112769. /**
  112770. * Connects two audio nodes
  112771. * @param inputAudioNode defines first node to connect
  112772. * @param outputAudioNode defines second node to connect
  112773. */
  112774. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  112775. /**
  112776. * Releases all associated resources
  112777. */
  112778. dispose(): void;
  112779. }
  112780. }
  112781. declare module BABYLON {
  112782. /**
  112783. * This represents an audio engine and it is responsible
  112784. * to play, synchronize and analyse sounds throughout the application.
  112785. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  112786. */
  112787. export interface IAudioEngine extends IDisposable {
  112788. /**
  112789. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  112790. */
  112791. readonly canUseWebAudio: boolean;
  112792. /**
  112793. * Gets the current AudioContext if available.
  112794. */
  112795. readonly audioContext: Nullable<AudioContext>;
  112796. /**
  112797. * The master gain node defines the global audio volume of your audio engine.
  112798. */
  112799. readonly masterGain: GainNode;
  112800. /**
  112801. * Gets whether or not mp3 are supported by your browser.
  112802. */
  112803. readonly isMP3supported: boolean;
  112804. /**
  112805. * Gets whether or not ogg are supported by your browser.
  112806. */
  112807. readonly isOGGsupported: boolean;
  112808. /**
  112809. * Defines if Babylon should emit a warning if WebAudio is not supported.
  112810. * @ignoreNaming
  112811. */
  112812. WarnedWebAudioUnsupported: boolean;
  112813. /**
  112814. * Defines if the audio engine relies on a custom unlocked button.
  112815. * In this case, the embedded button will not be displayed.
  112816. */
  112817. useCustomUnlockedButton: boolean;
  112818. /**
  112819. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  112820. */
  112821. readonly unlocked: boolean;
  112822. /**
  112823. * Event raised when audio has been unlocked on the browser.
  112824. */
  112825. onAudioUnlockedObservable: Observable<AudioEngine>;
  112826. /**
  112827. * Event raised when audio has been locked on the browser.
  112828. */
  112829. onAudioLockedObservable: Observable<AudioEngine>;
  112830. /**
  112831. * Flags the audio engine in Locked state.
  112832. * This happens due to new browser policies preventing audio to autoplay.
  112833. */
  112834. lock(): void;
  112835. /**
  112836. * Unlocks the audio engine once a user action has been done on the dom.
  112837. * This is helpful to resume play once browser policies have been satisfied.
  112838. */
  112839. unlock(): void;
  112840. /**
  112841. * Gets the global volume sets on the master gain.
  112842. * @returns the global volume if set or -1 otherwise
  112843. */
  112844. getGlobalVolume(): number;
  112845. /**
  112846. * Sets the global volume of your experience (sets on the master gain).
  112847. * @param newVolume Defines the new global volume of the application
  112848. */
  112849. setGlobalVolume(newVolume: number): void;
  112850. /**
  112851. * Connect the audio engine to an audio analyser allowing some amazing
  112852. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  112853. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  112854. * @param analyser The analyser to connect to the engine
  112855. */
  112856. connectToAnalyser(analyser: Analyser): void;
  112857. }
  112858. /**
  112859. * This represents the default audio engine used in babylon.
  112860. * It is responsible to play, synchronize and analyse sounds throughout the application.
  112861. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  112862. */
  112863. export class AudioEngine implements IAudioEngine {
  112864. private _audioContext;
  112865. private _audioContextInitialized;
  112866. private _muteButton;
  112867. private _hostElement;
  112868. /**
  112869. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  112870. */
  112871. canUseWebAudio: boolean;
  112872. /**
  112873. * The master gain node defines the global audio volume of your audio engine.
  112874. */
  112875. masterGain: GainNode;
  112876. /**
  112877. * Defines if Babylon should emit a warning if WebAudio is not supported.
  112878. * @ignoreNaming
  112879. */
  112880. WarnedWebAudioUnsupported: boolean;
  112881. /**
  112882. * Gets whether or not mp3 are supported by your browser.
  112883. */
  112884. isMP3supported: boolean;
  112885. /**
  112886. * Gets whether or not ogg are supported by your browser.
  112887. */
  112888. isOGGsupported: boolean;
  112889. /**
  112890. * Gets whether audio has been unlocked on the device.
  112891. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  112892. * a user interaction has happened.
  112893. */
  112894. unlocked: boolean;
  112895. /**
  112896. * Defines if the audio engine relies on a custom unlocked button.
  112897. * In this case, the embedded button will not be displayed.
  112898. */
  112899. useCustomUnlockedButton: boolean;
  112900. /**
  112901. * Event raised when audio has been unlocked on the browser.
  112902. */
  112903. onAudioUnlockedObservable: Observable<AudioEngine>;
  112904. /**
  112905. * Event raised when audio has been locked on the browser.
  112906. */
  112907. onAudioLockedObservable: Observable<AudioEngine>;
  112908. /**
  112909. * Gets the current AudioContext if available.
  112910. */
  112911. get audioContext(): Nullable<AudioContext>;
  112912. private _connectedAnalyser;
  112913. /**
  112914. * Instantiates a new audio engine.
  112915. *
  112916. * There should be only one per page as some browsers restrict the number
  112917. * of audio contexts you can create.
  112918. * @param hostElement defines the host element where to display the mute icon if necessary
  112919. */
  112920. constructor(hostElement?: Nullable<HTMLElement>);
  112921. /**
  112922. * Flags the audio engine in Locked state.
  112923. * This happens due to new browser policies preventing audio to autoplay.
  112924. */
  112925. lock(): void;
  112926. /**
  112927. * Unlocks the audio engine once a user action has been done on the dom.
  112928. * This is helpful to resume play once browser policies have been satisfied.
  112929. */
  112930. unlock(): void;
  112931. private _resumeAudioContext;
  112932. private _initializeAudioContext;
  112933. private _tryToRun;
  112934. private _triggerRunningState;
  112935. private _triggerSuspendedState;
  112936. private _displayMuteButton;
  112937. private _moveButtonToTopLeft;
  112938. private _onResize;
  112939. private _hideMuteButton;
  112940. /**
  112941. * Destroy and release the resources associated with the audio ccontext.
  112942. */
  112943. dispose(): void;
  112944. /**
  112945. * Gets the global volume sets on the master gain.
  112946. * @returns the global volume if set or -1 otherwise
  112947. */
  112948. getGlobalVolume(): number;
  112949. /**
  112950. * Sets the global volume of your experience (sets on the master gain).
  112951. * @param newVolume Defines the new global volume of the application
  112952. */
  112953. setGlobalVolume(newVolume: number): void;
  112954. /**
  112955. * Connect the audio engine to an audio analyser allowing some amazing
  112956. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  112957. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  112958. * @param analyser The analyser to connect to the engine
  112959. */
  112960. connectToAnalyser(analyser: Analyser): void;
  112961. }
  112962. }
  112963. declare module BABYLON {
  112964. /**
  112965. * Interface used to present a loading screen while loading a scene
  112966. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  112967. */
  112968. export interface ILoadingScreen {
  112969. /**
  112970. * Function called to display the loading screen
  112971. */
  112972. displayLoadingUI: () => void;
  112973. /**
  112974. * Function called to hide the loading screen
  112975. */
  112976. hideLoadingUI: () => void;
  112977. /**
  112978. * Gets or sets the color to use for the background
  112979. */
  112980. loadingUIBackgroundColor: string;
  112981. /**
  112982. * Gets or sets the text to display while loading
  112983. */
  112984. loadingUIText: string;
  112985. }
  112986. /**
  112987. * Class used for the default loading screen
  112988. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  112989. */
  112990. export class DefaultLoadingScreen implements ILoadingScreen {
  112991. private _renderingCanvas;
  112992. private _loadingText;
  112993. private _loadingDivBackgroundColor;
  112994. private _loadingDiv;
  112995. private _loadingTextDiv;
  112996. /** Gets or sets the logo url to use for the default loading screen */
  112997. static DefaultLogoUrl: string;
  112998. /** Gets or sets the spinner url to use for the default loading screen */
  112999. static DefaultSpinnerUrl: string;
  113000. /**
  113001. * Creates a new default loading screen
  113002. * @param _renderingCanvas defines the canvas used to render the scene
  113003. * @param _loadingText defines the default text to display
  113004. * @param _loadingDivBackgroundColor defines the default background color
  113005. */
  113006. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  113007. /**
  113008. * Function called to display the loading screen
  113009. */
  113010. displayLoadingUI(): void;
  113011. /**
  113012. * Function called to hide the loading screen
  113013. */
  113014. hideLoadingUI(): void;
  113015. /**
  113016. * Gets or sets the text to display while loading
  113017. */
  113018. set loadingUIText(text: string);
  113019. get loadingUIText(): string;
  113020. /**
  113021. * Gets or sets the color to use for the background
  113022. */
  113023. get loadingUIBackgroundColor(): string;
  113024. set loadingUIBackgroundColor(color: string);
  113025. private _resizeLoadingUI;
  113026. }
  113027. }
  113028. declare module BABYLON {
  113029. /**
  113030. * Interface for any object that can request an animation frame
  113031. */
  113032. export interface ICustomAnimationFrameRequester {
  113033. /**
  113034. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  113035. */
  113036. renderFunction?: Function;
  113037. /**
  113038. * Called to request the next frame to render to
  113039. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  113040. */
  113041. requestAnimationFrame: Function;
  113042. /**
  113043. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  113044. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  113045. */
  113046. requestID?: number;
  113047. }
  113048. }
  113049. declare module BABYLON {
  113050. /**
  113051. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  113052. */
  113053. export class PerformanceMonitor {
  113054. private _enabled;
  113055. private _rollingFrameTime;
  113056. private _lastFrameTimeMs;
  113057. /**
  113058. * constructor
  113059. * @param frameSampleSize The number of samples required to saturate the sliding window
  113060. */
  113061. constructor(frameSampleSize?: number);
  113062. /**
  113063. * Samples current frame
  113064. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  113065. */
  113066. sampleFrame(timeMs?: number): void;
  113067. /**
  113068. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  113069. */
  113070. get averageFrameTime(): number;
  113071. /**
  113072. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  113073. */
  113074. get averageFrameTimeVariance(): number;
  113075. /**
  113076. * Returns the frame time of the most recent frame
  113077. */
  113078. get instantaneousFrameTime(): number;
  113079. /**
  113080. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  113081. */
  113082. get averageFPS(): number;
  113083. /**
  113084. * Returns the average framerate in frames per second using the most recent frame time
  113085. */
  113086. get instantaneousFPS(): number;
  113087. /**
  113088. * Returns true if enough samples have been taken to completely fill the sliding window
  113089. */
  113090. get isSaturated(): boolean;
  113091. /**
  113092. * Enables contributions to the sliding window sample set
  113093. */
  113094. enable(): void;
  113095. /**
  113096. * Disables contributions to the sliding window sample set
  113097. * Samples will not be interpolated over the disabled period
  113098. */
  113099. disable(): void;
  113100. /**
  113101. * Returns true if sampling is enabled
  113102. */
  113103. get isEnabled(): boolean;
  113104. /**
  113105. * Resets performance monitor
  113106. */
  113107. reset(): void;
  113108. }
  113109. /**
  113110. * RollingAverage
  113111. *
  113112. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  113113. */
  113114. export class RollingAverage {
  113115. /**
  113116. * Current average
  113117. */
  113118. average: number;
  113119. /**
  113120. * Current variance
  113121. */
  113122. variance: number;
  113123. protected _samples: Array<number>;
  113124. protected _sampleCount: number;
  113125. protected _pos: number;
  113126. protected _m2: number;
  113127. /**
  113128. * constructor
  113129. * @param length The number of samples required to saturate the sliding window
  113130. */
  113131. constructor(length: number);
  113132. /**
  113133. * Adds a sample to the sample set
  113134. * @param v The sample value
  113135. */
  113136. add(v: number): void;
  113137. /**
  113138. * Returns previously added values or null if outside of history or outside the sliding window domain
  113139. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  113140. * @return Value previously recorded with add() or null if outside of range
  113141. */
  113142. history(i: number): number;
  113143. /**
  113144. * Returns true if enough samples have been taken to completely fill the sliding window
  113145. * @return true if sample-set saturated
  113146. */
  113147. isSaturated(): boolean;
  113148. /**
  113149. * Resets the rolling average (equivalent to 0 samples taken so far)
  113150. */
  113151. reset(): void;
  113152. /**
  113153. * Wraps a value around the sample range boundaries
  113154. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  113155. * @return Wrapped position in sample range
  113156. */
  113157. protected _wrapPosition(i: number): number;
  113158. }
  113159. }
  113160. declare module BABYLON {
  113161. /**
  113162. * This class is used to track a performance counter which is number based.
  113163. * The user has access to many properties which give statistics of different nature.
  113164. *
  113165. * The implementer can track two kinds of Performance Counter: time and count.
  113166. * 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.
  113167. * 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.
  113168. */
  113169. export class PerfCounter {
  113170. /**
  113171. * Gets or sets a global boolean to turn on and off all the counters
  113172. */
  113173. static Enabled: boolean;
  113174. /**
  113175. * Returns the smallest value ever
  113176. */
  113177. get min(): number;
  113178. /**
  113179. * Returns the biggest value ever
  113180. */
  113181. get max(): number;
  113182. /**
  113183. * Returns the average value since the performance counter is running
  113184. */
  113185. get average(): number;
  113186. /**
  113187. * Returns the average value of the last second the counter was monitored
  113188. */
  113189. get lastSecAverage(): number;
  113190. /**
  113191. * Returns the current value
  113192. */
  113193. get current(): number;
  113194. /**
  113195. * Gets the accumulated total
  113196. */
  113197. get total(): number;
  113198. /**
  113199. * Gets the total value count
  113200. */
  113201. get count(): number;
  113202. /**
  113203. * Creates a new counter
  113204. */
  113205. constructor();
  113206. /**
  113207. * Call this method to start monitoring a new frame.
  113208. * 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.
  113209. */
  113210. fetchNewFrame(): void;
  113211. /**
  113212. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  113213. * @param newCount the count value to add to the monitored count
  113214. * @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.
  113215. */
  113216. addCount(newCount: number, fetchResult: boolean): void;
  113217. /**
  113218. * Start monitoring this performance counter
  113219. */
  113220. beginMonitoring(): void;
  113221. /**
  113222. * Compute the time lapsed since the previous beginMonitoring() call.
  113223. * @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
  113224. */
  113225. endMonitoring(newFrame?: boolean): void;
  113226. private _fetchResult;
  113227. private _startMonitoringTime;
  113228. private _min;
  113229. private _max;
  113230. private _average;
  113231. private _current;
  113232. private _totalValueCount;
  113233. private _totalAccumulated;
  113234. private _lastSecAverage;
  113235. private _lastSecAccumulated;
  113236. private _lastSecTime;
  113237. private _lastSecValueCount;
  113238. }
  113239. }
  113240. declare module BABYLON {
  113241. interface ThinEngine {
  113242. /**
  113243. * Sets alpha constants used by some alpha blending modes
  113244. * @param r defines the red component
  113245. * @param g defines the green component
  113246. * @param b defines the blue component
  113247. * @param a defines the alpha component
  113248. */
  113249. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  113250. /**
  113251. * Sets the current alpha mode
  113252. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  113253. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  113254. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  113255. */
  113256. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  113257. /**
  113258. * Gets the current alpha mode
  113259. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  113260. * @returns the current alpha mode
  113261. */
  113262. getAlphaMode(): number;
  113263. /**
  113264. * Sets the current alpha equation
  113265. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  113266. */
  113267. setAlphaEquation(equation: number): void;
  113268. /**
  113269. * Gets the current alpha equation.
  113270. * @returns the current alpha equation
  113271. */
  113272. getAlphaEquation(): number;
  113273. }
  113274. }
  113275. declare module BABYLON {
  113276. interface ThinEngine {
  113277. /** @hidden */
  113278. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  113279. }
  113280. }
  113281. declare module BABYLON {
  113282. /**
  113283. * Defines the interface used by display changed events
  113284. */
  113285. export interface IDisplayChangedEventArgs {
  113286. /** Gets the vrDisplay object (if any) */
  113287. vrDisplay: Nullable<any>;
  113288. /** Gets a boolean indicating if webVR is supported */
  113289. vrSupported: boolean;
  113290. }
  113291. /**
  113292. * Defines the interface used by objects containing a viewport (like a camera)
  113293. */
  113294. interface IViewportOwnerLike {
  113295. /**
  113296. * Gets or sets the viewport
  113297. */
  113298. viewport: IViewportLike;
  113299. }
  113300. /**
  113301. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  113302. */
  113303. export class Engine extends ThinEngine {
  113304. /** Defines that alpha blending is disabled */
  113305. static readonly ALPHA_DISABLE: number;
  113306. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  113307. static readonly ALPHA_ADD: number;
  113308. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  113309. static readonly ALPHA_COMBINE: number;
  113310. /** Defines that alpha blending to DEST - SRC * DEST */
  113311. static readonly ALPHA_SUBTRACT: number;
  113312. /** Defines that alpha blending to SRC * DEST */
  113313. static readonly ALPHA_MULTIPLY: number;
  113314. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  113315. static readonly ALPHA_MAXIMIZED: number;
  113316. /** Defines that alpha blending to SRC + DEST */
  113317. static readonly ALPHA_ONEONE: number;
  113318. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  113319. static readonly ALPHA_PREMULTIPLIED: number;
  113320. /**
  113321. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  113322. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  113323. */
  113324. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  113325. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  113326. static readonly ALPHA_INTERPOLATE: number;
  113327. /**
  113328. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  113329. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  113330. */
  113331. static readonly ALPHA_SCREENMODE: number;
  113332. /** Defines that the ressource is not delayed*/
  113333. static readonly DELAYLOADSTATE_NONE: number;
  113334. /** Defines that the ressource was successfully delay loaded */
  113335. static readonly DELAYLOADSTATE_LOADED: number;
  113336. /** Defines that the ressource is currently delay loading */
  113337. static readonly DELAYLOADSTATE_LOADING: number;
  113338. /** Defines that the ressource is delayed and has not started loading */
  113339. static readonly DELAYLOADSTATE_NOTLOADED: number;
  113340. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  113341. static readonly NEVER: number;
  113342. /** 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 */
  113343. static readonly ALWAYS: number;
  113344. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  113345. static readonly LESS: number;
  113346. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  113347. static readonly EQUAL: number;
  113348. /** 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 */
  113349. static readonly LEQUAL: number;
  113350. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  113351. static readonly GREATER: number;
  113352. /** 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 */
  113353. static readonly GEQUAL: number;
  113354. /** 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 */
  113355. static readonly NOTEQUAL: number;
  113356. /** Passed to stencilOperation to specify that stencil value must be kept */
  113357. static readonly KEEP: number;
  113358. /** Passed to stencilOperation to specify that stencil value must be replaced */
  113359. static readonly REPLACE: number;
  113360. /** Passed to stencilOperation to specify that stencil value must be incremented */
  113361. static readonly INCR: number;
  113362. /** Passed to stencilOperation to specify that stencil value must be decremented */
  113363. static readonly DECR: number;
  113364. /** Passed to stencilOperation to specify that stencil value must be inverted */
  113365. static readonly INVERT: number;
  113366. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  113367. static readonly INCR_WRAP: number;
  113368. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  113369. static readonly DECR_WRAP: number;
  113370. /** Texture is not repeating outside of 0..1 UVs */
  113371. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  113372. /** Texture is repeating outside of 0..1 UVs */
  113373. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  113374. /** Texture is repeating and mirrored */
  113375. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  113376. /** ALPHA */
  113377. static readonly TEXTUREFORMAT_ALPHA: number;
  113378. /** LUMINANCE */
  113379. static readonly TEXTUREFORMAT_LUMINANCE: number;
  113380. /** LUMINANCE_ALPHA */
  113381. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  113382. /** RGB */
  113383. static readonly TEXTUREFORMAT_RGB: number;
  113384. /** RGBA */
  113385. static readonly TEXTUREFORMAT_RGBA: number;
  113386. /** RED */
  113387. static readonly TEXTUREFORMAT_RED: number;
  113388. /** RED (2nd reference) */
  113389. static readonly TEXTUREFORMAT_R: number;
  113390. /** RG */
  113391. static readonly TEXTUREFORMAT_RG: number;
  113392. /** RED_INTEGER */
  113393. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  113394. /** RED_INTEGER (2nd reference) */
  113395. static readonly TEXTUREFORMAT_R_INTEGER: number;
  113396. /** RG_INTEGER */
  113397. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  113398. /** RGB_INTEGER */
  113399. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  113400. /** RGBA_INTEGER */
  113401. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  113402. /** UNSIGNED_BYTE */
  113403. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  113404. /** UNSIGNED_BYTE (2nd reference) */
  113405. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  113406. /** FLOAT */
  113407. static readonly TEXTURETYPE_FLOAT: number;
  113408. /** HALF_FLOAT */
  113409. static readonly TEXTURETYPE_HALF_FLOAT: number;
  113410. /** BYTE */
  113411. static readonly TEXTURETYPE_BYTE: number;
  113412. /** SHORT */
  113413. static readonly TEXTURETYPE_SHORT: number;
  113414. /** UNSIGNED_SHORT */
  113415. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  113416. /** INT */
  113417. static readonly TEXTURETYPE_INT: number;
  113418. /** UNSIGNED_INT */
  113419. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  113420. /** UNSIGNED_SHORT_4_4_4_4 */
  113421. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  113422. /** UNSIGNED_SHORT_5_5_5_1 */
  113423. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  113424. /** UNSIGNED_SHORT_5_6_5 */
  113425. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  113426. /** UNSIGNED_INT_2_10_10_10_REV */
  113427. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  113428. /** UNSIGNED_INT_24_8 */
  113429. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  113430. /** UNSIGNED_INT_10F_11F_11F_REV */
  113431. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  113432. /** UNSIGNED_INT_5_9_9_9_REV */
  113433. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  113434. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  113435. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  113436. /** nearest is mag = nearest and min = nearest and mip = linear */
  113437. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  113438. /** Bilinear is mag = linear and min = linear and mip = nearest */
  113439. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  113440. /** Trilinear is mag = linear and min = linear and mip = linear */
  113441. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  113442. /** nearest is mag = nearest and min = nearest and mip = linear */
  113443. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  113444. /** Bilinear is mag = linear and min = linear and mip = nearest */
  113445. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  113446. /** Trilinear is mag = linear and min = linear and mip = linear */
  113447. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  113448. /** mag = nearest and min = nearest and mip = nearest */
  113449. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  113450. /** mag = nearest and min = linear and mip = nearest */
  113451. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  113452. /** mag = nearest and min = linear and mip = linear */
  113453. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  113454. /** mag = nearest and min = linear and mip = none */
  113455. static readonly TEXTURE_NEAREST_LINEAR: number;
  113456. /** mag = nearest and min = nearest and mip = none */
  113457. static readonly TEXTURE_NEAREST_NEAREST: number;
  113458. /** mag = linear and min = nearest and mip = nearest */
  113459. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  113460. /** mag = linear and min = nearest and mip = linear */
  113461. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  113462. /** mag = linear and min = linear and mip = none */
  113463. static readonly TEXTURE_LINEAR_LINEAR: number;
  113464. /** mag = linear and min = nearest and mip = none */
  113465. static readonly TEXTURE_LINEAR_NEAREST: number;
  113466. /** Explicit coordinates mode */
  113467. static readonly TEXTURE_EXPLICIT_MODE: number;
  113468. /** Spherical coordinates mode */
  113469. static readonly TEXTURE_SPHERICAL_MODE: number;
  113470. /** Planar coordinates mode */
  113471. static readonly TEXTURE_PLANAR_MODE: number;
  113472. /** Cubic coordinates mode */
  113473. static readonly TEXTURE_CUBIC_MODE: number;
  113474. /** Projection coordinates mode */
  113475. static readonly TEXTURE_PROJECTION_MODE: number;
  113476. /** Skybox coordinates mode */
  113477. static readonly TEXTURE_SKYBOX_MODE: number;
  113478. /** Inverse Cubic coordinates mode */
  113479. static readonly TEXTURE_INVCUBIC_MODE: number;
  113480. /** Equirectangular coordinates mode */
  113481. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  113482. /** Equirectangular Fixed coordinates mode */
  113483. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  113484. /** Equirectangular Fixed Mirrored coordinates mode */
  113485. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  113486. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  113487. static readonly SCALEMODE_FLOOR: number;
  113488. /** Defines that texture rescaling will look for the nearest power of 2 size */
  113489. static readonly SCALEMODE_NEAREST: number;
  113490. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  113491. static readonly SCALEMODE_CEILING: number;
  113492. /**
  113493. * Returns the current npm package of the sdk
  113494. */
  113495. static get NpmPackage(): string;
  113496. /**
  113497. * Returns the current version of the framework
  113498. */
  113499. static get Version(): string;
  113500. /** Gets the list of created engines */
  113501. static get Instances(): Engine[];
  113502. /**
  113503. * Gets the latest created engine
  113504. */
  113505. static get LastCreatedEngine(): Nullable<Engine>;
  113506. /**
  113507. * Gets the latest created scene
  113508. */
  113509. static get LastCreatedScene(): Nullable<Scene>;
  113510. /**
  113511. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  113512. * @param flag defines which part of the materials must be marked as dirty
  113513. * @param predicate defines a predicate used to filter which materials should be affected
  113514. */
  113515. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  113516. /**
  113517. * Method called to create the default loading screen.
  113518. * This can be overriden in your own app.
  113519. * @param canvas The rendering canvas element
  113520. * @returns The loading screen
  113521. */
  113522. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  113523. /**
  113524. * Method called to create the default rescale post process on each engine.
  113525. */
  113526. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  113527. /**
  113528. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  113529. **/
  113530. enableOfflineSupport: boolean;
  113531. /**
  113532. * 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)
  113533. **/
  113534. disableManifestCheck: boolean;
  113535. /**
  113536. * Gets the list of created scenes
  113537. */
  113538. scenes: Scene[];
  113539. /**
  113540. * Event raised when a new scene is created
  113541. */
  113542. onNewSceneAddedObservable: Observable<Scene>;
  113543. /**
  113544. * Gets the list of created postprocesses
  113545. */
  113546. postProcesses: PostProcess[];
  113547. /**
  113548. * Gets a boolean indicating if the pointer is currently locked
  113549. */
  113550. isPointerLock: boolean;
  113551. /**
  113552. * Observable event triggered each time the rendering canvas is resized
  113553. */
  113554. onResizeObservable: Observable<Engine>;
  113555. /**
  113556. * Observable event triggered each time the canvas loses focus
  113557. */
  113558. onCanvasBlurObservable: Observable<Engine>;
  113559. /**
  113560. * Observable event triggered each time the canvas gains focus
  113561. */
  113562. onCanvasFocusObservable: Observable<Engine>;
  113563. /**
  113564. * Observable event triggered each time the canvas receives pointerout event
  113565. */
  113566. onCanvasPointerOutObservable: Observable<PointerEvent>;
  113567. /**
  113568. * Observable raised when the engine begins a new frame
  113569. */
  113570. onBeginFrameObservable: Observable<Engine>;
  113571. /**
  113572. * If set, will be used to request the next animation frame for the render loop
  113573. */
  113574. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  113575. /**
  113576. * Observable raised when the engine ends the current frame
  113577. */
  113578. onEndFrameObservable: Observable<Engine>;
  113579. /**
  113580. * Observable raised when the engine is about to compile a shader
  113581. */
  113582. onBeforeShaderCompilationObservable: Observable<Engine>;
  113583. /**
  113584. * Observable raised when the engine has jsut compiled a shader
  113585. */
  113586. onAfterShaderCompilationObservable: Observable<Engine>;
  113587. /**
  113588. * Gets the audio engine
  113589. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  113590. * @ignorenaming
  113591. */
  113592. static audioEngine: IAudioEngine;
  113593. /**
  113594. * Default AudioEngine factory responsible of creating the Audio Engine.
  113595. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  113596. */
  113597. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  113598. /**
  113599. * Default offline support factory responsible of creating a tool used to store data locally.
  113600. * By default, this will create a Database object if the workload has been embedded.
  113601. */
  113602. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  113603. private _loadingScreen;
  113604. private _pointerLockRequested;
  113605. private _rescalePostProcess;
  113606. private _deterministicLockstep;
  113607. private _lockstepMaxSteps;
  113608. private _timeStep;
  113609. protected get _supportsHardwareTextureRescaling(): boolean;
  113610. private _fps;
  113611. private _deltaTime;
  113612. /** @hidden */
  113613. _drawCalls: PerfCounter;
  113614. /** 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 */
  113615. canvasTabIndex: number;
  113616. /**
  113617. * Turn this value on if you want to pause FPS computation when in background
  113618. */
  113619. disablePerformanceMonitorInBackground: boolean;
  113620. private _performanceMonitor;
  113621. /**
  113622. * Gets the performance monitor attached to this engine
  113623. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  113624. */
  113625. get performanceMonitor(): PerformanceMonitor;
  113626. private _onFocus;
  113627. private _onBlur;
  113628. private _onCanvasPointerOut;
  113629. private _onCanvasBlur;
  113630. private _onCanvasFocus;
  113631. private _onFullscreenChange;
  113632. private _onPointerLockChange;
  113633. /**
  113634. * Gets the HTML element used to attach event listeners
  113635. * @returns a HTML element
  113636. */
  113637. getInputElement(): Nullable<HTMLElement>;
  113638. /**
  113639. * Creates a new engine
  113640. * @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
  113641. * @param antialias defines enable antialiasing (default: false)
  113642. * @param options defines further options to be sent to the getContext() function
  113643. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  113644. */
  113645. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  113646. /**
  113647. * Gets current aspect ratio
  113648. * @param viewportOwner defines the camera to use to get the aspect ratio
  113649. * @param useScreen defines if screen size must be used (or the current render target if any)
  113650. * @returns a number defining the aspect ratio
  113651. */
  113652. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  113653. /**
  113654. * Gets current screen aspect ratio
  113655. * @returns a number defining the aspect ratio
  113656. */
  113657. getScreenAspectRatio(): number;
  113658. /**
  113659. * Gets the client rect of the HTML canvas attached with the current webGL context
  113660. * @returns a client rectanglee
  113661. */
  113662. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  113663. /**
  113664. * Gets the client rect of the HTML element used for events
  113665. * @returns a client rectanglee
  113666. */
  113667. getInputElementClientRect(): Nullable<ClientRect>;
  113668. /**
  113669. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  113670. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  113671. * @returns true if engine is in deterministic lock step mode
  113672. */
  113673. isDeterministicLockStep(): boolean;
  113674. /**
  113675. * Gets the max steps when engine is running in deterministic lock step
  113676. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  113677. * @returns the max steps
  113678. */
  113679. getLockstepMaxSteps(): number;
  113680. /**
  113681. * Returns the time in ms between steps when using deterministic lock step.
  113682. * @returns time step in (ms)
  113683. */
  113684. getTimeStep(): number;
  113685. /**
  113686. * Force the mipmap generation for the given render target texture
  113687. * @param texture defines the render target texture to use
  113688. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  113689. */
  113690. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  113691. /** States */
  113692. /**
  113693. * Set various states to the webGL context
  113694. * @param culling defines backface culling state
  113695. * @param zOffset defines the value to apply to zOffset (0 by default)
  113696. * @param force defines if states must be applied even if cache is up to date
  113697. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  113698. */
  113699. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  113700. /**
  113701. * Set the z offset to apply to current rendering
  113702. * @param value defines the offset to apply
  113703. */
  113704. setZOffset(value: number): void;
  113705. /**
  113706. * Gets the current value of the zOffset
  113707. * @returns the current zOffset state
  113708. */
  113709. getZOffset(): number;
  113710. /**
  113711. * Enable or disable depth buffering
  113712. * @param enable defines the state to set
  113713. */
  113714. setDepthBuffer(enable: boolean): void;
  113715. /**
  113716. * Gets a boolean indicating if depth writing is enabled
  113717. * @returns the current depth writing state
  113718. */
  113719. getDepthWrite(): boolean;
  113720. /**
  113721. * Enable or disable depth writing
  113722. * @param enable defines the state to set
  113723. */
  113724. setDepthWrite(enable: boolean): void;
  113725. /**
  113726. * Gets a boolean indicating if stencil buffer is enabled
  113727. * @returns the current stencil buffer state
  113728. */
  113729. getStencilBuffer(): boolean;
  113730. /**
  113731. * Enable or disable the stencil buffer
  113732. * @param enable defines if the stencil buffer must be enabled or disabled
  113733. */
  113734. setStencilBuffer(enable: boolean): void;
  113735. /**
  113736. * Gets the current stencil mask
  113737. * @returns a number defining the new stencil mask to use
  113738. */
  113739. getStencilMask(): number;
  113740. /**
  113741. * Sets the current stencil mask
  113742. * @param mask defines the new stencil mask to use
  113743. */
  113744. setStencilMask(mask: number): void;
  113745. /**
  113746. * Gets the current stencil function
  113747. * @returns a number defining the stencil function to use
  113748. */
  113749. getStencilFunction(): number;
  113750. /**
  113751. * Gets the current stencil reference value
  113752. * @returns a number defining the stencil reference value to use
  113753. */
  113754. getStencilFunctionReference(): number;
  113755. /**
  113756. * Gets the current stencil mask
  113757. * @returns a number defining the stencil mask to use
  113758. */
  113759. getStencilFunctionMask(): number;
  113760. /**
  113761. * Sets the current stencil function
  113762. * @param stencilFunc defines the new stencil function to use
  113763. */
  113764. setStencilFunction(stencilFunc: number): void;
  113765. /**
  113766. * Sets the current stencil reference
  113767. * @param reference defines the new stencil reference to use
  113768. */
  113769. setStencilFunctionReference(reference: number): void;
  113770. /**
  113771. * Sets the current stencil mask
  113772. * @param mask defines the new stencil mask to use
  113773. */
  113774. setStencilFunctionMask(mask: number): void;
  113775. /**
  113776. * Gets the current stencil operation when stencil fails
  113777. * @returns a number defining stencil operation to use when stencil fails
  113778. */
  113779. getStencilOperationFail(): number;
  113780. /**
  113781. * Gets the current stencil operation when depth fails
  113782. * @returns a number defining stencil operation to use when depth fails
  113783. */
  113784. getStencilOperationDepthFail(): number;
  113785. /**
  113786. * Gets the current stencil operation when stencil passes
  113787. * @returns a number defining stencil operation to use when stencil passes
  113788. */
  113789. getStencilOperationPass(): number;
  113790. /**
  113791. * Sets the stencil operation to use when stencil fails
  113792. * @param operation defines the stencil operation to use when stencil fails
  113793. */
  113794. setStencilOperationFail(operation: number): void;
  113795. /**
  113796. * Sets the stencil operation to use when depth fails
  113797. * @param operation defines the stencil operation to use when depth fails
  113798. */
  113799. setStencilOperationDepthFail(operation: number): void;
  113800. /**
  113801. * Sets the stencil operation to use when stencil passes
  113802. * @param operation defines the stencil operation to use when stencil passes
  113803. */
  113804. setStencilOperationPass(operation: number): void;
  113805. /**
  113806. * Sets a boolean indicating if the dithering state is enabled or disabled
  113807. * @param value defines the dithering state
  113808. */
  113809. setDitheringState(value: boolean): void;
  113810. /**
  113811. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  113812. * @param value defines the rasterizer state
  113813. */
  113814. setRasterizerState(value: boolean): void;
  113815. /**
  113816. * Gets the current depth function
  113817. * @returns a number defining the depth function
  113818. */
  113819. getDepthFunction(): Nullable<number>;
  113820. /**
  113821. * Sets the current depth function
  113822. * @param depthFunc defines the function to use
  113823. */
  113824. setDepthFunction(depthFunc: number): void;
  113825. /**
  113826. * Sets the current depth function to GREATER
  113827. */
  113828. setDepthFunctionToGreater(): void;
  113829. /**
  113830. * Sets the current depth function to GEQUAL
  113831. */
  113832. setDepthFunctionToGreaterOrEqual(): void;
  113833. /**
  113834. * Sets the current depth function to LESS
  113835. */
  113836. setDepthFunctionToLess(): void;
  113837. /**
  113838. * Sets the current depth function to LEQUAL
  113839. */
  113840. setDepthFunctionToLessOrEqual(): void;
  113841. private _cachedStencilBuffer;
  113842. private _cachedStencilFunction;
  113843. private _cachedStencilMask;
  113844. private _cachedStencilOperationPass;
  113845. private _cachedStencilOperationFail;
  113846. private _cachedStencilOperationDepthFail;
  113847. private _cachedStencilReference;
  113848. /**
  113849. * Caches the the state of the stencil buffer
  113850. */
  113851. cacheStencilState(): void;
  113852. /**
  113853. * Restores the state of the stencil buffer
  113854. */
  113855. restoreStencilState(): void;
  113856. /**
  113857. * Directly set the WebGL Viewport
  113858. * @param x defines the x coordinate of the viewport (in screen space)
  113859. * @param y defines the y coordinate of the viewport (in screen space)
  113860. * @param width defines the width of the viewport (in screen space)
  113861. * @param height defines the height of the viewport (in screen space)
  113862. * @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
  113863. */
  113864. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  113865. /**
  113866. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  113867. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  113868. * @param y defines the y-coordinate of the corner of the clear rectangle
  113869. * @param width defines the width of the clear rectangle
  113870. * @param height defines the height of the clear rectangle
  113871. * @param clearColor defines the clear color
  113872. */
  113873. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  113874. /**
  113875. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  113876. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  113877. * @param y defines the y-coordinate of the corner of the clear rectangle
  113878. * @param width defines the width of the clear rectangle
  113879. * @param height defines the height of the clear rectangle
  113880. */
  113881. enableScissor(x: number, y: number, width: number, height: number): void;
  113882. /**
  113883. * Disable previously set scissor test rectangle
  113884. */
  113885. disableScissor(): void;
  113886. protected _reportDrawCall(): void;
  113887. /**
  113888. * Initializes a webVR display and starts listening to display change events
  113889. * The onVRDisplayChangedObservable will be notified upon these changes
  113890. * @returns The onVRDisplayChangedObservable
  113891. */
  113892. initWebVR(): Observable<IDisplayChangedEventArgs>;
  113893. /** @hidden */
  113894. _prepareVRComponent(): void;
  113895. /** @hidden */
  113896. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  113897. /** @hidden */
  113898. _submitVRFrame(): void;
  113899. /**
  113900. * Call this function to leave webVR mode
  113901. * Will do nothing if webVR is not supported or if there is no webVR device
  113902. * @see http://doc.babylonjs.com/how_to/webvr_camera
  113903. */
  113904. disableVR(): void;
  113905. /**
  113906. * Gets a boolean indicating that the system is in VR mode and is presenting
  113907. * @returns true if VR mode is engaged
  113908. */
  113909. isVRPresenting(): boolean;
  113910. /** @hidden */
  113911. _requestVRFrame(): void;
  113912. /** @hidden */
  113913. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  113914. /**
  113915. * Gets the source code of the vertex shader associated with a specific webGL program
  113916. * @param program defines the program to use
  113917. * @returns a string containing the source code of the vertex shader associated with the program
  113918. */
  113919. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  113920. /**
  113921. * Gets the source code of the fragment shader associated with a specific webGL program
  113922. * @param program defines the program to use
  113923. * @returns a string containing the source code of the fragment shader associated with the program
  113924. */
  113925. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  113926. /**
  113927. * Sets a depth stencil texture from a render target to the according uniform.
  113928. * @param channel The texture channel
  113929. * @param uniform The uniform to set
  113930. * @param texture The render target texture containing the depth stencil texture to apply
  113931. */
  113932. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  113933. /**
  113934. * Sets a texture to the webGL context from a postprocess
  113935. * @param channel defines the channel to use
  113936. * @param postProcess defines the source postprocess
  113937. */
  113938. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  113939. /**
  113940. * Binds the output of the passed in post process to the texture channel specified
  113941. * @param channel The channel the texture should be bound to
  113942. * @param postProcess The post process which's output should be bound
  113943. */
  113944. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  113945. protected _rebuildBuffers(): void;
  113946. /** @hidden */
  113947. _renderFrame(): void;
  113948. _renderLoop(): void;
  113949. /** @hidden */
  113950. _renderViews(): boolean;
  113951. /**
  113952. * Toggle full screen mode
  113953. * @param requestPointerLock defines if a pointer lock should be requested from the user
  113954. */
  113955. switchFullscreen(requestPointerLock: boolean): void;
  113956. /**
  113957. * Enters full screen mode
  113958. * @param requestPointerLock defines if a pointer lock should be requested from the user
  113959. */
  113960. enterFullscreen(requestPointerLock: boolean): void;
  113961. /**
  113962. * Exits full screen mode
  113963. */
  113964. exitFullscreen(): void;
  113965. /**
  113966. * Enters Pointerlock mode
  113967. */
  113968. enterPointerlock(): void;
  113969. /**
  113970. * Exits Pointerlock mode
  113971. */
  113972. exitPointerlock(): void;
  113973. /**
  113974. * Begin a new frame
  113975. */
  113976. beginFrame(): void;
  113977. /**
  113978. * Enf the current frame
  113979. */
  113980. endFrame(): void;
  113981. resize(): void;
  113982. /**
  113983. * Force a specific size of the canvas
  113984. * @param width defines the new canvas' width
  113985. * @param height defines the new canvas' height
  113986. */
  113987. setSize(width: number, height: number): void;
  113988. /**
  113989. * Updates a dynamic vertex buffer.
  113990. * @param vertexBuffer the vertex buffer to update
  113991. * @param data the data used to update the vertex buffer
  113992. * @param byteOffset the byte offset of the data
  113993. * @param byteLength the byte length of the data
  113994. */
  113995. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  113996. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  113997. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  113998. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  113999. _releaseTexture(texture: InternalTexture): void;
  114000. /**
  114001. * @hidden
  114002. * Rescales a texture
  114003. * @param source input texutre
  114004. * @param destination destination texture
  114005. * @param scene scene to use to render the resize
  114006. * @param internalFormat format to use when resizing
  114007. * @param onComplete callback to be called when resize has completed
  114008. */
  114009. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  114010. /**
  114011. * Gets the current framerate
  114012. * @returns a number representing the framerate
  114013. */
  114014. getFps(): number;
  114015. /**
  114016. * Gets the time spent between current and previous frame
  114017. * @returns a number representing the delta time in ms
  114018. */
  114019. getDeltaTime(): number;
  114020. private _measureFps;
  114021. /** @hidden */
  114022. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  114023. /**
  114024. * Update a dynamic index buffer
  114025. * @param indexBuffer defines the target index buffer
  114026. * @param indices defines the data to update
  114027. * @param offset defines the offset in the target index buffer where update should start
  114028. */
  114029. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  114030. /**
  114031. * Updates the sample count of a render target texture
  114032. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  114033. * @param texture defines the texture to update
  114034. * @param samples defines the sample count to set
  114035. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  114036. */
  114037. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  114038. /**
  114039. * Updates a depth texture Comparison Mode and Function.
  114040. * If the comparison Function is equal to 0, the mode will be set to none.
  114041. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  114042. * @param texture The texture to set the comparison function for
  114043. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  114044. */
  114045. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  114046. /**
  114047. * Creates a webGL buffer to use with instanciation
  114048. * @param capacity defines the size of the buffer
  114049. * @returns the webGL buffer
  114050. */
  114051. createInstancesBuffer(capacity: number): DataBuffer;
  114052. /**
  114053. * Delete a webGL buffer used with instanciation
  114054. * @param buffer defines the webGL buffer to delete
  114055. */
  114056. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  114057. private _clientWaitAsync;
  114058. /** @hidden */
  114059. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  114060. dispose(): void;
  114061. private _disableTouchAction;
  114062. /**
  114063. * Display the loading screen
  114064. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  114065. */
  114066. displayLoadingUI(): void;
  114067. /**
  114068. * Hide the loading screen
  114069. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  114070. */
  114071. hideLoadingUI(): void;
  114072. /**
  114073. * Gets the current loading screen object
  114074. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  114075. */
  114076. get loadingScreen(): ILoadingScreen;
  114077. /**
  114078. * Sets the current loading screen object
  114079. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  114080. */
  114081. set loadingScreen(loadingScreen: ILoadingScreen);
  114082. /**
  114083. * Sets the current loading screen text
  114084. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  114085. */
  114086. set loadingUIText(text: string);
  114087. /**
  114088. * Sets the current loading screen background color
  114089. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  114090. */
  114091. set loadingUIBackgroundColor(color: string);
  114092. /** Pointerlock and fullscreen */
  114093. /**
  114094. * Ask the browser to promote the current element to pointerlock mode
  114095. * @param element defines the DOM element to promote
  114096. */
  114097. static _RequestPointerlock(element: HTMLElement): void;
  114098. /**
  114099. * Asks the browser to exit pointerlock mode
  114100. */
  114101. static _ExitPointerlock(): void;
  114102. /**
  114103. * Ask the browser to promote the current element to fullscreen rendering mode
  114104. * @param element defines the DOM element to promote
  114105. */
  114106. static _RequestFullscreen(element: HTMLElement): void;
  114107. /**
  114108. * Asks the browser to exit fullscreen mode
  114109. */
  114110. static _ExitFullscreen(): void;
  114111. }
  114112. }
  114113. declare module BABYLON {
  114114. /**
  114115. * The engine store class is responsible to hold all the instances of Engine and Scene created
  114116. * during the life time of the application.
  114117. */
  114118. export class EngineStore {
  114119. /** Gets the list of created engines */
  114120. static Instances: Engine[];
  114121. /** @hidden */
  114122. static _LastCreatedScene: Nullable<Scene>;
  114123. /**
  114124. * Gets the latest created engine
  114125. */
  114126. static get LastCreatedEngine(): Nullable<Engine>;
  114127. /**
  114128. * Gets the latest created scene
  114129. */
  114130. static get LastCreatedScene(): Nullable<Scene>;
  114131. /**
  114132. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  114133. * @ignorenaming
  114134. */
  114135. static UseFallbackTexture: boolean;
  114136. /**
  114137. * Texture content used if a texture cannot loaded
  114138. * @ignorenaming
  114139. */
  114140. static FallbackTexture: string;
  114141. }
  114142. }
  114143. declare module BABYLON {
  114144. /**
  114145. * Helper class that provides a small promise polyfill
  114146. */
  114147. export class PromisePolyfill {
  114148. /**
  114149. * Static function used to check if the polyfill is required
  114150. * If this is the case then the function will inject the polyfill to window.Promise
  114151. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  114152. */
  114153. static Apply(force?: boolean): void;
  114154. }
  114155. }
  114156. declare module BABYLON {
  114157. /**
  114158. * Interface for screenshot methods with describe argument called `size` as object with options
  114159. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  114160. */
  114161. export interface IScreenshotSize {
  114162. /**
  114163. * number in pixels for canvas height
  114164. */
  114165. height?: number;
  114166. /**
  114167. * multiplier allowing render at a higher or lower resolution
  114168. * If value is defined then height and width will be ignored and taken from camera
  114169. */
  114170. precision?: number;
  114171. /**
  114172. * number in pixels for canvas width
  114173. */
  114174. width?: number;
  114175. }
  114176. }
  114177. declare module BABYLON {
  114178. interface IColor4Like {
  114179. r: float;
  114180. g: float;
  114181. b: float;
  114182. a: float;
  114183. }
  114184. /**
  114185. * Class containing a set of static utilities functions
  114186. */
  114187. export class Tools {
  114188. /**
  114189. * Gets or sets the base URL to use to load assets
  114190. */
  114191. static get BaseUrl(): string;
  114192. static set BaseUrl(value: string);
  114193. /**
  114194. * Enable/Disable Custom HTTP Request Headers globally.
  114195. * default = false
  114196. * @see CustomRequestHeaders
  114197. */
  114198. static UseCustomRequestHeaders: boolean;
  114199. /**
  114200. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  114201. * i.e. when loading files, where the server/service expects an Authorization header
  114202. */
  114203. static CustomRequestHeaders: {
  114204. [key: string]: string;
  114205. };
  114206. /**
  114207. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  114208. */
  114209. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  114210. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  114211. /**
  114212. * Default behaviour for cors in the application.
  114213. * It can be a string if the expected behavior is identical in the entire app.
  114214. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  114215. */
  114216. static get CorsBehavior(): string | ((url: string | string[]) => string);
  114217. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  114218. /**
  114219. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  114220. * @ignorenaming
  114221. */
  114222. static get UseFallbackTexture(): boolean;
  114223. static set UseFallbackTexture(value: boolean);
  114224. /**
  114225. * Use this object to register external classes like custom textures or material
  114226. * to allow the laoders to instantiate them
  114227. */
  114228. static get RegisteredExternalClasses(): {
  114229. [key: string]: Object;
  114230. };
  114231. static set RegisteredExternalClasses(classes: {
  114232. [key: string]: Object;
  114233. });
  114234. /**
  114235. * Texture content used if a texture cannot loaded
  114236. * @ignorenaming
  114237. */
  114238. static get fallbackTexture(): string;
  114239. static set fallbackTexture(value: string);
  114240. /**
  114241. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  114242. * @param u defines the coordinate on X axis
  114243. * @param v defines the coordinate on Y axis
  114244. * @param width defines the width of the source data
  114245. * @param height defines the height of the source data
  114246. * @param pixels defines the source byte array
  114247. * @param color defines the output color
  114248. */
  114249. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  114250. /**
  114251. * Interpolates between a and b via alpha
  114252. * @param a The lower value (returned when alpha = 0)
  114253. * @param b The upper value (returned when alpha = 1)
  114254. * @param alpha The interpolation-factor
  114255. * @return The mixed value
  114256. */
  114257. static Mix(a: number, b: number, alpha: number): number;
  114258. /**
  114259. * Tries to instantiate a new object from a given class name
  114260. * @param className defines the class name to instantiate
  114261. * @returns the new object or null if the system was not able to do the instantiation
  114262. */
  114263. static Instantiate(className: string): any;
  114264. /**
  114265. * Provides a slice function that will work even on IE
  114266. * @param data defines the array to slice
  114267. * @param start defines the start of the data (optional)
  114268. * @param end defines the end of the data (optional)
  114269. * @returns the new sliced array
  114270. */
  114271. static Slice<T>(data: T, start?: number, end?: number): T;
  114272. /**
  114273. * Polyfill for setImmediate
  114274. * @param action defines the action to execute after the current execution block
  114275. */
  114276. static SetImmediate(action: () => void): void;
  114277. /**
  114278. * Function indicating if a number is an exponent of 2
  114279. * @param value defines the value to test
  114280. * @returns true if the value is an exponent of 2
  114281. */
  114282. static IsExponentOfTwo(value: number): boolean;
  114283. private static _tmpFloatArray;
  114284. /**
  114285. * Returns the nearest 32-bit single precision float representation of a Number
  114286. * @param value A Number. If the parameter is of a different type, it will get converted
  114287. * to a number or to NaN if it cannot be converted
  114288. * @returns number
  114289. */
  114290. static FloatRound(value: number): number;
  114291. /**
  114292. * Extracts the filename from a path
  114293. * @param path defines the path to use
  114294. * @returns the filename
  114295. */
  114296. static GetFilename(path: string): string;
  114297. /**
  114298. * Extracts the "folder" part of a path (everything before the filename).
  114299. * @param uri The URI to extract the info from
  114300. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  114301. * @returns The "folder" part of the path
  114302. */
  114303. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  114304. /**
  114305. * Extracts text content from a DOM element hierarchy
  114306. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  114307. */
  114308. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  114309. /**
  114310. * Convert an angle in radians to degrees
  114311. * @param angle defines the angle to convert
  114312. * @returns the angle in degrees
  114313. */
  114314. static ToDegrees(angle: number): number;
  114315. /**
  114316. * Convert an angle in degrees to radians
  114317. * @param angle defines the angle to convert
  114318. * @returns the angle in radians
  114319. */
  114320. static ToRadians(angle: number): number;
  114321. /**
  114322. * Returns an array if obj is not an array
  114323. * @param obj defines the object to evaluate as an array
  114324. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  114325. * @returns either obj directly if obj is an array or a new array containing obj
  114326. */
  114327. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  114328. /**
  114329. * Gets the pointer prefix to use
  114330. * @param engine defines the engine we are finding the prefix for
  114331. * @returns "pointer" if touch is enabled. Else returns "mouse"
  114332. */
  114333. static GetPointerPrefix(engine: Engine): string;
  114334. /**
  114335. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  114336. * @param url define the url we are trying
  114337. * @param element define the dom element where to configure the cors policy
  114338. */
  114339. static SetCorsBehavior(url: string | string[], element: {
  114340. crossOrigin: string | null;
  114341. }): void;
  114342. /**
  114343. * Removes unwanted characters from an url
  114344. * @param url defines the url to clean
  114345. * @returns the cleaned url
  114346. */
  114347. static CleanUrl(url: string): string;
  114348. /**
  114349. * Gets or sets a function used to pre-process url before using them to load assets
  114350. */
  114351. static get PreprocessUrl(): (url: string) => string;
  114352. static set PreprocessUrl(processor: (url: string) => string);
  114353. /**
  114354. * Loads an image as an HTMLImageElement.
  114355. * @param input url string, ArrayBuffer, or Blob to load
  114356. * @param onLoad callback called when the image successfully loads
  114357. * @param onError callback called when the image fails to load
  114358. * @param offlineProvider offline provider for caching
  114359. * @param mimeType optional mime type
  114360. * @returns the HTMLImageElement of the loaded image
  114361. */
  114362. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  114363. /**
  114364. * Loads a file from a url
  114365. * @param url url string, ArrayBuffer, or Blob to load
  114366. * @param onSuccess callback called when the file successfully loads
  114367. * @param onProgress callback called while file is loading (if the server supports this mode)
  114368. * @param offlineProvider defines the offline provider for caching
  114369. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  114370. * @param onError callback called when the file fails to load
  114371. * @returns a file request object
  114372. */
  114373. 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;
  114374. /**
  114375. * Loads a file from a url
  114376. * @param url the file url to load
  114377. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  114378. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  114379. */
  114380. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  114381. /**
  114382. * Load a script (identified by an url). When the url returns, the
  114383. * content of this file is added into a new script element, attached to the DOM (body element)
  114384. * @param scriptUrl defines the url of the script to laod
  114385. * @param onSuccess defines the callback called when the script is loaded
  114386. * @param onError defines the callback to call if an error occurs
  114387. * @param scriptId defines the id of the script element
  114388. */
  114389. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  114390. /**
  114391. * Load an asynchronous script (identified by an url). When the url returns, the
  114392. * content of this file is added into a new script element, attached to the DOM (body element)
  114393. * @param scriptUrl defines the url of the script to laod
  114394. * @param scriptId defines the id of the script element
  114395. * @returns a promise request object
  114396. */
  114397. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  114398. /**
  114399. * Loads a file from a blob
  114400. * @param fileToLoad defines the blob to use
  114401. * @param callback defines the callback to call when data is loaded
  114402. * @param progressCallback defines the callback to call during loading process
  114403. * @returns a file request object
  114404. */
  114405. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  114406. /**
  114407. * Reads a file from a File object
  114408. * @param file defines the file to load
  114409. * @param onSuccess defines the callback to call when data is loaded
  114410. * @param onProgress defines the callback to call during loading process
  114411. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  114412. * @param onError defines the callback to call when an error occurs
  114413. * @returns a file request object
  114414. */
  114415. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  114416. /**
  114417. * Creates a data url from a given string content
  114418. * @param content defines the content to convert
  114419. * @returns the new data url link
  114420. */
  114421. static FileAsURL(content: string): string;
  114422. /**
  114423. * Format the given number to a specific decimal format
  114424. * @param value defines the number to format
  114425. * @param decimals defines the number of decimals to use
  114426. * @returns the formatted string
  114427. */
  114428. static Format(value: number, decimals?: number): string;
  114429. /**
  114430. * Tries to copy an object by duplicating every property
  114431. * @param source defines the source object
  114432. * @param destination defines the target object
  114433. * @param doNotCopyList defines a list of properties to avoid
  114434. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  114435. */
  114436. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  114437. /**
  114438. * Gets a boolean indicating if the given object has no own property
  114439. * @param obj defines the object to test
  114440. * @returns true if object has no own property
  114441. */
  114442. static IsEmpty(obj: any): boolean;
  114443. /**
  114444. * Function used to register events at window level
  114445. * @param windowElement defines the Window object to use
  114446. * @param events defines the events to register
  114447. */
  114448. static RegisterTopRootEvents(windowElement: Window, events: {
  114449. name: string;
  114450. handler: Nullable<(e: FocusEvent) => any>;
  114451. }[]): void;
  114452. /**
  114453. * Function used to unregister events from window level
  114454. * @param windowElement defines the Window object to use
  114455. * @param events defines the events to unregister
  114456. */
  114457. static UnregisterTopRootEvents(windowElement: Window, events: {
  114458. name: string;
  114459. handler: Nullable<(e: FocusEvent) => any>;
  114460. }[]): void;
  114461. /**
  114462. * @ignore
  114463. */
  114464. static _ScreenshotCanvas: HTMLCanvasElement;
  114465. /**
  114466. * Dumps the current bound framebuffer
  114467. * @param width defines the rendering width
  114468. * @param height defines the rendering height
  114469. * @param engine defines the hosting engine
  114470. * @param successCallback defines the callback triggered once the data are available
  114471. * @param mimeType defines the mime type of the result
  114472. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  114473. */
  114474. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  114475. /**
  114476. * Converts the canvas data to blob.
  114477. * This acts as a polyfill for browsers not supporting the to blob function.
  114478. * @param canvas Defines the canvas to extract the data from
  114479. * @param successCallback Defines the callback triggered once the data are available
  114480. * @param mimeType Defines the mime type of the result
  114481. */
  114482. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  114483. /**
  114484. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  114485. * @param successCallback defines the callback triggered once the data are available
  114486. * @param mimeType defines the mime type of the result
  114487. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  114488. */
  114489. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  114490. /**
  114491. * Downloads a blob in the browser
  114492. * @param blob defines the blob to download
  114493. * @param fileName defines the name of the downloaded file
  114494. */
  114495. static Download(blob: Blob, fileName: string): void;
  114496. /**
  114497. * Captures a screenshot of the current rendering
  114498. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  114499. * @param engine defines the rendering engine
  114500. * @param camera defines the source camera
  114501. * @param size This parameter can be set to a single number or to an object with the
  114502. * following (optional) properties: precision, width, height. If a single number is passed,
  114503. * it will be used for both width and height. If an object is passed, the screenshot size
  114504. * will be derived from the parameters. The precision property is a multiplier allowing
  114505. * rendering at a higher or lower resolution
  114506. * @param successCallback defines the callback receives a single parameter which contains the
  114507. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  114508. * src parameter of an <img> to display it
  114509. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  114510. * Check your browser for supported MIME types
  114511. */
  114512. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  114513. /**
  114514. * Captures a screenshot of the current rendering
  114515. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  114516. * @param engine defines the rendering engine
  114517. * @param camera defines the source camera
  114518. * @param size This parameter can be set to a single number or to an object with the
  114519. * following (optional) properties: precision, width, height. If a single number is passed,
  114520. * it will be used for both width and height. If an object is passed, the screenshot size
  114521. * will be derived from the parameters. The precision property is a multiplier allowing
  114522. * rendering at a higher or lower resolution
  114523. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  114524. * Check your browser for supported MIME types
  114525. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  114526. * to the src parameter of an <img> to display it
  114527. */
  114528. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  114529. /**
  114530. * Generates an image screenshot from the specified camera.
  114531. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  114532. * @param engine The engine to use for rendering
  114533. * @param camera The camera to use for rendering
  114534. * @param size This parameter can be set to a single number or to an object with the
  114535. * following (optional) properties: precision, width, height. If a single number is passed,
  114536. * it will be used for both width and height. If an object is passed, the screenshot size
  114537. * will be derived from the parameters. The precision property is a multiplier allowing
  114538. * rendering at a higher or lower resolution
  114539. * @param successCallback The callback receives a single parameter which contains the
  114540. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  114541. * src parameter of an <img> to display it
  114542. * @param mimeType The MIME type of the screenshot image (default: image/png).
  114543. * Check your browser for supported MIME types
  114544. * @param samples Texture samples (default: 1)
  114545. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  114546. * @param fileName A name for for the downloaded file.
  114547. */
  114548. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  114549. /**
  114550. * Generates an image screenshot from the specified camera.
  114551. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  114552. * @param engine The engine to use for rendering
  114553. * @param camera The camera to use for rendering
  114554. * @param size This parameter can be set to a single number or to an object with the
  114555. * following (optional) properties: precision, width, height. If a single number is passed,
  114556. * it will be used for both width and height. If an object is passed, the screenshot size
  114557. * will be derived from the parameters. The precision property is a multiplier allowing
  114558. * rendering at a higher or lower resolution
  114559. * @param mimeType The MIME type of the screenshot image (default: image/png).
  114560. * Check your browser for supported MIME types
  114561. * @param samples Texture samples (default: 1)
  114562. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  114563. * @param fileName A name for for the downloaded file.
  114564. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  114565. * to the src parameter of an <img> to display it
  114566. */
  114567. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  114568. /**
  114569. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  114570. * Be aware Math.random() could cause collisions, but:
  114571. * "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"
  114572. * @returns a pseudo random id
  114573. */
  114574. static RandomId(): string;
  114575. /**
  114576. * Test if the given uri is a base64 string
  114577. * @param uri The uri to test
  114578. * @return True if the uri is a base64 string or false otherwise
  114579. */
  114580. static IsBase64(uri: string): boolean;
  114581. /**
  114582. * Decode the given base64 uri.
  114583. * @param uri The uri to decode
  114584. * @return The decoded base64 data.
  114585. */
  114586. static DecodeBase64(uri: string): ArrayBuffer;
  114587. /**
  114588. * Gets the absolute url.
  114589. * @param url the input url
  114590. * @return the absolute url
  114591. */
  114592. static GetAbsoluteUrl(url: string): string;
  114593. /**
  114594. * No log
  114595. */
  114596. static readonly NoneLogLevel: number;
  114597. /**
  114598. * Only message logs
  114599. */
  114600. static readonly MessageLogLevel: number;
  114601. /**
  114602. * Only warning logs
  114603. */
  114604. static readonly WarningLogLevel: number;
  114605. /**
  114606. * Only error logs
  114607. */
  114608. static readonly ErrorLogLevel: number;
  114609. /**
  114610. * All logs
  114611. */
  114612. static readonly AllLogLevel: number;
  114613. /**
  114614. * Gets a value indicating the number of loading errors
  114615. * @ignorenaming
  114616. */
  114617. static get errorsCount(): number;
  114618. /**
  114619. * Callback called when a new log is added
  114620. */
  114621. static OnNewCacheEntry: (entry: string) => void;
  114622. /**
  114623. * Log a message to the console
  114624. * @param message defines the message to log
  114625. */
  114626. static Log(message: string): void;
  114627. /**
  114628. * Write a warning message to the console
  114629. * @param message defines the message to log
  114630. */
  114631. static Warn(message: string): void;
  114632. /**
  114633. * Write an error message to the console
  114634. * @param message defines the message to log
  114635. */
  114636. static Error(message: string): void;
  114637. /**
  114638. * Gets current log cache (list of logs)
  114639. */
  114640. static get LogCache(): string;
  114641. /**
  114642. * Clears the log cache
  114643. */
  114644. static ClearLogCache(): void;
  114645. /**
  114646. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  114647. */
  114648. static set LogLevels(level: number);
  114649. /**
  114650. * Checks if the window object exists
  114651. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  114652. */
  114653. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  114654. /**
  114655. * No performance log
  114656. */
  114657. static readonly PerformanceNoneLogLevel: number;
  114658. /**
  114659. * Use user marks to log performance
  114660. */
  114661. static readonly PerformanceUserMarkLogLevel: number;
  114662. /**
  114663. * Log performance to the console
  114664. */
  114665. static readonly PerformanceConsoleLogLevel: number;
  114666. private static _performance;
  114667. /**
  114668. * Sets the current performance log level
  114669. */
  114670. static set PerformanceLogLevel(level: number);
  114671. private static _StartPerformanceCounterDisabled;
  114672. private static _EndPerformanceCounterDisabled;
  114673. private static _StartUserMark;
  114674. private static _EndUserMark;
  114675. private static _StartPerformanceConsole;
  114676. private static _EndPerformanceConsole;
  114677. /**
  114678. * Starts a performance counter
  114679. */
  114680. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  114681. /**
  114682. * Ends a specific performance coutner
  114683. */
  114684. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  114685. /**
  114686. * Gets either window.performance.now() if supported or Date.now() else
  114687. */
  114688. static get Now(): number;
  114689. /**
  114690. * This method will return the name of the class used to create the instance of the given object.
  114691. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  114692. * @param object the object to get the class name from
  114693. * @param isType defines if the object is actually a type
  114694. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  114695. */
  114696. static GetClassName(object: any, isType?: boolean): string;
  114697. /**
  114698. * Gets the first element of an array satisfying a given predicate
  114699. * @param array defines the array to browse
  114700. * @param predicate defines the predicate to use
  114701. * @returns null if not found or the element
  114702. */
  114703. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  114704. /**
  114705. * This method will return the name of the full name of the class, including its owning module (if any).
  114706. * 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).
  114707. * @param object the object to get the class name from
  114708. * @param isType defines if the object is actually a type
  114709. * @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.
  114710. * @ignorenaming
  114711. */
  114712. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  114713. /**
  114714. * Returns a promise that resolves after the given amount of time.
  114715. * @param delay Number of milliseconds to delay
  114716. * @returns Promise that resolves after the given amount of time
  114717. */
  114718. static DelayAsync(delay: number): Promise<void>;
  114719. /**
  114720. * Utility function to detect if the current user agent is Safari
  114721. * @returns whether or not the current user agent is safari
  114722. */
  114723. static IsSafari(): boolean;
  114724. }
  114725. /**
  114726. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  114727. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  114728. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  114729. * @param name The name of the class, case should be preserved
  114730. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  114731. */
  114732. export function className(name: string, module?: string): (target: Object) => void;
  114733. /**
  114734. * An implementation of a loop for asynchronous functions.
  114735. */
  114736. export class AsyncLoop {
  114737. /**
  114738. * Defines the number of iterations for the loop
  114739. */
  114740. iterations: number;
  114741. /**
  114742. * Defines the current index of the loop.
  114743. */
  114744. index: number;
  114745. private _done;
  114746. private _fn;
  114747. private _successCallback;
  114748. /**
  114749. * Constructor.
  114750. * @param iterations the number of iterations.
  114751. * @param func the function to run each iteration
  114752. * @param successCallback the callback that will be called upon succesful execution
  114753. * @param offset starting offset.
  114754. */
  114755. constructor(
  114756. /**
  114757. * Defines the number of iterations for the loop
  114758. */
  114759. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  114760. /**
  114761. * Execute the next iteration. Must be called after the last iteration was finished.
  114762. */
  114763. executeNext(): void;
  114764. /**
  114765. * Break the loop and run the success callback.
  114766. */
  114767. breakLoop(): void;
  114768. /**
  114769. * Create and run an async loop.
  114770. * @param iterations the number of iterations.
  114771. * @param fn the function to run each iteration
  114772. * @param successCallback the callback that will be called upon succesful execution
  114773. * @param offset starting offset.
  114774. * @returns the created async loop object
  114775. */
  114776. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  114777. /**
  114778. * A for-loop that will run a given number of iterations synchronous and the rest async.
  114779. * @param iterations total number of iterations
  114780. * @param syncedIterations number of synchronous iterations in each async iteration.
  114781. * @param fn the function to call each iteration.
  114782. * @param callback a success call back that will be called when iterating stops.
  114783. * @param breakFunction a break condition (optional)
  114784. * @param timeout timeout settings for the setTimeout function. default - 0.
  114785. * @returns the created async loop object
  114786. */
  114787. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  114788. }
  114789. }
  114790. declare module BABYLON {
  114791. /**
  114792. * This class implement a typical dictionary using a string as key and the generic type T as value.
  114793. * The underlying implementation relies on an associative array to ensure the best performances.
  114794. * The value can be anything including 'null' but except 'undefined'
  114795. */
  114796. export class StringDictionary<T> {
  114797. /**
  114798. * This will clear this dictionary and copy the content from the 'source' one.
  114799. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  114800. * @param source the dictionary to take the content from and copy to this dictionary
  114801. */
  114802. copyFrom(source: StringDictionary<T>): void;
  114803. /**
  114804. * Get a value based from its key
  114805. * @param key the given key to get the matching value from
  114806. * @return the value if found, otherwise undefined is returned
  114807. */
  114808. get(key: string): T | undefined;
  114809. /**
  114810. * Get a value from its key or add it if it doesn't exist.
  114811. * This method will ensure you that a given key/data will be present in the dictionary.
  114812. * @param key the given key to get the matching value from
  114813. * @param factory the factory that will create the value if the key is not present in the dictionary.
  114814. * The factory will only be invoked if there's no data for the given key.
  114815. * @return the value corresponding to the key.
  114816. */
  114817. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  114818. /**
  114819. * Get a value from its key if present in the dictionary otherwise add it
  114820. * @param key the key to get the value from
  114821. * @param val if there's no such key/value pair in the dictionary add it with this value
  114822. * @return the value corresponding to the key
  114823. */
  114824. getOrAdd(key: string, val: T): T;
  114825. /**
  114826. * Check if there's a given key in the dictionary
  114827. * @param key the key to check for
  114828. * @return true if the key is present, false otherwise
  114829. */
  114830. contains(key: string): boolean;
  114831. /**
  114832. * Add a new key and its corresponding value
  114833. * @param key the key to add
  114834. * @param value the value corresponding to the key
  114835. * @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
  114836. */
  114837. add(key: string, value: T): boolean;
  114838. /**
  114839. * Update a specific value associated to a key
  114840. * @param key defines the key to use
  114841. * @param value defines the value to store
  114842. * @returns true if the value was updated (or false if the key was not found)
  114843. */
  114844. set(key: string, value: T): boolean;
  114845. /**
  114846. * Get the element of the given key and remove it from the dictionary
  114847. * @param key defines the key to search
  114848. * @returns the value associated with the key or null if not found
  114849. */
  114850. getAndRemove(key: string): Nullable<T>;
  114851. /**
  114852. * Remove a key/value from the dictionary.
  114853. * @param key the key to remove
  114854. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  114855. */
  114856. remove(key: string): boolean;
  114857. /**
  114858. * Clear the whole content of the dictionary
  114859. */
  114860. clear(): void;
  114861. /**
  114862. * Gets the current count
  114863. */
  114864. get count(): number;
  114865. /**
  114866. * Execute a callback on each key/val of the dictionary.
  114867. * Note that you can remove any element in this dictionary in the callback implementation
  114868. * @param callback the callback to execute on a given key/value pair
  114869. */
  114870. forEach(callback: (key: string, val: T) => void): void;
  114871. /**
  114872. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  114873. * If the callback returns null or undefined the method will iterate to the next key/value pair
  114874. * Note that you can remove any element in this dictionary in the callback implementation
  114875. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  114876. * @returns the first item
  114877. */
  114878. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  114879. private _count;
  114880. private _data;
  114881. }
  114882. }
  114883. declare module BABYLON {
  114884. /** @hidden */
  114885. export interface ICollisionCoordinator {
  114886. createCollider(): Collider;
  114887. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  114888. init(scene: Scene): void;
  114889. }
  114890. /** @hidden */
  114891. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  114892. private _scene;
  114893. private _scaledPosition;
  114894. private _scaledVelocity;
  114895. private _finalPosition;
  114896. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  114897. createCollider(): Collider;
  114898. init(scene: Scene): void;
  114899. private _collideWithWorld;
  114900. }
  114901. }
  114902. declare module BABYLON {
  114903. /**
  114904. * Class used to manage all inputs for the scene.
  114905. */
  114906. export class InputManager {
  114907. /** The distance in pixel that you have to move to prevent some events */
  114908. static DragMovementThreshold: number;
  114909. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  114910. static LongPressDelay: number;
  114911. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  114912. static DoubleClickDelay: number;
  114913. /** If you need to check double click without raising a single click at first click, enable this flag */
  114914. static ExclusiveDoubleClickMode: boolean;
  114915. private _wheelEventName;
  114916. private _onPointerMove;
  114917. private _onPointerDown;
  114918. private _onPointerUp;
  114919. private _initClickEvent;
  114920. private _initActionManager;
  114921. private _delayedSimpleClick;
  114922. private _delayedSimpleClickTimeout;
  114923. private _previousDelayedSimpleClickTimeout;
  114924. private _meshPickProceed;
  114925. private _previousButtonPressed;
  114926. private _currentPickResult;
  114927. private _previousPickResult;
  114928. private _totalPointersPressed;
  114929. private _doubleClickOccured;
  114930. private _pointerOverMesh;
  114931. private _pickedDownMesh;
  114932. private _pickedUpMesh;
  114933. private _pointerX;
  114934. private _pointerY;
  114935. private _unTranslatedPointerX;
  114936. private _unTranslatedPointerY;
  114937. private _startingPointerPosition;
  114938. private _previousStartingPointerPosition;
  114939. private _startingPointerTime;
  114940. private _previousStartingPointerTime;
  114941. private _pointerCaptures;
  114942. private _onKeyDown;
  114943. private _onKeyUp;
  114944. private _onCanvasFocusObserver;
  114945. private _onCanvasBlurObserver;
  114946. private _scene;
  114947. /**
  114948. * Creates a new InputManager
  114949. * @param scene defines the hosting scene
  114950. */
  114951. constructor(scene: Scene);
  114952. /**
  114953. * Gets the mesh that is currently under the pointer
  114954. */
  114955. get meshUnderPointer(): Nullable<AbstractMesh>;
  114956. /**
  114957. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  114958. */
  114959. get unTranslatedPointer(): Vector2;
  114960. /**
  114961. * Gets or sets the current on-screen X position of the pointer
  114962. */
  114963. get pointerX(): number;
  114964. set pointerX(value: number);
  114965. /**
  114966. * Gets or sets the current on-screen Y position of the pointer
  114967. */
  114968. get pointerY(): number;
  114969. set pointerY(value: number);
  114970. private _updatePointerPosition;
  114971. private _processPointerMove;
  114972. private _setRayOnPointerInfo;
  114973. private _checkPrePointerObservable;
  114974. /**
  114975. * Use this method to simulate a pointer move on a mesh
  114976. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  114977. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  114978. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  114979. */
  114980. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  114981. /**
  114982. * Use this method to simulate a pointer down on a mesh
  114983. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  114984. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  114985. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  114986. */
  114987. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  114988. private _processPointerDown;
  114989. /** @hidden */
  114990. _isPointerSwiping(): boolean;
  114991. /**
  114992. * Use this method to simulate a pointer up on a mesh
  114993. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  114994. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  114995. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  114996. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  114997. */
  114998. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  114999. private _processPointerUp;
  115000. /**
  115001. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  115002. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  115003. * @returns true if the pointer was captured
  115004. */
  115005. isPointerCaptured(pointerId?: number): boolean;
  115006. /**
  115007. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  115008. * @param attachUp defines if you want to attach events to pointerup
  115009. * @param attachDown defines if you want to attach events to pointerdown
  115010. * @param attachMove defines if you want to attach events to pointermove
  115011. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  115012. */
  115013. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  115014. /**
  115015. * Detaches all event handlers
  115016. */
  115017. detachControl(): void;
  115018. /**
  115019. * Force the value of meshUnderPointer
  115020. * @param mesh defines the mesh to use
  115021. */
  115022. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  115023. /**
  115024. * Gets the mesh under the pointer
  115025. * @returns a Mesh or null if no mesh is under the pointer
  115026. */
  115027. getPointerOverMesh(): Nullable<AbstractMesh>;
  115028. }
  115029. }
  115030. declare module BABYLON {
  115031. /**
  115032. * This class defines the direct association between an animation and a target
  115033. */
  115034. export class TargetedAnimation {
  115035. /**
  115036. * Animation to perform
  115037. */
  115038. animation: Animation;
  115039. /**
  115040. * Target to animate
  115041. */
  115042. target: any;
  115043. /**
  115044. * Serialize the object
  115045. * @returns the JSON object representing the current entity
  115046. */
  115047. serialize(): any;
  115048. }
  115049. /**
  115050. * Use this class to create coordinated animations on multiple targets
  115051. */
  115052. export class AnimationGroup implements IDisposable {
  115053. /** The name of the animation group */
  115054. name: string;
  115055. private _scene;
  115056. private _targetedAnimations;
  115057. private _animatables;
  115058. private _from;
  115059. private _to;
  115060. private _isStarted;
  115061. private _isPaused;
  115062. private _speedRatio;
  115063. private _loopAnimation;
  115064. private _isAdditive;
  115065. /**
  115066. * Gets or sets the unique id of the node
  115067. */
  115068. uniqueId: number;
  115069. /**
  115070. * This observable will notify when one animation have ended
  115071. */
  115072. onAnimationEndObservable: Observable<TargetedAnimation>;
  115073. /**
  115074. * Observer raised when one animation loops
  115075. */
  115076. onAnimationLoopObservable: Observable<TargetedAnimation>;
  115077. /**
  115078. * Observer raised when all animations have looped
  115079. */
  115080. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  115081. /**
  115082. * This observable will notify when all animations have ended.
  115083. */
  115084. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  115085. /**
  115086. * This observable will notify when all animations have paused.
  115087. */
  115088. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  115089. /**
  115090. * This observable will notify when all animations are playing.
  115091. */
  115092. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  115093. /**
  115094. * Gets the first frame
  115095. */
  115096. get from(): number;
  115097. /**
  115098. * Gets the last frame
  115099. */
  115100. get to(): number;
  115101. /**
  115102. * Define if the animations are started
  115103. */
  115104. get isStarted(): boolean;
  115105. /**
  115106. * Gets a value indicating that the current group is playing
  115107. */
  115108. get isPlaying(): boolean;
  115109. /**
  115110. * Gets or sets the speed ratio to use for all animations
  115111. */
  115112. get speedRatio(): number;
  115113. /**
  115114. * Gets or sets the speed ratio to use for all animations
  115115. */
  115116. set speedRatio(value: number);
  115117. /**
  115118. * Gets or sets if all animations should loop or not
  115119. */
  115120. get loopAnimation(): boolean;
  115121. set loopAnimation(value: boolean);
  115122. /**
  115123. * Gets or sets if all animations should be evaluated additively
  115124. */
  115125. get isAdditive(): boolean;
  115126. set isAdditive(value: boolean);
  115127. /**
  115128. * Gets the targeted animations for this animation group
  115129. */
  115130. get targetedAnimations(): Array<TargetedAnimation>;
  115131. /**
  115132. * returning the list of animatables controlled by this animation group.
  115133. */
  115134. get animatables(): Array<Animatable>;
  115135. /**
  115136. * Instantiates a new Animation Group.
  115137. * This helps managing several animations at once.
  115138. * @see http://doc.babylonjs.com/how_to/group
  115139. * @param name Defines the name of the group
  115140. * @param scene Defines the scene the group belongs to
  115141. */
  115142. constructor(
  115143. /** The name of the animation group */
  115144. name: string, scene?: Nullable<Scene>);
  115145. /**
  115146. * Add an animation (with its target) in the group
  115147. * @param animation defines the animation we want to add
  115148. * @param target defines the target of the animation
  115149. * @returns the TargetedAnimation object
  115150. */
  115151. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  115152. /**
  115153. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  115154. * It can add constant keys at begin or end
  115155. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  115156. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  115157. * @returns the animation group
  115158. */
  115159. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  115160. private _animationLoopCount;
  115161. private _animationLoopFlags;
  115162. private _processLoop;
  115163. /**
  115164. * Start all animations on given targets
  115165. * @param loop defines if animations must loop
  115166. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  115167. * @param from defines the from key (optional)
  115168. * @param to defines the to key (optional)
  115169. * @param isAdditive defines the additive state for the resulting animatables (optional)
  115170. * @returns the current animation group
  115171. */
  115172. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  115173. /**
  115174. * Pause all animations
  115175. * @returns the animation group
  115176. */
  115177. pause(): AnimationGroup;
  115178. /**
  115179. * Play all animations to initial state
  115180. * This function will start() the animations if they were not started or will restart() them if they were paused
  115181. * @param loop defines if animations must loop
  115182. * @returns the animation group
  115183. */
  115184. play(loop?: boolean): AnimationGroup;
  115185. /**
  115186. * Reset all animations to initial state
  115187. * @returns the animation group
  115188. */
  115189. reset(): AnimationGroup;
  115190. /**
  115191. * Restart animations from key 0
  115192. * @returns the animation group
  115193. */
  115194. restart(): AnimationGroup;
  115195. /**
  115196. * Stop all animations
  115197. * @returns the animation group
  115198. */
  115199. stop(): AnimationGroup;
  115200. /**
  115201. * Set animation weight for all animatables
  115202. * @param weight defines the weight to use
  115203. * @return the animationGroup
  115204. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  115205. */
  115206. setWeightForAllAnimatables(weight: number): AnimationGroup;
  115207. /**
  115208. * Synchronize and normalize all animatables with a source animatable
  115209. * @param root defines the root animatable to synchronize with
  115210. * @return the animationGroup
  115211. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  115212. */
  115213. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  115214. /**
  115215. * Goes to a specific frame in this animation group
  115216. * @param frame the frame number to go to
  115217. * @return the animationGroup
  115218. */
  115219. goToFrame(frame: number): AnimationGroup;
  115220. /**
  115221. * Dispose all associated resources
  115222. */
  115223. dispose(): void;
  115224. private _checkAnimationGroupEnded;
  115225. /**
  115226. * Clone the current animation group and returns a copy
  115227. * @param newName defines the name of the new group
  115228. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  115229. * @returns the new aniamtion group
  115230. */
  115231. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  115232. /**
  115233. * Serializes the animationGroup to an object
  115234. * @returns Serialized object
  115235. */
  115236. serialize(): any;
  115237. /**
  115238. * Returns a new AnimationGroup object parsed from the source provided.
  115239. * @param parsedAnimationGroup defines the source
  115240. * @param scene defines the scene that will receive the animationGroup
  115241. * @returns a new AnimationGroup
  115242. */
  115243. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  115244. /**
  115245. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  115246. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  115247. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  115248. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  115249. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  115250. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  115251. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  115252. */
  115253. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  115254. /**
  115255. * Returns the string "AnimationGroup"
  115256. * @returns "AnimationGroup"
  115257. */
  115258. getClassName(): string;
  115259. /**
  115260. * Creates a detailled string about the object
  115261. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  115262. * @returns a string representing the object
  115263. */
  115264. toString(fullDetails?: boolean): string;
  115265. }
  115266. }
  115267. declare module BABYLON {
  115268. /**
  115269. * Define an interface for all classes that will hold resources
  115270. */
  115271. export interface IDisposable {
  115272. /**
  115273. * Releases all held resources
  115274. */
  115275. dispose(): void;
  115276. }
  115277. /** Interface defining initialization parameters for Scene class */
  115278. export interface SceneOptions {
  115279. /**
  115280. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  115281. * It will improve performance when the number of geometries becomes important.
  115282. */
  115283. useGeometryUniqueIdsMap?: boolean;
  115284. /**
  115285. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  115286. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  115287. */
  115288. useMaterialMeshMap?: boolean;
  115289. /**
  115290. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  115291. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  115292. */
  115293. useClonedMeshMap?: boolean;
  115294. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  115295. virtual?: boolean;
  115296. }
  115297. /**
  115298. * Represents a scene to be rendered by the engine.
  115299. * @see http://doc.babylonjs.com/features/scene
  115300. */
  115301. export class Scene extends AbstractScene implements IAnimatable {
  115302. /** The fog is deactivated */
  115303. static readonly FOGMODE_NONE: number;
  115304. /** The fog density is following an exponential function */
  115305. static readonly FOGMODE_EXP: number;
  115306. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  115307. static readonly FOGMODE_EXP2: number;
  115308. /** The fog density is following a linear function. */
  115309. static readonly FOGMODE_LINEAR: number;
  115310. /**
  115311. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  115312. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  115313. */
  115314. static MinDeltaTime: number;
  115315. /**
  115316. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  115317. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  115318. */
  115319. static MaxDeltaTime: number;
  115320. /**
  115321. * Factory used to create the default material.
  115322. * @param name The name of the material to create
  115323. * @param scene The scene to create the material for
  115324. * @returns The default material
  115325. */
  115326. static DefaultMaterialFactory(scene: Scene): Material;
  115327. /**
  115328. * Factory used to create the a collision coordinator.
  115329. * @returns The collision coordinator
  115330. */
  115331. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  115332. /** @hidden */
  115333. _inputManager: InputManager;
  115334. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  115335. cameraToUseForPointers: Nullable<Camera>;
  115336. /** @hidden */
  115337. readonly _isScene: boolean;
  115338. /** @hidden */
  115339. _blockEntityCollection: boolean;
  115340. /**
  115341. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  115342. */
  115343. autoClear: boolean;
  115344. /**
  115345. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  115346. */
  115347. autoClearDepthAndStencil: boolean;
  115348. /**
  115349. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  115350. */
  115351. clearColor: Color4;
  115352. /**
  115353. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  115354. */
  115355. ambientColor: Color3;
  115356. /**
  115357. * This is use to store the default BRDF lookup for PBR materials in your scene.
  115358. * It should only be one of the following (if not the default embedded one):
  115359. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  115360. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  115361. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  115362. * The material properties need to be setup according to the type of texture in use.
  115363. */
  115364. environmentBRDFTexture: BaseTexture;
  115365. /** @hidden */
  115366. protected _environmentTexture: Nullable<BaseTexture>;
  115367. /**
  115368. * Texture used in all pbr material as the reflection texture.
  115369. * As in the majority of the scene they are the same (exception for multi room and so on),
  115370. * this is easier to reference from here than from all the materials.
  115371. */
  115372. get environmentTexture(): Nullable<BaseTexture>;
  115373. /**
  115374. * Texture used in all pbr material as the reflection texture.
  115375. * As in the majority of the scene they are the same (exception for multi room and so on),
  115376. * this is easier to set here than in all the materials.
  115377. */
  115378. set environmentTexture(value: Nullable<BaseTexture>);
  115379. /** @hidden */
  115380. protected _environmentIntensity: number;
  115381. /**
  115382. * Intensity of the environment in all pbr material.
  115383. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  115384. * As in the majority of the scene they are the same (exception for multi room and so on),
  115385. * this is easier to reference from here than from all the materials.
  115386. */
  115387. get environmentIntensity(): number;
  115388. /**
  115389. * Intensity of the environment in all pbr material.
  115390. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  115391. * As in the majority of the scene they are the same (exception for multi room and so on),
  115392. * this is easier to set here than in all the materials.
  115393. */
  115394. set environmentIntensity(value: number);
  115395. /** @hidden */
  115396. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  115397. /**
  115398. * Default image processing configuration used either in the rendering
  115399. * Forward main pass or through the imageProcessingPostProcess if present.
  115400. * As in the majority of the scene they are the same (exception for multi camera),
  115401. * this is easier to reference from here than from all the materials and post process.
  115402. *
  115403. * No setter as we it is a shared configuration, you can set the values instead.
  115404. */
  115405. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  115406. private _forceWireframe;
  115407. /**
  115408. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  115409. */
  115410. set forceWireframe(value: boolean);
  115411. get forceWireframe(): boolean;
  115412. private _skipFrustumClipping;
  115413. /**
  115414. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  115415. */
  115416. set skipFrustumClipping(value: boolean);
  115417. get skipFrustumClipping(): boolean;
  115418. private _forcePointsCloud;
  115419. /**
  115420. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  115421. */
  115422. set forcePointsCloud(value: boolean);
  115423. get forcePointsCloud(): boolean;
  115424. /**
  115425. * Gets or sets the active clipplane 1
  115426. */
  115427. clipPlane: Nullable<Plane>;
  115428. /**
  115429. * Gets or sets the active clipplane 2
  115430. */
  115431. clipPlane2: Nullable<Plane>;
  115432. /**
  115433. * Gets or sets the active clipplane 3
  115434. */
  115435. clipPlane3: Nullable<Plane>;
  115436. /**
  115437. * Gets or sets the active clipplane 4
  115438. */
  115439. clipPlane4: Nullable<Plane>;
  115440. /**
  115441. * Gets or sets the active clipplane 5
  115442. */
  115443. clipPlane5: Nullable<Plane>;
  115444. /**
  115445. * Gets or sets the active clipplane 6
  115446. */
  115447. clipPlane6: Nullable<Plane>;
  115448. /**
  115449. * Gets or sets a boolean indicating if animations are enabled
  115450. */
  115451. animationsEnabled: boolean;
  115452. private _animationPropertiesOverride;
  115453. /**
  115454. * Gets or sets the animation properties override
  115455. */
  115456. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  115457. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  115458. /**
  115459. * Gets or sets a boolean indicating if a constant deltatime has to be used
  115460. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  115461. */
  115462. useConstantAnimationDeltaTime: boolean;
  115463. /**
  115464. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  115465. * Please note that it requires to run a ray cast through the scene on every frame
  115466. */
  115467. constantlyUpdateMeshUnderPointer: boolean;
  115468. /**
  115469. * Defines the HTML cursor to use when hovering over interactive elements
  115470. */
  115471. hoverCursor: string;
  115472. /**
  115473. * Defines the HTML default cursor to use (empty by default)
  115474. */
  115475. defaultCursor: string;
  115476. /**
  115477. * Defines whether cursors are handled by the scene.
  115478. */
  115479. doNotHandleCursors: boolean;
  115480. /**
  115481. * This is used to call preventDefault() on pointer down
  115482. * in order to block unwanted artifacts like system double clicks
  115483. */
  115484. preventDefaultOnPointerDown: boolean;
  115485. /**
  115486. * This is used to call preventDefault() on pointer up
  115487. * in order to block unwanted artifacts like system double clicks
  115488. */
  115489. preventDefaultOnPointerUp: boolean;
  115490. /**
  115491. * Gets or sets user defined metadata
  115492. */
  115493. metadata: any;
  115494. /**
  115495. * For internal use only. Please do not use.
  115496. */
  115497. reservedDataStore: any;
  115498. /**
  115499. * Gets the name of the plugin used to load this scene (null by default)
  115500. */
  115501. loadingPluginName: string;
  115502. /**
  115503. * Use this array to add regular expressions used to disable offline support for specific urls
  115504. */
  115505. disableOfflineSupportExceptionRules: RegExp[];
  115506. /**
  115507. * An event triggered when the scene is disposed.
  115508. */
  115509. onDisposeObservable: Observable<Scene>;
  115510. private _onDisposeObserver;
  115511. /** Sets a function to be executed when this scene is disposed. */
  115512. set onDispose(callback: () => void);
  115513. /**
  115514. * An event triggered before rendering the scene (right after animations and physics)
  115515. */
  115516. onBeforeRenderObservable: Observable<Scene>;
  115517. private _onBeforeRenderObserver;
  115518. /** Sets a function to be executed before rendering this scene */
  115519. set beforeRender(callback: Nullable<() => void>);
  115520. /**
  115521. * An event triggered after rendering the scene
  115522. */
  115523. onAfterRenderObservable: Observable<Scene>;
  115524. /**
  115525. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  115526. */
  115527. onAfterRenderCameraObservable: Observable<Camera>;
  115528. private _onAfterRenderObserver;
  115529. /** Sets a function to be executed after rendering this scene */
  115530. set afterRender(callback: Nullable<() => void>);
  115531. /**
  115532. * An event triggered before animating the scene
  115533. */
  115534. onBeforeAnimationsObservable: Observable<Scene>;
  115535. /**
  115536. * An event triggered after animations processing
  115537. */
  115538. onAfterAnimationsObservable: Observable<Scene>;
  115539. /**
  115540. * An event triggered before draw calls are ready to be sent
  115541. */
  115542. onBeforeDrawPhaseObservable: Observable<Scene>;
  115543. /**
  115544. * An event triggered after draw calls have been sent
  115545. */
  115546. onAfterDrawPhaseObservable: Observable<Scene>;
  115547. /**
  115548. * An event triggered when the scene is ready
  115549. */
  115550. onReadyObservable: Observable<Scene>;
  115551. /**
  115552. * An event triggered before rendering a camera
  115553. */
  115554. onBeforeCameraRenderObservable: Observable<Camera>;
  115555. private _onBeforeCameraRenderObserver;
  115556. /** Sets a function to be executed before rendering a camera*/
  115557. set beforeCameraRender(callback: () => void);
  115558. /**
  115559. * An event triggered after rendering a camera
  115560. */
  115561. onAfterCameraRenderObservable: Observable<Camera>;
  115562. private _onAfterCameraRenderObserver;
  115563. /** Sets a function to be executed after rendering a camera*/
  115564. set afterCameraRender(callback: () => void);
  115565. /**
  115566. * An event triggered when active meshes evaluation is about to start
  115567. */
  115568. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  115569. /**
  115570. * An event triggered when active meshes evaluation is done
  115571. */
  115572. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  115573. /**
  115574. * An event triggered when particles rendering is about to start
  115575. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  115576. */
  115577. onBeforeParticlesRenderingObservable: Observable<Scene>;
  115578. /**
  115579. * An event triggered when particles rendering is done
  115580. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  115581. */
  115582. onAfterParticlesRenderingObservable: Observable<Scene>;
  115583. /**
  115584. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  115585. */
  115586. onDataLoadedObservable: Observable<Scene>;
  115587. /**
  115588. * An event triggered when a camera is created
  115589. */
  115590. onNewCameraAddedObservable: Observable<Camera>;
  115591. /**
  115592. * An event triggered when a camera is removed
  115593. */
  115594. onCameraRemovedObservable: Observable<Camera>;
  115595. /**
  115596. * An event triggered when a light is created
  115597. */
  115598. onNewLightAddedObservable: Observable<Light>;
  115599. /**
  115600. * An event triggered when a light is removed
  115601. */
  115602. onLightRemovedObservable: Observable<Light>;
  115603. /**
  115604. * An event triggered when a geometry is created
  115605. */
  115606. onNewGeometryAddedObservable: Observable<Geometry>;
  115607. /**
  115608. * An event triggered when a geometry is removed
  115609. */
  115610. onGeometryRemovedObservable: Observable<Geometry>;
  115611. /**
  115612. * An event triggered when a transform node is created
  115613. */
  115614. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  115615. /**
  115616. * An event triggered when a transform node is removed
  115617. */
  115618. onTransformNodeRemovedObservable: Observable<TransformNode>;
  115619. /**
  115620. * An event triggered when a mesh is created
  115621. */
  115622. onNewMeshAddedObservable: Observable<AbstractMesh>;
  115623. /**
  115624. * An event triggered when a mesh is removed
  115625. */
  115626. onMeshRemovedObservable: Observable<AbstractMesh>;
  115627. /**
  115628. * An event triggered when a skeleton is created
  115629. */
  115630. onNewSkeletonAddedObservable: Observable<Skeleton>;
  115631. /**
  115632. * An event triggered when a skeleton is removed
  115633. */
  115634. onSkeletonRemovedObservable: Observable<Skeleton>;
  115635. /**
  115636. * An event triggered when a material is created
  115637. */
  115638. onNewMaterialAddedObservable: Observable<Material>;
  115639. /**
  115640. * An event triggered when a material is removed
  115641. */
  115642. onMaterialRemovedObservable: Observable<Material>;
  115643. /**
  115644. * An event triggered when a texture is created
  115645. */
  115646. onNewTextureAddedObservable: Observable<BaseTexture>;
  115647. /**
  115648. * An event triggered when a texture is removed
  115649. */
  115650. onTextureRemovedObservable: Observable<BaseTexture>;
  115651. /**
  115652. * An event triggered when render targets are about to be rendered
  115653. * Can happen multiple times per frame.
  115654. */
  115655. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  115656. /**
  115657. * An event triggered when render targets were rendered.
  115658. * Can happen multiple times per frame.
  115659. */
  115660. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  115661. /**
  115662. * An event triggered before calculating deterministic simulation step
  115663. */
  115664. onBeforeStepObservable: Observable<Scene>;
  115665. /**
  115666. * An event triggered after calculating deterministic simulation step
  115667. */
  115668. onAfterStepObservable: Observable<Scene>;
  115669. /**
  115670. * An event triggered when the activeCamera property is updated
  115671. */
  115672. onActiveCameraChanged: Observable<Scene>;
  115673. /**
  115674. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  115675. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  115676. * 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)
  115677. */
  115678. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  115679. /**
  115680. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  115681. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  115682. * 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)
  115683. */
  115684. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  115685. /**
  115686. * This Observable will when a mesh has been imported into the scene.
  115687. */
  115688. onMeshImportedObservable: Observable<AbstractMesh>;
  115689. /**
  115690. * This Observable will when an animation file has been imported into the scene.
  115691. */
  115692. onAnimationFileImportedObservable: Observable<Scene>;
  115693. /**
  115694. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  115695. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  115696. */
  115697. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  115698. /** @hidden */
  115699. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  115700. /**
  115701. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  115702. */
  115703. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  115704. /**
  115705. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  115706. */
  115707. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  115708. /**
  115709. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  115710. */
  115711. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  115712. /** Callback called when a pointer move is detected */
  115713. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  115714. /** Callback called when a pointer down is detected */
  115715. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  115716. /** Callback called when a pointer up is detected */
  115717. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  115718. /** Callback called when a pointer pick is detected */
  115719. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  115720. /**
  115721. * 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).
  115722. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  115723. */
  115724. onPrePointerObservable: Observable<PointerInfoPre>;
  115725. /**
  115726. * Observable event triggered each time an input event is received from the rendering canvas
  115727. */
  115728. onPointerObservable: Observable<PointerInfo>;
  115729. /**
  115730. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  115731. */
  115732. get unTranslatedPointer(): Vector2;
  115733. /**
  115734. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  115735. */
  115736. static get DragMovementThreshold(): number;
  115737. static set DragMovementThreshold(value: number);
  115738. /**
  115739. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  115740. */
  115741. static get LongPressDelay(): number;
  115742. static set LongPressDelay(value: number);
  115743. /**
  115744. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  115745. */
  115746. static get DoubleClickDelay(): number;
  115747. static set DoubleClickDelay(value: number);
  115748. /** If you need to check double click without raising a single click at first click, enable this flag */
  115749. static get ExclusiveDoubleClickMode(): boolean;
  115750. static set ExclusiveDoubleClickMode(value: boolean);
  115751. /** @hidden */
  115752. _mirroredCameraPosition: Nullable<Vector3>;
  115753. /**
  115754. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  115755. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  115756. */
  115757. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  115758. /**
  115759. * Observable event triggered each time an keyboard event is received from the hosting window
  115760. */
  115761. onKeyboardObservable: Observable<KeyboardInfo>;
  115762. private _useRightHandedSystem;
  115763. /**
  115764. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  115765. */
  115766. set useRightHandedSystem(value: boolean);
  115767. get useRightHandedSystem(): boolean;
  115768. private _timeAccumulator;
  115769. private _currentStepId;
  115770. private _currentInternalStep;
  115771. /**
  115772. * Sets the step Id used by deterministic lock step
  115773. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  115774. * @param newStepId defines the step Id
  115775. */
  115776. setStepId(newStepId: number): void;
  115777. /**
  115778. * Gets the step Id used by deterministic lock step
  115779. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  115780. * @returns the step Id
  115781. */
  115782. getStepId(): number;
  115783. /**
  115784. * Gets the internal step used by deterministic lock step
  115785. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  115786. * @returns the internal step
  115787. */
  115788. getInternalStep(): number;
  115789. private _fogEnabled;
  115790. /**
  115791. * Gets or sets a boolean indicating if fog is enabled on this scene
  115792. * @see http://doc.babylonjs.com/babylon101/environment#fog
  115793. * (Default is true)
  115794. */
  115795. set fogEnabled(value: boolean);
  115796. get fogEnabled(): boolean;
  115797. private _fogMode;
  115798. /**
  115799. * Gets or sets the fog mode to use
  115800. * @see http://doc.babylonjs.com/babylon101/environment#fog
  115801. * | mode | value |
  115802. * | --- | --- |
  115803. * | FOGMODE_NONE | 0 |
  115804. * | FOGMODE_EXP | 1 |
  115805. * | FOGMODE_EXP2 | 2 |
  115806. * | FOGMODE_LINEAR | 3 |
  115807. */
  115808. set fogMode(value: number);
  115809. get fogMode(): number;
  115810. /**
  115811. * Gets or sets the fog color to use
  115812. * @see http://doc.babylonjs.com/babylon101/environment#fog
  115813. * (Default is Color3(0.2, 0.2, 0.3))
  115814. */
  115815. fogColor: Color3;
  115816. /**
  115817. * Gets or sets the fog density to use
  115818. * @see http://doc.babylonjs.com/babylon101/environment#fog
  115819. * (Default is 0.1)
  115820. */
  115821. fogDensity: number;
  115822. /**
  115823. * Gets or sets the fog start distance to use
  115824. * @see http://doc.babylonjs.com/babylon101/environment#fog
  115825. * (Default is 0)
  115826. */
  115827. fogStart: number;
  115828. /**
  115829. * Gets or sets the fog end distance to use
  115830. * @see http://doc.babylonjs.com/babylon101/environment#fog
  115831. * (Default is 1000)
  115832. */
  115833. fogEnd: number;
  115834. private _shadowsEnabled;
  115835. /**
  115836. * Gets or sets a boolean indicating if shadows are enabled on this scene
  115837. */
  115838. set shadowsEnabled(value: boolean);
  115839. get shadowsEnabled(): boolean;
  115840. private _lightsEnabled;
  115841. /**
  115842. * Gets or sets a boolean indicating if lights are enabled on this scene
  115843. */
  115844. set lightsEnabled(value: boolean);
  115845. get lightsEnabled(): boolean;
  115846. /** All of the active cameras added to this scene. */
  115847. activeCameras: Camera[];
  115848. /** @hidden */
  115849. _activeCamera: Nullable<Camera>;
  115850. /** Gets or sets the current active camera */
  115851. get activeCamera(): Nullable<Camera>;
  115852. set activeCamera(value: Nullable<Camera>);
  115853. private _defaultMaterial;
  115854. /** The default material used on meshes when no material is affected */
  115855. get defaultMaterial(): Material;
  115856. /** The default material used on meshes when no material is affected */
  115857. set defaultMaterial(value: Material);
  115858. private _texturesEnabled;
  115859. /**
  115860. * Gets or sets a boolean indicating if textures are enabled on this scene
  115861. */
  115862. set texturesEnabled(value: boolean);
  115863. get texturesEnabled(): boolean;
  115864. /**
  115865. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  115866. */
  115867. physicsEnabled: boolean;
  115868. /**
  115869. * Gets or sets a boolean indicating if particles are enabled on this scene
  115870. */
  115871. particlesEnabled: boolean;
  115872. /**
  115873. * Gets or sets a boolean indicating if sprites are enabled on this scene
  115874. */
  115875. spritesEnabled: boolean;
  115876. private _skeletonsEnabled;
  115877. /**
  115878. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  115879. */
  115880. set skeletonsEnabled(value: boolean);
  115881. get skeletonsEnabled(): boolean;
  115882. /**
  115883. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  115884. */
  115885. lensFlaresEnabled: boolean;
  115886. /**
  115887. * Gets or sets a boolean indicating if collisions are enabled on this scene
  115888. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  115889. */
  115890. collisionsEnabled: boolean;
  115891. private _collisionCoordinator;
  115892. /** @hidden */
  115893. get collisionCoordinator(): ICollisionCoordinator;
  115894. /**
  115895. * Defines the gravity applied to this scene (used only for collisions)
  115896. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  115897. */
  115898. gravity: Vector3;
  115899. /**
  115900. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  115901. */
  115902. postProcessesEnabled: boolean;
  115903. /**
  115904. * The list of postprocesses added to the scene
  115905. */
  115906. postProcesses: PostProcess[];
  115907. /**
  115908. * Gets the current postprocess manager
  115909. */
  115910. postProcessManager: PostProcessManager;
  115911. /**
  115912. * Gets or sets a boolean indicating if render targets are enabled on this scene
  115913. */
  115914. renderTargetsEnabled: boolean;
  115915. /**
  115916. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  115917. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  115918. */
  115919. dumpNextRenderTargets: boolean;
  115920. /**
  115921. * The list of user defined render targets added to the scene
  115922. */
  115923. customRenderTargets: RenderTargetTexture[];
  115924. /**
  115925. * Defines if texture loading must be delayed
  115926. * If true, textures will only be loaded when they need to be rendered
  115927. */
  115928. useDelayedTextureLoading: boolean;
  115929. /**
  115930. * Gets the list of meshes imported to the scene through SceneLoader
  115931. */
  115932. importedMeshesFiles: String[];
  115933. /**
  115934. * Gets or sets a boolean indicating if probes are enabled on this scene
  115935. */
  115936. probesEnabled: boolean;
  115937. /**
  115938. * Gets or sets the current offline provider to use to store scene data
  115939. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  115940. */
  115941. offlineProvider: IOfflineProvider;
  115942. /**
  115943. * Gets or sets the action manager associated with the scene
  115944. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  115945. */
  115946. actionManager: AbstractActionManager;
  115947. private _meshesForIntersections;
  115948. /**
  115949. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  115950. */
  115951. proceduralTexturesEnabled: boolean;
  115952. private _engine;
  115953. private _totalVertices;
  115954. /** @hidden */
  115955. _activeIndices: PerfCounter;
  115956. /** @hidden */
  115957. _activeParticles: PerfCounter;
  115958. /** @hidden */
  115959. _activeBones: PerfCounter;
  115960. private _animationRatio;
  115961. /** @hidden */
  115962. _animationTimeLast: number;
  115963. /** @hidden */
  115964. _animationTime: number;
  115965. /**
  115966. * Gets or sets a general scale for animation speed
  115967. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  115968. */
  115969. animationTimeScale: number;
  115970. /** @hidden */
  115971. _cachedMaterial: Nullable<Material>;
  115972. /** @hidden */
  115973. _cachedEffect: Nullable<Effect>;
  115974. /** @hidden */
  115975. _cachedVisibility: Nullable<number>;
  115976. private _renderId;
  115977. private _frameId;
  115978. private _executeWhenReadyTimeoutId;
  115979. private _intermediateRendering;
  115980. private _viewUpdateFlag;
  115981. private _projectionUpdateFlag;
  115982. /** @hidden */
  115983. _toBeDisposed: Nullable<IDisposable>[];
  115984. private _activeRequests;
  115985. /** @hidden */
  115986. _pendingData: any[];
  115987. private _isDisposed;
  115988. /**
  115989. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  115990. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  115991. */
  115992. dispatchAllSubMeshesOfActiveMeshes: boolean;
  115993. private _activeMeshes;
  115994. private _processedMaterials;
  115995. private _renderTargets;
  115996. /** @hidden */
  115997. _activeParticleSystems: SmartArray<IParticleSystem>;
  115998. private _activeSkeletons;
  115999. private _softwareSkinnedMeshes;
  116000. private _renderingManager;
  116001. /** @hidden */
  116002. _activeAnimatables: Animatable[];
  116003. private _transformMatrix;
  116004. private _sceneUbo;
  116005. /** @hidden */
  116006. _viewMatrix: Matrix;
  116007. private _projectionMatrix;
  116008. /** @hidden */
  116009. _forcedViewPosition: Nullable<Vector3>;
  116010. /** @hidden */
  116011. _frustumPlanes: Plane[];
  116012. /**
  116013. * Gets the list of frustum planes (built from the active camera)
  116014. */
  116015. get frustumPlanes(): Plane[];
  116016. /**
  116017. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  116018. * This is useful if there are more lights that the maximum simulteanous authorized
  116019. */
  116020. requireLightSorting: boolean;
  116021. /** @hidden */
  116022. readonly useMaterialMeshMap: boolean;
  116023. /** @hidden */
  116024. readonly useClonedMeshMap: boolean;
  116025. private _externalData;
  116026. private _uid;
  116027. /**
  116028. * @hidden
  116029. * Backing store of defined scene components.
  116030. */
  116031. _components: ISceneComponent[];
  116032. /**
  116033. * @hidden
  116034. * Backing store of defined scene components.
  116035. */
  116036. _serializableComponents: ISceneSerializableComponent[];
  116037. /**
  116038. * List of components to register on the next registration step.
  116039. */
  116040. private _transientComponents;
  116041. /**
  116042. * Registers the transient components if needed.
  116043. */
  116044. private _registerTransientComponents;
  116045. /**
  116046. * @hidden
  116047. * Add a component to the scene.
  116048. * Note that the ccomponent could be registered on th next frame if this is called after
  116049. * the register component stage.
  116050. * @param component Defines the component to add to the scene
  116051. */
  116052. _addComponent(component: ISceneComponent): void;
  116053. /**
  116054. * @hidden
  116055. * Gets a component from the scene.
  116056. * @param name defines the name of the component to retrieve
  116057. * @returns the component or null if not present
  116058. */
  116059. _getComponent(name: string): Nullable<ISceneComponent>;
  116060. /**
  116061. * @hidden
  116062. * Defines the actions happening before camera updates.
  116063. */
  116064. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  116065. /**
  116066. * @hidden
  116067. * Defines the actions happening before clear the canvas.
  116068. */
  116069. _beforeClearStage: Stage<SimpleStageAction>;
  116070. /**
  116071. * @hidden
  116072. * Defines the actions when collecting render targets for the frame.
  116073. */
  116074. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  116075. /**
  116076. * @hidden
  116077. * Defines the actions happening for one camera in the frame.
  116078. */
  116079. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  116080. /**
  116081. * @hidden
  116082. * Defines the actions happening during the per mesh ready checks.
  116083. */
  116084. _isReadyForMeshStage: Stage<MeshStageAction>;
  116085. /**
  116086. * @hidden
  116087. * Defines the actions happening before evaluate active mesh checks.
  116088. */
  116089. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  116090. /**
  116091. * @hidden
  116092. * Defines the actions happening during the evaluate sub mesh checks.
  116093. */
  116094. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  116095. /**
  116096. * @hidden
  116097. * Defines the actions happening during the active mesh stage.
  116098. */
  116099. _activeMeshStage: Stage<ActiveMeshStageAction>;
  116100. /**
  116101. * @hidden
  116102. * Defines the actions happening during the per camera render target step.
  116103. */
  116104. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  116105. /**
  116106. * @hidden
  116107. * Defines the actions happening just before the active camera is drawing.
  116108. */
  116109. _beforeCameraDrawStage: Stage<CameraStageAction>;
  116110. /**
  116111. * @hidden
  116112. * Defines the actions happening just before a render target is drawing.
  116113. */
  116114. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  116115. /**
  116116. * @hidden
  116117. * Defines the actions happening just before a rendering group is drawing.
  116118. */
  116119. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  116120. /**
  116121. * @hidden
  116122. * Defines the actions happening just before a mesh is drawing.
  116123. */
  116124. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  116125. /**
  116126. * @hidden
  116127. * Defines the actions happening just after a mesh has been drawn.
  116128. */
  116129. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  116130. /**
  116131. * @hidden
  116132. * Defines the actions happening just after a rendering group has been drawn.
  116133. */
  116134. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  116135. /**
  116136. * @hidden
  116137. * Defines the actions happening just after the active camera has been drawn.
  116138. */
  116139. _afterCameraDrawStage: Stage<CameraStageAction>;
  116140. /**
  116141. * @hidden
  116142. * Defines the actions happening just after a render target has been drawn.
  116143. */
  116144. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  116145. /**
  116146. * @hidden
  116147. * Defines the actions happening just after rendering all cameras and computing intersections.
  116148. */
  116149. _afterRenderStage: Stage<SimpleStageAction>;
  116150. /**
  116151. * @hidden
  116152. * Defines the actions happening when a pointer move event happens.
  116153. */
  116154. _pointerMoveStage: Stage<PointerMoveStageAction>;
  116155. /**
  116156. * @hidden
  116157. * Defines the actions happening when a pointer down event happens.
  116158. */
  116159. _pointerDownStage: Stage<PointerUpDownStageAction>;
  116160. /**
  116161. * @hidden
  116162. * Defines the actions happening when a pointer up event happens.
  116163. */
  116164. _pointerUpStage: Stage<PointerUpDownStageAction>;
  116165. /**
  116166. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  116167. */
  116168. private geometriesByUniqueId;
  116169. /**
  116170. * Creates a new Scene
  116171. * @param engine defines the engine to use to render this scene
  116172. * @param options defines the scene options
  116173. */
  116174. constructor(engine: Engine, options?: SceneOptions);
  116175. /**
  116176. * Gets a string idenfifying the name of the class
  116177. * @returns "Scene" string
  116178. */
  116179. getClassName(): string;
  116180. private _defaultMeshCandidates;
  116181. /**
  116182. * @hidden
  116183. */
  116184. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  116185. private _defaultSubMeshCandidates;
  116186. /**
  116187. * @hidden
  116188. */
  116189. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  116190. /**
  116191. * Sets the default candidate providers for the scene.
  116192. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  116193. * and getCollidingSubMeshCandidates to their default function
  116194. */
  116195. setDefaultCandidateProviders(): void;
  116196. /**
  116197. * Gets the mesh that is currently under the pointer
  116198. */
  116199. get meshUnderPointer(): Nullable<AbstractMesh>;
  116200. /**
  116201. * Gets or sets the current on-screen X position of the pointer
  116202. */
  116203. get pointerX(): number;
  116204. set pointerX(value: number);
  116205. /**
  116206. * Gets or sets the current on-screen Y position of the pointer
  116207. */
  116208. get pointerY(): number;
  116209. set pointerY(value: number);
  116210. /**
  116211. * Gets the cached material (ie. the latest rendered one)
  116212. * @returns the cached material
  116213. */
  116214. getCachedMaterial(): Nullable<Material>;
  116215. /**
  116216. * Gets the cached effect (ie. the latest rendered one)
  116217. * @returns the cached effect
  116218. */
  116219. getCachedEffect(): Nullable<Effect>;
  116220. /**
  116221. * Gets the cached visibility state (ie. the latest rendered one)
  116222. * @returns the cached visibility state
  116223. */
  116224. getCachedVisibility(): Nullable<number>;
  116225. /**
  116226. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  116227. * @param material defines the current material
  116228. * @param effect defines the current effect
  116229. * @param visibility defines the current visibility state
  116230. * @returns true if one parameter is not cached
  116231. */
  116232. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  116233. /**
  116234. * Gets the engine associated with the scene
  116235. * @returns an Engine
  116236. */
  116237. getEngine(): Engine;
  116238. /**
  116239. * Gets the total number of vertices rendered per frame
  116240. * @returns the total number of vertices rendered per frame
  116241. */
  116242. getTotalVertices(): number;
  116243. /**
  116244. * Gets the performance counter for total vertices
  116245. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  116246. */
  116247. get totalVerticesPerfCounter(): PerfCounter;
  116248. /**
  116249. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  116250. * @returns the total number of active indices rendered per frame
  116251. */
  116252. getActiveIndices(): number;
  116253. /**
  116254. * Gets the performance counter for active indices
  116255. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  116256. */
  116257. get totalActiveIndicesPerfCounter(): PerfCounter;
  116258. /**
  116259. * Gets the total number of active particles rendered per frame
  116260. * @returns the total number of active particles rendered per frame
  116261. */
  116262. getActiveParticles(): number;
  116263. /**
  116264. * Gets the performance counter for active particles
  116265. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  116266. */
  116267. get activeParticlesPerfCounter(): PerfCounter;
  116268. /**
  116269. * Gets the total number of active bones rendered per frame
  116270. * @returns the total number of active bones rendered per frame
  116271. */
  116272. getActiveBones(): number;
  116273. /**
  116274. * Gets the performance counter for active bones
  116275. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  116276. */
  116277. get activeBonesPerfCounter(): PerfCounter;
  116278. /**
  116279. * Gets the array of active meshes
  116280. * @returns an array of AbstractMesh
  116281. */
  116282. getActiveMeshes(): SmartArray<AbstractMesh>;
  116283. /**
  116284. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  116285. * @returns a number
  116286. */
  116287. getAnimationRatio(): number;
  116288. /**
  116289. * Gets an unique Id for the current render phase
  116290. * @returns a number
  116291. */
  116292. getRenderId(): number;
  116293. /**
  116294. * Gets an unique Id for the current frame
  116295. * @returns a number
  116296. */
  116297. getFrameId(): number;
  116298. /** Call this function if you want to manually increment the render Id*/
  116299. incrementRenderId(): void;
  116300. private _createUbo;
  116301. /**
  116302. * Use this method to simulate a pointer move on a mesh
  116303. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  116304. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  116305. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  116306. * @returns the current scene
  116307. */
  116308. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  116309. /**
  116310. * Use this method to simulate a pointer down on a mesh
  116311. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  116312. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  116313. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  116314. * @returns the current scene
  116315. */
  116316. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  116317. /**
  116318. * Use this method to simulate a pointer up on a mesh
  116319. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  116320. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  116321. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  116322. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  116323. * @returns the current scene
  116324. */
  116325. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  116326. /**
  116327. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  116328. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  116329. * @returns true if the pointer was captured
  116330. */
  116331. isPointerCaptured(pointerId?: number): boolean;
  116332. /**
  116333. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  116334. * @param attachUp defines if you want to attach events to pointerup
  116335. * @param attachDown defines if you want to attach events to pointerdown
  116336. * @param attachMove defines if you want to attach events to pointermove
  116337. */
  116338. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  116339. /** Detaches all event handlers*/
  116340. detachControl(): void;
  116341. /**
  116342. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  116343. * Delay loaded resources are not taking in account
  116344. * @return true if all required resources are ready
  116345. */
  116346. isReady(): boolean;
  116347. /** Resets all cached information relative to material (including effect and visibility) */
  116348. resetCachedMaterial(): void;
  116349. /**
  116350. * Registers a function to be called before every frame render
  116351. * @param func defines the function to register
  116352. */
  116353. registerBeforeRender(func: () => void): void;
  116354. /**
  116355. * Unregisters a function called before every frame render
  116356. * @param func defines the function to unregister
  116357. */
  116358. unregisterBeforeRender(func: () => void): void;
  116359. /**
  116360. * Registers a function to be called after every frame render
  116361. * @param func defines the function to register
  116362. */
  116363. registerAfterRender(func: () => void): void;
  116364. /**
  116365. * Unregisters a function called after every frame render
  116366. * @param func defines the function to unregister
  116367. */
  116368. unregisterAfterRender(func: () => void): void;
  116369. private _executeOnceBeforeRender;
  116370. /**
  116371. * The provided function will run before render once and will be disposed afterwards.
  116372. * A timeout delay can be provided so that the function will be executed in N ms.
  116373. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  116374. * @param func The function to be executed.
  116375. * @param timeout optional delay in ms
  116376. */
  116377. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  116378. /** @hidden */
  116379. _addPendingData(data: any): void;
  116380. /** @hidden */
  116381. _removePendingData(data: any): void;
  116382. /**
  116383. * Returns the number of items waiting to be loaded
  116384. * @returns the number of items waiting to be loaded
  116385. */
  116386. getWaitingItemsCount(): number;
  116387. /**
  116388. * Returns a boolean indicating if the scene is still loading data
  116389. */
  116390. get isLoading(): boolean;
  116391. /**
  116392. * Registers a function to be executed when the scene is ready
  116393. * @param {Function} func - the function to be executed
  116394. */
  116395. executeWhenReady(func: () => void): void;
  116396. /**
  116397. * Returns a promise that resolves when the scene is ready
  116398. * @returns A promise that resolves when the scene is ready
  116399. */
  116400. whenReadyAsync(): Promise<void>;
  116401. /** @hidden */
  116402. _checkIsReady(): void;
  116403. /**
  116404. * Gets all animatable attached to the scene
  116405. */
  116406. get animatables(): Animatable[];
  116407. /**
  116408. * Resets the last animation time frame.
  116409. * Useful to override when animations start running when loading a scene for the first time.
  116410. */
  116411. resetLastAnimationTimeFrame(): void;
  116412. /**
  116413. * Gets the current view matrix
  116414. * @returns a Matrix
  116415. */
  116416. getViewMatrix(): Matrix;
  116417. /**
  116418. * Gets the current projection matrix
  116419. * @returns a Matrix
  116420. */
  116421. getProjectionMatrix(): Matrix;
  116422. /**
  116423. * Gets the current transform matrix
  116424. * @returns a Matrix made of View * Projection
  116425. */
  116426. getTransformMatrix(): Matrix;
  116427. /**
  116428. * Sets the current transform matrix
  116429. * @param viewL defines the View matrix to use
  116430. * @param projectionL defines the Projection matrix to use
  116431. * @param viewR defines the right View matrix to use (if provided)
  116432. * @param projectionR defines the right Projection matrix to use (if provided)
  116433. */
  116434. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  116435. /**
  116436. * Gets the uniform buffer used to store scene data
  116437. * @returns a UniformBuffer
  116438. */
  116439. getSceneUniformBuffer(): UniformBuffer;
  116440. /**
  116441. * Gets an unique (relatively to the current scene) Id
  116442. * @returns an unique number for the scene
  116443. */
  116444. getUniqueId(): number;
  116445. /**
  116446. * Add a mesh to the list of scene's meshes
  116447. * @param newMesh defines the mesh to add
  116448. * @param recursive if all child meshes should also be added to the scene
  116449. */
  116450. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  116451. /**
  116452. * Remove a mesh for the list of scene's meshes
  116453. * @param toRemove defines the mesh to remove
  116454. * @param recursive if all child meshes should also be removed from the scene
  116455. * @returns the index where the mesh was in the mesh list
  116456. */
  116457. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  116458. /**
  116459. * Add a transform node to the list of scene's transform nodes
  116460. * @param newTransformNode defines the transform node to add
  116461. */
  116462. addTransformNode(newTransformNode: TransformNode): void;
  116463. /**
  116464. * Remove a transform node for the list of scene's transform nodes
  116465. * @param toRemove defines the transform node to remove
  116466. * @returns the index where the transform node was in the transform node list
  116467. */
  116468. removeTransformNode(toRemove: TransformNode): number;
  116469. /**
  116470. * Remove a skeleton for the list of scene's skeletons
  116471. * @param toRemove defines the skeleton to remove
  116472. * @returns the index where the skeleton was in the skeleton list
  116473. */
  116474. removeSkeleton(toRemove: Skeleton): number;
  116475. /**
  116476. * Remove a morph target for the list of scene's morph targets
  116477. * @param toRemove defines the morph target to remove
  116478. * @returns the index where the morph target was in the morph target list
  116479. */
  116480. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  116481. /**
  116482. * Remove a light for the list of scene's lights
  116483. * @param toRemove defines the light to remove
  116484. * @returns the index where the light was in the light list
  116485. */
  116486. removeLight(toRemove: Light): number;
  116487. /**
  116488. * Remove a camera for the list of scene's cameras
  116489. * @param toRemove defines the camera to remove
  116490. * @returns the index where the camera was in the camera list
  116491. */
  116492. removeCamera(toRemove: Camera): number;
  116493. /**
  116494. * Remove a particle system for the list of scene's particle systems
  116495. * @param toRemove defines the particle system to remove
  116496. * @returns the index where the particle system was in the particle system list
  116497. */
  116498. removeParticleSystem(toRemove: IParticleSystem): number;
  116499. /**
  116500. * Remove a animation for the list of scene's animations
  116501. * @param toRemove defines the animation to remove
  116502. * @returns the index where the animation was in the animation list
  116503. */
  116504. removeAnimation(toRemove: Animation): number;
  116505. /**
  116506. * Will stop the animation of the given target
  116507. * @param target - the target
  116508. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  116509. * @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)
  116510. */
  116511. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  116512. /**
  116513. * Removes the given animation group from this scene.
  116514. * @param toRemove The animation group to remove
  116515. * @returns The index of the removed animation group
  116516. */
  116517. removeAnimationGroup(toRemove: AnimationGroup): number;
  116518. /**
  116519. * Removes the given multi-material from this scene.
  116520. * @param toRemove The multi-material to remove
  116521. * @returns The index of the removed multi-material
  116522. */
  116523. removeMultiMaterial(toRemove: MultiMaterial): number;
  116524. /**
  116525. * Removes the given material from this scene.
  116526. * @param toRemove The material to remove
  116527. * @returns The index of the removed material
  116528. */
  116529. removeMaterial(toRemove: Material): number;
  116530. /**
  116531. * Removes the given action manager from this scene.
  116532. * @param toRemove The action manager to remove
  116533. * @returns The index of the removed action manager
  116534. */
  116535. removeActionManager(toRemove: AbstractActionManager): number;
  116536. /**
  116537. * Removes the given texture from this scene.
  116538. * @param toRemove The texture to remove
  116539. * @returns The index of the removed texture
  116540. */
  116541. removeTexture(toRemove: BaseTexture): number;
  116542. /**
  116543. * Adds the given light to this scene
  116544. * @param newLight The light to add
  116545. */
  116546. addLight(newLight: Light): void;
  116547. /**
  116548. * Sorts the list list based on light priorities
  116549. */
  116550. sortLightsByPriority(): void;
  116551. /**
  116552. * Adds the given camera to this scene
  116553. * @param newCamera The camera to add
  116554. */
  116555. addCamera(newCamera: Camera): void;
  116556. /**
  116557. * Adds the given skeleton to this scene
  116558. * @param newSkeleton The skeleton to add
  116559. */
  116560. addSkeleton(newSkeleton: Skeleton): void;
  116561. /**
  116562. * Adds the given particle system to this scene
  116563. * @param newParticleSystem The particle system to add
  116564. */
  116565. addParticleSystem(newParticleSystem: IParticleSystem): void;
  116566. /**
  116567. * Adds the given animation to this scene
  116568. * @param newAnimation The animation to add
  116569. */
  116570. addAnimation(newAnimation: Animation): void;
  116571. /**
  116572. * Adds the given animation group to this scene.
  116573. * @param newAnimationGroup The animation group to add
  116574. */
  116575. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  116576. /**
  116577. * Adds the given multi-material to this scene
  116578. * @param newMultiMaterial The multi-material to add
  116579. */
  116580. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  116581. /**
  116582. * Adds the given material to this scene
  116583. * @param newMaterial The material to add
  116584. */
  116585. addMaterial(newMaterial: Material): void;
  116586. /**
  116587. * Adds the given morph target to this scene
  116588. * @param newMorphTargetManager The morph target to add
  116589. */
  116590. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  116591. /**
  116592. * Adds the given geometry to this scene
  116593. * @param newGeometry The geometry to add
  116594. */
  116595. addGeometry(newGeometry: Geometry): void;
  116596. /**
  116597. * Adds the given action manager to this scene
  116598. * @param newActionManager The action manager to add
  116599. */
  116600. addActionManager(newActionManager: AbstractActionManager): void;
  116601. /**
  116602. * Adds the given texture to this scene.
  116603. * @param newTexture The texture to add
  116604. */
  116605. addTexture(newTexture: BaseTexture): void;
  116606. /**
  116607. * Switch active camera
  116608. * @param newCamera defines the new active camera
  116609. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  116610. */
  116611. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  116612. /**
  116613. * sets the active camera of the scene using its ID
  116614. * @param id defines the camera's ID
  116615. * @return the new active camera or null if none found.
  116616. */
  116617. setActiveCameraByID(id: string): Nullable<Camera>;
  116618. /**
  116619. * sets the active camera of the scene using its name
  116620. * @param name defines the camera's name
  116621. * @returns the new active camera or null if none found.
  116622. */
  116623. setActiveCameraByName(name: string): Nullable<Camera>;
  116624. /**
  116625. * get an animation group using its name
  116626. * @param name defines the material's name
  116627. * @return the animation group or null if none found.
  116628. */
  116629. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  116630. /**
  116631. * Get a material using its unique id
  116632. * @param uniqueId defines the material's unique id
  116633. * @return the material or null if none found.
  116634. */
  116635. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  116636. /**
  116637. * get a material using its id
  116638. * @param id defines the material's ID
  116639. * @return the material or null if none found.
  116640. */
  116641. getMaterialByID(id: string): Nullable<Material>;
  116642. /**
  116643. * Gets a the last added material using a given id
  116644. * @param id defines the material's ID
  116645. * @return the last material with the given id or null if none found.
  116646. */
  116647. getLastMaterialByID(id: string): Nullable<Material>;
  116648. /**
  116649. * Gets a material using its name
  116650. * @param name defines the material's name
  116651. * @return the material or null if none found.
  116652. */
  116653. getMaterialByName(name: string): Nullable<Material>;
  116654. /**
  116655. * Get a texture using its unique id
  116656. * @param uniqueId defines the texture's unique id
  116657. * @return the texture or null if none found.
  116658. */
  116659. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  116660. /**
  116661. * Gets a camera using its id
  116662. * @param id defines the id to look for
  116663. * @returns the camera or null if not found
  116664. */
  116665. getCameraByID(id: string): Nullable<Camera>;
  116666. /**
  116667. * Gets a camera using its unique id
  116668. * @param uniqueId defines the unique id to look for
  116669. * @returns the camera or null if not found
  116670. */
  116671. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  116672. /**
  116673. * Gets a camera using its name
  116674. * @param name defines the camera's name
  116675. * @return the camera or null if none found.
  116676. */
  116677. getCameraByName(name: string): Nullable<Camera>;
  116678. /**
  116679. * Gets a bone using its id
  116680. * @param id defines the bone's id
  116681. * @return the bone or null if not found
  116682. */
  116683. getBoneByID(id: string): Nullable<Bone>;
  116684. /**
  116685. * Gets a bone using its id
  116686. * @param name defines the bone's name
  116687. * @return the bone or null if not found
  116688. */
  116689. getBoneByName(name: string): Nullable<Bone>;
  116690. /**
  116691. * Gets a light node using its name
  116692. * @param name defines the the light's name
  116693. * @return the light or null if none found.
  116694. */
  116695. getLightByName(name: string): Nullable<Light>;
  116696. /**
  116697. * Gets a light node using its id
  116698. * @param id defines the light's id
  116699. * @return the light or null if none found.
  116700. */
  116701. getLightByID(id: string): Nullable<Light>;
  116702. /**
  116703. * Gets a light node using its scene-generated unique ID
  116704. * @param uniqueId defines the light's unique id
  116705. * @return the light or null if none found.
  116706. */
  116707. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  116708. /**
  116709. * Gets a particle system by id
  116710. * @param id defines the particle system id
  116711. * @return the corresponding system or null if none found
  116712. */
  116713. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  116714. /**
  116715. * Gets a geometry using its ID
  116716. * @param id defines the geometry's id
  116717. * @return the geometry or null if none found.
  116718. */
  116719. getGeometryByID(id: string): Nullable<Geometry>;
  116720. private _getGeometryByUniqueID;
  116721. /**
  116722. * Add a new geometry to this scene
  116723. * @param geometry defines the geometry to be added to the scene.
  116724. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  116725. * @return a boolean defining if the geometry was added or not
  116726. */
  116727. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  116728. /**
  116729. * Removes an existing geometry
  116730. * @param geometry defines the geometry to be removed from the scene
  116731. * @return a boolean defining if the geometry was removed or not
  116732. */
  116733. removeGeometry(geometry: Geometry): boolean;
  116734. /**
  116735. * Gets the list of geometries attached to the scene
  116736. * @returns an array of Geometry
  116737. */
  116738. getGeometries(): Geometry[];
  116739. /**
  116740. * Gets the first added mesh found of a given ID
  116741. * @param id defines the id to search for
  116742. * @return the mesh found or null if not found at all
  116743. */
  116744. getMeshByID(id: string): Nullable<AbstractMesh>;
  116745. /**
  116746. * Gets a list of meshes using their id
  116747. * @param id defines the id to search for
  116748. * @returns a list of meshes
  116749. */
  116750. getMeshesByID(id: string): Array<AbstractMesh>;
  116751. /**
  116752. * Gets the first added transform node found of a given ID
  116753. * @param id defines the id to search for
  116754. * @return the found transform node or null if not found at all.
  116755. */
  116756. getTransformNodeByID(id: string): Nullable<TransformNode>;
  116757. /**
  116758. * Gets a transform node with its auto-generated unique id
  116759. * @param uniqueId efines the unique id to search for
  116760. * @return the found transform node or null if not found at all.
  116761. */
  116762. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  116763. /**
  116764. * Gets a list of transform nodes using their id
  116765. * @param id defines the id to search for
  116766. * @returns a list of transform nodes
  116767. */
  116768. getTransformNodesByID(id: string): Array<TransformNode>;
  116769. /**
  116770. * Gets a mesh with its auto-generated unique id
  116771. * @param uniqueId defines the unique id to search for
  116772. * @return the found mesh or null if not found at all.
  116773. */
  116774. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  116775. /**
  116776. * Gets a the last added mesh using a given id
  116777. * @param id defines the id to search for
  116778. * @return the found mesh or null if not found at all.
  116779. */
  116780. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  116781. /**
  116782. * Gets a the last added node (Mesh, Camera, Light) using a given id
  116783. * @param id defines the id to search for
  116784. * @return the found node or null if not found at all
  116785. */
  116786. getLastEntryByID(id: string): Nullable<Node>;
  116787. /**
  116788. * Gets a node (Mesh, Camera, Light) using a given id
  116789. * @param id defines the id to search for
  116790. * @return the found node or null if not found at all
  116791. */
  116792. getNodeByID(id: string): Nullable<Node>;
  116793. /**
  116794. * Gets a node (Mesh, Camera, Light) using a given name
  116795. * @param name defines the name to search for
  116796. * @return the found node or null if not found at all.
  116797. */
  116798. getNodeByName(name: string): Nullable<Node>;
  116799. /**
  116800. * Gets a mesh using a given name
  116801. * @param name defines the name to search for
  116802. * @return the found mesh or null if not found at all.
  116803. */
  116804. getMeshByName(name: string): Nullable<AbstractMesh>;
  116805. /**
  116806. * Gets a transform node using a given name
  116807. * @param name defines the name to search for
  116808. * @return the found transform node or null if not found at all.
  116809. */
  116810. getTransformNodeByName(name: string): Nullable<TransformNode>;
  116811. /**
  116812. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  116813. * @param id defines the id to search for
  116814. * @return the found skeleton or null if not found at all.
  116815. */
  116816. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  116817. /**
  116818. * Gets a skeleton using a given auto generated unique id
  116819. * @param uniqueId defines the unique id to search for
  116820. * @return the found skeleton or null if not found at all.
  116821. */
  116822. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  116823. /**
  116824. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  116825. * @param id defines the id to search for
  116826. * @return the found skeleton or null if not found at all.
  116827. */
  116828. getSkeletonById(id: string): Nullable<Skeleton>;
  116829. /**
  116830. * Gets a skeleton using a given name
  116831. * @param name defines the name to search for
  116832. * @return the found skeleton or null if not found at all.
  116833. */
  116834. getSkeletonByName(name: string): Nullable<Skeleton>;
  116835. /**
  116836. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  116837. * @param id defines the id to search for
  116838. * @return the found morph target manager or null if not found at all.
  116839. */
  116840. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  116841. /**
  116842. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  116843. * @param id defines the id to search for
  116844. * @return the found morph target or null if not found at all.
  116845. */
  116846. getMorphTargetById(id: string): Nullable<MorphTarget>;
  116847. /**
  116848. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  116849. * @param name defines the name to search for
  116850. * @return the found morph target or null if not found at all.
  116851. */
  116852. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  116853. /**
  116854. * Gets a boolean indicating if the given mesh is active
  116855. * @param mesh defines the mesh to look for
  116856. * @returns true if the mesh is in the active list
  116857. */
  116858. isActiveMesh(mesh: AbstractMesh): boolean;
  116859. /**
  116860. * Return a unique id as a string which can serve as an identifier for the scene
  116861. */
  116862. get uid(): string;
  116863. /**
  116864. * Add an externaly attached data from its key.
  116865. * This method call will fail and return false, if such key already exists.
  116866. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  116867. * @param key the unique key that identifies the data
  116868. * @param data the data object to associate to the key for this Engine instance
  116869. * @return true if no such key were already present and the data was added successfully, false otherwise
  116870. */
  116871. addExternalData<T>(key: string, data: T): boolean;
  116872. /**
  116873. * Get an externaly attached data from its key
  116874. * @param key the unique key that identifies the data
  116875. * @return the associated data, if present (can be null), or undefined if not present
  116876. */
  116877. getExternalData<T>(key: string): Nullable<T>;
  116878. /**
  116879. * Get an externaly attached data from its key, create it using a factory if it's not already present
  116880. * @param key the unique key that identifies the data
  116881. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  116882. * @return the associated data, can be null if the factory returned null.
  116883. */
  116884. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  116885. /**
  116886. * Remove an externaly attached data from the Engine instance
  116887. * @param key the unique key that identifies the data
  116888. * @return true if the data was successfully removed, false if it doesn't exist
  116889. */
  116890. removeExternalData(key: string): boolean;
  116891. private _evaluateSubMesh;
  116892. /**
  116893. * Clear the processed materials smart array preventing retention point in material dispose.
  116894. */
  116895. freeProcessedMaterials(): void;
  116896. private _preventFreeActiveMeshesAndRenderingGroups;
  116897. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  116898. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  116899. * when disposing several meshes in a row or a hierarchy of meshes.
  116900. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  116901. */
  116902. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  116903. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  116904. /**
  116905. * Clear the active meshes smart array preventing retention point in mesh dispose.
  116906. */
  116907. freeActiveMeshes(): void;
  116908. /**
  116909. * Clear the info related to rendering groups preventing retention points during dispose.
  116910. */
  116911. freeRenderingGroups(): void;
  116912. /** @hidden */
  116913. _isInIntermediateRendering(): boolean;
  116914. /**
  116915. * Lambda returning the list of potentially active meshes.
  116916. */
  116917. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  116918. /**
  116919. * Lambda returning the list of potentially active sub meshes.
  116920. */
  116921. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  116922. /**
  116923. * Lambda returning the list of potentially intersecting sub meshes.
  116924. */
  116925. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  116926. /**
  116927. * Lambda returning the list of potentially colliding sub meshes.
  116928. */
  116929. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  116930. private _activeMeshesFrozen;
  116931. private _skipEvaluateActiveMeshesCompletely;
  116932. /**
  116933. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  116934. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  116935. * @returns the current scene
  116936. */
  116937. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  116938. /**
  116939. * Use this function to restart evaluating active meshes on every frame
  116940. * @returns the current scene
  116941. */
  116942. unfreezeActiveMeshes(): Scene;
  116943. private _evaluateActiveMeshes;
  116944. private _activeMesh;
  116945. /**
  116946. * Update the transform matrix to update from the current active camera
  116947. * @param force defines a boolean used to force the update even if cache is up to date
  116948. */
  116949. updateTransformMatrix(force?: boolean): void;
  116950. private _bindFrameBuffer;
  116951. /** @hidden */
  116952. _allowPostProcessClearColor: boolean;
  116953. /** @hidden */
  116954. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  116955. private _processSubCameras;
  116956. private _checkIntersections;
  116957. /** @hidden */
  116958. _advancePhysicsEngineStep(step: number): void;
  116959. /**
  116960. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  116961. */
  116962. getDeterministicFrameTime: () => number;
  116963. /** @hidden */
  116964. _animate(): void;
  116965. /** Execute all animations (for a frame) */
  116966. animate(): void;
  116967. /**
  116968. * Render the scene
  116969. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  116970. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  116971. */
  116972. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  116973. /**
  116974. * Freeze all materials
  116975. * A frozen material will not be updatable but should be faster to render
  116976. */
  116977. freezeMaterials(): void;
  116978. /**
  116979. * Unfreeze all materials
  116980. * A frozen material will not be updatable but should be faster to render
  116981. */
  116982. unfreezeMaterials(): void;
  116983. /**
  116984. * Releases all held ressources
  116985. */
  116986. dispose(): void;
  116987. /**
  116988. * Gets if the scene is already disposed
  116989. */
  116990. get isDisposed(): boolean;
  116991. /**
  116992. * Call this function to reduce memory footprint of the scene.
  116993. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  116994. */
  116995. clearCachedVertexData(): void;
  116996. /**
  116997. * This function will remove the local cached buffer data from texture.
  116998. * It will save memory but will prevent the texture from being rebuilt
  116999. */
  117000. cleanCachedTextureBuffer(): void;
  117001. /**
  117002. * Get the world extend vectors with an optional filter
  117003. *
  117004. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  117005. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  117006. */
  117007. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  117008. min: Vector3;
  117009. max: Vector3;
  117010. };
  117011. /**
  117012. * Creates a ray that can be used to pick in the scene
  117013. * @param x defines the x coordinate of the origin (on-screen)
  117014. * @param y defines the y coordinate of the origin (on-screen)
  117015. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  117016. * @param camera defines the camera to use for the picking
  117017. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  117018. * @returns a Ray
  117019. */
  117020. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  117021. /**
  117022. * Creates a ray that can be used to pick in the scene
  117023. * @param x defines the x coordinate of the origin (on-screen)
  117024. * @param y defines the y coordinate of the origin (on-screen)
  117025. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  117026. * @param result defines the ray where to store the picking ray
  117027. * @param camera defines the camera to use for the picking
  117028. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  117029. * @returns the current scene
  117030. */
  117031. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  117032. /**
  117033. * Creates a ray that can be used to pick in the scene
  117034. * @param x defines the x coordinate of the origin (on-screen)
  117035. * @param y defines the y coordinate of the origin (on-screen)
  117036. * @param camera defines the camera to use for the picking
  117037. * @returns a Ray
  117038. */
  117039. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  117040. /**
  117041. * Creates a ray that can be used to pick in the scene
  117042. * @param x defines the x coordinate of the origin (on-screen)
  117043. * @param y defines the y coordinate of the origin (on-screen)
  117044. * @param result defines the ray where to store the picking ray
  117045. * @param camera defines the camera to use for the picking
  117046. * @returns the current scene
  117047. */
  117048. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  117049. /** Launch a ray to try to pick a mesh in the scene
  117050. * @param x position on screen
  117051. * @param y position on screen
  117052. * @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
  117053. * @param fastCheck defines if the first intersection will be used (and not the closest)
  117054. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  117055. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  117056. * @returns a PickingInfo
  117057. */
  117058. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  117059. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  117060. * @param x position on screen
  117061. * @param y position on screen
  117062. * @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
  117063. * @param fastCheck defines if the first intersection will be used (and not the closest)
  117064. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  117065. * @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)
  117066. */
  117067. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  117068. /** Use the given ray to pick a mesh in the scene
  117069. * @param ray The ray to use to pick meshes
  117070. * @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
  117071. * @param fastCheck defines if the first intersection will be used (and not the closest)
  117072. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  117073. * @returns a PickingInfo
  117074. */
  117075. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  117076. /**
  117077. * Launch a ray to try to pick a mesh in the scene
  117078. * @param x X position on screen
  117079. * @param y Y position on screen
  117080. * @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
  117081. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  117082. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  117083. * @returns an array of PickingInfo
  117084. */
  117085. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  117086. /**
  117087. * Launch a ray to try to pick a mesh in the scene
  117088. * @param ray Ray to use
  117089. * @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
  117090. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  117091. * @returns an array of PickingInfo
  117092. */
  117093. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  117094. /**
  117095. * Force the value of meshUnderPointer
  117096. * @param mesh defines the mesh to use
  117097. */
  117098. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  117099. /**
  117100. * Gets the mesh under the pointer
  117101. * @returns a Mesh or null if no mesh is under the pointer
  117102. */
  117103. getPointerOverMesh(): Nullable<AbstractMesh>;
  117104. /** @hidden */
  117105. _rebuildGeometries(): void;
  117106. /** @hidden */
  117107. _rebuildTextures(): void;
  117108. private _getByTags;
  117109. /**
  117110. * Get a list of meshes by tags
  117111. * @param tagsQuery defines the tags query to use
  117112. * @param forEach defines a predicate used to filter results
  117113. * @returns an array of Mesh
  117114. */
  117115. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  117116. /**
  117117. * Get a list of cameras by tags
  117118. * @param tagsQuery defines the tags query to use
  117119. * @param forEach defines a predicate used to filter results
  117120. * @returns an array of Camera
  117121. */
  117122. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  117123. /**
  117124. * Get a list of lights by tags
  117125. * @param tagsQuery defines the tags query to use
  117126. * @param forEach defines a predicate used to filter results
  117127. * @returns an array of Light
  117128. */
  117129. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  117130. /**
  117131. * Get a list of materials by tags
  117132. * @param tagsQuery defines the tags query to use
  117133. * @param forEach defines a predicate used to filter results
  117134. * @returns an array of Material
  117135. */
  117136. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  117137. /**
  117138. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  117139. * This allowed control for front to back rendering or reversly depending of the special needs.
  117140. *
  117141. * @param renderingGroupId The rendering group id corresponding to its index
  117142. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  117143. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  117144. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  117145. */
  117146. 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;
  117147. /**
  117148. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  117149. *
  117150. * @param renderingGroupId The rendering group id corresponding to its index
  117151. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  117152. * @param depth Automatically clears depth between groups if true and autoClear is true.
  117153. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  117154. */
  117155. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  117156. /**
  117157. * Gets the current auto clear configuration for one rendering group of the rendering
  117158. * manager.
  117159. * @param index the rendering group index to get the information for
  117160. * @returns The auto clear setup for the requested rendering group
  117161. */
  117162. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  117163. private _blockMaterialDirtyMechanism;
  117164. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  117165. get blockMaterialDirtyMechanism(): boolean;
  117166. set blockMaterialDirtyMechanism(value: boolean);
  117167. /**
  117168. * Will flag all materials as dirty to trigger new shader compilation
  117169. * @param flag defines the flag used to specify which material part must be marked as dirty
  117170. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  117171. */
  117172. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  117173. /** @hidden */
  117174. _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;
  117175. /** @hidden */
  117176. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  117177. /** @hidden */
  117178. _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;
  117179. /** @hidden */
  117180. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  117181. /** @hidden */
  117182. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  117183. /** @hidden */
  117184. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  117185. }
  117186. }
  117187. declare module BABYLON {
  117188. /**
  117189. * Set of assets to keep when moving a scene into an asset container.
  117190. */
  117191. export class KeepAssets extends AbstractScene {
  117192. }
  117193. /**
  117194. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  117195. */
  117196. export class InstantiatedEntries {
  117197. /**
  117198. * List of new root nodes (eg. nodes with no parent)
  117199. */
  117200. rootNodes: TransformNode[];
  117201. /**
  117202. * List of new skeletons
  117203. */
  117204. skeletons: Skeleton[];
  117205. /**
  117206. * List of new animation groups
  117207. */
  117208. animationGroups: AnimationGroup[];
  117209. }
  117210. /**
  117211. * Container with a set of assets that can be added or removed from a scene.
  117212. */
  117213. export class AssetContainer extends AbstractScene {
  117214. private _wasAddedToScene;
  117215. /**
  117216. * The scene the AssetContainer belongs to.
  117217. */
  117218. scene: Scene;
  117219. /**
  117220. * Instantiates an AssetContainer.
  117221. * @param scene The scene the AssetContainer belongs to.
  117222. */
  117223. constructor(scene: Scene);
  117224. /**
  117225. * Instantiate or clone all meshes and add the new ones to the scene.
  117226. * Skeletons and animation groups will all be cloned
  117227. * @param nameFunction defines an optional function used to get new names for clones
  117228. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  117229. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  117230. */
  117231. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  117232. /**
  117233. * Adds all the assets from the container to the scene.
  117234. */
  117235. addAllToScene(): void;
  117236. /**
  117237. * Removes all the assets in the container from the scene
  117238. */
  117239. removeAllFromScene(): void;
  117240. /**
  117241. * Disposes all the assets in the container
  117242. */
  117243. dispose(): void;
  117244. private _moveAssets;
  117245. /**
  117246. * Removes all the assets contained in the scene and adds them to the container.
  117247. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  117248. */
  117249. moveAllFromScene(keepAssets?: KeepAssets): void;
  117250. /**
  117251. * 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.
  117252. * @returns the root mesh
  117253. */
  117254. createRootMesh(): Mesh;
  117255. /**
  117256. * Merge animations (direct and animation groups) from this asset container into a scene
  117257. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  117258. * @param animatables set of animatables to retarget to a node from the scene
  117259. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  117260. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  117261. */
  117262. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  117263. }
  117264. }
  117265. declare module BABYLON {
  117266. /**
  117267. * Defines how the parser contract is defined.
  117268. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  117269. */
  117270. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  117271. /**
  117272. * Defines how the individual parser contract is defined.
  117273. * These parser can parse an individual asset
  117274. */
  117275. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  117276. /**
  117277. * Base class of the scene acting as a container for the different elements composing a scene.
  117278. * This class is dynamically extended by the different components of the scene increasing
  117279. * flexibility and reducing coupling
  117280. */
  117281. export abstract class AbstractScene {
  117282. /**
  117283. * Stores the list of available parsers in the application.
  117284. */
  117285. private static _BabylonFileParsers;
  117286. /**
  117287. * Stores the list of available individual parsers in the application.
  117288. */
  117289. private static _IndividualBabylonFileParsers;
  117290. /**
  117291. * Adds a parser in the list of available ones
  117292. * @param name Defines the name of the parser
  117293. * @param parser Defines the parser to add
  117294. */
  117295. static AddParser(name: string, parser: BabylonFileParser): void;
  117296. /**
  117297. * Gets a general parser from the list of avaialble ones
  117298. * @param name Defines the name of the parser
  117299. * @returns the requested parser or null
  117300. */
  117301. static GetParser(name: string): Nullable<BabylonFileParser>;
  117302. /**
  117303. * Adds n individual parser in the list of available ones
  117304. * @param name Defines the name of the parser
  117305. * @param parser Defines the parser to add
  117306. */
  117307. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  117308. /**
  117309. * Gets an individual parser from the list of avaialble ones
  117310. * @param name Defines the name of the parser
  117311. * @returns the requested parser or null
  117312. */
  117313. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  117314. /**
  117315. * Parser json data and populate both a scene and its associated container object
  117316. * @param jsonData Defines the data to parse
  117317. * @param scene Defines the scene to parse the data for
  117318. * @param container Defines the container attached to the parsing sequence
  117319. * @param rootUrl Defines the root url of the data
  117320. */
  117321. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  117322. /**
  117323. * Gets the list of root nodes (ie. nodes with no parent)
  117324. */
  117325. rootNodes: Node[];
  117326. /** All of the cameras added to this scene
  117327. * @see http://doc.babylonjs.com/babylon101/cameras
  117328. */
  117329. cameras: Camera[];
  117330. /**
  117331. * All of the lights added to this scene
  117332. * @see http://doc.babylonjs.com/babylon101/lights
  117333. */
  117334. lights: Light[];
  117335. /**
  117336. * All of the (abstract) meshes added to this scene
  117337. */
  117338. meshes: AbstractMesh[];
  117339. /**
  117340. * The list of skeletons added to the scene
  117341. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  117342. */
  117343. skeletons: Skeleton[];
  117344. /**
  117345. * All of the particle systems added to this scene
  117346. * @see http://doc.babylonjs.com/babylon101/particles
  117347. */
  117348. particleSystems: IParticleSystem[];
  117349. /**
  117350. * Gets a list of Animations associated with the scene
  117351. */
  117352. animations: Animation[];
  117353. /**
  117354. * All of the animation groups added to this scene
  117355. * @see http://doc.babylonjs.com/how_to/group
  117356. */
  117357. animationGroups: AnimationGroup[];
  117358. /**
  117359. * All of the multi-materials added to this scene
  117360. * @see http://doc.babylonjs.com/how_to/multi_materials
  117361. */
  117362. multiMaterials: MultiMaterial[];
  117363. /**
  117364. * All of the materials added to this scene
  117365. * In the context of a Scene, it is not supposed to be modified manually.
  117366. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  117367. * Note also that the order of the Material within the array is not significant and might change.
  117368. * @see http://doc.babylonjs.com/babylon101/materials
  117369. */
  117370. materials: Material[];
  117371. /**
  117372. * The list of morph target managers added to the scene
  117373. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  117374. */
  117375. morphTargetManagers: MorphTargetManager[];
  117376. /**
  117377. * The list of geometries used in the scene.
  117378. */
  117379. geometries: Geometry[];
  117380. /**
  117381. * All of the tranform nodes added to this scene
  117382. * In the context of a Scene, it is not supposed to be modified manually.
  117383. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  117384. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  117385. * @see http://doc.babylonjs.com/how_to/transformnode
  117386. */
  117387. transformNodes: TransformNode[];
  117388. /**
  117389. * ActionManagers available on the scene.
  117390. */
  117391. actionManagers: AbstractActionManager[];
  117392. /**
  117393. * Textures to keep.
  117394. */
  117395. textures: BaseTexture[];
  117396. /**
  117397. * Environment texture for the scene
  117398. */
  117399. environmentTexture: Nullable<BaseTexture>;
  117400. /**
  117401. * @returns all meshes, lights, cameras, transformNodes and bones
  117402. */
  117403. getNodes(): Array<Node>;
  117404. }
  117405. }
  117406. declare module BABYLON {
  117407. /**
  117408. * Interface used to define options for Sound class
  117409. */
  117410. export interface ISoundOptions {
  117411. /**
  117412. * Does the sound autoplay once loaded.
  117413. */
  117414. autoplay?: boolean;
  117415. /**
  117416. * Does the sound loop after it finishes playing once.
  117417. */
  117418. loop?: boolean;
  117419. /**
  117420. * Sound's volume
  117421. */
  117422. volume?: number;
  117423. /**
  117424. * Is it a spatial sound?
  117425. */
  117426. spatialSound?: boolean;
  117427. /**
  117428. * Maximum distance to hear that sound
  117429. */
  117430. maxDistance?: number;
  117431. /**
  117432. * Uses user defined attenuation function
  117433. */
  117434. useCustomAttenuation?: boolean;
  117435. /**
  117436. * Define the roll off factor of spatial sounds.
  117437. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  117438. */
  117439. rolloffFactor?: number;
  117440. /**
  117441. * Define the reference distance the sound should be heard perfectly.
  117442. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  117443. */
  117444. refDistance?: number;
  117445. /**
  117446. * Define the distance attenuation model the sound will follow.
  117447. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  117448. */
  117449. distanceModel?: string;
  117450. /**
  117451. * Defines the playback speed (1 by default)
  117452. */
  117453. playbackRate?: number;
  117454. /**
  117455. * Defines if the sound is from a streaming source
  117456. */
  117457. streaming?: boolean;
  117458. /**
  117459. * Defines an optional length (in seconds) inside the sound file
  117460. */
  117461. length?: number;
  117462. /**
  117463. * Defines an optional offset (in seconds) inside the sound file
  117464. */
  117465. offset?: number;
  117466. /**
  117467. * If true, URLs will not be required to state the audio file codec to use.
  117468. */
  117469. skipCodecCheck?: boolean;
  117470. }
  117471. /**
  117472. * Defines a sound that can be played in the application.
  117473. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  117474. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  117475. */
  117476. export class Sound {
  117477. /**
  117478. * The name of the sound in the scene.
  117479. */
  117480. name: string;
  117481. /**
  117482. * Does the sound autoplay once loaded.
  117483. */
  117484. autoplay: boolean;
  117485. /**
  117486. * Does the sound loop after it finishes playing once.
  117487. */
  117488. loop: boolean;
  117489. /**
  117490. * Does the sound use a custom attenuation curve to simulate the falloff
  117491. * happening when the source gets further away from the camera.
  117492. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  117493. */
  117494. useCustomAttenuation: boolean;
  117495. /**
  117496. * The sound track id this sound belongs to.
  117497. */
  117498. soundTrackId: number;
  117499. /**
  117500. * Is this sound currently played.
  117501. */
  117502. isPlaying: boolean;
  117503. /**
  117504. * Is this sound currently paused.
  117505. */
  117506. isPaused: boolean;
  117507. /**
  117508. * Does this sound enables spatial sound.
  117509. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  117510. */
  117511. spatialSound: boolean;
  117512. /**
  117513. * Define the reference distance the sound should be heard perfectly.
  117514. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  117515. */
  117516. refDistance: number;
  117517. /**
  117518. * Define the roll off factor of spatial sounds.
  117519. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  117520. */
  117521. rolloffFactor: number;
  117522. /**
  117523. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  117524. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  117525. */
  117526. maxDistance: number;
  117527. /**
  117528. * Define the distance attenuation model the sound will follow.
  117529. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  117530. */
  117531. distanceModel: string;
  117532. /**
  117533. * @hidden
  117534. * Back Compat
  117535. **/
  117536. onended: () => any;
  117537. /**
  117538. * Gets or sets an object used to store user defined information for the sound.
  117539. */
  117540. metadata: any;
  117541. /**
  117542. * Observable event when the current playing sound finishes.
  117543. */
  117544. onEndedObservable: Observable<Sound>;
  117545. private _panningModel;
  117546. private _playbackRate;
  117547. private _streaming;
  117548. private _startTime;
  117549. private _startOffset;
  117550. private _position;
  117551. /** @hidden */
  117552. _positionInEmitterSpace: boolean;
  117553. private _localDirection;
  117554. private _volume;
  117555. private _isReadyToPlay;
  117556. private _isDirectional;
  117557. private _readyToPlayCallback;
  117558. private _audioBuffer;
  117559. private _soundSource;
  117560. private _streamingSource;
  117561. private _soundPanner;
  117562. private _soundGain;
  117563. private _inputAudioNode;
  117564. private _outputAudioNode;
  117565. private _coneInnerAngle;
  117566. private _coneOuterAngle;
  117567. private _coneOuterGain;
  117568. private _scene;
  117569. private _connectedTransformNode;
  117570. private _customAttenuationFunction;
  117571. private _registerFunc;
  117572. private _isOutputConnected;
  117573. private _htmlAudioElement;
  117574. private _urlType;
  117575. private _length?;
  117576. private _offset?;
  117577. /** @hidden */
  117578. static _SceneComponentInitialization: (scene: Scene) => void;
  117579. /**
  117580. * Create a sound and attach it to a scene
  117581. * @param name Name of your sound
  117582. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  117583. * @param scene defines the scene the sound belongs to
  117584. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  117585. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  117586. */
  117587. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  117588. /**
  117589. * Release the sound and its associated resources
  117590. */
  117591. dispose(): void;
  117592. /**
  117593. * Gets if the sounds is ready to be played or not.
  117594. * @returns true if ready, otherwise false
  117595. */
  117596. isReady(): boolean;
  117597. private _soundLoaded;
  117598. /**
  117599. * Sets the data of the sound from an audiobuffer
  117600. * @param audioBuffer The audioBuffer containing the data
  117601. */
  117602. setAudioBuffer(audioBuffer: AudioBuffer): void;
  117603. /**
  117604. * Updates the current sounds options such as maxdistance, loop...
  117605. * @param options A JSON object containing values named as the object properties
  117606. */
  117607. updateOptions(options: ISoundOptions): void;
  117608. private _createSpatialParameters;
  117609. private _updateSpatialParameters;
  117610. /**
  117611. * Switch the panning model to HRTF:
  117612. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  117613. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  117614. */
  117615. switchPanningModelToHRTF(): void;
  117616. /**
  117617. * Switch the panning model to Equal Power:
  117618. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  117619. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  117620. */
  117621. switchPanningModelToEqualPower(): void;
  117622. private _switchPanningModel;
  117623. /**
  117624. * Connect this sound to a sound track audio node like gain...
  117625. * @param soundTrackAudioNode the sound track audio node to connect to
  117626. */
  117627. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  117628. /**
  117629. * Transform this sound into a directional source
  117630. * @param coneInnerAngle Size of the inner cone in degree
  117631. * @param coneOuterAngle Size of the outer cone in degree
  117632. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  117633. */
  117634. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  117635. /**
  117636. * Gets or sets the inner angle for the directional cone.
  117637. */
  117638. get directionalConeInnerAngle(): number;
  117639. /**
  117640. * Gets or sets the inner angle for the directional cone.
  117641. */
  117642. set directionalConeInnerAngle(value: number);
  117643. /**
  117644. * Gets or sets the outer angle for the directional cone.
  117645. */
  117646. get directionalConeOuterAngle(): number;
  117647. /**
  117648. * Gets or sets the outer angle for the directional cone.
  117649. */
  117650. set directionalConeOuterAngle(value: number);
  117651. /**
  117652. * Sets the position of the emitter if spatial sound is enabled
  117653. * @param newPosition Defines the new posisiton
  117654. */
  117655. setPosition(newPosition: Vector3): void;
  117656. /**
  117657. * Sets the local direction of the emitter if spatial sound is enabled
  117658. * @param newLocalDirection Defines the new local direction
  117659. */
  117660. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  117661. private _updateDirection;
  117662. /** @hidden */
  117663. updateDistanceFromListener(): void;
  117664. /**
  117665. * Sets a new custom attenuation function for the sound.
  117666. * @param callback Defines the function used for the attenuation
  117667. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  117668. */
  117669. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  117670. /**
  117671. * Play the sound
  117672. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  117673. * @param offset (optional) Start the sound at a specific time in seconds
  117674. * @param length (optional) Sound duration (in seconds)
  117675. */
  117676. play(time?: number, offset?: number, length?: number): void;
  117677. private _onended;
  117678. /**
  117679. * Stop the sound
  117680. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  117681. */
  117682. stop(time?: number): void;
  117683. /**
  117684. * Put the sound in pause
  117685. */
  117686. pause(): void;
  117687. /**
  117688. * Sets a dedicated volume for this sounds
  117689. * @param newVolume Define the new volume of the sound
  117690. * @param time Define time for gradual change to new volume
  117691. */
  117692. setVolume(newVolume: number, time?: number): void;
  117693. /**
  117694. * Set the sound play back rate
  117695. * @param newPlaybackRate Define the playback rate the sound should be played at
  117696. */
  117697. setPlaybackRate(newPlaybackRate: number): void;
  117698. /**
  117699. * Gets the volume of the sound.
  117700. * @returns the volume of the sound
  117701. */
  117702. getVolume(): number;
  117703. /**
  117704. * Attach the sound to a dedicated mesh
  117705. * @param transformNode The transform node to connect the sound with
  117706. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  117707. */
  117708. attachToMesh(transformNode: TransformNode): void;
  117709. /**
  117710. * Detach the sound from the previously attached mesh
  117711. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  117712. */
  117713. detachFromMesh(): void;
  117714. private _onRegisterAfterWorldMatrixUpdate;
  117715. /**
  117716. * Clone the current sound in the scene.
  117717. * @returns the new sound clone
  117718. */
  117719. clone(): Nullable<Sound>;
  117720. /**
  117721. * Gets the current underlying audio buffer containing the data
  117722. * @returns the audio buffer
  117723. */
  117724. getAudioBuffer(): Nullable<AudioBuffer>;
  117725. /**
  117726. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  117727. * @returns the source node
  117728. */
  117729. getSoundSource(): Nullable<AudioBufferSourceNode>;
  117730. /**
  117731. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  117732. * @returns the gain node
  117733. */
  117734. getSoundGain(): Nullable<GainNode>;
  117735. /**
  117736. * Serializes the Sound in a JSON representation
  117737. * @returns the JSON representation of the sound
  117738. */
  117739. serialize(): any;
  117740. /**
  117741. * Parse a JSON representation of a sound to innstantiate in a given scene
  117742. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  117743. * @param scene Define the scene the new parsed sound should be created in
  117744. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  117745. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  117746. * @returns the newly parsed sound
  117747. */
  117748. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  117749. }
  117750. }
  117751. declare module BABYLON {
  117752. /**
  117753. * This defines an action helpful to play a defined sound on a triggered action.
  117754. */
  117755. export class PlaySoundAction extends Action {
  117756. private _sound;
  117757. /**
  117758. * Instantiate the action
  117759. * @param triggerOptions defines the trigger options
  117760. * @param sound defines the sound to play
  117761. * @param condition defines the trigger related conditions
  117762. */
  117763. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  117764. /** @hidden */
  117765. _prepare(): void;
  117766. /**
  117767. * Execute the action and play the sound.
  117768. */
  117769. execute(): void;
  117770. /**
  117771. * Serializes the actions and its related information.
  117772. * @param parent defines the object to serialize in
  117773. * @returns the serialized object
  117774. */
  117775. serialize(parent: any): any;
  117776. }
  117777. /**
  117778. * This defines an action helpful to stop a defined sound on a triggered action.
  117779. */
  117780. export class StopSoundAction extends Action {
  117781. private _sound;
  117782. /**
  117783. * Instantiate the action
  117784. * @param triggerOptions defines the trigger options
  117785. * @param sound defines the sound to stop
  117786. * @param condition defines the trigger related conditions
  117787. */
  117788. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  117789. /** @hidden */
  117790. _prepare(): void;
  117791. /**
  117792. * Execute the action and stop the sound.
  117793. */
  117794. execute(): void;
  117795. /**
  117796. * Serializes the actions and its related information.
  117797. * @param parent defines the object to serialize in
  117798. * @returns the serialized object
  117799. */
  117800. serialize(parent: any): any;
  117801. }
  117802. }
  117803. declare module BABYLON {
  117804. /**
  117805. * This defines an action responsible to change the value of a property
  117806. * by interpolating between its current value and the newly set one once triggered.
  117807. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  117808. */
  117809. export class InterpolateValueAction extends Action {
  117810. /**
  117811. * Defines the path of the property where the value should be interpolated
  117812. */
  117813. propertyPath: string;
  117814. /**
  117815. * Defines the target value at the end of the interpolation.
  117816. */
  117817. value: any;
  117818. /**
  117819. * Defines the time it will take for the property to interpolate to the value.
  117820. */
  117821. duration: number;
  117822. /**
  117823. * Defines if the other scene animations should be stopped when the action has been triggered
  117824. */
  117825. stopOtherAnimations?: boolean;
  117826. /**
  117827. * Defines a callback raised once the interpolation animation has been done.
  117828. */
  117829. onInterpolationDone?: () => void;
  117830. /**
  117831. * Observable triggered once the interpolation animation has been done.
  117832. */
  117833. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  117834. private _target;
  117835. private _effectiveTarget;
  117836. private _property;
  117837. /**
  117838. * Instantiate the action
  117839. * @param triggerOptions defines the trigger options
  117840. * @param target defines the object containing the value to interpolate
  117841. * @param propertyPath defines the path to the property in the target object
  117842. * @param value defines the target value at the end of the interpolation
  117843. * @param duration deines the time it will take for the property to interpolate to the value.
  117844. * @param condition defines the trigger related conditions
  117845. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  117846. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  117847. */
  117848. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  117849. /** @hidden */
  117850. _prepare(): void;
  117851. /**
  117852. * Execute the action starts the value interpolation.
  117853. */
  117854. execute(): void;
  117855. /**
  117856. * Serializes the actions and its related information.
  117857. * @param parent defines the object to serialize in
  117858. * @returns the serialized object
  117859. */
  117860. serialize(parent: any): any;
  117861. }
  117862. }
  117863. declare module BABYLON {
  117864. /**
  117865. * Options allowed during the creation of a sound track.
  117866. */
  117867. export interface ISoundTrackOptions {
  117868. /**
  117869. * The volume the sound track should take during creation
  117870. */
  117871. volume?: number;
  117872. /**
  117873. * Define if the sound track is the main sound track of the scene
  117874. */
  117875. mainTrack?: boolean;
  117876. }
  117877. /**
  117878. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  117879. * It will be also used in a future release to apply effects on a specific track.
  117880. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  117881. */
  117882. export class SoundTrack {
  117883. /**
  117884. * The unique identifier of the sound track in the scene.
  117885. */
  117886. id: number;
  117887. /**
  117888. * The list of sounds included in the sound track.
  117889. */
  117890. soundCollection: Array<Sound>;
  117891. private _outputAudioNode;
  117892. private _scene;
  117893. private _connectedAnalyser;
  117894. private _options;
  117895. private _isInitialized;
  117896. /**
  117897. * Creates a new sound track.
  117898. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  117899. * @param scene Define the scene the sound track belongs to
  117900. * @param options
  117901. */
  117902. constructor(scene: Scene, options?: ISoundTrackOptions);
  117903. private _initializeSoundTrackAudioGraph;
  117904. /**
  117905. * Release the sound track and its associated resources
  117906. */
  117907. dispose(): void;
  117908. /**
  117909. * Adds a sound to this sound track
  117910. * @param sound define the cound to add
  117911. * @ignoreNaming
  117912. */
  117913. AddSound(sound: Sound): void;
  117914. /**
  117915. * Removes a sound to this sound track
  117916. * @param sound define the cound to remove
  117917. * @ignoreNaming
  117918. */
  117919. RemoveSound(sound: Sound): void;
  117920. /**
  117921. * Set a global volume for the full sound track.
  117922. * @param newVolume Define the new volume of the sound track
  117923. */
  117924. setVolume(newVolume: number): void;
  117925. /**
  117926. * Switch the panning model to HRTF:
  117927. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  117928. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  117929. */
  117930. switchPanningModelToHRTF(): void;
  117931. /**
  117932. * Switch the panning model to Equal Power:
  117933. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  117934. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  117935. */
  117936. switchPanningModelToEqualPower(): void;
  117937. /**
  117938. * Connect the sound track to an audio analyser allowing some amazing
  117939. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  117940. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  117941. * @param analyser The analyser to connect to the engine
  117942. */
  117943. connectToAnalyser(analyser: Analyser): void;
  117944. }
  117945. }
  117946. declare module BABYLON {
  117947. interface AbstractScene {
  117948. /**
  117949. * The list of sounds used in the scene.
  117950. */
  117951. sounds: Nullable<Array<Sound>>;
  117952. }
  117953. interface Scene {
  117954. /**
  117955. * @hidden
  117956. * Backing field
  117957. */
  117958. _mainSoundTrack: SoundTrack;
  117959. /**
  117960. * The main sound track played by the scene.
  117961. * It cotains your primary collection of sounds.
  117962. */
  117963. mainSoundTrack: SoundTrack;
  117964. /**
  117965. * The list of sound tracks added to the scene
  117966. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  117967. */
  117968. soundTracks: Nullable<Array<SoundTrack>>;
  117969. /**
  117970. * Gets a sound using a given name
  117971. * @param name defines the name to search for
  117972. * @return the found sound or null if not found at all.
  117973. */
  117974. getSoundByName(name: string): Nullable<Sound>;
  117975. /**
  117976. * Gets or sets if audio support is enabled
  117977. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  117978. */
  117979. audioEnabled: boolean;
  117980. /**
  117981. * Gets or sets if audio will be output to headphones
  117982. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  117983. */
  117984. headphone: boolean;
  117985. /**
  117986. * Gets or sets custom audio listener position provider
  117987. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  117988. */
  117989. audioListenerPositionProvider: Nullable<() => Vector3>;
  117990. /**
  117991. * Gets or sets a refresh rate when using 3D audio positioning
  117992. */
  117993. audioPositioningRefreshRate: number;
  117994. }
  117995. /**
  117996. * Defines the sound scene component responsible to manage any sounds
  117997. * in a given scene.
  117998. */
  117999. export class AudioSceneComponent implements ISceneSerializableComponent {
  118000. /**
  118001. * The component name helpfull to identify the component in the list of scene components.
  118002. */
  118003. readonly name: string;
  118004. /**
  118005. * The scene the component belongs to.
  118006. */
  118007. scene: Scene;
  118008. private _audioEnabled;
  118009. /**
  118010. * Gets whether audio is enabled or not.
  118011. * Please use related enable/disable method to switch state.
  118012. */
  118013. get audioEnabled(): boolean;
  118014. private _headphone;
  118015. /**
  118016. * Gets whether audio is outputing to headphone or not.
  118017. * Please use the according Switch methods to change output.
  118018. */
  118019. get headphone(): boolean;
  118020. /**
  118021. * Gets or sets a refresh rate when using 3D audio positioning
  118022. */
  118023. audioPositioningRefreshRate: number;
  118024. private _audioListenerPositionProvider;
  118025. /**
  118026. * Gets the current audio listener position provider
  118027. */
  118028. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  118029. /**
  118030. * Sets a custom listener position for all sounds in the scene
  118031. * By default, this is the position of the first active camera
  118032. */
  118033. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  118034. /**
  118035. * Creates a new instance of the component for the given scene
  118036. * @param scene Defines the scene to register the component in
  118037. */
  118038. constructor(scene: Scene);
  118039. /**
  118040. * Registers the component in a given scene
  118041. */
  118042. register(): void;
  118043. /**
  118044. * Rebuilds the elements related to this component in case of
  118045. * context lost for instance.
  118046. */
  118047. rebuild(): void;
  118048. /**
  118049. * Serializes the component data to the specified json object
  118050. * @param serializationObject The object to serialize to
  118051. */
  118052. serialize(serializationObject: any): void;
  118053. /**
  118054. * Adds all the elements from the container to the scene
  118055. * @param container the container holding the elements
  118056. */
  118057. addFromContainer(container: AbstractScene): void;
  118058. /**
  118059. * Removes all the elements in the container from the scene
  118060. * @param container contains the elements to remove
  118061. * @param dispose if the removed element should be disposed (default: false)
  118062. */
  118063. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  118064. /**
  118065. * Disposes the component and the associated ressources.
  118066. */
  118067. dispose(): void;
  118068. /**
  118069. * Disables audio in the associated scene.
  118070. */
  118071. disableAudio(): void;
  118072. /**
  118073. * Enables audio in the associated scene.
  118074. */
  118075. enableAudio(): void;
  118076. /**
  118077. * Switch audio to headphone output.
  118078. */
  118079. switchAudioModeForHeadphones(): void;
  118080. /**
  118081. * Switch audio to normal speakers.
  118082. */
  118083. switchAudioModeForNormalSpeakers(): void;
  118084. private _cachedCameraDirection;
  118085. private _cachedCameraPosition;
  118086. private _lastCheck;
  118087. private _afterRender;
  118088. }
  118089. }
  118090. declare module BABYLON {
  118091. /**
  118092. * Wraps one or more Sound objects and selects one with random weight for playback.
  118093. */
  118094. export class WeightedSound {
  118095. /** When true a Sound will be selected and played when the current playing Sound completes. */
  118096. loop: boolean;
  118097. private _coneInnerAngle;
  118098. private _coneOuterAngle;
  118099. private _volume;
  118100. /** A Sound is currently playing. */
  118101. isPlaying: boolean;
  118102. /** A Sound is currently paused. */
  118103. isPaused: boolean;
  118104. private _sounds;
  118105. private _weights;
  118106. private _currentIndex?;
  118107. /**
  118108. * Creates a new WeightedSound from the list of sounds given.
  118109. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  118110. * @param sounds Array of Sounds that will be selected from.
  118111. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  118112. */
  118113. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  118114. /**
  118115. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  118116. */
  118117. get directionalConeInnerAngle(): number;
  118118. /**
  118119. * The size of cone in degress for a directional sound in which there will be no attenuation.
  118120. */
  118121. set directionalConeInnerAngle(value: number);
  118122. /**
  118123. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  118124. * Listener angles between innerAngle and outerAngle will falloff linearly.
  118125. */
  118126. get directionalConeOuterAngle(): number;
  118127. /**
  118128. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  118129. * Listener angles between innerAngle and outerAngle will falloff linearly.
  118130. */
  118131. set directionalConeOuterAngle(value: number);
  118132. /**
  118133. * Playback volume.
  118134. */
  118135. get volume(): number;
  118136. /**
  118137. * Playback volume.
  118138. */
  118139. set volume(value: number);
  118140. private _onended;
  118141. /**
  118142. * Suspend playback
  118143. */
  118144. pause(): void;
  118145. /**
  118146. * Stop playback
  118147. */
  118148. stop(): void;
  118149. /**
  118150. * Start playback.
  118151. * @param startOffset Position the clip head at a specific time in seconds.
  118152. */
  118153. play(startOffset?: number): void;
  118154. }
  118155. }
  118156. declare module BABYLON {
  118157. /**
  118158. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  118159. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  118160. */
  118161. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  118162. /**
  118163. * Gets the name of the behavior.
  118164. */
  118165. get name(): string;
  118166. /**
  118167. * The easing function used by animations
  118168. */
  118169. static EasingFunction: BackEase;
  118170. /**
  118171. * The easing mode used by animations
  118172. */
  118173. static EasingMode: number;
  118174. /**
  118175. * The duration of the animation, in milliseconds
  118176. */
  118177. transitionDuration: number;
  118178. /**
  118179. * Length of the distance animated by the transition when lower radius is reached
  118180. */
  118181. lowerRadiusTransitionRange: number;
  118182. /**
  118183. * Length of the distance animated by the transition when upper radius is reached
  118184. */
  118185. upperRadiusTransitionRange: number;
  118186. private _autoTransitionRange;
  118187. /**
  118188. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  118189. */
  118190. get autoTransitionRange(): boolean;
  118191. /**
  118192. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  118193. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  118194. */
  118195. set autoTransitionRange(value: boolean);
  118196. private _attachedCamera;
  118197. private _onAfterCheckInputsObserver;
  118198. private _onMeshTargetChangedObserver;
  118199. /**
  118200. * Initializes the behavior.
  118201. */
  118202. init(): void;
  118203. /**
  118204. * Attaches the behavior to its arc rotate camera.
  118205. * @param camera Defines the camera to attach the behavior to
  118206. */
  118207. attach(camera: ArcRotateCamera): void;
  118208. /**
  118209. * Detaches the behavior from its current arc rotate camera.
  118210. */
  118211. detach(): void;
  118212. private _radiusIsAnimating;
  118213. private _radiusBounceTransition;
  118214. private _animatables;
  118215. private _cachedWheelPrecision;
  118216. /**
  118217. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  118218. * @param radiusLimit The limit to check against.
  118219. * @return Bool to indicate if at limit.
  118220. */
  118221. private _isRadiusAtLimit;
  118222. /**
  118223. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  118224. * @param radiusDelta The delta by which to animate to. Can be negative.
  118225. */
  118226. private _applyBoundRadiusAnimation;
  118227. /**
  118228. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  118229. */
  118230. protected _clearAnimationLocks(): void;
  118231. /**
  118232. * Stops and removes all animations that have been applied to the camera
  118233. */
  118234. stopAllAnimations(): void;
  118235. }
  118236. }
  118237. declare module BABYLON {
  118238. /**
  118239. * 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.
  118240. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  118241. */
  118242. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  118243. /**
  118244. * Gets the name of the behavior.
  118245. */
  118246. get name(): string;
  118247. private _mode;
  118248. private _radiusScale;
  118249. private _positionScale;
  118250. private _defaultElevation;
  118251. private _elevationReturnTime;
  118252. private _elevationReturnWaitTime;
  118253. private _zoomStopsAnimation;
  118254. private _framingTime;
  118255. /**
  118256. * The easing function used by animations
  118257. */
  118258. static EasingFunction: ExponentialEase;
  118259. /**
  118260. * The easing mode used by animations
  118261. */
  118262. static EasingMode: number;
  118263. /**
  118264. * Sets the current mode used by the behavior
  118265. */
  118266. set mode(mode: number);
  118267. /**
  118268. * Gets current mode used by the behavior.
  118269. */
  118270. get mode(): number;
  118271. /**
  118272. * Sets the scale applied to the radius (1 by default)
  118273. */
  118274. set radiusScale(radius: number);
  118275. /**
  118276. * Gets the scale applied to the radius
  118277. */
  118278. get radiusScale(): number;
  118279. /**
  118280. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  118281. */
  118282. set positionScale(scale: number);
  118283. /**
  118284. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  118285. */
  118286. get positionScale(): number;
  118287. /**
  118288. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  118289. * behaviour is triggered, in radians.
  118290. */
  118291. set defaultElevation(elevation: number);
  118292. /**
  118293. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  118294. * behaviour is triggered, in radians.
  118295. */
  118296. get defaultElevation(): number;
  118297. /**
  118298. * Sets the time (in milliseconds) taken to return to the default beta position.
  118299. * Negative value indicates camera should not return to default.
  118300. */
  118301. set elevationReturnTime(speed: number);
  118302. /**
  118303. * Gets the time (in milliseconds) taken to return to the default beta position.
  118304. * Negative value indicates camera should not return to default.
  118305. */
  118306. get elevationReturnTime(): number;
  118307. /**
  118308. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  118309. */
  118310. set elevationReturnWaitTime(time: number);
  118311. /**
  118312. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  118313. */
  118314. get elevationReturnWaitTime(): number;
  118315. /**
  118316. * Sets the flag that indicates if user zooming should stop animation.
  118317. */
  118318. set zoomStopsAnimation(flag: boolean);
  118319. /**
  118320. * Gets the flag that indicates if user zooming should stop animation.
  118321. */
  118322. get zoomStopsAnimation(): boolean;
  118323. /**
  118324. * Sets the transition time when framing the mesh, in milliseconds
  118325. */
  118326. set framingTime(time: number);
  118327. /**
  118328. * Gets the transition time when framing the mesh, in milliseconds
  118329. */
  118330. get framingTime(): number;
  118331. /**
  118332. * Define if the behavior should automatically change the configured
  118333. * camera limits and sensibilities.
  118334. */
  118335. autoCorrectCameraLimitsAndSensibility: boolean;
  118336. private _onPrePointerObservableObserver;
  118337. private _onAfterCheckInputsObserver;
  118338. private _onMeshTargetChangedObserver;
  118339. private _attachedCamera;
  118340. private _isPointerDown;
  118341. private _lastInteractionTime;
  118342. /**
  118343. * Initializes the behavior.
  118344. */
  118345. init(): void;
  118346. /**
  118347. * Attaches the behavior to its arc rotate camera.
  118348. * @param camera Defines the camera to attach the behavior to
  118349. */
  118350. attach(camera: ArcRotateCamera): void;
  118351. /**
  118352. * Detaches the behavior from its current arc rotate camera.
  118353. */
  118354. detach(): void;
  118355. private _animatables;
  118356. private _betaIsAnimating;
  118357. private _betaTransition;
  118358. private _radiusTransition;
  118359. private _vectorTransition;
  118360. /**
  118361. * Targets the given mesh and updates zoom level accordingly.
  118362. * @param mesh The mesh to target.
  118363. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  118364. * @param onAnimationEnd Callback triggered at the end of the framing animation
  118365. */
  118366. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  118367. /**
  118368. * Targets the given mesh with its children and updates zoom level accordingly.
  118369. * @param mesh The mesh to target.
  118370. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  118371. * @param onAnimationEnd Callback triggered at the end of the framing animation
  118372. */
  118373. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  118374. /**
  118375. * Targets the given meshes with their children and updates zoom level accordingly.
  118376. * @param meshes The mesh to target.
  118377. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  118378. * @param onAnimationEnd Callback triggered at the end of the framing animation
  118379. */
  118380. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  118381. /**
  118382. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  118383. * @param minimumWorld Determines the smaller position of the bounding box extend
  118384. * @param maximumWorld Determines the bigger position of the bounding box extend
  118385. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  118386. * @param onAnimationEnd Callback triggered at the end of the framing animation
  118387. */
  118388. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  118389. /**
  118390. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  118391. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  118392. * frustum width.
  118393. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  118394. * to fully enclose the mesh in the viewing frustum.
  118395. */
  118396. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  118397. /**
  118398. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  118399. * is automatically returned to its default position (expected to be above ground plane).
  118400. */
  118401. private _maintainCameraAboveGround;
  118402. /**
  118403. * Returns the frustum slope based on the canvas ratio and camera FOV
  118404. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  118405. */
  118406. private _getFrustumSlope;
  118407. /**
  118408. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  118409. */
  118410. private _clearAnimationLocks;
  118411. /**
  118412. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  118413. */
  118414. private _applyUserInteraction;
  118415. /**
  118416. * Stops and removes all animations that have been applied to the camera
  118417. */
  118418. stopAllAnimations(): void;
  118419. /**
  118420. * Gets a value indicating if the user is moving the camera
  118421. */
  118422. get isUserIsMoving(): boolean;
  118423. /**
  118424. * The camera can move all the way towards the mesh.
  118425. */
  118426. static IgnoreBoundsSizeMode: number;
  118427. /**
  118428. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  118429. */
  118430. static FitFrustumSidesMode: number;
  118431. }
  118432. }
  118433. declare module BABYLON {
  118434. /**
  118435. * Base class for Camera Pointer Inputs.
  118436. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  118437. * for example usage.
  118438. */
  118439. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  118440. /**
  118441. * Defines the camera the input is attached to.
  118442. */
  118443. abstract camera: Camera;
  118444. /**
  118445. * Whether keyboard modifier keys are pressed at time of last mouse event.
  118446. */
  118447. protected _altKey: boolean;
  118448. protected _ctrlKey: boolean;
  118449. protected _metaKey: boolean;
  118450. protected _shiftKey: boolean;
  118451. /**
  118452. * Which mouse buttons were pressed at time of last mouse event.
  118453. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  118454. */
  118455. protected _buttonsPressed: number;
  118456. /**
  118457. * Defines the buttons associated with the input to handle camera move.
  118458. */
  118459. buttons: number[];
  118460. /**
  118461. * Attach the input controls to a specific dom element to get the input from.
  118462. * @param element Defines the element the controls should be listened from
  118463. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  118464. */
  118465. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  118466. /**
  118467. * Detach the current controls from the specified dom element.
  118468. * @param element Defines the element to stop listening the inputs from
  118469. */
  118470. detachControl(element: Nullable<HTMLElement>): void;
  118471. /**
  118472. * Gets the class name of the current input.
  118473. * @returns the class name
  118474. */
  118475. getClassName(): string;
  118476. /**
  118477. * Get the friendly name associated with the input class.
  118478. * @returns the input friendly name
  118479. */
  118480. getSimpleName(): string;
  118481. /**
  118482. * Called on pointer POINTERDOUBLETAP event.
  118483. * Override this method to provide functionality on POINTERDOUBLETAP event.
  118484. */
  118485. protected onDoubleTap(type: string): void;
  118486. /**
  118487. * Called on pointer POINTERMOVE event if only a single touch is active.
  118488. * Override this method to provide functionality.
  118489. */
  118490. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  118491. /**
  118492. * Called on pointer POINTERMOVE event if multiple touches are active.
  118493. * Override this method to provide functionality.
  118494. */
  118495. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  118496. /**
  118497. * Called on JS contextmenu event.
  118498. * Override this method to provide functionality.
  118499. */
  118500. protected onContextMenu(evt: PointerEvent): void;
  118501. /**
  118502. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  118503. * press.
  118504. * Override this method to provide functionality.
  118505. */
  118506. protected onButtonDown(evt: PointerEvent): void;
  118507. /**
  118508. * Called each time a new POINTERUP event occurs. Ie, for each button
  118509. * release.
  118510. * Override this method to provide functionality.
  118511. */
  118512. protected onButtonUp(evt: PointerEvent): void;
  118513. /**
  118514. * Called when window becomes inactive.
  118515. * Override this method to provide functionality.
  118516. */
  118517. protected onLostFocus(): void;
  118518. private _pointerInput;
  118519. private _observer;
  118520. private _onLostFocus;
  118521. private pointA;
  118522. private pointB;
  118523. }
  118524. }
  118525. declare module BABYLON {
  118526. /**
  118527. * Manage the pointers inputs to control an arc rotate camera.
  118528. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  118529. */
  118530. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  118531. /**
  118532. * Defines the camera the input is attached to.
  118533. */
  118534. camera: ArcRotateCamera;
  118535. /**
  118536. * Gets the class name of the current input.
  118537. * @returns the class name
  118538. */
  118539. getClassName(): string;
  118540. /**
  118541. * Defines the buttons associated with the input to handle camera move.
  118542. */
  118543. buttons: number[];
  118544. /**
  118545. * Defines the pointer angular sensibility along the X axis or how fast is
  118546. * the camera rotating.
  118547. */
  118548. angularSensibilityX: number;
  118549. /**
  118550. * Defines the pointer angular sensibility along the Y axis or how fast is
  118551. * the camera rotating.
  118552. */
  118553. angularSensibilityY: number;
  118554. /**
  118555. * Defines the pointer pinch precision or how fast is the camera zooming.
  118556. */
  118557. pinchPrecision: number;
  118558. /**
  118559. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  118560. * from 0.
  118561. * It defines the percentage of current camera.radius to use as delta when
  118562. * pinch zoom is used.
  118563. */
  118564. pinchDeltaPercentage: number;
  118565. /**
  118566. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  118567. * that any object in the plane at the camera's target point will scale
  118568. * perfectly with finger motion.
  118569. * Overrides pinchDeltaPercentage and pinchPrecision.
  118570. */
  118571. useNaturalPinchZoom: boolean;
  118572. /**
  118573. * Defines the pointer panning sensibility or how fast is the camera moving.
  118574. */
  118575. panningSensibility: number;
  118576. /**
  118577. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  118578. */
  118579. multiTouchPanning: boolean;
  118580. /**
  118581. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  118582. * zoom (pinch) through multitouch.
  118583. */
  118584. multiTouchPanAndZoom: boolean;
  118585. /**
  118586. * Revers pinch action direction.
  118587. */
  118588. pinchInwards: boolean;
  118589. private _isPanClick;
  118590. private _twoFingerActivityCount;
  118591. private _isPinching;
  118592. /**
  118593. * Called on pointer POINTERMOVE event if only a single touch is active.
  118594. */
  118595. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  118596. /**
  118597. * Called on pointer POINTERDOUBLETAP event.
  118598. */
  118599. protected onDoubleTap(type: string): void;
  118600. /**
  118601. * Called on pointer POINTERMOVE event if multiple touches are active.
  118602. */
  118603. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  118604. /**
  118605. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  118606. * press.
  118607. */
  118608. protected onButtonDown(evt: PointerEvent): void;
  118609. /**
  118610. * Called each time a new POINTERUP event occurs. Ie, for each button
  118611. * release.
  118612. */
  118613. protected onButtonUp(evt: PointerEvent): void;
  118614. /**
  118615. * Called when window becomes inactive.
  118616. */
  118617. protected onLostFocus(): void;
  118618. }
  118619. }
  118620. declare module BABYLON {
  118621. /**
  118622. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  118623. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  118624. */
  118625. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  118626. /**
  118627. * Defines the camera the input is attached to.
  118628. */
  118629. camera: ArcRotateCamera;
  118630. /**
  118631. * Defines the list of key codes associated with the up action (increase alpha)
  118632. */
  118633. keysUp: number[];
  118634. /**
  118635. * Defines the list of key codes associated with the down action (decrease alpha)
  118636. */
  118637. keysDown: number[];
  118638. /**
  118639. * Defines the list of key codes associated with the left action (increase beta)
  118640. */
  118641. keysLeft: number[];
  118642. /**
  118643. * Defines the list of key codes associated with the right action (decrease beta)
  118644. */
  118645. keysRight: number[];
  118646. /**
  118647. * Defines the list of key codes associated with the reset action.
  118648. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  118649. */
  118650. keysReset: number[];
  118651. /**
  118652. * Defines the panning sensibility of the inputs.
  118653. * (How fast is the camera panning)
  118654. */
  118655. panningSensibility: number;
  118656. /**
  118657. * Defines the zooming sensibility of the inputs.
  118658. * (How fast is the camera zooming)
  118659. */
  118660. zoomingSensibility: number;
  118661. /**
  118662. * Defines whether maintaining the alt key down switch the movement mode from
  118663. * orientation to zoom.
  118664. */
  118665. useAltToZoom: boolean;
  118666. /**
  118667. * Rotation speed of the camera
  118668. */
  118669. angularSpeed: number;
  118670. private _keys;
  118671. private _ctrlPressed;
  118672. private _altPressed;
  118673. private _onCanvasBlurObserver;
  118674. private _onKeyboardObserver;
  118675. private _engine;
  118676. private _scene;
  118677. /**
  118678. * Attach the input controls to a specific dom element to get the input from.
  118679. * @param element Defines the element the controls should be listened from
  118680. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  118681. */
  118682. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  118683. /**
  118684. * Detach the current controls from the specified dom element.
  118685. * @param element Defines the element to stop listening the inputs from
  118686. */
  118687. detachControl(element: Nullable<HTMLElement>): void;
  118688. /**
  118689. * Update the current camera state depending on the inputs that have been used this frame.
  118690. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  118691. */
  118692. checkInputs(): void;
  118693. /**
  118694. * Gets the class name of the current intput.
  118695. * @returns the class name
  118696. */
  118697. getClassName(): string;
  118698. /**
  118699. * Get the friendly name associated with the input class.
  118700. * @returns the input friendly name
  118701. */
  118702. getSimpleName(): string;
  118703. }
  118704. }
  118705. declare module BABYLON {
  118706. /**
  118707. * Manage the mouse wheel inputs to control an arc rotate camera.
  118708. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  118709. */
  118710. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  118711. /**
  118712. * Defines the camera the input is attached to.
  118713. */
  118714. camera: ArcRotateCamera;
  118715. /**
  118716. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  118717. */
  118718. wheelPrecision: number;
  118719. /**
  118720. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  118721. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  118722. */
  118723. wheelDeltaPercentage: number;
  118724. private _wheel;
  118725. private _observer;
  118726. private computeDeltaFromMouseWheelLegacyEvent;
  118727. /**
  118728. * Attach the input controls to a specific dom element to get the input from.
  118729. * @param element Defines the element the controls should be listened from
  118730. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  118731. */
  118732. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  118733. /**
  118734. * Detach the current controls from the specified dom element.
  118735. * @param element Defines the element to stop listening the inputs from
  118736. */
  118737. detachControl(element: Nullable<HTMLElement>): void;
  118738. /**
  118739. * Gets the class name of the current intput.
  118740. * @returns the class name
  118741. */
  118742. getClassName(): string;
  118743. /**
  118744. * Get the friendly name associated with the input class.
  118745. * @returns the input friendly name
  118746. */
  118747. getSimpleName(): string;
  118748. }
  118749. }
  118750. declare module BABYLON {
  118751. /**
  118752. * Default Inputs manager for the ArcRotateCamera.
  118753. * It groups all the default supported inputs for ease of use.
  118754. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  118755. */
  118756. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  118757. /**
  118758. * Instantiates a new ArcRotateCameraInputsManager.
  118759. * @param camera Defines the camera the inputs belong to
  118760. */
  118761. constructor(camera: ArcRotateCamera);
  118762. /**
  118763. * Add mouse wheel input support to the input manager.
  118764. * @returns the current input manager
  118765. */
  118766. addMouseWheel(): ArcRotateCameraInputsManager;
  118767. /**
  118768. * Add pointers input support to the input manager.
  118769. * @returns the current input manager
  118770. */
  118771. addPointers(): ArcRotateCameraInputsManager;
  118772. /**
  118773. * Add keyboard input support to the input manager.
  118774. * @returns the current input manager
  118775. */
  118776. addKeyboard(): ArcRotateCameraInputsManager;
  118777. }
  118778. }
  118779. declare module BABYLON {
  118780. /**
  118781. * This represents an orbital type of camera.
  118782. *
  118783. * 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.
  118784. * 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.
  118785. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  118786. */
  118787. export class ArcRotateCamera extends TargetCamera {
  118788. /**
  118789. * Defines the rotation angle of the camera along the longitudinal axis.
  118790. */
  118791. alpha: number;
  118792. /**
  118793. * Defines the rotation angle of the camera along the latitudinal axis.
  118794. */
  118795. beta: number;
  118796. /**
  118797. * Defines the radius of the camera from it s target point.
  118798. */
  118799. radius: number;
  118800. protected _target: Vector3;
  118801. protected _targetHost: Nullable<AbstractMesh>;
  118802. /**
  118803. * Defines the target point of the camera.
  118804. * The camera looks towards it form the radius distance.
  118805. */
  118806. get target(): Vector3;
  118807. set target(value: Vector3);
  118808. /**
  118809. * Define the current local position of the camera in the scene
  118810. */
  118811. get position(): Vector3;
  118812. set position(newPosition: Vector3);
  118813. protected _upVector: Vector3;
  118814. protected _upToYMatrix: Matrix;
  118815. protected _YToUpMatrix: Matrix;
  118816. /**
  118817. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  118818. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  118819. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  118820. */
  118821. set upVector(vec: Vector3);
  118822. get upVector(): Vector3;
  118823. /**
  118824. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  118825. */
  118826. setMatUp(): void;
  118827. /**
  118828. * Current inertia value on the longitudinal axis.
  118829. * The bigger this number the longer it will take for the camera to stop.
  118830. */
  118831. inertialAlphaOffset: number;
  118832. /**
  118833. * Current inertia value on the latitudinal axis.
  118834. * The bigger this number the longer it will take for the camera to stop.
  118835. */
  118836. inertialBetaOffset: number;
  118837. /**
  118838. * Current inertia value on the radius axis.
  118839. * The bigger this number the longer it will take for the camera to stop.
  118840. */
  118841. inertialRadiusOffset: number;
  118842. /**
  118843. * Minimum allowed angle on the longitudinal axis.
  118844. * This can help limiting how the Camera is able to move in the scene.
  118845. */
  118846. lowerAlphaLimit: Nullable<number>;
  118847. /**
  118848. * Maximum allowed angle on the longitudinal axis.
  118849. * This can help limiting how the Camera is able to move in the scene.
  118850. */
  118851. upperAlphaLimit: Nullable<number>;
  118852. /**
  118853. * Minimum allowed angle on the latitudinal axis.
  118854. * This can help limiting how the Camera is able to move in the scene.
  118855. */
  118856. lowerBetaLimit: number;
  118857. /**
  118858. * Maximum allowed angle on the latitudinal axis.
  118859. * This can help limiting how the Camera is able to move in the scene.
  118860. */
  118861. upperBetaLimit: number;
  118862. /**
  118863. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  118864. * This can help limiting how the Camera is able to move in the scene.
  118865. */
  118866. lowerRadiusLimit: Nullable<number>;
  118867. /**
  118868. * Maximum allowed distance of the camera to the target (The camera can not get further).
  118869. * This can help limiting how the Camera is able to move in the scene.
  118870. */
  118871. upperRadiusLimit: Nullable<number>;
  118872. /**
  118873. * Defines the current inertia value used during panning of the camera along the X axis.
  118874. */
  118875. inertialPanningX: number;
  118876. /**
  118877. * Defines the current inertia value used during panning of the camera along the Y axis.
  118878. */
  118879. inertialPanningY: number;
  118880. /**
  118881. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  118882. * Basically if your fingers moves away from more than this distance you will be considered
  118883. * in pinch mode.
  118884. */
  118885. pinchToPanMaxDistance: number;
  118886. /**
  118887. * Defines the maximum distance the camera can pan.
  118888. * This could help keeping the cammera always in your scene.
  118889. */
  118890. panningDistanceLimit: Nullable<number>;
  118891. /**
  118892. * Defines the target of the camera before paning.
  118893. */
  118894. panningOriginTarget: Vector3;
  118895. /**
  118896. * Defines the value of the inertia used during panning.
  118897. * 0 would mean stop inertia and one would mean no decelleration at all.
  118898. */
  118899. panningInertia: number;
  118900. /**
  118901. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  118902. */
  118903. get angularSensibilityX(): number;
  118904. set angularSensibilityX(value: number);
  118905. /**
  118906. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  118907. */
  118908. get angularSensibilityY(): number;
  118909. set angularSensibilityY(value: number);
  118910. /**
  118911. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  118912. */
  118913. get pinchPrecision(): number;
  118914. set pinchPrecision(value: number);
  118915. /**
  118916. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  118917. * It will be used instead of pinchDeltaPrecision if different from 0.
  118918. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  118919. */
  118920. get pinchDeltaPercentage(): number;
  118921. set pinchDeltaPercentage(value: number);
  118922. /**
  118923. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  118924. * and pinch delta percentage.
  118925. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  118926. * that any object in the plane at the camera's target point will scale
  118927. * perfectly with finger motion.
  118928. */
  118929. get useNaturalPinchZoom(): boolean;
  118930. set useNaturalPinchZoom(value: boolean);
  118931. /**
  118932. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  118933. */
  118934. get panningSensibility(): number;
  118935. set panningSensibility(value: number);
  118936. /**
  118937. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  118938. */
  118939. get keysUp(): number[];
  118940. set keysUp(value: number[]);
  118941. /**
  118942. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  118943. */
  118944. get keysDown(): number[];
  118945. set keysDown(value: number[]);
  118946. /**
  118947. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  118948. */
  118949. get keysLeft(): number[];
  118950. set keysLeft(value: number[]);
  118951. /**
  118952. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  118953. */
  118954. get keysRight(): number[];
  118955. set keysRight(value: number[]);
  118956. /**
  118957. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  118958. */
  118959. get wheelPrecision(): number;
  118960. set wheelPrecision(value: number);
  118961. /**
  118962. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  118963. * It will be used instead of pinchDeltaPrecision if different from 0.
  118964. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  118965. */
  118966. get wheelDeltaPercentage(): number;
  118967. set wheelDeltaPercentage(value: number);
  118968. /**
  118969. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  118970. */
  118971. zoomOnFactor: number;
  118972. /**
  118973. * Defines a screen offset for the camera position.
  118974. */
  118975. targetScreenOffset: Vector2;
  118976. /**
  118977. * Allows the camera to be completely reversed.
  118978. * If false the camera can not arrive upside down.
  118979. */
  118980. allowUpsideDown: boolean;
  118981. /**
  118982. * Define if double tap/click is used to restore the previously saved state of the camera.
  118983. */
  118984. useInputToRestoreState: boolean;
  118985. /** @hidden */
  118986. _viewMatrix: Matrix;
  118987. /** @hidden */
  118988. _useCtrlForPanning: boolean;
  118989. /** @hidden */
  118990. _panningMouseButton: number;
  118991. /**
  118992. * Defines the input associated to the camera.
  118993. */
  118994. inputs: ArcRotateCameraInputsManager;
  118995. /** @hidden */
  118996. _reset: () => void;
  118997. /**
  118998. * Defines the allowed panning axis.
  118999. */
  119000. panningAxis: Vector3;
  119001. protected _localDirection: Vector3;
  119002. protected _transformedDirection: Vector3;
  119003. private _bouncingBehavior;
  119004. /**
  119005. * Gets the bouncing behavior of the camera if it has been enabled.
  119006. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  119007. */
  119008. get bouncingBehavior(): Nullable<BouncingBehavior>;
  119009. /**
  119010. * Defines if the bouncing behavior of the camera is enabled on the camera.
  119011. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  119012. */
  119013. get useBouncingBehavior(): boolean;
  119014. set useBouncingBehavior(value: boolean);
  119015. private _framingBehavior;
  119016. /**
  119017. * Gets the framing behavior of the camera if it has been enabled.
  119018. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  119019. */
  119020. get framingBehavior(): Nullable<FramingBehavior>;
  119021. /**
  119022. * Defines if the framing behavior of the camera is enabled on the camera.
  119023. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  119024. */
  119025. get useFramingBehavior(): boolean;
  119026. set useFramingBehavior(value: boolean);
  119027. private _autoRotationBehavior;
  119028. /**
  119029. * Gets the auto rotation behavior of the camera if it has been enabled.
  119030. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  119031. */
  119032. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  119033. /**
  119034. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  119035. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  119036. */
  119037. get useAutoRotationBehavior(): boolean;
  119038. set useAutoRotationBehavior(value: boolean);
  119039. /**
  119040. * Observable triggered when the mesh target has been changed on the camera.
  119041. */
  119042. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  119043. /**
  119044. * Event raised when the camera is colliding with a mesh.
  119045. */
  119046. onCollide: (collidedMesh: AbstractMesh) => void;
  119047. /**
  119048. * Defines whether the camera should check collision with the objects oh the scene.
  119049. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  119050. */
  119051. checkCollisions: boolean;
  119052. /**
  119053. * Defines the collision radius of the camera.
  119054. * This simulates a sphere around the camera.
  119055. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  119056. */
  119057. collisionRadius: Vector3;
  119058. protected _collider: Collider;
  119059. protected _previousPosition: Vector3;
  119060. protected _collisionVelocity: Vector3;
  119061. protected _newPosition: Vector3;
  119062. protected _previousAlpha: number;
  119063. protected _previousBeta: number;
  119064. protected _previousRadius: number;
  119065. protected _collisionTriggered: boolean;
  119066. protected _targetBoundingCenter: Nullable<Vector3>;
  119067. private _computationVector;
  119068. /**
  119069. * Instantiates a new ArcRotateCamera in a given scene
  119070. * @param name Defines the name of the camera
  119071. * @param alpha Defines the camera rotation along the logitudinal axis
  119072. * @param beta Defines the camera rotation along the latitudinal axis
  119073. * @param radius Defines the camera distance from its target
  119074. * @param target Defines the camera target
  119075. * @param scene Defines the scene the camera belongs to
  119076. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  119077. */
  119078. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  119079. /** @hidden */
  119080. _initCache(): void;
  119081. /** @hidden */
  119082. _updateCache(ignoreParentClass?: boolean): void;
  119083. protected _getTargetPosition(): Vector3;
  119084. private _storedAlpha;
  119085. private _storedBeta;
  119086. private _storedRadius;
  119087. private _storedTarget;
  119088. private _storedTargetScreenOffset;
  119089. /**
  119090. * Stores the current state of the camera (alpha, beta, radius and target)
  119091. * @returns the camera itself
  119092. */
  119093. storeState(): Camera;
  119094. /**
  119095. * @hidden
  119096. * Restored camera state. You must call storeState() first
  119097. */
  119098. _restoreStateValues(): boolean;
  119099. /** @hidden */
  119100. _isSynchronizedViewMatrix(): boolean;
  119101. /**
  119102. * Attached controls to the current camera.
  119103. * @param element Defines the element the controls should be listened from
  119104. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  119105. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  119106. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  119107. */
  119108. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  119109. /**
  119110. * Detach the current controls from the camera.
  119111. * The camera will stop reacting to inputs.
  119112. * @param element Defines the element to stop listening the inputs from
  119113. */
  119114. detachControl(element: HTMLElement): void;
  119115. /** @hidden */
  119116. _checkInputs(): void;
  119117. protected _checkLimits(): void;
  119118. /**
  119119. * Rebuilds angles (alpha, beta) and radius from the give position and target
  119120. */
  119121. rebuildAnglesAndRadius(): void;
  119122. /**
  119123. * Use a position to define the current camera related information like alpha, beta and radius
  119124. * @param position Defines the position to set the camera at
  119125. */
  119126. setPosition(position: Vector3): void;
  119127. /**
  119128. * Defines the target the camera should look at.
  119129. * This will automatically adapt alpha beta and radius to fit within the new target.
  119130. * @param target Defines the new target as a Vector or a mesh
  119131. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  119132. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  119133. */
  119134. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  119135. /** @hidden */
  119136. _getViewMatrix(): Matrix;
  119137. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  119138. /**
  119139. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  119140. * @param meshes Defines the mesh to zoom on
  119141. * @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)
  119142. */
  119143. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  119144. /**
  119145. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  119146. * The target will be changed but the radius
  119147. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  119148. * @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)
  119149. */
  119150. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  119151. min: Vector3;
  119152. max: Vector3;
  119153. distance: number;
  119154. }, doNotUpdateMaxZ?: boolean): void;
  119155. /**
  119156. * @override
  119157. * Override Camera.createRigCamera
  119158. */
  119159. createRigCamera(name: string, cameraIndex: number): Camera;
  119160. /**
  119161. * @hidden
  119162. * @override
  119163. * Override Camera._updateRigCameras
  119164. */
  119165. _updateRigCameras(): void;
  119166. /**
  119167. * Destroy the camera and release the current resources hold by it.
  119168. */
  119169. dispose(): void;
  119170. /**
  119171. * Gets the current object class name.
  119172. * @return the class name
  119173. */
  119174. getClassName(): string;
  119175. }
  119176. }
  119177. declare module BABYLON {
  119178. /**
  119179. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  119180. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  119181. */
  119182. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  119183. /**
  119184. * Gets the name of the behavior.
  119185. */
  119186. get name(): string;
  119187. private _zoomStopsAnimation;
  119188. private _idleRotationSpeed;
  119189. private _idleRotationWaitTime;
  119190. private _idleRotationSpinupTime;
  119191. /**
  119192. * Sets the flag that indicates if user zooming should stop animation.
  119193. */
  119194. set zoomStopsAnimation(flag: boolean);
  119195. /**
  119196. * Gets the flag that indicates if user zooming should stop animation.
  119197. */
  119198. get zoomStopsAnimation(): boolean;
  119199. /**
  119200. * Sets the default speed at which the camera rotates around the model.
  119201. */
  119202. set idleRotationSpeed(speed: number);
  119203. /**
  119204. * Gets the default speed at which the camera rotates around the model.
  119205. */
  119206. get idleRotationSpeed(): number;
  119207. /**
  119208. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  119209. */
  119210. set idleRotationWaitTime(time: number);
  119211. /**
  119212. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  119213. */
  119214. get idleRotationWaitTime(): number;
  119215. /**
  119216. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  119217. */
  119218. set idleRotationSpinupTime(time: number);
  119219. /**
  119220. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  119221. */
  119222. get idleRotationSpinupTime(): number;
  119223. /**
  119224. * Gets a value indicating if the camera is currently rotating because of this behavior
  119225. */
  119226. get rotationInProgress(): boolean;
  119227. private _onPrePointerObservableObserver;
  119228. private _onAfterCheckInputsObserver;
  119229. private _attachedCamera;
  119230. private _isPointerDown;
  119231. private _lastFrameTime;
  119232. private _lastInteractionTime;
  119233. private _cameraRotationSpeed;
  119234. /**
  119235. * Initializes the behavior.
  119236. */
  119237. init(): void;
  119238. /**
  119239. * Attaches the behavior to its arc rotate camera.
  119240. * @param camera Defines the camera to attach the behavior to
  119241. */
  119242. attach(camera: ArcRotateCamera): void;
  119243. /**
  119244. * Detaches the behavior from its current arc rotate camera.
  119245. */
  119246. detach(): void;
  119247. /**
  119248. * Returns true if user is scrolling.
  119249. * @return true if user is scrolling.
  119250. */
  119251. private _userIsZooming;
  119252. private _lastFrameRadius;
  119253. private _shouldAnimationStopForInteraction;
  119254. /**
  119255. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  119256. */
  119257. private _applyUserInteraction;
  119258. private _userIsMoving;
  119259. }
  119260. }
  119261. declare module BABYLON {
  119262. /**
  119263. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  119264. */
  119265. export class AttachToBoxBehavior implements Behavior<Mesh> {
  119266. private ui;
  119267. /**
  119268. * The name of the behavior
  119269. */
  119270. name: string;
  119271. /**
  119272. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  119273. */
  119274. distanceAwayFromFace: number;
  119275. /**
  119276. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  119277. */
  119278. distanceAwayFromBottomOfFace: number;
  119279. private _faceVectors;
  119280. private _target;
  119281. private _scene;
  119282. private _onRenderObserver;
  119283. private _tmpMatrix;
  119284. private _tmpVector;
  119285. /**
  119286. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  119287. * @param ui The transform node that should be attched to the mesh
  119288. */
  119289. constructor(ui: TransformNode);
  119290. /**
  119291. * Initializes the behavior
  119292. */
  119293. init(): void;
  119294. private _closestFace;
  119295. private _zeroVector;
  119296. private _lookAtTmpMatrix;
  119297. private _lookAtToRef;
  119298. /**
  119299. * Attaches the AttachToBoxBehavior to the passed in mesh
  119300. * @param target The mesh that the specified node will be attached to
  119301. */
  119302. attach(target: Mesh): void;
  119303. /**
  119304. * Detaches the behavior from the mesh
  119305. */
  119306. detach(): void;
  119307. }
  119308. }
  119309. declare module BABYLON {
  119310. /**
  119311. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  119312. */
  119313. export class FadeInOutBehavior implements Behavior<Mesh> {
  119314. /**
  119315. * Time in milliseconds to delay before fading in (Default: 0)
  119316. */
  119317. delay: number;
  119318. /**
  119319. * Time in milliseconds for the mesh to fade in (Default: 300)
  119320. */
  119321. fadeInTime: number;
  119322. private _millisecondsPerFrame;
  119323. private _hovered;
  119324. private _hoverValue;
  119325. private _ownerNode;
  119326. /**
  119327. * Instatiates the FadeInOutBehavior
  119328. */
  119329. constructor();
  119330. /**
  119331. * The name of the behavior
  119332. */
  119333. get name(): string;
  119334. /**
  119335. * Initializes the behavior
  119336. */
  119337. init(): void;
  119338. /**
  119339. * Attaches the fade behavior on the passed in mesh
  119340. * @param ownerNode The mesh that will be faded in/out once attached
  119341. */
  119342. attach(ownerNode: Mesh): void;
  119343. /**
  119344. * Detaches the behavior from the mesh
  119345. */
  119346. detach(): void;
  119347. /**
  119348. * Triggers the mesh to begin fading in or out
  119349. * @param value if the object should fade in or out (true to fade in)
  119350. */
  119351. fadeIn(value: boolean): void;
  119352. private _update;
  119353. private _setAllVisibility;
  119354. }
  119355. }
  119356. declare module BABYLON {
  119357. /**
  119358. * Class containing a set of static utilities functions for managing Pivots
  119359. * @hidden
  119360. */
  119361. export class PivotTools {
  119362. private static _PivotCached;
  119363. private static _OldPivotPoint;
  119364. private static _PivotTranslation;
  119365. private static _PivotTmpVector;
  119366. /** @hidden */
  119367. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  119368. /** @hidden */
  119369. static _RestorePivotPoint(mesh: AbstractMesh): void;
  119370. }
  119371. }
  119372. declare module BABYLON {
  119373. /**
  119374. * Class containing static functions to help procedurally build meshes
  119375. */
  119376. export class PlaneBuilder {
  119377. /**
  119378. * Creates a plane mesh
  119379. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  119380. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  119381. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  119382. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119383. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119384. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119385. * @param name defines the name of the mesh
  119386. * @param options defines the options used to create the mesh
  119387. * @param scene defines the hosting scene
  119388. * @returns the plane mesh
  119389. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  119390. */
  119391. static CreatePlane(name: string, options: {
  119392. size?: number;
  119393. width?: number;
  119394. height?: number;
  119395. sideOrientation?: number;
  119396. frontUVs?: Vector4;
  119397. backUVs?: Vector4;
  119398. updatable?: boolean;
  119399. sourcePlane?: Plane;
  119400. }, scene?: Nullable<Scene>): Mesh;
  119401. }
  119402. }
  119403. declare module BABYLON {
  119404. /**
  119405. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  119406. */
  119407. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  119408. private static _AnyMouseID;
  119409. /**
  119410. * Abstract mesh the behavior is set on
  119411. */
  119412. attachedNode: AbstractMesh;
  119413. private _dragPlane;
  119414. private _scene;
  119415. private _pointerObserver;
  119416. private _beforeRenderObserver;
  119417. private static _planeScene;
  119418. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  119419. /**
  119420. * 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)
  119421. */
  119422. maxDragAngle: number;
  119423. /**
  119424. * @hidden
  119425. */
  119426. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  119427. /**
  119428. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  119429. */
  119430. currentDraggingPointerID: number;
  119431. /**
  119432. * The last position where the pointer hit the drag plane in world space
  119433. */
  119434. lastDragPosition: Vector3;
  119435. /**
  119436. * If the behavior is currently in a dragging state
  119437. */
  119438. dragging: boolean;
  119439. /**
  119440. * 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)
  119441. */
  119442. dragDeltaRatio: number;
  119443. /**
  119444. * If the drag plane orientation should be updated during the dragging (Default: true)
  119445. */
  119446. updateDragPlane: boolean;
  119447. private _debugMode;
  119448. private _moving;
  119449. /**
  119450. * Fires each time the attached mesh is dragged with the pointer
  119451. * * delta between last drag position and current drag position in world space
  119452. * * dragDistance along the drag axis
  119453. * * dragPlaneNormal normal of the current drag plane used during the drag
  119454. * * dragPlanePoint in world space where the drag intersects the drag plane
  119455. */
  119456. onDragObservable: Observable<{
  119457. delta: Vector3;
  119458. dragPlanePoint: Vector3;
  119459. dragPlaneNormal: Vector3;
  119460. dragDistance: number;
  119461. pointerId: number;
  119462. }>;
  119463. /**
  119464. * Fires each time a drag begins (eg. mouse down on mesh)
  119465. */
  119466. onDragStartObservable: Observable<{
  119467. dragPlanePoint: Vector3;
  119468. pointerId: number;
  119469. }>;
  119470. /**
  119471. * Fires each time a drag ends (eg. mouse release after drag)
  119472. */
  119473. onDragEndObservable: Observable<{
  119474. dragPlanePoint: Vector3;
  119475. pointerId: number;
  119476. }>;
  119477. /**
  119478. * If the attached mesh should be moved when dragged
  119479. */
  119480. moveAttached: boolean;
  119481. /**
  119482. * If the drag behavior will react to drag events (Default: true)
  119483. */
  119484. enabled: boolean;
  119485. /**
  119486. * If pointer events should start and release the drag (Default: true)
  119487. */
  119488. startAndReleaseDragOnPointerEvents: boolean;
  119489. /**
  119490. * If camera controls should be detached during the drag
  119491. */
  119492. detachCameraControls: boolean;
  119493. /**
  119494. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  119495. */
  119496. useObjectOrientationForDragging: boolean;
  119497. private _options;
  119498. /**
  119499. * Gets the options used by the behavior
  119500. */
  119501. get options(): {
  119502. dragAxis?: Vector3;
  119503. dragPlaneNormal?: Vector3;
  119504. };
  119505. /**
  119506. * Sets the options used by the behavior
  119507. */
  119508. set options(options: {
  119509. dragAxis?: Vector3;
  119510. dragPlaneNormal?: Vector3;
  119511. });
  119512. /**
  119513. * Creates a pointer drag behavior that can be attached to a mesh
  119514. * @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)
  119515. */
  119516. constructor(options?: {
  119517. dragAxis?: Vector3;
  119518. dragPlaneNormal?: Vector3;
  119519. });
  119520. /**
  119521. * Predicate to determine if it is valid to move the object to a new position when it is moved
  119522. */
  119523. validateDrag: (targetPosition: Vector3) => boolean;
  119524. /**
  119525. * The name of the behavior
  119526. */
  119527. get name(): string;
  119528. /**
  119529. * Initializes the behavior
  119530. */
  119531. init(): void;
  119532. private _tmpVector;
  119533. private _alternatePickedPoint;
  119534. private _worldDragAxis;
  119535. private _targetPosition;
  119536. private _attachedElement;
  119537. /**
  119538. * Attaches the drag behavior the passed in mesh
  119539. * @param ownerNode The mesh that will be dragged around once attached
  119540. * @param predicate Predicate to use for pick filtering
  119541. */
  119542. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  119543. /**
  119544. * Force relase the drag action by code.
  119545. */
  119546. releaseDrag(): void;
  119547. private _startDragRay;
  119548. private _lastPointerRay;
  119549. /**
  119550. * Simulates the start of a pointer drag event on the behavior
  119551. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  119552. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  119553. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  119554. */
  119555. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  119556. private _startDrag;
  119557. private _dragDelta;
  119558. private _moveDrag;
  119559. private _pickWithRayOnDragPlane;
  119560. private _pointA;
  119561. private _pointB;
  119562. private _pointC;
  119563. private _lineA;
  119564. private _lineB;
  119565. private _localAxis;
  119566. private _lookAt;
  119567. private _updateDragPlanePosition;
  119568. /**
  119569. * Detaches the behavior from the mesh
  119570. */
  119571. detach(): void;
  119572. }
  119573. }
  119574. declare module BABYLON {
  119575. /**
  119576. * A behavior that when attached to a mesh will allow the mesh to be scaled
  119577. */
  119578. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  119579. private _dragBehaviorA;
  119580. private _dragBehaviorB;
  119581. private _startDistance;
  119582. private _initialScale;
  119583. private _targetScale;
  119584. private _ownerNode;
  119585. private _sceneRenderObserver;
  119586. /**
  119587. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  119588. */
  119589. constructor();
  119590. /**
  119591. * The name of the behavior
  119592. */
  119593. get name(): string;
  119594. /**
  119595. * Initializes the behavior
  119596. */
  119597. init(): void;
  119598. private _getCurrentDistance;
  119599. /**
  119600. * Attaches the scale behavior the passed in mesh
  119601. * @param ownerNode The mesh that will be scaled around once attached
  119602. */
  119603. attach(ownerNode: Mesh): void;
  119604. /**
  119605. * Detaches the behavior from the mesh
  119606. */
  119607. detach(): void;
  119608. }
  119609. }
  119610. declare module BABYLON {
  119611. /**
  119612. * 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
  119613. */
  119614. export class SixDofDragBehavior implements Behavior<Mesh> {
  119615. private static _virtualScene;
  119616. private _ownerNode;
  119617. private _sceneRenderObserver;
  119618. private _scene;
  119619. private _targetPosition;
  119620. private _virtualOriginMesh;
  119621. private _virtualDragMesh;
  119622. private _pointerObserver;
  119623. private _moving;
  119624. private _startingOrientation;
  119625. private _attachedElement;
  119626. /**
  119627. * 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)
  119628. */
  119629. private zDragFactor;
  119630. /**
  119631. * If the object should rotate to face the drag origin
  119632. */
  119633. rotateDraggedObject: boolean;
  119634. /**
  119635. * If the behavior is currently in a dragging state
  119636. */
  119637. dragging: boolean;
  119638. /**
  119639. * 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)
  119640. */
  119641. dragDeltaRatio: number;
  119642. /**
  119643. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  119644. */
  119645. currentDraggingPointerID: number;
  119646. /**
  119647. * If camera controls should be detached during the drag
  119648. */
  119649. detachCameraControls: boolean;
  119650. /**
  119651. * Fires each time a drag starts
  119652. */
  119653. onDragStartObservable: Observable<{}>;
  119654. /**
  119655. * Fires each time a drag ends (eg. mouse release after drag)
  119656. */
  119657. onDragEndObservable: Observable<{}>;
  119658. /**
  119659. * 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
  119660. */
  119661. constructor();
  119662. /**
  119663. * The name of the behavior
  119664. */
  119665. get name(): string;
  119666. /**
  119667. * Initializes the behavior
  119668. */
  119669. init(): void;
  119670. /**
  119671. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  119672. */
  119673. private get _pointerCamera();
  119674. /**
  119675. * Attaches the scale behavior the passed in mesh
  119676. * @param ownerNode The mesh that will be scaled around once attached
  119677. */
  119678. attach(ownerNode: Mesh): void;
  119679. /**
  119680. * Detaches the behavior from the mesh
  119681. */
  119682. detach(): void;
  119683. }
  119684. }
  119685. declare module BABYLON {
  119686. /**
  119687. * Class used to apply inverse kinematics to bones
  119688. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  119689. */
  119690. export class BoneIKController {
  119691. private static _tmpVecs;
  119692. private static _tmpQuat;
  119693. private static _tmpMats;
  119694. /**
  119695. * Gets or sets the target mesh
  119696. */
  119697. targetMesh: AbstractMesh;
  119698. /** Gets or sets the mesh used as pole */
  119699. poleTargetMesh: AbstractMesh;
  119700. /**
  119701. * Gets or sets the bone used as pole
  119702. */
  119703. poleTargetBone: Nullable<Bone>;
  119704. /**
  119705. * Gets or sets the target position
  119706. */
  119707. targetPosition: Vector3;
  119708. /**
  119709. * Gets or sets the pole target position
  119710. */
  119711. poleTargetPosition: Vector3;
  119712. /**
  119713. * Gets or sets the pole target local offset
  119714. */
  119715. poleTargetLocalOffset: Vector3;
  119716. /**
  119717. * Gets or sets the pole angle
  119718. */
  119719. poleAngle: number;
  119720. /**
  119721. * Gets or sets the mesh associated with the controller
  119722. */
  119723. mesh: AbstractMesh;
  119724. /**
  119725. * 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)
  119726. */
  119727. slerpAmount: number;
  119728. private _bone1Quat;
  119729. private _bone1Mat;
  119730. private _bone2Ang;
  119731. private _bone1;
  119732. private _bone2;
  119733. private _bone1Length;
  119734. private _bone2Length;
  119735. private _maxAngle;
  119736. private _maxReach;
  119737. private _rightHandedSystem;
  119738. private _bendAxis;
  119739. private _slerping;
  119740. private _adjustRoll;
  119741. /**
  119742. * Gets or sets maximum allowed angle
  119743. */
  119744. get maxAngle(): number;
  119745. set maxAngle(value: number);
  119746. /**
  119747. * Creates a new BoneIKController
  119748. * @param mesh defines the mesh to control
  119749. * @param bone defines the bone to control
  119750. * @param options defines options to set up the controller
  119751. */
  119752. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  119753. targetMesh?: AbstractMesh;
  119754. poleTargetMesh?: AbstractMesh;
  119755. poleTargetBone?: Bone;
  119756. poleTargetLocalOffset?: Vector3;
  119757. poleAngle?: number;
  119758. bendAxis?: Vector3;
  119759. maxAngle?: number;
  119760. slerpAmount?: number;
  119761. });
  119762. private _setMaxAngle;
  119763. /**
  119764. * Force the controller to update the bones
  119765. */
  119766. update(): void;
  119767. }
  119768. }
  119769. declare module BABYLON {
  119770. /**
  119771. * Class used to make a bone look toward a point in space
  119772. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  119773. */
  119774. export class BoneLookController {
  119775. private static _tmpVecs;
  119776. private static _tmpQuat;
  119777. private static _tmpMats;
  119778. /**
  119779. * The target Vector3 that the bone will look at
  119780. */
  119781. target: Vector3;
  119782. /**
  119783. * The mesh that the bone is attached to
  119784. */
  119785. mesh: AbstractMesh;
  119786. /**
  119787. * The bone that will be looking to the target
  119788. */
  119789. bone: Bone;
  119790. /**
  119791. * The up axis of the coordinate system that is used when the bone is rotated
  119792. */
  119793. upAxis: Vector3;
  119794. /**
  119795. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  119796. */
  119797. upAxisSpace: Space;
  119798. /**
  119799. * Used to make an adjustment to the yaw of the bone
  119800. */
  119801. adjustYaw: number;
  119802. /**
  119803. * Used to make an adjustment to the pitch of the bone
  119804. */
  119805. adjustPitch: number;
  119806. /**
  119807. * Used to make an adjustment to the roll of the bone
  119808. */
  119809. adjustRoll: number;
  119810. /**
  119811. * 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)
  119812. */
  119813. slerpAmount: number;
  119814. private _minYaw;
  119815. private _maxYaw;
  119816. private _minPitch;
  119817. private _maxPitch;
  119818. private _minYawSin;
  119819. private _minYawCos;
  119820. private _maxYawSin;
  119821. private _maxYawCos;
  119822. private _midYawConstraint;
  119823. private _minPitchTan;
  119824. private _maxPitchTan;
  119825. private _boneQuat;
  119826. private _slerping;
  119827. private _transformYawPitch;
  119828. private _transformYawPitchInv;
  119829. private _firstFrameSkipped;
  119830. private _yawRange;
  119831. private _fowardAxis;
  119832. /**
  119833. * Gets or sets the minimum yaw angle that the bone can look to
  119834. */
  119835. get minYaw(): number;
  119836. set minYaw(value: number);
  119837. /**
  119838. * Gets or sets the maximum yaw angle that the bone can look to
  119839. */
  119840. get maxYaw(): number;
  119841. set maxYaw(value: number);
  119842. /**
  119843. * Gets or sets the minimum pitch angle that the bone can look to
  119844. */
  119845. get minPitch(): number;
  119846. set minPitch(value: number);
  119847. /**
  119848. * Gets or sets the maximum pitch angle that the bone can look to
  119849. */
  119850. get maxPitch(): number;
  119851. set maxPitch(value: number);
  119852. /**
  119853. * Create a BoneLookController
  119854. * @param mesh the mesh that the bone belongs to
  119855. * @param bone the bone that will be looking to the target
  119856. * @param target the target Vector3 to look at
  119857. * @param options optional settings:
  119858. * * maxYaw: the maximum angle the bone will yaw to
  119859. * * minYaw: the minimum angle the bone will yaw to
  119860. * * maxPitch: the maximum angle the bone will pitch to
  119861. * * minPitch: the minimum angle the bone will yaw to
  119862. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  119863. * * upAxis: the up axis of the coordinate system
  119864. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  119865. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  119866. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  119867. * * adjustYaw: used to make an adjustment to the yaw of the bone
  119868. * * adjustPitch: used to make an adjustment to the pitch of the bone
  119869. * * adjustRoll: used to make an adjustment to the roll of the bone
  119870. **/
  119871. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  119872. maxYaw?: number;
  119873. minYaw?: number;
  119874. maxPitch?: number;
  119875. minPitch?: number;
  119876. slerpAmount?: number;
  119877. upAxis?: Vector3;
  119878. upAxisSpace?: Space;
  119879. yawAxis?: Vector3;
  119880. pitchAxis?: Vector3;
  119881. adjustYaw?: number;
  119882. adjustPitch?: number;
  119883. adjustRoll?: number;
  119884. });
  119885. /**
  119886. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  119887. */
  119888. update(): void;
  119889. private _getAngleDiff;
  119890. private _getAngleBetween;
  119891. private _isAngleBetween;
  119892. }
  119893. }
  119894. declare module BABYLON {
  119895. /**
  119896. * Manage the gamepad inputs to control an arc rotate camera.
  119897. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  119898. */
  119899. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  119900. /**
  119901. * Defines the camera the input is attached to.
  119902. */
  119903. camera: ArcRotateCamera;
  119904. /**
  119905. * Defines the gamepad the input is gathering event from.
  119906. */
  119907. gamepad: Nullable<Gamepad>;
  119908. /**
  119909. * Defines the gamepad rotation sensiblity.
  119910. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  119911. */
  119912. gamepadRotationSensibility: number;
  119913. /**
  119914. * Defines the gamepad move sensiblity.
  119915. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  119916. */
  119917. gamepadMoveSensibility: number;
  119918. private _yAxisScale;
  119919. /**
  119920. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  119921. */
  119922. get invertYAxis(): boolean;
  119923. set invertYAxis(value: boolean);
  119924. private _onGamepadConnectedObserver;
  119925. private _onGamepadDisconnectedObserver;
  119926. /**
  119927. * Attach the input controls to a specific dom element to get the input from.
  119928. * @param element Defines the element the controls should be listened from
  119929. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  119930. */
  119931. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  119932. /**
  119933. * Detach the current controls from the specified dom element.
  119934. * @param element Defines the element to stop listening the inputs from
  119935. */
  119936. detachControl(element: Nullable<HTMLElement>): void;
  119937. /**
  119938. * Update the current camera state depending on the inputs that have been used this frame.
  119939. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  119940. */
  119941. checkInputs(): void;
  119942. /**
  119943. * Gets the class name of the current intput.
  119944. * @returns the class name
  119945. */
  119946. getClassName(): string;
  119947. /**
  119948. * Get the friendly name associated with the input class.
  119949. * @returns the input friendly name
  119950. */
  119951. getSimpleName(): string;
  119952. }
  119953. }
  119954. declare module BABYLON {
  119955. interface ArcRotateCameraInputsManager {
  119956. /**
  119957. * Add orientation input support to the input manager.
  119958. * @returns the current input manager
  119959. */
  119960. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  119961. }
  119962. /**
  119963. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  119964. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  119965. */
  119966. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  119967. /**
  119968. * Defines the camera the input is attached to.
  119969. */
  119970. camera: ArcRotateCamera;
  119971. /**
  119972. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  119973. */
  119974. alphaCorrection: number;
  119975. /**
  119976. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  119977. */
  119978. gammaCorrection: number;
  119979. private _alpha;
  119980. private _gamma;
  119981. private _dirty;
  119982. private _deviceOrientationHandler;
  119983. /**
  119984. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  119985. */
  119986. constructor();
  119987. /**
  119988. * Attach the input controls to a specific dom element to get the input from.
  119989. * @param element Defines the element the controls should be listened from
  119990. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  119991. */
  119992. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  119993. /** @hidden */
  119994. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  119995. /**
  119996. * Update the current camera state depending on the inputs that have been used this frame.
  119997. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  119998. */
  119999. checkInputs(): void;
  120000. /**
  120001. * Detach the current controls from the specified dom element.
  120002. * @param element Defines the element to stop listening the inputs from
  120003. */
  120004. detachControl(element: Nullable<HTMLElement>): void;
  120005. /**
  120006. * Gets the class name of the current intput.
  120007. * @returns the class name
  120008. */
  120009. getClassName(): string;
  120010. /**
  120011. * Get the friendly name associated with the input class.
  120012. * @returns the input friendly name
  120013. */
  120014. getSimpleName(): string;
  120015. }
  120016. }
  120017. declare module BABYLON {
  120018. /**
  120019. * Listen to mouse events to control the camera.
  120020. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120021. */
  120022. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  120023. /**
  120024. * Defines the camera the input is attached to.
  120025. */
  120026. camera: FlyCamera;
  120027. /**
  120028. * Defines if touch is enabled. (Default is true.)
  120029. */
  120030. touchEnabled: boolean;
  120031. /**
  120032. * Defines the buttons associated with the input to handle camera rotation.
  120033. */
  120034. buttons: number[];
  120035. /**
  120036. * Assign buttons for Yaw control.
  120037. */
  120038. buttonsYaw: number[];
  120039. /**
  120040. * Assign buttons for Pitch control.
  120041. */
  120042. buttonsPitch: number[];
  120043. /**
  120044. * Assign buttons for Roll control.
  120045. */
  120046. buttonsRoll: number[];
  120047. /**
  120048. * Detect if any button is being pressed while mouse is moved.
  120049. * -1 = Mouse locked.
  120050. * 0 = Left button.
  120051. * 1 = Middle Button.
  120052. * 2 = Right Button.
  120053. */
  120054. activeButton: number;
  120055. /**
  120056. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  120057. * Higher values reduce its sensitivity.
  120058. */
  120059. angularSensibility: number;
  120060. private _mousemoveCallback;
  120061. private _observer;
  120062. private _rollObserver;
  120063. private previousPosition;
  120064. private noPreventDefault;
  120065. private element;
  120066. /**
  120067. * Listen to mouse events to control the camera.
  120068. * @param touchEnabled Define if touch is enabled. (Default is true.)
  120069. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120070. */
  120071. constructor(touchEnabled?: boolean);
  120072. /**
  120073. * Attach the mouse control to the HTML DOM element.
  120074. * @param element Defines the element that listens to the input events.
  120075. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  120076. */
  120077. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  120078. /**
  120079. * Detach the current controls from the specified dom element.
  120080. * @param element Defines the element to stop listening the inputs from
  120081. */
  120082. detachControl(element: Nullable<HTMLElement>): void;
  120083. /**
  120084. * Gets the class name of the current input.
  120085. * @returns the class name.
  120086. */
  120087. getClassName(): string;
  120088. /**
  120089. * Get the friendly name associated with the input class.
  120090. * @returns the input's friendly name.
  120091. */
  120092. getSimpleName(): string;
  120093. private _pointerInput;
  120094. private _onMouseMove;
  120095. /**
  120096. * Rotate camera by mouse offset.
  120097. */
  120098. private rotateCamera;
  120099. }
  120100. }
  120101. declare module BABYLON {
  120102. /**
  120103. * Default Inputs manager for the FlyCamera.
  120104. * It groups all the default supported inputs for ease of use.
  120105. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120106. */
  120107. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  120108. /**
  120109. * Instantiates a new FlyCameraInputsManager.
  120110. * @param camera Defines the camera the inputs belong to.
  120111. */
  120112. constructor(camera: FlyCamera);
  120113. /**
  120114. * Add keyboard input support to the input manager.
  120115. * @returns the new FlyCameraKeyboardMoveInput().
  120116. */
  120117. addKeyboard(): FlyCameraInputsManager;
  120118. /**
  120119. * Add mouse input support to the input manager.
  120120. * @param touchEnabled Enable touch screen support.
  120121. * @returns the new FlyCameraMouseInput().
  120122. */
  120123. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  120124. }
  120125. }
  120126. declare module BABYLON {
  120127. /**
  120128. * This is a flying camera, designed for 3D movement and rotation in all directions,
  120129. * such as in a 3D Space Shooter or a Flight Simulator.
  120130. */
  120131. export class FlyCamera extends TargetCamera {
  120132. /**
  120133. * Define the collision ellipsoid of the camera.
  120134. * This is helpful for simulating a camera body, like a player's body.
  120135. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  120136. */
  120137. ellipsoid: Vector3;
  120138. /**
  120139. * Define an offset for the position of the ellipsoid around the camera.
  120140. * This can be helpful if the camera is attached away from the player's body center,
  120141. * such as at its head.
  120142. */
  120143. ellipsoidOffset: Vector3;
  120144. /**
  120145. * Enable or disable collisions of the camera with the rest of the scene objects.
  120146. */
  120147. checkCollisions: boolean;
  120148. /**
  120149. * Enable or disable gravity on the camera.
  120150. */
  120151. applyGravity: boolean;
  120152. /**
  120153. * Define the current direction the camera is moving to.
  120154. */
  120155. cameraDirection: Vector3;
  120156. /**
  120157. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  120158. * This overrides and empties cameraRotation.
  120159. */
  120160. rotationQuaternion: Quaternion;
  120161. /**
  120162. * Track Roll to maintain the wanted Rolling when looking around.
  120163. */
  120164. _trackRoll: number;
  120165. /**
  120166. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  120167. */
  120168. rollCorrect: number;
  120169. /**
  120170. * Mimic a banked turn, Rolling the camera when Yawing.
  120171. * It's recommended to use rollCorrect = 10 for faster banking correction.
  120172. */
  120173. bankedTurn: boolean;
  120174. /**
  120175. * Limit in radians for how much Roll banking will add. (Default: 90°)
  120176. */
  120177. bankedTurnLimit: number;
  120178. /**
  120179. * Value of 0 disables the banked Roll.
  120180. * Value of 1 is equal to the Yaw angle in radians.
  120181. */
  120182. bankedTurnMultiplier: number;
  120183. /**
  120184. * The inputs manager loads all the input sources, such as keyboard and mouse.
  120185. */
  120186. inputs: FlyCameraInputsManager;
  120187. /**
  120188. * Gets the input sensibility for mouse input.
  120189. * Higher values reduce sensitivity.
  120190. */
  120191. get angularSensibility(): number;
  120192. /**
  120193. * Sets the input sensibility for a mouse input.
  120194. * Higher values reduce sensitivity.
  120195. */
  120196. set angularSensibility(value: number);
  120197. /**
  120198. * Get the keys for camera movement forward.
  120199. */
  120200. get keysForward(): number[];
  120201. /**
  120202. * Set the keys for camera movement forward.
  120203. */
  120204. set keysForward(value: number[]);
  120205. /**
  120206. * Get the keys for camera movement backward.
  120207. */
  120208. get keysBackward(): number[];
  120209. set keysBackward(value: number[]);
  120210. /**
  120211. * Get the keys for camera movement up.
  120212. */
  120213. get keysUp(): number[];
  120214. /**
  120215. * Set the keys for camera movement up.
  120216. */
  120217. set keysUp(value: number[]);
  120218. /**
  120219. * Get the keys for camera movement down.
  120220. */
  120221. get keysDown(): number[];
  120222. /**
  120223. * Set the keys for camera movement down.
  120224. */
  120225. set keysDown(value: number[]);
  120226. /**
  120227. * Get the keys for camera movement left.
  120228. */
  120229. get keysLeft(): number[];
  120230. /**
  120231. * Set the keys for camera movement left.
  120232. */
  120233. set keysLeft(value: number[]);
  120234. /**
  120235. * Set the keys for camera movement right.
  120236. */
  120237. get keysRight(): number[];
  120238. /**
  120239. * Set the keys for camera movement right.
  120240. */
  120241. set keysRight(value: number[]);
  120242. /**
  120243. * Event raised when the camera collides with a mesh in the scene.
  120244. */
  120245. onCollide: (collidedMesh: AbstractMesh) => void;
  120246. private _collider;
  120247. private _needMoveForGravity;
  120248. private _oldPosition;
  120249. private _diffPosition;
  120250. private _newPosition;
  120251. /** @hidden */
  120252. _localDirection: Vector3;
  120253. /** @hidden */
  120254. _transformedDirection: Vector3;
  120255. /**
  120256. * Instantiates a FlyCamera.
  120257. * This is a flying camera, designed for 3D movement and rotation in all directions,
  120258. * such as in a 3D Space Shooter or a Flight Simulator.
  120259. * @param name Define the name of the camera in the scene.
  120260. * @param position Define the starting position of the camera in the scene.
  120261. * @param scene Define the scene the camera belongs to.
  120262. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  120263. */
  120264. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  120265. /**
  120266. * Attach a control to the HTML DOM element.
  120267. * @param element Defines the element that listens to the input events.
  120268. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  120269. */
  120270. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  120271. /**
  120272. * Detach a control from the HTML DOM element.
  120273. * The camera will stop reacting to that input.
  120274. * @param element Defines the element that listens to the input events.
  120275. */
  120276. detachControl(element: HTMLElement): void;
  120277. private _collisionMask;
  120278. /**
  120279. * Get the mask that the camera ignores in collision events.
  120280. */
  120281. get collisionMask(): number;
  120282. /**
  120283. * Set the mask that the camera ignores in collision events.
  120284. */
  120285. set collisionMask(mask: number);
  120286. /** @hidden */
  120287. _collideWithWorld(displacement: Vector3): void;
  120288. /** @hidden */
  120289. private _onCollisionPositionChange;
  120290. /** @hidden */
  120291. _checkInputs(): void;
  120292. /** @hidden */
  120293. _decideIfNeedsToMove(): boolean;
  120294. /** @hidden */
  120295. _updatePosition(): void;
  120296. /**
  120297. * Restore the Roll to its target value at the rate specified.
  120298. * @param rate - Higher means slower restoring.
  120299. * @hidden
  120300. */
  120301. restoreRoll(rate: number): void;
  120302. /**
  120303. * Destroy the camera and release the current resources held by it.
  120304. */
  120305. dispose(): void;
  120306. /**
  120307. * Get the current object class name.
  120308. * @returns the class name.
  120309. */
  120310. getClassName(): string;
  120311. }
  120312. }
  120313. declare module BABYLON {
  120314. /**
  120315. * Listen to keyboard events to control the camera.
  120316. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120317. */
  120318. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  120319. /**
  120320. * Defines the camera the input is attached to.
  120321. */
  120322. camera: FlyCamera;
  120323. /**
  120324. * The list of keyboard keys used to control the forward move of the camera.
  120325. */
  120326. keysForward: number[];
  120327. /**
  120328. * The list of keyboard keys used to control the backward move of the camera.
  120329. */
  120330. keysBackward: number[];
  120331. /**
  120332. * The list of keyboard keys used to control the forward move of the camera.
  120333. */
  120334. keysUp: number[];
  120335. /**
  120336. * The list of keyboard keys used to control the backward move of the camera.
  120337. */
  120338. keysDown: number[];
  120339. /**
  120340. * The list of keyboard keys used to control the right strafe move of the camera.
  120341. */
  120342. keysRight: number[];
  120343. /**
  120344. * The list of keyboard keys used to control the left strafe move of the camera.
  120345. */
  120346. keysLeft: number[];
  120347. private _keys;
  120348. private _onCanvasBlurObserver;
  120349. private _onKeyboardObserver;
  120350. private _engine;
  120351. private _scene;
  120352. /**
  120353. * Attach the input controls to a specific dom element to get the input from.
  120354. * @param element Defines the element the controls should be listened from
  120355. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  120356. */
  120357. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  120358. /**
  120359. * Detach the current controls from the specified dom element.
  120360. * @param element Defines the element to stop listening the inputs from
  120361. */
  120362. detachControl(element: Nullable<HTMLElement>): void;
  120363. /**
  120364. * Gets the class name of the current intput.
  120365. * @returns the class name
  120366. */
  120367. getClassName(): string;
  120368. /** @hidden */
  120369. _onLostFocus(e: FocusEvent): void;
  120370. /**
  120371. * Get the friendly name associated with the input class.
  120372. * @returns the input friendly name
  120373. */
  120374. getSimpleName(): string;
  120375. /**
  120376. * Update the current camera state depending on the inputs that have been used this frame.
  120377. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  120378. */
  120379. checkInputs(): void;
  120380. }
  120381. }
  120382. declare module BABYLON {
  120383. /**
  120384. * Manage the mouse wheel inputs to control a follow camera.
  120385. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120386. */
  120387. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  120388. /**
  120389. * Defines the camera the input is attached to.
  120390. */
  120391. camera: FollowCamera;
  120392. /**
  120393. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  120394. */
  120395. axisControlRadius: boolean;
  120396. /**
  120397. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  120398. */
  120399. axisControlHeight: boolean;
  120400. /**
  120401. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  120402. */
  120403. axisControlRotation: boolean;
  120404. /**
  120405. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  120406. * relation to mouseWheel events.
  120407. */
  120408. wheelPrecision: number;
  120409. /**
  120410. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  120411. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  120412. */
  120413. wheelDeltaPercentage: number;
  120414. private _wheel;
  120415. private _observer;
  120416. /**
  120417. * Attach the input controls to a specific dom element to get the input from.
  120418. * @param element Defines the element the controls should be listened from
  120419. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  120420. */
  120421. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  120422. /**
  120423. * Detach the current controls from the specified dom element.
  120424. * @param element Defines the element to stop listening the inputs from
  120425. */
  120426. detachControl(element: Nullable<HTMLElement>): void;
  120427. /**
  120428. * Gets the class name of the current intput.
  120429. * @returns the class name
  120430. */
  120431. getClassName(): string;
  120432. /**
  120433. * Get the friendly name associated with the input class.
  120434. * @returns the input friendly name
  120435. */
  120436. getSimpleName(): string;
  120437. }
  120438. }
  120439. declare module BABYLON {
  120440. /**
  120441. * Manage the pointers inputs to control an follow camera.
  120442. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120443. */
  120444. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  120445. /**
  120446. * Defines the camera the input is attached to.
  120447. */
  120448. camera: FollowCamera;
  120449. /**
  120450. * Gets the class name of the current input.
  120451. * @returns the class name
  120452. */
  120453. getClassName(): string;
  120454. /**
  120455. * Defines the pointer angular sensibility along the X axis or how fast is
  120456. * the camera rotating.
  120457. * A negative number will reverse the axis direction.
  120458. */
  120459. angularSensibilityX: number;
  120460. /**
  120461. * Defines the pointer angular sensibility along the Y axis or how fast is
  120462. * the camera rotating.
  120463. * A negative number will reverse the axis direction.
  120464. */
  120465. angularSensibilityY: number;
  120466. /**
  120467. * Defines the pointer pinch precision or how fast is the camera zooming.
  120468. * A negative number will reverse the axis direction.
  120469. */
  120470. pinchPrecision: number;
  120471. /**
  120472. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  120473. * from 0.
  120474. * It defines the percentage of current camera.radius to use as delta when
  120475. * pinch zoom is used.
  120476. */
  120477. pinchDeltaPercentage: number;
  120478. /**
  120479. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  120480. */
  120481. axisXControlRadius: boolean;
  120482. /**
  120483. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  120484. */
  120485. axisXControlHeight: boolean;
  120486. /**
  120487. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  120488. */
  120489. axisXControlRotation: boolean;
  120490. /**
  120491. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  120492. */
  120493. axisYControlRadius: boolean;
  120494. /**
  120495. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  120496. */
  120497. axisYControlHeight: boolean;
  120498. /**
  120499. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  120500. */
  120501. axisYControlRotation: boolean;
  120502. /**
  120503. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  120504. */
  120505. axisPinchControlRadius: boolean;
  120506. /**
  120507. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  120508. */
  120509. axisPinchControlHeight: boolean;
  120510. /**
  120511. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  120512. */
  120513. axisPinchControlRotation: boolean;
  120514. /**
  120515. * Log error messages if basic misconfiguration has occurred.
  120516. */
  120517. warningEnable: boolean;
  120518. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  120519. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  120520. private _warningCounter;
  120521. private _warning;
  120522. }
  120523. }
  120524. declare module BABYLON {
  120525. /**
  120526. * Default Inputs manager for the FollowCamera.
  120527. * It groups all the default supported inputs for ease of use.
  120528. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120529. */
  120530. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  120531. /**
  120532. * Instantiates a new FollowCameraInputsManager.
  120533. * @param camera Defines the camera the inputs belong to
  120534. */
  120535. constructor(camera: FollowCamera);
  120536. /**
  120537. * Add keyboard input support to the input manager.
  120538. * @returns the current input manager
  120539. */
  120540. addKeyboard(): FollowCameraInputsManager;
  120541. /**
  120542. * Add mouse wheel input support to the input manager.
  120543. * @returns the current input manager
  120544. */
  120545. addMouseWheel(): FollowCameraInputsManager;
  120546. /**
  120547. * Add pointers input support to the input manager.
  120548. * @returns the current input manager
  120549. */
  120550. addPointers(): FollowCameraInputsManager;
  120551. /**
  120552. * Add orientation input support to the input manager.
  120553. * @returns the current input manager
  120554. */
  120555. addVRDeviceOrientation(): FollowCameraInputsManager;
  120556. }
  120557. }
  120558. declare module BABYLON {
  120559. /**
  120560. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  120561. * an arc rotate version arcFollowCamera are available.
  120562. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  120563. */
  120564. export class FollowCamera extends TargetCamera {
  120565. /**
  120566. * Distance the follow camera should follow an object at
  120567. */
  120568. radius: number;
  120569. /**
  120570. * Minimum allowed distance of the camera to the axis of rotation
  120571. * (The camera can not get closer).
  120572. * This can help limiting how the Camera is able to move in the scene.
  120573. */
  120574. lowerRadiusLimit: Nullable<number>;
  120575. /**
  120576. * Maximum allowed distance of the camera to the axis of rotation
  120577. * (The camera can not get further).
  120578. * This can help limiting how the Camera is able to move in the scene.
  120579. */
  120580. upperRadiusLimit: Nullable<number>;
  120581. /**
  120582. * Define a rotation offset between the camera and the object it follows
  120583. */
  120584. rotationOffset: number;
  120585. /**
  120586. * Minimum allowed angle to camera position relative to target object.
  120587. * This can help limiting how the Camera is able to move in the scene.
  120588. */
  120589. lowerRotationOffsetLimit: Nullable<number>;
  120590. /**
  120591. * Maximum allowed angle to camera position relative to target object.
  120592. * This can help limiting how the Camera is able to move in the scene.
  120593. */
  120594. upperRotationOffsetLimit: Nullable<number>;
  120595. /**
  120596. * Define a height offset between the camera and the object it follows.
  120597. * It can help following an object from the top (like a car chaing a plane)
  120598. */
  120599. heightOffset: number;
  120600. /**
  120601. * Minimum allowed height of camera position relative to target object.
  120602. * This can help limiting how the Camera is able to move in the scene.
  120603. */
  120604. lowerHeightOffsetLimit: Nullable<number>;
  120605. /**
  120606. * Maximum allowed height of camera position relative to target object.
  120607. * This can help limiting how the Camera is able to move in the scene.
  120608. */
  120609. upperHeightOffsetLimit: Nullable<number>;
  120610. /**
  120611. * Define how fast the camera can accelerate to follow it s target.
  120612. */
  120613. cameraAcceleration: number;
  120614. /**
  120615. * Define the speed limit of the camera following an object.
  120616. */
  120617. maxCameraSpeed: number;
  120618. /**
  120619. * Define the target of the camera.
  120620. */
  120621. lockedTarget: Nullable<AbstractMesh>;
  120622. /**
  120623. * Defines the input associated with the camera.
  120624. */
  120625. inputs: FollowCameraInputsManager;
  120626. /**
  120627. * Instantiates the follow camera.
  120628. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  120629. * @param name Define the name of the camera in the scene
  120630. * @param position Define the position of the camera
  120631. * @param scene Define the scene the camera belong to
  120632. * @param lockedTarget Define the target of the camera
  120633. */
  120634. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  120635. private _follow;
  120636. /**
  120637. * Attached controls to the current camera.
  120638. * @param element Defines the element the controls should be listened from
  120639. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  120640. */
  120641. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  120642. /**
  120643. * Detach the current controls from the camera.
  120644. * The camera will stop reacting to inputs.
  120645. * @param element Defines the element to stop listening the inputs from
  120646. */
  120647. detachControl(element: HTMLElement): void;
  120648. /** @hidden */
  120649. _checkInputs(): void;
  120650. private _checkLimits;
  120651. /**
  120652. * Gets the camera class name.
  120653. * @returns the class name
  120654. */
  120655. getClassName(): string;
  120656. }
  120657. /**
  120658. * Arc Rotate version of the follow camera.
  120659. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  120660. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  120661. */
  120662. export class ArcFollowCamera extends TargetCamera {
  120663. /** The longitudinal angle of the camera */
  120664. alpha: number;
  120665. /** The latitudinal angle of the camera */
  120666. beta: number;
  120667. /** The radius of the camera from its target */
  120668. radius: number;
  120669. /** Define the camera target (the messh it should follow) */
  120670. target: Nullable<AbstractMesh>;
  120671. private _cartesianCoordinates;
  120672. /**
  120673. * Instantiates a new ArcFollowCamera
  120674. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  120675. * @param name Define the name of the camera
  120676. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  120677. * @param beta Define the rotation angle of the camera around the elevation axis
  120678. * @param radius Define the radius of the camera from its target point
  120679. * @param target Define the target of the camera
  120680. * @param scene Define the scene the camera belongs to
  120681. */
  120682. constructor(name: string,
  120683. /** The longitudinal angle of the camera */
  120684. alpha: number,
  120685. /** The latitudinal angle of the camera */
  120686. beta: number,
  120687. /** The radius of the camera from its target */
  120688. radius: number,
  120689. /** Define the camera target (the messh it should follow) */
  120690. target: Nullable<AbstractMesh>, scene: Scene);
  120691. private _follow;
  120692. /** @hidden */
  120693. _checkInputs(): void;
  120694. /**
  120695. * Returns the class name of the object.
  120696. * It is mostly used internally for serialization purposes.
  120697. */
  120698. getClassName(): string;
  120699. }
  120700. }
  120701. declare module BABYLON {
  120702. /**
  120703. * Manage the keyboard inputs to control the movement of a follow camera.
  120704. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120705. */
  120706. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  120707. /**
  120708. * Defines the camera the input is attached to.
  120709. */
  120710. camera: FollowCamera;
  120711. /**
  120712. * Defines the list of key codes associated with the up action (increase heightOffset)
  120713. */
  120714. keysHeightOffsetIncr: number[];
  120715. /**
  120716. * Defines the list of key codes associated with the down action (decrease heightOffset)
  120717. */
  120718. keysHeightOffsetDecr: number[];
  120719. /**
  120720. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  120721. */
  120722. keysHeightOffsetModifierAlt: boolean;
  120723. /**
  120724. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  120725. */
  120726. keysHeightOffsetModifierCtrl: boolean;
  120727. /**
  120728. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  120729. */
  120730. keysHeightOffsetModifierShift: boolean;
  120731. /**
  120732. * Defines the list of key codes associated with the left action (increase rotationOffset)
  120733. */
  120734. keysRotationOffsetIncr: number[];
  120735. /**
  120736. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  120737. */
  120738. keysRotationOffsetDecr: number[];
  120739. /**
  120740. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  120741. */
  120742. keysRotationOffsetModifierAlt: boolean;
  120743. /**
  120744. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  120745. */
  120746. keysRotationOffsetModifierCtrl: boolean;
  120747. /**
  120748. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  120749. */
  120750. keysRotationOffsetModifierShift: boolean;
  120751. /**
  120752. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  120753. */
  120754. keysRadiusIncr: number[];
  120755. /**
  120756. * Defines the list of key codes associated with the zoom-out action (increase radius)
  120757. */
  120758. keysRadiusDecr: number[];
  120759. /**
  120760. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  120761. */
  120762. keysRadiusModifierAlt: boolean;
  120763. /**
  120764. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  120765. */
  120766. keysRadiusModifierCtrl: boolean;
  120767. /**
  120768. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  120769. */
  120770. keysRadiusModifierShift: boolean;
  120771. /**
  120772. * Defines the rate of change of heightOffset.
  120773. */
  120774. heightSensibility: number;
  120775. /**
  120776. * Defines the rate of change of rotationOffset.
  120777. */
  120778. rotationSensibility: number;
  120779. /**
  120780. * Defines the rate of change of radius.
  120781. */
  120782. radiusSensibility: number;
  120783. private _keys;
  120784. private _ctrlPressed;
  120785. private _altPressed;
  120786. private _shiftPressed;
  120787. private _onCanvasBlurObserver;
  120788. private _onKeyboardObserver;
  120789. private _engine;
  120790. private _scene;
  120791. /**
  120792. * Attach the input controls to a specific dom element to get the input from.
  120793. * @param element Defines the element the controls should be listened from
  120794. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  120795. */
  120796. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  120797. /**
  120798. * Detach the current controls from the specified dom element.
  120799. * @param element Defines the element to stop listening the inputs from
  120800. */
  120801. detachControl(element: Nullable<HTMLElement>): 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. * Gets the class name of the current input.
  120809. * @returns the class name
  120810. */
  120811. getClassName(): string;
  120812. /**
  120813. * Get the friendly name associated with the input class.
  120814. * @returns the input friendly name
  120815. */
  120816. getSimpleName(): string;
  120817. /**
  120818. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  120819. * allow modification of the heightOffset value.
  120820. */
  120821. private _modifierHeightOffset;
  120822. /**
  120823. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  120824. * allow modification of the rotationOffset value.
  120825. */
  120826. private _modifierRotationOffset;
  120827. /**
  120828. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  120829. * allow modification of the radius value.
  120830. */
  120831. private _modifierRadius;
  120832. }
  120833. }
  120834. declare module BABYLON {
  120835. interface FreeCameraInputsManager {
  120836. /**
  120837. * @hidden
  120838. */
  120839. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  120840. /**
  120841. * Add orientation input support to the input manager.
  120842. * @returns the current input manager
  120843. */
  120844. addDeviceOrientation(): FreeCameraInputsManager;
  120845. }
  120846. /**
  120847. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  120848. * Screen rotation is taken into account.
  120849. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120850. */
  120851. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  120852. private _camera;
  120853. private _screenOrientationAngle;
  120854. private _constantTranform;
  120855. private _screenQuaternion;
  120856. private _alpha;
  120857. private _beta;
  120858. private _gamma;
  120859. /**
  120860. * Can be used to detect if a device orientation sensor is available on a device
  120861. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  120862. * @returns a promise that will resolve on orientation change
  120863. */
  120864. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  120865. /**
  120866. * @hidden
  120867. */
  120868. _onDeviceOrientationChangedObservable: Observable<void>;
  120869. /**
  120870. * Instantiates a new input
  120871. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120872. */
  120873. constructor();
  120874. /**
  120875. * Define the camera controlled by the input.
  120876. */
  120877. get camera(): FreeCamera;
  120878. set camera(camera: FreeCamera);
  120879. /**
  120880. * Attach the input controls to a specific dom element to get the input from.
  120881. * @param element Defines the element the controls should be listened from
  120882. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  120883. */
  120884. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  120885. private _orientationChanged;
  120886. private _deviceOrientation;
  120887. /**
  120888. * Detach the current controls from the specified dom element.
  120889. * @param element Defines the element to stop listening the inputs from
  120890. */
  120891. detachControl(element: Nullable<HTMLElement>): void;
  120892. /**
  120893. * Update the current camera state depending on the inputs that have been used this frame.
  120894. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  120895. */
  120896. checkInputs(): void;
  120897. /**
  120898. * Gets the class name of the current intput.
  120899. * @returns the class name
  120900. */
  120901. getClassName(): string;
  120902. /**
  120903. * Get the friendly name associated with the input class.
  120904. * @returns the input friendly name
  120905. */
  120906. getSimpleName(): string;
  120907. }
  120908. }
  120909. declare module BABYLON {
  120910. /**
  120911. * Manage the gamepad inputs to control a free camera.
  120912. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120913. */
  120914. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  120915. /**
  120916. * Define the camera the input is attached to.
  120917. */
  120918. camera: FreeCamera;
  120919. /**
  120920. * Define the Gamepad controlling the input
  120921. */
  120922. gamepad: Nullable<Gamepad>;
  120923. /**
  120924. * Defines the gamepad rotation sensiblity.
  120925. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  120926. */
  120927. gamepadAngularSensibility: number;
  120928. /**
  120929. * Defines the gamepad move sensiblity.
  120930. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  120931. */
  120932. gamepadMoveSensibility: number;
  120933. private _yAxisScale;
  120934. /**
  120935. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  120936. */
  120937. get invertYAxis(): boolean;
  120938. set invertYAxis(value: boolean);
  120939. private _onGamepadConnectedObserver;
  120940. private _onGamepadDisconnectedObserver;
  120941. private _cameraTransform;
  120942. private _deltaTransform;
  120943. private _vector3;
  120944. private _vector2;
  120945. /**
  120946. * Attach the input controls to a specific dom element to get the input from.
  120947. * @param element Defines the element the controls should be listened from
  120948. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  120949. */
  120950. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  120951. /**
  120952. * Detach the current controls from the specified dom element.
  120953. * @param element Defines the element to stop listening the inputs from
  120954. */
  120955. detachControl(element: Nullable<HTMLElement>): void;
  120956. /**
  120957. * Update the current camera state depending on the inputs that have been used this frame.
  120958. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  120959. */
  120960. checkInputs(): void;
  120961. /**
  120962. * Gets the class name of the current intput.
  120963. * @returns the class name
  120964. */
  120965. getClassName(): string;
  120966. /**
  120967. * Get the friendly name associated with the input class.
  120968. * @returns the input friendly name
  120969. */
  120970. getSimpleName(): string;
  120971. }
  120972. }
  120973. declare module BABYLON {
  120974. /**
  120975. * Defines the potential axis of a Joystick
  120976. */
  120977. export enum JoystickAxis {
  120978. /** X axis */
  120979. X = 0,
  120980. /** Y axis */
  120981. Y = 1,
  120982. /** Z axis */
  120983. Z = 2
  120984. }
  120985. /**
  120986. * Class used to define virtual joystick (used in touch mode)
  120987. */
  120988. export class VirtualJoystick {
  120989. /**
  120990. * Gets or sets a boolean indicating that left and right values must be inverted
  120991. */
  120992. reverseLeftRight: boolean;
  120993. /**
  120994. * Gets or sets a boolean indicating that up and down values must be inverted
  120995. */
  120996. reverseUpDown: boolean;
  120997. /**
  120998. * Gets the offset value for the position (ie. the change of the position value)
  120999. */
  121000. deltaPosition: Vector3;
  121001. /**
  121002. * Gets a boolean indicating if the virtual joystick was pressed
  121003. */
  121004. pressed: boolean;
  121005. /**
  121006. * Canvas the virtual joystick will render onto, default z-index of this is 5
  121007. */
  121008. static Canvas: Nullable<HTMLCanvasElement>;
  121009. private static _globalJoystickIndex;
  121010. private static vjCanvasContext;
  121011. private static vjCanvasWidth;
  121012. private static vjCanvasHeight;
  121013. private static halfWidth;
  121014. private _action;
  121015. private _axisTargetedByLeftAndRight;
  121016. private _axisTargetedByUpAndDown;
  121017. private _joystickSensibility;
  121018. private _inversedSensibility;
  121019. private _joystickPointerID;
  121020. private _joystickColor;
  121021. private _joystickPointerPos;
  121022. private _joystickPreviousPointerPos;
  121023. private _joystickPointerStartPos;
  121024. private _deltaJoystickVector;
  121025. private _leftJoystick;
  121026. private _touches;
  121027. private _onPointerDownHandlerRef;
  121028. private _onPointerMoveHandlerRef;
  121029. private _onPointerUpHandlerRef;
  121030. private _onResize;
  121031. /**
  121032. * Creates a new virtual joystick
  121033. * @param leftJoystick defines that the joystick is for left hand (false by default)
  121034. */
  121035. constructor(leftJoystick?: boolean);
  121036. /**
  121037. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  121038. * @param newJoystickSensibility defines the new sensibility
  121039. */
  121040. setJoystickSensibility(newJoystickSensibility: number): void;
  121041. private _onPointerDown;
  121042. private _onPointerMove;
  121043. private _onPointerUp;
  121044. /**
  121045. * Change the color of the virtual joystick
  121046. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  121047. */
  121048. setJoystickColor(newColor: string): void;
  121049. /**
  121050. * Defines a callback to call when the joystick is touched
  121051. * @param action defines the callback
  121052. */
  121053. setActionOnTouch(action: () => any): void;
  121054. /**
  121055. * Defines which axis you'd like to control for left & right
  121056. * @param axis defines the axis to use
  121057. */
  121058. setAxisForLeftRight(axis: JoystickAxis): void;
  121059. /**
  121060. * Defines which axis you'd like to control for up & down
  121061. * @param axis defines the axis to use
  121062. */
  121063. setAxisForUpDown(axis: JoystickAxis): void;
  121064. private _drawVirtualJoystick;
  121065. /**
  121066. * Release internal HTML canvas
  121067. */
  121068. releaseCanvas(): void;
  121069. }
  121070. }
  121071. declare module BABYLON {
  121072. interface FreeCameraInputsManager {
  121073. /**
  121074. * Add virtual joystick input support to the input manager.
  121075. * @returns the current input manager
  121076. */
  121077. addVirtualJoystick(): FreeCameraInputsManager;
  121078. }
  121079. /**
  121080. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  121081. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  121082. */
  121083. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  121084. /**
  121085. * Defines the camera the input is attached to.
  121086. */
  121087. camera: FreeCamera;
  121088. private _leftjoystick;
  121089. private _rightjoystick;
  121090. /**
  121091. * Gets the left stick of the virtual joystick.
  121092. * @returns The virtual Joystick
  121093. */
  121094. getLeftJoystick(): VirtualJoystick;
  121095. /**
  121096. * Gets the right stick of the virtual joystick.
  121097. * @returns The virtual Joystick
  121098. */
  121099. getRightJoystick(): VirtualJoystick;
  121100. /**
  121101. * Update the current camera state depending on the inputs that have been used this frame.
  121102. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  121103. */
  121104. checkInputs(): void;
  121105. /**
  121106. * Attach the input controls to a specific dom element to get the input from.
  121107. * @param element Defines the element the controls should be listened from
  121108. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121109. */
  121110. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121111. /**
  121112. * Detach the current controls from the specified dom element.
  121113. * @param element Defines the element to stop listening the inputs from
  121114. */
  121115. detachControl(element: Nullable<HTMLElement>): void;
  121116. /**
  121117. * Gets the class name of the current intput.
  121118. * @returns the class name
  121119. */
  121120. getClassName(): string;
  121121. /**
  121122. * Get the friendly name associated with the input class.
  121123. * @returns the input friendly name
  121124. */
  121125. getSimpleName(): string;
  121126. }
  121127. }
  121128. declare module BABYLON {
  121129. /**
  121130. * This represents a FPS type of camera controlled by touch.
  121131. * This is like a universal camera minus the Gamepad controls.
  121132. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  121133. */
  121134. export class TouchCamera extends FreeCamera {
  121135. /**
  121136. * Defines the touch sensibility for rotation.
  121137. * The higher the faster.
  121138. */
  121139. get touchAngularSensibility(): number;
  121140. set touchAngularSensibility(value: number);
  121141. /**
  121142. * Defines the touch sensibility for move.
  121143. * The higher the faster.
  121144. */
  121145. get touchMoveSensibility(): number;
  121146. set touchMoveSensibility(value: number);
  121147. /**
  121148. * Instantiates a new touch camera.
  121149. * This represents a FPS type of camera controlled by touch.
  121150. * This is like a universal camera minus the Gamepad controls.
  121151. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  121152. * @param name Define the name of the camera in the scene
  121153. * @param position Define the start position of the camera in the scene
  121154. * @param scene Define the scene the camera belongs to
  121155. */
  121156. constructor(name: string, position: Vector3, scene: Scene);
  121157. /**
  121158. * Gets the current object class name.
  121159. * @return the class name
  121160. */
  121161. getClassName(): string;
  121162. /** @hidden */
  121163. _setupInputs(): void;
  121164. }
  121165. }
  121166. declare module BABYLON {
  121167. /**
  121168. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  121169. * being tilted forward or back and left or right.
  121170. */
  121171. export class DeviceOrientationCamera extends FreeCamera {
  121172. private _initialQuaternion;
  121173. private _quaternionCache;
  121174. private _tmpDragQuaternion;
  121175. private _disablePointerInputWhenUsingDeviceOrientation;
  121176. /**
  121177. * Creates a new device orientation camera
  121178. * @param name The name of the camera
  121179. * @param position The start position camera
  121180. * @param scene The scene the camera belongs to
  121181. */
  121182. constructor(name: string, position: Vector3, scene: Scene);
  121183. /**
  121184. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  121185. */
  121186. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  121187. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  121188. private _dragFactor;
  121189. /**
  121190. * Enabled turning on the y axis when the orientation sensor is active
  121191. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  121192. */
  121193. enableHorizontalDragging(dragFactor?: number): void;
  121194. /**
  121195. * Gets the current instance class name ("DeviceOrientationCamera").
  121196. * This helps avoiding instanceof at run time.
  121197. * @returns the class name
  121198. */
  121199. getClassName(): string;
  121200. /**
  121201. * @hidden
  121202. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  121203. */
  121204. _checkInputs(): void;
  121205. /**
  121206. * Reset the camera to its default orientation on the specified axis only.
  121207. * @param axis The axis to reset
  121208. */
  121209. resetToCurrentRotation(axis?: Axis): void;
  121210. }
  121211. }
  121212. declare module BABYLON {
  121213. /**
  121214. * Defines supported buttons for XBox360 compatible gamepads
  121215. */
  121216. export enum Xbox360Button {
  121217. /** A */
  121218. A = 0,
  121219. /** B */
  121220. B = 1,
  121221. /** X */
  121222. X = 2,
  121223. /** Y */
  121224. Y = 3,
  121225. /** Left button */
  121226. LB = 4,
  121227. /** Right button */
  121228. RB = 5,
  121229. /** Back */
  121230. Back = 8,
  121231. /** Start */
  121232. Start = 9,
  121233. /** Left stick */
  121234. LeftStick = 10,
  121235. /** Right stick */
  121236. RightStick = 11
  121237. }
  121238. /** Defines values for XBox360 DPad */
  121239. export enum Xbox360Dpad {
  121240. /** Up */
  121241. Up = 12,
  121242. /** Down */
  121243. Down = 13,
  121244. /** Left */
  121245. Left = 14,
  121246. /** Right */
  121247. Right = 15
  121248. }
  121249. /**
  121250. * Defines a XBox360 gamepad
  121251. */
  121252. export class Xbox360Pad extends Gamepad {
  121253. private _leftTrigger;
  121254. private _rightTrigger;
  121255. private _onlefttriggerchanged;
  121256. private _onrighttriggerchanged;
  121257. private _onbuttondown;
  121258. private _onbuttonup;
  121259. private _ondpaddown;
  121260. private _ondpadup;
  121261. /** Observable raised when a button is pressed */
  121262. onButtonDownObservable: Observable<Xbox360Button>;
  121263. /** Observable raised when a button is released */
  121264. onButtonUpObservable: Observable<Xbox360Button>;
  121265. /** Observable raised when a pad is pressed */
  121266. onPadDownObservable: Observable<Xbox360Dpad>;
  121267. /** Observable raised when a pad is released */
  121268. onPadUpObservable: Observable<Xbox360Dpad>;
  121269. private _buttonA;
  121270. private _buttonB;
  121271. private _buttonX;
  121272. private _buttonY;
  121273. private _buttonBack;
  121274. private _buttonStart;
  121275. private _buttonLB;
  121276. private _buttonRB;
  121277. private _buttonLeftStick;
  121278. private _buttonRightStick;
  121279. private _dPadUp;
  121280. private _dPadDown;
  121281. private _dPadLeft;
  121282. private _dPadRight;
  121283. private _isXboxOnePad;
  121284. /**
  121285. * Creates a new XBox360 gamepad object
  121286. * @param id defines the id of this gamepad
  121287. * @param index defines its index
  121288. * @param gamepad defines the internal HTML gamepad object
  121289. * @param xboxOne defines if it is a XBox One gamepad
  121290. */
  121291. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  121292. /**
  121293. * Defines the callback to call when left trigger is pressed
  121294. * @param callback defines the callback to use
  121295. */
  121296. onlefttriggerchanged(callback: (value: number) => void): void;
  121297. /**
  121298. * Defines the callback to call when right trigger is pressed
  121299. * @param callback defines the callback to use
  121300. */
  121301. onrighttriggerchanged(callback: (value: number) => void): void;
  121302. /**
  121303. * Gets the left trigger value
  121304. */
  121305. get leftTrigger(): number;
  121306. /**
  121307. * Sets the left trigger value
  121308. */
  121309. set leftTrigger(newValue: number);
  121310. /**
  121311. * Gets the right trigger value
  121312. */
  121313. get rightTrigger(): number;
  121314. /**
  121315. * Sets the right trigger value
  121316. */
  121317. set rightTrigger(newValue: number);
  121318. /**
  121319. * Defines the callback to call when a button is pressed
  121320. * @param callback defines the callback to use
  121321. */
  121322. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  121323. /**
  121324. * Defines the callback to call when a button is released
  121325. * @param callback defines the callback to use
  121326. */
  121327. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  121328. /**
  121329. * Defines the callback to call when a pad is pressed
  121330. * @param callback defines the callback to use
  121331. */
  121332. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  121333. /**
  121334. * Defines the callback to call when a pad is released
  121335. * @param callback defines the callback to use
  121336. */
  121337. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  121338. private _setButtonValue;
  121339. private _setDPadValue;
  121340. /**
  121341. * Gets the value of the `A` button
  121342. */
  121343. get buttonA(): number;
  121344. /**
  121345. * Sets the value of the `A` button
  121346. */
  121347. set buttonA(value: number);
  121348. /**
  121349. * Gets the value of the `B` button
  121350. */
  121351. get buttonB(): number;
  121352. /**
  121353. * Sets the value of the `B` button
  121354. */
  121355. set buttonB(value: number);
  121356. /**
  121357. * Gets the value of the `X` button
  121358. */
  121359. get buttonX(): number;
  121360. /**
  121361. * Sets the value of the `X` button
  121362. */
  121363. set buttonX(value: number);
  121364. /**
  121365. * Gets the value of the `Y` button
  121366. */
  121367. get buttonY(): number;
  121368. /**
  121369. * Sets the value of the `Y` button
  121370. */
  121371. set buttonY(value: number);
  121372. /**
  121373. * Gets the value of the `Start` button
  121374. */
  121375. get buttonStart(): number;
  121376. /**
  121377. * Sets the value of the `Start` button
  121378. */
  121379. set buttonStart(value: number);
  121380. /**
  121381. * Gets the value of the `Back` button
  121382. */
  121383. get buttonBack(): number;
  121384. /**
  121385. * Sets the value of the `Back` button
  121386. */
  121387. set buttonBack(value: number);
  121388. /**
  121389. * Gets the value of the `Left` button
  121390. */
  121391. get buttonLB(): number;
  121392. /**
  121393. * Sets the value of the `Left` button
  121394. */
  121395. set buttonLB(value: number);
  121396. /**
  121397. * Gets the value of the `Right` button
  121398. */
  121399. get buttonRB(): number;
  121400. /**
  121401. * Sets the value of the `Right` button
  121402. */
  121403. set buttonRB(value: number);
  121404. /**
  121405. * Gets the value of the Left joystick
  121406. */
  121407. get buttonLeftStick(): number;
  121408. /**
  121409. * Sets the value of the Left joystick
  121410. */
  121411. set buttonLeftStick(value: number);
  121412. /**
  121413. * Gets the value of the Right joystick
  121414. */
  121415. get buttonRightStick(): number;
  121416. /**
  121417. * Sets the value of the Right joystick
  121418. */
  121419. set buttonRightStick(value: number);
  121420. /**
  121421. * Gets the value of D-pad up
  121422. */
  121423. get dPadUp(): number;
  121424. /**
  121425. * Sets the value of D-pad up
  121426. */
  121427. set dPadUp(value: number);
  121428. /**
  121429. * Gets the value of D-pad down
  121430. */
  121431. get dPadDown(): number;
  121432. /**
  121433. * Sets the value of D-pad down
  121434. */
  121435. set dPadDown(value: number);
  121436. /**
  121437. * Gets the value of D-pad left
  121438. */
  121439. get dPadLeft(): number;
  121440. /**
  121441. * Sets the value of D-pad left
  121442. */
  121443. set dPadLeft(value: number);
  121444. /**
  121445. * Gets the value of D-pad right
  121446. */
  121447. get dPadRight(): number;
  121448. /**
  121449. * Sets the value of D-pad right
  121450. */
  121451. set dPadRight(value: number);
  121452. /**
  121453. * Force the gamepad to synchronize with device values
  121454. */
  121455. update(): void;
  121456. /**
  121457. * Disposes the gamepad
  121458. */
  121459. dispose(): void;
  121460. }
  121461. }
  121462. declare module BABYLON {
  121463. /**
  121464. * Defines supported buttons for DualShock compatible gamepads
  121465. */
  121466. export enum DualShockButton {
  121467. /** Cross */
  121468. Cross = 0,
  121469. /** Circle */
  121470. Circle = 1,
  121471. /** Square */
  121472. Square = 2,
  121473. /** Triangle */
  121474. Triangle = 3,
  121475. /** L1 */
  121476. L1 = 4,
  121477. /** R1 */
  121478. R1 = 5,
  121479. /** Share */
  121480. Share = 8,
  121481. /** Options */
  121482. Options = 9,
  121483. /** Left stick */
  121484. LeftStick = 10,
  121485. /** Right stick */
  121486. RightStick = 11
  121487. }
  121488. /** Defines values for DualShock DPad */
  121489. export enum DualShockDpad {
  121490. /** Up */
  121491. Up = 12,
  121492. /** Down */
  121493. Down = 13,
  121494. /** Left */
  121495. Left = 14,
  121496. /** Right */
  121497. Right = 15
  121498. }
  121499. /**
  121500. * Defines a DualShock gamepad
  121501. */
  121502. export class DualShockPad extends Gamepad {
  121503. private _leftTrigger;
  121504. private _rightTrigger;
  121505. private _onlefttriggerchanged;
  121506. private _onrighttriggerchanged;
  121507. private _onbuttondown;
  121508. private _onbuttonup;
  121509. private _ondpaddown;
  121510. private _ondpadup;
  121511. /** Observable raised when a button is pressed */
  121512. onButtonDownObservable: Observable<DualShockButton>;
  121513. /** Observable raised when a button is released */
  121514. onButtonUpObservable: Observable<DualShockButton>;
  121515. /** Observable raised when a pad is pressed */
  121516. onPadDownObservable: Observable<DualShockDpad>;
  121517. /** Observable raised when a pad is released */
  121518. onPadUpObservable: Observable<DualShockDpad>;
  121519. private _buttonCross;
  121520. private _buttonCircle;
  121521. private _buttonSquare;
  121522. private _buttonTriangle;
  121523. private _buttonShare;
  121524. private _buttonOptions;
  121525. private _buttonL1;
  121526. private _buttonR1;
  121527. private _buttonLeftStick;
  121528. private _buttonRightStick;
  121529. private _dPadUp;
  121530. private _dPadDown;
  121531. private _dPadLeft;
  121532. private _dPadRight;
  121533. /**
  121534. * Creates a new DualShock gamepad object
  121535. * @param id defines the id of this gamepad
  121536. * @param index defines its index
  121537. * @param gamepad defines the internal HTML gamepad object
  121538. */
  121539. constructor(id: string, index: number, gamepad: any);
  121540. /**
  121541. * Defines the callback to call when left trigger is pressed
  121542. * @param callback defines the callback to use
  121543. */
  121544. onlefttriggerchanged(callback: (value: number) => void): void;
  121545. /**
  121546. * Defines the callback to call when right trigger is pressed
  121547. * @param callback defines the callback to use
  121548. */
  121549. onrighttriggerchanged(callback: (value: number) => void): void;
  121550. /**
  121551. * Gets the left trigger value
  121552. */
  121553. get leftTrigger(): number;
  121554. /**
  121555. * Sets the left trigger value
  121556. */
  121557. set leftTrigger(newValue: number);
  121558. /**
  121559. * Gets the right trigger value
  121560. */
  121561. get rightTrigger(): number;
  121562. /**
  121563. * Sets the right trigger value
  121564. */
  121565. set rightTrigger(newValue: number);
  121566. /**
  121567. * Defines the callback to call when a button is pressed
  121568. * @param callback defines the callback to use
  121569. */
  121570. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  121571. /**
  121572. * Defines the callback to call when a button is released
  121573. * @param callback defines the callback to use
  121574. */
  121575. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  121576. /**
  121577. * Defines the callback to call when a pad is pressed
  121578. * @param callback defines the callback to use
  121579. */
  121580. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  121581. /**
  121582. * Defines the callback to call when a pad is released
  121583. * @param callback defines the callback to use
  121584. */
  121585. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  121586. private _setButtonValue;
  121587. private _setDPadValue;
  121588. /**
  121589. * Gets the value of the `Cross` button
  121590. */
  121591. get buttonCross(): number;
  121592. /**
  121593. * Sets the value of the `Cross` button
  121594. */
  121595. set buttonCross(value: number);
  121596. /**
  121597. * Gets the value of the `Circle` button
  121598. */
  121599. get buttonCircle(): number;
  121600. /**
  121601. * Sets the value of the `Circle` button
  121602. */
  121603. set buttonCircle(value: number);
  121604. /**
  121605. * Gets the value of the `Square` button
  121606. */
  121607. get buttonSquare(): number;
  121608. /**
  121609. * Sets the value of the `Square` button
  121610. */
  121611. set buttonSquare(value: number);
  121612. /**
  121613. * Gets the value of the `Triangle` button
  121614. */
  121615. get buttonTriangle(): number;
  121616. /**
  121617. * Sets the value of the `Triangle` button
  121618. */
  121619. set buttonTriangle(value: number);
  121620. /**
  121621. * Gets the value of the `Options` button
  121622. */
  121623. get buttonOptions(): number;
  121624. /**
  121625. * Sets the value of the `Options` button
  121626. */
  121627. set buttonOptions(value: number);
  121628. /**
  121629. * Gets the value of the `Share` button
  121630. */
  121631. get buttonShare(): number;
  121632. /**
  121633. * Sets the value of the `Share` button
  121634. */
  121635. set buttonShare(value: number);
  121636. /**
  121637. * Gets the value of the `L1` button
  121638. */
  121639. get buttonL1(): number;
  121640. /**
  121641. * Sets the value of the `L1` button
  121642. */
  121643. set buttonL1(value: number);
  121644. /**
  121645. * Gets the value of the `R1` button
  121646. */
  121647. get buttonR1(): number;
  121648. /**
  121649. * Sets the value of the `R1` button
  121650. */
  121651. set buttonR1(value: number);
  121652. /**
  121653. * Gets the value of the Left joystick
  121654. */
  121655. get buttonLeftStick(): number;
  121656. /**
  121657. * Sets the value of the Left joystick
  121658. */
  121659. set buttonLeftStick(value: number);
  121660. /**
  121661. * Gets the value of the Right joystick
  121662. */
  121663. get buttonRightStick(): number;
  121664. /**
  121665. * Sets the value of the Right joystick
  121666. */
  121667. set buttonRightStick(value: number);
  121668. /**
  121669. * Gets the value of D-pad up
  121670. */
  121671. get dPadUp(): number;
  121672. /**
  121673. * Sets the value of D-pad up
  121674. */
  121675. set dPadUp(value: number);
  121676. /**
  121677. * Gets the value of D-pad down
  121678. */
  121679. get dPadDown(): number;
  121680. /**
  121681. * Sets the value of D-pad down
  121682. */
  121683. set dPadDown(value: number);
  121684. /**
  121685. * Gets the value of D-pad left
  121686. */
  121687. get dPadLeft(): number;
  121688. /**
  121689. * Sets the value of D-pad left
  121690. */
  121691. set dPadLeft(value: number);
  121692. /**
  121693. * Gets the value of D-pad right
  121694. */
  121695. get dPadRight(): number;
  121696. /**
  121697. * Sets the value of D-pad right
  121698. */
  121699. set dPadRight(value: number);
  121700. /**
  121701. * Force the gamepad to synchronize with device values
  121702. */
  121703. update(): void;
  121704. /**
  121705. * Disposes the gamepad
  121706. */
  121707. dispose(): void;
  121708. }
  121709. }
  121710. declare module BABYLON {
  121711. /**
  121712. * Manager for handling gamepads
  121713. */
  121714. export class GamepadManager {
  121715. private _scene?;
  121716. private _babylonGamepads;
  121717. private _oneGamepadConnected;
  121718. /** @hidden */
  121719. _isMonitoring: boolean;
  121720. private _gamepadEventSupported;
  121721. private _gamepadSupport?;
  121722. /**
  121723. * observable to be triggered when the gamepad controller has been connected
  121724. */
  121725. onGamepadConnectedObservable: Observable<Gamepad>;
  121726. /**
  121727. * observable to be triggered when the gamepad controller has been disconnected
  121728. */
  121729. onGamepadDisconnectedObservable: Observable<Gamepad>;
  121730. private _onGamepadConnectedEvent;
  121731. private _onGamepadDisconnectedEvent;
  121732. /**
  121733. * Initializes the gamepad manager
  121734. * @param _scene BabylonJS scene
  121735. */
  121736. constructor(_scene?: Scene | undefined);
  121737. /**
  121738. * The gamepads in the game pad manager
  121739. */
  121740. get gamepads(): Gamepad[];
  121741. /**
  121742. * Get the gamepad controllers based on type
  121743. * @param type The type of gamepad controller
  121744. * @returns Nullable gamepad
  121745. */
  121746. getGamepadByType(type?: number): Nullable<Gamepad>;
  121747. /**
  121748. * Disposes the gamepad manager
  121749. */
  121750. dispose(): void;
  121751. private _addNewGamepad;
  121752. private _startMonitoringGamepads;
  121753. private _stopMonitoringGamepads;
  121754. /** @hidden */
  121755. _checkGamepadsStatus(): void;
  121756. private _updateGamepadObjects;
  121757. }
  121758. }
  121759. declare module BABYLON {
  121760. interface Scene {
  121761. /** @hidden */
  121762. _gamepadManager: Nullable<GamepadManager>;
  121763. /**
  121764. * Gets the gamepad manager associated with the scene
  121765. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  121766. */
  121767. gamepadManager: GamepadManager;
  121768. }
  121769. /**
  121770. * Interface representing a free camera inputs manager
  121771. */
  121772. interface FreeCameraInputsManager {
  121773. /**
  121774. * Adds gamepad input support to the FreeCameraInputsManager.
  121775. * @returns the FreeCameraInputsManager
  121776. */
  121777. addGamepad(): FreeCameraInputsManager;
  121778. }
  121779. /**
  121780. * Interface representing an arc rotate camera inputs manager
  121781. */
  121782. interface ArcRotateCameraInputsManager {
  121783. /**
  121784. * Adds gamepad input support to the ArcRotateCamera InputManager.
  121785. * @returns the camera inputs manager
  121786. */
  121787. addGamepad(): ArcRotateCameraInputsManager;
  121788. }
  121789. /**
  121790. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  121791. */
  121792. export class GamepadSystemSceneComponent implements ISceneComponent {
  121793. /**
  121794. * The component name helpfull to identify the component in the list of scene components.
  121795. */
  121796. readonly name: string;
  121797. /**
  121798. * The scene the component belongs to.
  121799. */
  121800. scene: Scene;
  121801. /**
  121802. * Creates a new instance of the component for the given scene
  121803. * @param scene Defines the scene to register the component in
  121804. */
  121805. constructor(scene: Scene);
  121806. /**
  121807. * Registers the component in a given scene
  121808. */
  121809. register(): void;
  121810. /**
  121811. * Rebuilds the elements related to this component in case of
  121812. * context lost for instance.
  121813. */
  121814. rebuild(): void;
  121815. /**
  121816. * Disposes the component and the associated ressources
  121817. */
  121818. dispose(): void;
  121819. private _beforeCameraUpdate;
  121820. }
  121821. }
  121822. declare module BABYLON {
  121823. /**
  121824. * 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,
  121825. * which still works and will still be found in many Playgrounds.
  121826. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  121827. */
  121828. export class UniversalCamera extends TouchCamera {
  121829. /**
  121830. * Defines the gamepad rotation sensiblity.
  121831. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  121832. */
  121833. get gamepadAngularSensibility(): number;
  121834. set gamepadAngularSensibility(value: number);
  121835. /**
  121836. * Defines the gamepad move sensiblity.
  121837. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  121838. */
  121839. get gamepadMoveSensibility(): number;
  121840. set gamepadMoveSensibility(value: number);
  121841. /**
  121842. * 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,
  121843. * which still works and will still be found in many Playgrounds.
  121844. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  121845. * @param name Define the name of the camera in the scene
  121846. * @param position Define the start position of the camera in the scene
  121847. * @param scene Define the scene the camera belongs to
  121848. */
  121849. constructor(name: string, position: Vector3, scene: Scene);
  121850. /**
  121851. * Gets the current object class name.
  121852. * @return the class name
  121853. */
  121854. getClassName(): string;
  121855. }
  121856. }
  121857. declare module BABYLON {
  121858. /**
  121859. * This represents a FPS type of camera. This is only here for back compat purpose.
  121860. * Please use the UniversalCamera instead as both are identical.
  121861. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  121862. */
  121863. export class GamepadCamera extends UniversalCamera {
  121864. /**
  121865. * Instantiates a new Gamepad Camera
  121866. * This represents a FPS type of camera. This is only here for back compat purpose.
  121867. * Please use the UniversalCamera instead as both are identical.
  121868. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  121869. * @param name Define the name of the camera in the scene
  121870. * @param position Define the start position of the camera in the scene
  121871. * @param scene Define the scene the camera belongs to
  121872. */
  121873. constructor(name: string, position: Vector3, scene: Scene);
  121874. /**
  121875. * Gets the current object class name.
  121876. * @return the class name
  121877. */
  121878. getClassName(): string;
  121879. }
  121880. }
  121881. declare module BABYLON {
  121882. /** @hidden */
  121883. export var passPixelShader: {
  121884. name: string;
  121885. shader: string;
  121886. };
  121887. }
  121888. declare module BABYLON {
  121889. /** @hidden */
  121890. export var passCubePixelShader: {
  121891. name: string;
  121892. shader: string;
  121893. };
  121894. }
  121895. declare module BABYLON {
  121896. /**
  121897. * PassPostProcess which produces an output the same as it's input
  121898. */
  121899. export class PassPostProcess extends PostProcess {
  121900. /**
  121901. * Creates the PassPostProcess
  121902. * @param name The name of the effect.
  121903. * @param options The required width/height ratio to downsize to before computing the render pass.
  121904. * @param camera The camera to apply the render pass to.
  121905. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121906. * @param engine The engine which the post process will be applied. (default: current engine)
  121907. * @param reusable If the post process can be reused on the same frame. (default: false)
  121908. * @param textureType The type of texture to be used when performing the post processing.
  121909. * @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)
  121910. */
  121911. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  121912. }
  121913. /**
  121914. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  121915. */
  121916. export class PassCubePostProcess extends PostProcess {
  121917. private _face;
  121918. /**
  121919. * Gets or sets the cube face to display.
  121920. * * 0 is +X
  121921. * * 1 is -X
  121922. * * 2 is +Y
  121923. * * 3 is -Y
  121924. * * 4 is +Z
  121925. * * 5 is -Z
  121926. */
  121927. get face(): number;
  121928. set face(value: number);
  121929. /**
  121930. * Creates the PassCubePostProcess
  121931. * @param name The name of the effect.
  121932. * @param options The required width/height ratio to downsize to before computing the render pass.
  121933. * @param camera The camera to apply the render pass to.
  121934. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121935. * @param engine The engine which the post process will be applied. (default: current engine)
  121936. * @param reusable If the post process can be reused on the same frame. (default: false)
  121937. * @param textureType The type of texture to be used when performing the post processing.
  121938. * @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)
  121939. */
  121940. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  121941. }
  121942. }
  121943. declare module BABYLON {
  121944. /** @hidden */
  121945. export var anaglyphPixelShader: {
  121946. name: string;
  121947. shader: string;
  121948. };
  121949. }
  121950. declare module BABYLON {
  121951. /**
  121952. * Postprocess used to generate anaglyphic rendering
  121953. */
  121954. export class AnaglyphPostProcess extends PostProcess {
  121955. private _passedProcess;
  121956. /**
  121957. * Creates a new AnaglyphPostProcess
  121958. * @param name defines postprocess name
  121959. * @param options defines creation options or target ratio scale
  121960. * @param rigCameras defines cameras using this postprocess
  121961. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  121962. * @param engine defines hosting engine
  121963. * @param reusable defines if the postprocess will be reused multiple times per frame
  121964. */
  121965. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  121966. }
  121967. }
  121968. declare module BABYLON {
  121969. /**
  121970. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  121971. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  121972. */
  121973. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  121974. /**
  121975. * Creates a new AnaglyphArcRotateCamera
  121976. * @param name defines camera name
  121977. * @param alpha defines alpha angle (in radians)
  121978. * @param beta defines beta angle (in radians)
  121979. * @param radius defines radius
  121980. * @param target defines camera target
  121981. * @param interaxialDistance defines distance between each color axis
  121982. * @param scene defines the hosting scene
  121983. */
  121984. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  121985. /**
  121986. * Gets camera class name
  121987. * @returns AnaglyphArcRotateCamera
  121988. */
  121989. getClassName(): string;
  121990. }
  121991. }
  121992. declare module BABYLON {
  121993. /**
  121994. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  121995. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  121996. */
  121997. export class AnaglyphFreeCamera extends FreeCamera {
  121998. /**
  121999. * Creates a new AnaglyphFreeCamera
  122000. * @param name defines camera name
  122001. * @param position defines initial position
  122002. * @param interaxialDistance defines distance between each color axis
  122003. * @param scene defines the hosting scene
  122004. */
  122005. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  122006. /**
  122007. * Gets camera class name
  122008. * @returns AnaglyphFreeCamera
  122009. */
  122010. getClassName(): string;
  122011. }
  122012. }
  122013. declare module BABYLON {
  122014. /**
  122015. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  122016. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  122017. */
  122018. export class AnaglyphGamepadCamera extends GamepadCamera {
  122019. /**
  122020. * Creates a new AnaglyphGamepadCamera
  122021. * @param name defines camera name
  122022. * @param position defines initial position
  122023. * @param interaxialDistance defines distance between each color axis
  122024. * @param scene defines the hosting scene
  122025. */
  122026. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  122027. /**
  122028. * Gets camera class name
  122029. * @returns AnaglyphGamepadCamera
  122030. */
  122031. getClassName(): string;
  122032. }
  122033. }
  122034. declare module BABYLON {
  122035. /**
  122036. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  122037. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  122038. */
  122039. export class AnaglyphUniversalCamera extends UniversalCamera {
  122040. /**
  122041. * Creates a new AnaglyphUniversalCamera
  122042. * @param name defines camera name
  122043. * @param position defines initial position
  122044. * @param interaxialDistance defines distance between each color axis
  122045. * @param scene defines the hosting scene
  122046. */
  122047. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  122048. /**
  122049. * Gets camera class name
  122050. * @returns AnaglyphUniversalCamera
  122051. */
  122052. getClassName(): string;
  122053. }
  122054. }
  122055. declare module BABYLON {
  122056. /**
  122057. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  122058. * @see http://doc.babylonjs.com/features/cameras
  122059. */
  122060. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  122061. /**
  122062. * Creates a new StereoscopicArcRotateCamera
  122063. * @param name defines camera name
  122064. * @param alpha defines alpha angle (in radians)
  122065. * @param beta defines beta angle (in radians)
  122066. * @param radius defines radius
  122067. * @param target defines camera target
  122068. * @param interaxialDistance defines distance between each color axis
  122069. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  122070. * @param scene defines the hosting scene
  122071. */
  122072. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  122073. /**
  122074. * Gets camera class name
  122075. * @returns StereoscopicArcRotateCamera
  122076. */
  122077. getClassName(): string;
  122078. }
  122079. }
  122080. declare module BABYLON {
  122081. /**
  122082. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  122083. * @see http://doc.babylonjs.com/features/cameras
  122084. */
  122085. export class StereoscopicFreeCamera extends FreeCamera {
  122086. /**
  122087. * Creates a new StereoscopicFreeCamera
  122088. * @param name defines camera name
  122089. * @param position defines initial position
  122090. * @param interaxialDistance defines distance between each color axis
  122091. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  122092. * @param scene defines the hosting scene
  122093. */
  122094. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  122095. /**
  122096. * Gets camera class name
  122097. * @returns StereoscopicFreeCamera
  122098. */
  122099. getClassName(): string;
  122100. }
  122101. }
  122102. declare module BABYLON {
  122103. /**
  122104. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  122105. * @see http://doc.babylonjs.com/features/cameras
  122106. */
  122107. export class StereoscopicGamepadCamera extends GamepadCamera {
  122108. /**
  122109. * Creates a new StereoscopicGamepadCamera
  122110. * @param name defines camera name
  122111. * @param position defines initial position
  122112. * @param interaxialDistance defines distance between each color axis
  122113. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  122114. * @param scene defines the hosting scene
  122115. */
  122116. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  122117. /**
  122118. * Gets camera class name
  122119. * @returns StereoscopicGamepadCamera
  122120. */
  122121. getClassName(): string;
  122122. }
  122123. }
  122124. declare module BABYLON {
  122125. /**
  122126. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  122127. * @see http://doc.babylonjs.com/features/cameras
  122128. */
  122129. export class StereoscopicUniversalCamera extends UniversalCamera {
  122130. /**
  122131. * Creates a new StereoscopicUniversalCamera
  122132. * @param name defines camera name
  122133. * @param position defines initial position
  122134. * @param interaxialDistance defines distance between each color axis
  122135. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  122136. * @param scene defines the hosting scene
  122137. */
  122138. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  122139. /**
  122140. * Gets camera class name
  122141. * @returns StereoscopicUniversalCamera
  122142. */
  122143. getClassName(): string;
  122144. }
  122145. }
  122146. declare module BABYLON {
  122147. /**
  122148. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  122149. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  122150. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  122151. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  122152. */
  122153. export class VirtualJoysticksCamera extends FreeCamera {
  122154. /**
  122155. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  122156. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  122157. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  122158. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  122159. * @param name Define the name of the camera in the scene
  122160. * @param position Define the start position of the camera in the scene
  122161. * @param scene Define the scene the camera belongs to
  122162. */
  122163. constructor(name: string, position: Vector3, scene: Scene);
  122164. /**
  122165. * Gets the current object class name.
  122166. * @return the class name
  122167. */
  122168. getClassName(): string;
  122169. }
  122170. }
  122171. declare module BABYLON {
  122172. /**
  122173. * This represents all the required metrics to create a VR camera.
  122174. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  122175. */
  122176. export class VRCameraMetrics {
  122177. /**
  122178. * Define the horizontal resolution off the screen.
  122179. */
  122180. hResolution: number;
  122181. /**
  122182. * Define the vertical resolution off the screen.
  122183. */
  122184. vResolution: number;
  122185. /**
  122186. * Define the horizontal screen size.
  122187. */
  122188. hScreenSize: number;
  122189. /**
  122190. * Define the vertical screen size.
  122191. */
  122192. vScreenSize: number;
  122193. /**
  122194. * Define the vertical screen center position.
  122195. */
  122196. vScreenCenter: number;
  122197. /**
  122198. * Define the distance of the eyes to the screen.
  122199. */
  122200. eyeToScreenDistance: number;
  122201. /**
  122202. * Define the distance between both lenses
  122203. */
  122204. lensSeparationDistance: number;
  122205. /**
  122206. * Define the distance between both viewer's eyes.
  122207. */
  122208. interpupillaryDistance: number;
  122209. /**
  122210. * Define the distortion factor of the VR postprocess.
  122211. * Please, touch with care.
  122212. */
  122213. distortionK: number[];
  122214. /**
  122215. * Define the chromatic aberration correction factors for the VR post process.
  122216. */
  122217. chromaAbCorrection: number[];
  122218. /**
  122219. * Define the scale factor of the post process.
  122220. * The smaller the better but the slower.
  122221. */
  122222. postProcessScaleFactor: number;
  122223. /**
  122224. * Define an offset for the lens center.
  122225. */
  122226. lensCenterOffset: number;
  122227. /**
  122228. * Define if the current vr camera should compensate the distortion of the lense or not.
  122229. */
  122230. compensateDistortion: boolean;
  122231. /**
  122232. * Defines if multiview should be enabled when rendering (Default: false)
  122233. */
  122234. multiviewEnabled: boolean;
  122235. /**
  122236. * Gets the rendering aspect ratio based on the provided resolutions.
  122237. */
  122238. get aspectRatio(): number;
  122239. /**
  122240. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  122241. */
  122242. get aspectRatioFov(): number;
  122243. /**
  122244. * @hidden
  122245. */
  122246. get leftHMatrix(): Matrix;
  122247. /**
  122248. * @hidden
  122249. */
  122250. get rightHMatrix(): Matrix;
  122251. /**
  122252. * @hidden
  122253. */
  122254. get leftPreViewMatrix(): Matrix;
  122255. /**
  122256. * @hidden
  122257. */
  122258. get rightPreViewMatrix(): Matrix;
  122259. /**
  122260. * Get the default VRMetrics based on the most generic setup.
  122261. * @returns the default vr metrics
  122262. */
  122263. static GetDefault(): VRCameraMetrics;
  122264. }
  122265. }
  122266. declare module BABYLON {
  122267. /** @hidden */
  122268. export var vrDistortionCorrectionPixelShader: {
  122269. name: string;
  122270. shader: string;
  122271. };
  122272. }
  122273. declare module BABYLON {
  122274. /**
  122275. * VRDistortionCorrectionPostProcess used for mobile VR
  122276. */
  122277. export class VRDistortionCorrectionPostProcess extends PostProcess {
  122278. private _isRightEye;
  122279. private _distortionFactors;
  122280. private _postProcessScaleFactor;
  122281. private _lensCenterOffset;
  122282. private _scaleIn;
  122283. private _scaleFactor;
  122284. private _lensCenter;
  122285. /**
  122286. * Initializes the VRDistortionCorrectionPostProcess
  122287. * @param name The name of the effect.
  122288. * @param camera The camera to apply the render pass to.
  122289. * @param isRightEye If this is for the right eye distortion
  122290. * @param vrMetrics All the required metrics for the VR camera
  122291. */
  122292. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  122293. }
  122294. }
  122295. declare module BABYLON {
  122296. /**
  122297. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  122298. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  122299. */
  122300. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  122301. /**
  122302. * Creates a new VRDeviceOrientationArcRotateCamera
  122303. * @param name defines camera name
  122304. * @param alpha defines the camera rotation along the logitudinal axis
  122305. * @param beta defines the camera rotation along the latitudinal axis
  122306. * @param radius defines the camera distance from its target
  122307. * @param target defines the camera target
  122308. * @param scene defines the scene the camera belongs to
  122309. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  122310. * @param vrCameraMetrics defines the vr metrics associated to the camera
  122311. */
  122312. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  122313. /**
  122314. * Gets camera class name
  122315. * @returns VRDeviceOrientationArcRotateCamera
  122316. */
  122317. getClassName(): string;
  122318. }
  122319. }
  122320. declare module BABYLON {
  122321. /**
  122322. * Camera used to simulate VR rendering (based on FreeCamera)
  122323. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  122324. */
  122325. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  122326. /**
  122327. * Creates a new VRDeviceOrientationFreeCamera
  122328. * @param name defines camera name
  122329. * @param position defines the start position of the camera
  122330. * @param scene defines the scene the camera belongs to
  122331. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  122332. * @param vrCameraMetrics defines the vr metrics associated to the camera
  122333. */
  122334. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  122335. /**
  122336. * Gets camera class name
  122337. * @returns VRDeviceOrientationFreeCamera
  122338. */
  122339. getClassName(): string;
  122340. }
  122341. }
  122342. declare module BABYLON {
  122343. /**
  122344. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  122345. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  122346. */
  122347. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  122348. /**
  122349. * Creates a new VRDeviceOrientationGamepadCamera
  122350. * @param name defines camera name
  122351. * @param position defines the start position of the camera
  122352. * @param scene defines the scene the camera belongs to
  122353. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  122354. * @param vrCameraMetrics defines the vr metrics associated to the camera
  122355. */
  122356. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  122357. /**
  122358. * Gets camera class name
  122359. * @returns VRDeviceOrientationGamepadCamera
  122360. */
  122361. getClassName(): string;
  122362. }
  122363. }
  122364. declare module BABYLON {
  122365. /** @hidden */
  122366. export var imageProcessingPixelShader: {
  122367. name: string;
  122368. shader: string;
  122369. };
  122370. }
  122371. declare module BABYLON {
  122372. /**
  122373. * ImageProcessingPostProcess
  122374. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  122375. */
  122376. export class ImageProcessingPostProcess extends PostProcess {
  122377. /**
  122378. * Default configuration related to image processing available in the PBR Material.
  122379. */
  122380. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  122381. /**
  122382. * Gets the image processing configuration used either in this material.
  122383. */
  122384. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  122385. /**
  122386. * Sets the Default image processing configuration used either in the this material.
  122387. *
  122388. * If sets to null, the scene one is in use.
  122389. */
  122390. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  122391. /**
  122392. * Keep track of the image processing observer to allow dispose and replace.
  122393. */
  122394. private _imageProcessingObserver;
  122395. /**
  122396. * Attaches a new image processing configuration to the PBR Material.
  122397. * @param configuration
  122398. */
  122399. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  122400. /**
  122401. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  122402. */
  122403. get colorCurves(): Nullable<ColorCurves>;
  122404. /**
  122405. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  122406. */
  122407. set colorCurves(value: Nullable<ColorCurves>);
  122408. /**
  122409. * Gets wether the color curves effect is enabled.
  122410. */
  122411. get colorCurvesEnabled(): boolean;
  122412. /**
  122413. * Sets wether the color curves effect is enabled.
  122414. */
  122415. set colorCurvesEnabled(value: boolean);
  122416. /**
  122417. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  122418. */
  122419. get colorGradingTexture(): Nullable<BaseTexture>;
  122420. /**
  122421. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  122422. */
  122423. set colorGradingTexture(value: Nullable<BaseTexture>);
  122424. /**
  122425. * Gets wether the color grading effect is enabled.
  122426. */
  122427. get colorGradingEnabled(): boolean;
  122428. /**
  122429. * Gets wether the color grading effect is enabled.
  122430. */
  122431. set colorGradingEnabled(value: boolean);
  122432. /**
  122433. * Gets exposure used in the effect.
  122434. */
  122435. get exposure(): number;
  122436. /**
  122437. * Sets exposure used in the effect.
  122438. */
  122439. set exposure(value: number);
  122440. /**
  122441. * Gets wether tonemapping is enabled or not.
  122442. */
  122443. get toneMappingEnabled(): boolean;
  122444. /**
  122445. * Sets wether tonemapping is enabled or not
  122446. */
  122447. set toneMappingEnabled(value: boolean);
  122448. /**
  122449. * Gets the type of tone mapping effect.
  122450. */
  122451. get toneMappingType(): number;
  122452. /**
  122453. * Sets the type of tone mapping effect.
  122454. */
  122455. set toneMappingType(value: number);
  122456. /**
  122457. * Gets contrast used in the effect.
  122458. */
  122459. get contrast(): number;
  122460. /**
  122461. * Sets contrast used in the effect.
  122462. */
  122463. set contrast(value: number);
  122464. /**
  122465. * Gets Vignette stretch size.
  122466. */
  122467. get vignetteStretch(): number;
  122468. /**
  122469. * Sets Vignette stretch size.
  122470. */
  122471. set vignetteStretch(value: number);
  122472. /**
  122473. * Gets Vignette centre X Offset.
  122474. */
  122475. get vignetteCentreX(): number;
  122476. /**
  122477. * Sets Vignette centre X Offset.
  122478. */
  122479. set vignetteCentreX(value: number);
  122480. /**
  122481. * Gets Vignette centre Y Offset.
  122482. */
  122483. get vignetteCentreY(): number;
  122484. /**
  122485. * Sets Vignette centre Y Offset.
  122486. */
  122487. set vignetteCentreY(value: number);
  122488. /**
  122489. * Gets Vignette weight or intensity of the vignette effect.
  122490. */
  122491. get vignetteWeight(): number;
  122492. /**
  122493. * Sets Vignette weight or intensity of the vignette effect.
  122494. */
  122495. set vignetteWeight(value: number);
  122496. /**
  122497. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  122498. * if vignetteEnabled is set to true.
  122499. */
  122500. get vignetteColor(): Color4;
  122501. /**
  122502. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  122503. * if vignetteEnabled is set to true.
  122504. */
  122505. set vignetteColor(value: Color4);
  122506. /**
  122507. * Gets Camera field of view used by the Vignette effect.
  122508. */
  122509. get vignetteCameraFov(): number;
  122510. /**
  122511. * Sets Camera field of view used by the Vignette effect.
  122512. */
  122513. set vignetteCameraFov(value: number);
  122514. /**
  122515. * Gets the vignette blend mode allowing different kind of effect.
  122516. */
  122517. get vignetteBlendMode(): number;
  122518. /**
  122519. * Sets the vignette blend mode allowing different kind of effect.
  122520. */
  122521. set vignetteBlendMode(value: number);
  122522. /**
  122523. * Gets wether the vignette effect is enabled.
  122524. */
  122525. get vignetteEnabled(): boolean;
  122526. /**
  122527. * Sets wether the vignette effect is enabled.
  122528. */
  122529. set vignetteEnabled(value: boolean);
  122530. private _fromLinearSpace;
  122531. /**
  122532. * Gets wether the input of the processing is in Gamma or Linear Space.
  122533. */
  122534. get fromLinearSpace(): boolean;
  122535. /**
  122536. * Sets wether the input of the processing is in Gamma or Linear Space.
  122537. */
  122538. set fromLinearSpace(value: boolean);
  122539. /**
  122540. * Defines cache preventing GC.
  122541. */
  122542. private _defines;
  122543. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  122544. /**
  122545. * "ImageProcessingPostProcess"
  122546. * @returns "ImageProcessingPostProcess"
  122547. */
  122548. getClassName(): string;
  122549. protected _updateParameters(): void;
  122550. dispose(camera?: Camera): void;
  122551. }
  122552. }
  122553. declare module BABYLON {
  122554. /**
  122555. * Class containing static functions to help procedurally build meshes
  122556. */
  122557. export class GroundBuilder {
  122558. /**
  122559. * Creates a ground mesh
  122560. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  122561. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  122562. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122563. * @param name defines the name of the mesh
  122564. * @param options defines the options used to create the mesh
  122565. * @param scene defines the hosting scene
  122566. * @returns the ground mesh
  122567. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  122568. */
  122569. static CreateGround(name: string, options: {
  122570. width?: number;
  122571. height?: number;
  122572. subdivisions?: number;
  122573. subdivisionsX?: number;
  122574. subdivisionsY?: number;
  122575. updatable?: boolean;
  122576. }, scene: any): Mesh;
  122577. /**
  122578. * Creates a tiled ground mesh
  122579. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  122580. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  122581. * * 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
  122582. * * 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
  122583. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  122584. * @param name defines the name of the mesh
  122585. * @param options defines the options used to create the mesh
  122586. * @param scene defines the hosting scene
  122587. * @returns the tiled ground mesh
  122588. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  122589. */
  122590. static CreateTiledGround(name: string, options: {
  122591. xmin: number;
  122592. zmin: number;
  122593. xmax: number;
  122594. zmax: number;
  122595. subdivisions?: {
  122596. w: number;
  122597. h: number;
  122598. };
  122599. precision?: {
  122600. w: number;
  122601. h: number;
  122602. };
  122603. updatable?: boolean;
  122604. }, scene?: Nullable<Scene>): Mesh;
  122605. /**
  122606. * Creates a ground mesh from a height map
  122607. * * The parameter `url` sets the URL of the height map image resource.
  122608. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  122609. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  122610. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  122611. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  122612. * * 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.
  122613. * * 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).
  122614. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  122615. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  122616. * @param name defines the name of the mesh
  122617. * @param url defines the url to the height map
  122618. * @param options defines the options used to create the mesh
  122619. * @param scene defines the hosting scene
  122620. * @returns the ground mesh
  122621. * @see https://doc.babylonjs.com/babylon101/height_map
  122622. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  122623. */
  122624. static CreateGroundFromHeightMap(name: string, url: string, options: {
  122625. width?: number;
  122626. height?: number;
  122627. subdivisions?: number;
  122628. minHeight?: number;
  122629. maxHeight?: number;
  122630. colorFilter?: Color3;
  122631. alphaFilter?: number;
  122632. updatable?: boolean;
  122633. onReady?: (mesh: GroundMesh) => void;
  122634. }, scene?: Nullable<Scene>): GroundMesh;
  122635. }
  122636. }
  122637. declare module BABYLON {
  122638. /**
  122639. * Class containing static functions to help procedurally build meshes
  122640. */
  122641. export class TorusBuilder {
  122642. /**
  122643. * Creates a torus mesh
  122644. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  122645. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  122646. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  122647. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122648. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122649. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  122650. * @param name defines the name of the mesh
  122651. * @param options defines the options used to create the mesh
  122652. * @param scene defines the hosting scene
  122653. * @returns the torus mesh
  122654. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  122655. */
  122656. static CreateTorus(name: string, options: {
  122657. diameter?: number;
  122658. thickness?: number;
  122659. tessellation?: number;
  122660. updatable?: boolean;
  122661. sideOrientation?: number;
  122662. frontUVs?: Vector4;
  122663. backUVs?: Vector4;
  122664. }, scene: any): Mesh;
  122665. }
  122666. }
  122667. declare module BABYLON {
  122668. /**
  122669. * Class containing static functions to help procedurally build meshes
  122670. */
  122671. export class CylinderBuilder {
  122672. /**
  122673. * Creates a cylinder or a cone mesh
  122674. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  122675. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  122676. * * 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.
  122677. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  122678. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  122679. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  122680. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  122681. * * 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).
  122682. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  122683. * * 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).
  122684. * * 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
  122685. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  122686. * * 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
  122687. * * 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.
  122688. * * If `enclose` is false, a ring surface is one element.
  122689. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  122690. * * 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
  122691. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122692. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122693. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  122694. * @param name defines the name of the mesh
  122695. * @param options defines the options used to create the mesh
  122696. * @param scene defines the hosting scene
  122697. * @returns the cylinder mesh
  122698. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  122699. */
  122700. static CreateCylinder(name: string, options: {
  122701. height?: number;
  122702. diameterTop?: number;
  122703. diameterBottom?: number;
  122704. diameter?: number;
  122705. tessellation?: number;
  122706. subdivisions?: number;
  122707. arc?: number;
  122708. faceColors?: Color4[];
  122709. faceUV?: Vector4[];
  122710. updatable?: boolean;
  122711. hasRings?: boolean;
  122712. enclose?: boolean;
  122713. cap?: number;
  122714. sideOrientation?: number;
  122715. frontUVs?: Vector4;
  122716. backUVs?: Vector4;
  122717. }, scene: any): Mesh;
  122718. }
  122719. }
  122720. declare module BABYLON {
  122721. /**
  122722. * States of the webXR experience
  122723. */
  122724. export enum WebXRState {
  122725. /**
  122726. * Transitioning to being in XR mode
  122727. */
  122728. ENTERING_XR = 0,
  122729. /**
  122730. * Transitioning to non XR mode
  122731. */
  122732. EXITING_XR = 1,
  122733. /**
  122734. * In XR mode and presenting
  122735. */
  122736. IN_XR = 2,
  122737. /**
  122738. * Not entered XR mode
  122739. */
  122740. NOT_IN_XR = 3
  122741. }
  122742. /**
  122743. * Abstraction of the XR render target
  122744. */
  122745. export interface WebXRRenderTarget extends IDisposable {
  122746. /**
  122747. * xrpresent context of the canvas which can be used to display/mirror xr content
  122748. */
  122749. canvasContext: WebGLRenderingContext;
  122750. /**
  122751. * xr layer for the canvas
  122752. */
  122753. xrLayer: Nullable<XRWebGLLayer>;
  122754. /**
  122755. * Initializes the xr layer for the session
  122756. * @param xrSession xr session
  122757. * @returns a promise that will resolve once the XR Layer has been created
  122758. */
  122759. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  122760. }
  122761. }
  122762. declare module BABYLON {
  122763. /**
  122764. * COnfiguration object for WebXR output canvas
  122765. */
  122766. export class WebXRManagedOutputCanvasOptions {
  122767. /**
  122768. * An optional canvas in case you wish to create it yourself and provide it here.
  122769. * If not provided, a new canvas will be created
  122770. */
  122771. canvasElement?: HTMLCanvasElement;
  122772. /**
  122773. * Options for this XR Layer output
  122774. */
  122775. canvasOptions?: XRWebGLLayerOptions;
  122776. /**
  122777. * CSS styling for a newly created canvas (if not provided)
  122778. */
  122779. newCanvasCssStyle?: string;
  122780. /**
  122781. * Get the default values of the configuration object
  122782. * @returns default values of this configuration object
  122783. */
  122784. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  122785. }
  122786. /**
  122787. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  122788. */
  122789. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  122790. private _options;
  122791. private _canvas;
  122792. private _engine;
  122793. /**
  122794. * Rendering context of the canvas which can be used to display/mirror xr content
  122795. */
  122796. canvasContext: WebGLRenderingContext;
  122797. /**
  122798. * xr layer for the canvas
  122799. */
  122800. xrLayer: Nullable<XRWebGLLayer>;
  122801. /**
  122802. * Initializes the canvas to be added/removed upon entering/exiting xr
  122803. * @param _xrSessionManager The XR Session manager
  122804. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  122805. */
  122806. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  122807. /**
  122808. * Disposes of the object
  122809. */
  122810. dispose(): void;
  122811. /**
  122812. * Initializes the xr layer for the session
  122813. * @param xrSession xr session
  122814. * @returns a promise that will resolve once the XR Layer has been created
  122815. */
  122816. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  122817. private _addCanvas;
  122818. private _removeCanvas;
  122819. private _setManagedOutputCanvas;
  122820. }
  122821. }
  122822. declare module BABYLON {
  122823. /**
  122824. * Manages an XRSession to work with Babylon's engine
  122825. * @see https://doc.babylonjs.com/how_to/webxr
  122826. */
  122827. export class WebXRSessionManager implements IDisposable {
  122828. /** The scene which the session should be created for */
  122829. scene: Scene;
  122830. private _referenceSpace;
  122831. private _rttProvider;
  122832. private _sessionEnded;
  122833. private _xrNavigator;
  122834. private baseLayer;
  122835. /**
  122836. * The base reference space from which the session started. good if you want to reset your
  122837. * reference space
  122838. */
  122839. baseReferenceSpace: XRReferenceSpace;
  122840. /**
  122841. * Current XR frame
  122842. */
  122843. currentFrame: Nullable<XRFrame>;
  122844. /** WebXR timestamp updated every frame */
  122845. currentTimestamp: number;
  122846. /**
  122847. * Used just in case of a failure to initialize an immersive session.
  122848. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  122849. */
  122850. defaultHeightCompensation: number;
  122851. /**
  122852. * Fires every time a new xrFrame arrives which can be used to update the camera
  122853. */
  122854. onXRFrameObservable: Observable<XRFrame>;
  122855. /**
  122856. * Fires when the reference space changed
  122857. */
  122858. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  122859. /**
  122860. * Fires when the xr session is ended either by the device or manually done
  122861. */
  122862. onXRSessionEnded: Observable<any>;
  122863. /**
  122864. * Fires when the xr session is ended either by the device or manually done
  122865. */
  122866. onXRSessionInit: Observable<XRSession>;
  122867. /**
  122868. * Underlying xr session
  122869. */
  122870. session: XRSession;
  122871. /**
  122872. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  122873. * or get the offset the player is currently at.
  122874. */
  122875. viewerReferenceSpace: XRReferenceSpace;
  122876. /**
  122877. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  122878. * @param scene The scene which the session should be created for
  122879. */
  122880. constructor(
  122881. /** The scene which the session should be created for */
  122882. scene: Scene);
  122883. /**
  122884. * The current reference space used in this session. This reference space can constantly change!
  122885. * It is mainly used to offset the camera's position.
  122886. */
  122887. get referenceSpace(): XRReferenceSpace;
  122888. /**
  122889. * Set a new reference space and triggers the observable
  122890. */
  122891. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  122892. /**
  122893. * Disposes of the session manager
  122894. */
  122895. dispose(): void;
  122896. /**
  122897. * Stops the xrSession and restores the render loop
  122898. * @returns Promise which resolves after it exits XR
  122899. */
  122900. exitXRAsync(): Promise<void>;
  122901. /**
  122902. * Gets the correct render target texture to be rendered this frame for this eye
  122903. * @param eye the eye for which to get the render target
  122904. * @returns the render target for the specified eye
  122905. */
  122906. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  122907. /**
  122908. * Creates a WebXRRenderTarget object for the XR session
  122909. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  122910. * @param options optional options to provide when creating a new render target
  122911. * @returns a WebXR render target to which the session can render
  122912. */
  122913. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  122914. /**
  122915. * Initializes the manager
  122916. * After initialization enterXR can be called to start an XR session
  122917. * @returns Promise which resolves after it is initialized
  122918. */
  122919. initializeAsync(): Promise<void>;
  122920. /**
  122921. * Initializes an xr session
  122922. * @param xrSessionMode mode to initialize
  122923. * @param xrSessionInit defines optional and required values to pass to the session builder
  122924. * @returns a promise which will resolve once the session has been initialized
  122925. */
  122926. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  122927. /**
  122928. * Checks if a session would be supported for the creation options specified
  122929. * @param sessionMode session mode to check if supported eg. immersive-vr
  122930. * @returns A Promise that resolves to true if supported and false if not
  122931. */
  122932. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  122933. /**
  122934. * Resets the reference space to the one started the session
  122935. */
  122936. resetReferenceSpace(): void;
  122937. /**
  122938. * Starts rendering to the xr layer
  122939. */
  122940. runXRRenderLoop(): void;
  122941. /**
  122942. * Sets the reference space on the xr session
  122943. * @param referenceSpaceType space to set
  122944. * @returns a promise that will resolve once the reference space has been set
  122945. */
  122946. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  122947. /**
  122948. * Updates the render state of the session
  122949. * @param state state to set
  122950. * @returns a promise that resolves once the render state has been updated
  122951. */
  122952. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  122953. /**
  122954. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  122955. * @param sessionMode defines the session to test
  122956. * @returns a promise with boolean as final value
  122957. */
  122958. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  122959. private _createRenderTargetTexture;
  122960. }
  122961. }
  122962. declare module BABYLON {
  122963. /**
  122964. * WebXR Camera which holds the views for the xrSession
  122965. * @see https://doc.babylonjs.com/how_to/webxr_camera
  122966. */
  122967. export class WebXRCamera extends FreeCamera {
  122968. private _xrSessionManager;
  122969. private _firstFrame;
  122970. private _referenceQuaternion;
  122971. private _referencedPosition;
  122972. private _xrInvPositionCache;
  122973. private _xrInvQuaternionCache;
  122974. /**
  122975. * Should position compensation execute on first frame.
  122976. * This is used when copying the position from a native (non XR) camera
  122977. */
  122978. compensateOnFirstFrame: boolean;
  122979. /**
  122980. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  122981. * @param name the name of the camera
  122982. * @param scene the scene to add the camera to
  122983. * @param _xrSessionManager a constructed xr session manager
  122984. */
  122985. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  122986. /**
  122987. * Return the user's height, unrelated to the current ground.
  122988. * This will be the y position of this camera, when ground level is 0.
  122989. */
  122990. get realWorldHeight(): number;
  122991. /** @hidden */
  122992. _updateForDualEyeDebugging(): void;
  122993. /**
  122994. * Sets this camera's transformation based on a non-vr camera
  122995. * @param otherCamera the non-vr camera to copy the transformation from
  122996. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  122997. */
  122998. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  122999. /**
  123000. * Gets the current instance class name ("WebXRCamera").
  123001. * @returns the class name
  123002. */
  123003. getClassName(): string;
  123004. /**
  123005. * Overriding the _getViewMatrix function, as it is computed by WebXR
  123006. */
  123007. _getViewMatrix(): Matrix;
  123008. private _updateFromXRSession;
  123009. private _updateNumberOfRigCameras;
  123010. private _updateReferenceSpace;
  123011. private _updateReferenceSpaceOffset;
  123012. }
  123013. }
  123014. declare module BABYLON {
  123015. /**
  123016. * Defining the interface required for a (webxr) feature
  123017. */
  123018. export interface IWebXRFeature extends IDisposable {
  123019. /**
  123020. * Is this feature attached
  123021. */
  123022. attached: boolean;
  123023. /**
  123024. * Should auto-attach be disabled?
  123025. */
  123026. disableAutoAttach: boolean;
  123027. /**
  123028. * Attach the feature to the session
  123029. * Will usually be called by the features manager
  123030. *
  123031. * @param force should attachment be forced (even when already attached)
  123032. * @returns true if successful.
  123033. */
  123034. attach(force?: boolean): boolean;
  123035. /**
  123036. * Detach the feature from the session
  123037. * Will usually be called by the features manager
  123038. *
  123039. * @returns true if successful.
  123040. */
  123041. detach(): boolean;
  123042. }
  123043. /**
  123044. * A list of the currently available features without referencing them
  123045. */
  123046. export class WebXRFeatureName {
  123047. /**
  123048. * The name of the anchor system feature
  123049. */
  123050. static ANCHOR_SYSTEM: string;
  123051. /**
  123052. * The name of the background remover feature
  123053. */
  123054. static BACKGROUND_REMOVER: string;
  123055. /**
  123056. * The name of the hit test feature
  123057. */
  123058. static HIT_TEST: string;
  123059. /**
  123060. * physics impostors for xr controllers feature
  123061. */
  123062. static PHYSICS_CONTROLLERS: string;
  123063. /**
  123064. * The name of the plane detection feature
  123065. */
  123066. static PLANE_DETECTION: string;
  123067. /**
  123068. * The name of the pointer selection feature
  123069. */
  123070. static POINTER_SELECTION: string;
  123071. /**
  123072. * The name of the teleportation feature
  123073. */
  123074. static TELEPORTATION: string;
  123075. }
  123076. /**
  123077. * Defining the constructor of a feature. Used to register the modules.
  123078. */
  123079. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  123080. /**
  123081. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  123082. * It is mainly used in AR sessions.
  123083. *
  123084. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  123085. */
  123086. export class WebXRFeaturesManager implements IDisposable {
  123087. private _xrSessionManager;
  123088. private static readonly _AvailableFeatures;
  123089. private _features;
  123090. /**
  123091. * constructs a new features manages.
  123092. *
  123093. * @param _xrSessionManager an instance of WebXRSessionManager
  123094. */
  123095. constructor(_xrSessionManager: WebXRSessionManager);
  123096. /**
  123097. * Used to register a module. After calling this function a developer can use this feature in the scene.
  123098. * Mainly used internally.
  123099. *
  123100. * @param featureName the name of the feature to register
  123101. * @param constructorFunction the function used to construct the module
  123102. * @param version the (babylon) version of the module
  123103. * @param stable is that a stable version of this module
  123104. */
  123105. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  123106. /**
  123107. * Returns a constructor of a specific feature.
  123108. *
  123109. * @param featureName the name of the feature to construct
  123110. * @param version the version of the feature to load
  123111. * @param xrSessionManager the xrSessionManager. Used to construct the module
  123112. * @param options optional options provided to the module.
  123113. * @returns a function that, when called, will return a new instance of this feature
  123114. */
  123115. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  123116. /**
  123117. * Can be used to return the list of features currently registered
  123118. *
  123119. * @returns an Array of available features
  123120. */
  123121. static GetAvailableFeatures(): string[];
  123122. /**
  123123. * Gets the versions available for a specific feature
  123124. * @param featureName the name of the feature
  123125. * @returns an array with the available versions
  123126. */
  123127. static GetAvailableVersions(featureName: string): string[];
  123128. /**
  123129. * Return the latest unstable version of this feature
  123130. * @param featureName the name of the feature to search
  123131. * @returns the version number. if not found will return -1
  123132. */
  123133. static GetLatestVersionOfFeature(featureName: string): number;
  123134. /**
  123135. * Return the latest stable version of this feature
  123136. * @param featureName the name of the feature to search
  123137. * @returns the version number. if not found will return -1
  123138. */
  123139. static GetStableVersionOfFeature(featureName: string): number;
  123140. /**
  123141. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  123142. * Can be used during a session to start a feature
  123143. * @param featureName the name of feature to attach
  123144. */
  123145. attachFeature(featureName: string): void;
  123146. /**
  123147. * Can be used inside a session or when the session ends to detach a specific feature
  123148. * @param featureName the name of the feature to detach
  123149. */
  123150. detachFeature(featureName: string): void;
  123151. /**
  123152. * Used to disable an already-enabled feature
  123153. * The feature will be disposed and will be recreated once enabled.
  123154. * @param featureName the feature to disable
  123155. * @returns true if disable was successful
  123156. */
  123157. disableFeature(featureName: string | {
  123158. Name: string;
  123159. }): boolean;
  123160. /**
  123161. * dispose this features manager
  123162. */
  123163. dispose(): void;
  123164. /**
  123165. * 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.
  123166. * 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.
  123167. *
  123168. * @param featureName the name of the feature to load or the class of the feature
  123169. * @param version optional version to load. if not provided the latest version will be enabled
  123170. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  123171. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  123172. * @returns a new constructed feature or throws an error if feature not found.
  123173. */
  123174. enableFeature(featureName: string | {
  123175. Name: string;
  123176. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  123177. /**
  123178. * get the implementation of an enabled feature.
  123179. * @param featureName the name of the feature to load
  123180. * @returns the feature class, if found
  123181. */
  123182. getEnabledFeature(featureName: string): IWebXRFeature;
  123183. /**
  123184. * Get the list of enabled features
  123185. * @returns an array of enabled features
  123186. */
  123187. getEnabledFeatures(): string[];
  123188. }
  123189. }
  123190. declare module BABYLON {
  123191. /**
  123192. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  123193. * @see https://doc.babylonjs.com/how_to/webxr
  123194. */
  123195. export class WebXRExperienceHelper implements IDisposable {
  123196. private scene;
  123197. private _nonVRCamera;
  123198. private _originalSceneAutoClear;
  123199. private _supported;
  123200. /**
  123201. * Camera used to render xr content
  123202. */
  123203. camera: WebXRCamera;
  123204. /** A features manager for this xr session */
  123205. featuresManager: WebXRFeaturesManager;
  123206. /**
  123207. * Observers registered here will be triggered after the camera's initial transformation is set
  123208. * This can be used to set a different ground level or an extra rotation.
  123209. *
  123210. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  123211. * to the position set after this observable is done executing.
  123212. */
  123213. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  123214. /**
  123215. * Fires when the state of the experience helper has changed
  123216. */
  123217. onStateChangedObservable: Observable<WebXRState>;
  123218. /** Session manager used to keep track of xr session */
  123219. sessionManager: WebXRSessionManager;
  123220. /**
  123221. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  123222. */
  123223. state: WebXRState;
  123224. /**
  123225. * Creates a WebXRExperienceHelper
  123226. * @param scene The scene the helper should be created in
  123227. */
  123228. private constructor();
  123229. /**
  123230. * Creates the experience helper
  123231. * @param scene the scene to attach the experience helper to
  123232. * @returns a promise for the experience helper
  123233. */
  123234. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  123235. /**
  123236. * Disposes of the experience helper
  123237. */
  123238. dispose(): void;
  123239. /**
  123240. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  123241. * @param sessionMode options for the XR session
  123242. * @param referenceSpaceType frame of reference of the XR session
  123243. * @param renderTarget the output canvas that will be used to enter XR mode
  123244. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  123245. * @returns promise that resolves after xr mode has entered
  123246. */
  123247. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  123248. /**
  123249. * Exits XR mode and returns the scene to its original state
  123250. * @returns promise that resolves after xr mode has exited
  123251. */
  123252. exitXRAsync(): Promise<void>;
  123253. private _nonXRToXRCamera;
  123254. private _setState;
  123255. }
  123256. }
  123257. declare module BABYLON {
  123258. /**
  123259. * X-Y values for axes in WebXR
  123260. */
  123261. export interface IWebXRMotionControllerAxesValue {
  123262. /**
  123263. * The value of the x axis
  123264. */
  123265. x: number;
  123266. /**
  123267. * The value of the y-axis
  123268. */
  123269. y: number;
  123270. }
  123271. /**
  123272. * changed / previous values for the values of this component
  123273. */
  123274. export interface IWebXRMotionControllerComponentChangesValues<T> {
  123275. /**
  123276. * current (this frame) value
  123277. */
  123278. current: T;
  123279. /**
  123280. * previous (last change) value
  123281. */
  123282. previous: T;
  123283. }
  123284. /**
  123285. * Represents changes in the component between current frame and last values recorded
  123286. */
  123287. export interface IWebXRMotionControllerComponentChanges {
  123288. /**
  123289. * will be populated with previous and current values if axes changed
  123290. */
  123291. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  123292. /**
  123293. * will be populated with previous and current values if pressed changed
  123294. */
  123295. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  123296. /**
  123297. * will be populated with previous and current values if touched changed
  123298. */
  123299. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  123300. /**
  123301. * will be populated with previous and current values if value changed
  123302. */
  123303. value?: IWebXRMotionControllerComponentChangesValues<number>;
  123304. }
  123305. /**
  123306. * This class represents a single component (for example button or thumbstick) of a motion controller
  123307. */
  123308. export class WebXRControllerComponent implements IDisposable {
  123309. /**
  123310. * the id of this component
  123311. */
  123312. id: string;
  123313. /**
  123314. * the type of the component
  123315. */
  123316. type: MotionControllerComponentType;
  123317. private _buttonIndex;
  123318. private _axesIndices;
  123319. private _axes;
  123320. private _changes;
  123321. private _currentValue;
  123322. private _hasChanges;
  123323. private _pressed;
  123324. private _touched;
  123325. /**
  123326. * button component type
  123327. */
  123328. static BUTTON_TYPE: MotionControllerComponentType;
  123329. /**
  123330. * squeeze component type
  123331. */
  123332. static SQUEEZE_TYPE: MotionControllerComponentType;
  123333. /**
  123334. * Thumbstick component type
  123335. */
  123336. static THUMBSTICK_TYPE: MotionControllerComponentType;
  123337. /**
  123338. * Touchpad component type
  123339. */
  123340. static TOUCHPAD_TYPE: MotionControllerComponentType;
  123341. /**
  123342. * trigger component type
  123343. */
  123344. static TRIGGER_TYPE: MotionControllerComponentType;
  123345. /**
  123346. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  123347. * the axes data changes
  123348. */
  123349. onAxisValueChangedObservable: Observable<{
  123350. x: number;
  123351. y: number;
  123352. }>;
  123353. /**
  123354. * Observers registered here will be triggered when the state of a button changes
  123355. * State change is either pressed / touched / value
  123356. */
  123357. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  123358. /**
  123359. * Creates a new component for a motion controller.
  123360. * It is created by the motion controller itself
  123361. *
  123362. * @param id the id of this component
  123363. * @param type the type of the component
  123364. * @param _buttonIndex index in the buttons array of the gamepad
  123365. * @param _axesIndices indices of the values in the axes array of the gamepad
  123366. */
  123367. constructor(
  123368. /**
  123369. * the id of this component
  123370. */
  123371. id: string,
  123372. /**
  123373. * the type of the component
  123374. */
  123375. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  123376. /**
  123377. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  123378. */
  123379. get axes(): IWebXRMotionControllerAxesValue;
  123380. /**
  123381. * Get the changes. Elements will be populated only if they changed with their previous and current value
  123382. */
  123383. get changes(): IWebXRMotionControllerComponentChanges;
  123384. /**
  123385. * Return whether or not the component changed the last frame
  123386. */
  123387. get hasChanges(): boolean;
  123388. /**
  123389. * is the button currently pressed
  123390. */
  123391. get pressed(): boolean;
  123392. /**
  123393. * is the button currently touched
  123394. */
  123395. get touched(): boolean;
  123396. /**
  123397. * Get the current value of this component
  123398. */
  123399. get value(): number;
  123400. /**
  123401. * Dispose this component
  123402. */
  123403. dispose(): void;
  123404. /**
  123405. * Are there axes correlating to this component
  123406. * @return true is axes data is available
  123407. */
  123408. isAxes(): boolean;
  123409. /**
  123410. * Is this component a button (hence - pressable)
  123411. * @returns true if can be pressed
  123412. */
  123413. isButton(): boolean;
  123414. /**
  123415. * update this component using the gamepad object it is in. Called on every frame
  123416. * @param nativeController the native gamepad controller object
  123417. */
  123418. update(nativeController: IMinimalMotionControllerObject): void;
  123419. }
  123420. }
  123421. declare module BABYLON {
  123422. /**
  123423. * Class used to represent data loading progression
  123424. */
  123425. export class SceneLoaderProgressEvent {
  123426. /** defines if data length to load can be evaluated */
  123427. readonly lengthComputable: boolean;
  123428. /** defines the loaded data length */
  123429. readonly loaded: number;
  123430. /** defines the data length to load */
  123431. readonly total: number;
  123432. /**
  123433. * Create a new progress event
  123434. * @param lengthComputable defines if data length to load can be evaluated
  123435. * @param loaded defines the loaded data length
  123436. * @param total defines the data length to load
  123437. */
  123438. constructor(
  123439. /** defines if data length to load can be evaluated */
  123440. lengthComputable: boolean,
  123441. /** defines the loaded data length */
  123442. loaded: number,
  123443. /** defines the data length to load */
  123444. total: number);
  123445. /**
  123446. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  123447. * @param event defines the source event
  123448. * @returns a new SceneLoaderProgressEvent
  123449. */
  123450. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  123451. }
  123452. /**
  123453. * Interface used by SceneLoader plugins to define supported file extensions
  123454. */
  123455. export interface ISceneLoaderPluginExtensions {
  123456. /**
  123457. * Defines the list of supported extensions
  123458. */
  123459. [extension: string]: {
  123460. isBinary: boolean;
  123461. };
  123462. }
  123463. /**
  123464. * Interface used by SceneLoader plugin factory
  123465. */
  123466. export interface ISceneLoaderPluginFactory {
  123467. /**
  123468. * Defines the name of the factory
  123469. */
  123470. name: string;
  123471. /**
  123472. * Function called to create a new plugin
  123473. * @return the new plugin
  123474. */
  123475. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  123476. /**
  123477. * The callback that returns true if the data can be directly loaded.
  123478. * @param data string containing the file data
  123479. * @returns if the data can be loaded directly
  123480. */
  123481. canDirectLoad?(data: string): boolean;
  123482. }
  123483. /**
  123484. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  123485. */
  123486. export interface ISceneLoaderPluginBase {
  123487. /**
  123488. * The friendly name of this plugin.
  123489. */
  123490. name: string;
  123491. /**
  123492. * The file extensions supported by this plugin.
  123493. */
  123494. extensions: string | ISceneLoaderPluginExtensions;
  123495. /**
  123496. * The callback called when loading from a url.
  123497. * @param scene scene loading this url
  123498. * @param url url to load
  123499. * @param onSuccess callback called when the file successfully loads
  123500. * @param onProgress callback called while file is loading (if the server supports this mode)
  123501. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  123502. * @param onError callback called when the file fails to load
  123503. * @returns a file request object
  123504. */
  123505. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  123506. /**
  123507. * The callback called when loading from a file object.
  123508. * @param scene scene loading this file
  123509. * @param file defines the file to load
  123510. * @param onSuccess defines the callback to call when data is loaded
  123511. * @param onProgress defines the callback to call during loading process
  123512. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  123513. * @param onError defines the callback to call when an error occurs
  123514. * @returns a file request object
  123515. */
  123516. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  123517. /**
  123518. * The callback that returns true if the data can be directly loaded.
  123519. * @param data string containing the file data
  123520. * @returns if the data can be loaded directly
  123521. */
  123522. canDirectLoad?(data: string): boolean;
  123523. /**
  123524. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  123525. * @param scene scene loading this data
  123526. * @param data string containing the data
  123527. * @returns data to pass to the plugin
  123528. */
  123529. directLoad?(scene: Scene, data: string): any;
  123530. /**
  123531. * The callback that allows custom handling of the root url based on the response url.
  123532. * @param rootUrl the original root url
  123533. * @param responseURL the response url if available
  123534. * @returns the new root url
  123535. */
  123536. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  123537. }
  123538. /**
  123539. * Interface used to define a SceneLoader plugin
  123540. */
  123541. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  123542. /**
  123543. * Import meshes into a scene.
  123544. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  123545. * @param scene The scene to import into
  123546. * @param data The data to import
  123547. * @param rootUrl The root url for scene and resources
  123548. * @param meshes The meshes array to import into
  123549. * @param particleSystems The particle systems array to import into
  123550. * @param skeletons The skeletons array to import into
  123551. * @param onError The callback when import fails
  123552. * @returns True if successful or false otherwise
  123553. */
  123554. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  123555. /**
  123556. * Load into a scene.
  123557. * @param scene The scene to load into
  123558. * @param data The data to import
  123559. * @param rootUrl The root url for scene and resources
  123560. * @param onError The callback when import fails
  123561. * @returns True if successful or false otherwise
  123562. */
  123563. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  123564. /**
  123565. * Load into an asset container.
  123566. * @param scene The scene to load into
  123567. * @param data The data to import
  123568. * @param rootUrl The root url for scene and resources
  123569. * @param onError The callback when import fails
  123570. * @returns The loaded asset container
  123571. */
  123572. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  123573. }
  123574. /**
  123575. * Interface used to define an async SceneLoader plugin
  123576. */
  123577. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  123578. /**
  123579. * Import meshes into a scene.
  123580. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  123581. * @param scene The scene to import into
  123582. * @param data The data to import
  123583. * @param rootUrl The root url for scene and resources
  123584. * @param onProgress The callback when the load progresses
  123585. * @param fileName Defines the name of the file to load
  123586. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  123587. */
  123588. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  123589. meshes: AbstractMesh[];
  123590. particleSystems: IParticleSystem[];
  123591. skeletons: Skeleton[];
  123592. animationGroups: AnimationGroup[];
  123593. }>;
  123594. /**
  123595. * Load into a scene.
  123596. * @param scene The scene to load into
  123597. * @param data The data to import
  123598. * @param rootUrl The root url for scene and resources
  123599. * @param onProgress The callback when the load progresses
  123600. * @param fileName Defines the name of the file to load
  123601. * @returns Nothing
  123602. */
  123603. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  123604. /**
  123605. * Load into an asset container.
  123606. * @param scene The scene to load into
  123607. * @param data The data to import
  123608. * @param rootUrl The root url for scene and resources
  123609. * @param onProgress The callback when the load progresses
  123610. * @param fileName Defines the name of the file to load
  123611. * @returns The loaded asset container
  123612. */
  123613. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  123614. }
  123615. /**
  123616. * Mode that determines how to handle old animation groups before loading new ones.
  123617. */
  123618. export enum SceneLoaderAnimationGroupLoadingMode {
  123619. /**
  123620. * Reset all old animations to initial state then dispose them.
  123621. */
  123622. Clean = 0,
  123623. /**
  123624. * Stop all old animations.
  123625. */
  123626. Stop = 1,
  123627. /**
  123628. * Restart old animations from first frame.
  123629. */
  123630. Sync = 2,
  123631. /**
  123632. * Old animations remains untouched.
  123633. */
  123634. NoSync = 3
  123635. }
  123636. /**
  123637. * Class used to load scene from various file formats using registered plugins
  123638. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  123639. */
  123640. export class SceneLoader {
  123641. /**
  123642. * No logging while loading
  123643. */
  123644. static readonly NO_LOGGING: number;
  123645. /**
  123646. * Minimal logging while loading
  123647. */
  123648. static readonly MINIMAL_LOGGING: number;
  123649. /**
  123650. * Summary logging while loading
  123651. */
  123652. static readonly SUMMARY_LOGGING: number;
  123653. /**
  123654. * Detailled logging while loading
  123655. */
  123656. static readonly DETAILED_LOGGING: number;
  123657. /**
  123658. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  123659. */
  123660. static get ForceFullSceneLoadingForIncremental(): boolean;
  123661. static set ForceFullSceneLoadingForIncremental(value: boolean);
  123662. /**
  123663. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  123664. */
  123665. static get ShowLoadingScreen(): boolean;
  123666. static set ShowLoadingScreen(value: boolean);
  123667. /**
  123668. * Defines the current logging level (while loading the scene)
  123669. * @ignorenaming
  123670. */
  123671. static get loggingLevel(): number;
  123672. static set loggingLevel(value: number);
  123673. /**
  123674. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  123675. */
  123676. static get CleanBoneMatrixWeights(): boolean;
  123677. static set CleanBoneMatrixWeights(value: boolean);
  123678. /**
  123679. * Event raised when a plugin is used to load a scene
  123680. */
  123681. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  123682. private static _registeredPlugins;
  123683. private static _getDefaultPlugin;
  123684. private static _getPluginForExtension;
  123685. private static _getPluginForDirectLoad;
  123686. private static _getPluginForFilename;
  123687. private static _getDirectLoad;
  123688. private static _loadData;
  123689. private static _getFileInfo;
  123690. /**
  123691. * Gets a plugin that can load the given extension
  123692. * @param extension defines the extension to load
  123693. * @returns a plugin or null if none works
  123694. */
  123695. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  123696. /**
  123697. * Gets a boolean indicating that the given extension can be loaded
  123698. * @param extension defines the extension to load
  123699. * @returns true if the extension is supported
  123700. */
  123701. static IsPluginForExtensionAvailable(extension: string): boolean;
  123702. /**
  123703. * Adds a new plugin to the list of registered plugins
  123704. * @param plugin defines the plugin to add
  123705. */
  123706. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  123707. /**
  123708. * Import meshes into a scene
  123709. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  123710. * @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)
  123711. * @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)
  123712. * @param scene the instance of BABYLON.Scene to append to
  123713. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  123714. * @param onProgress a callback with a progress event for each file being loaded
  123715. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  123716. * @param pluginExtension the extension used to determine the plugin
  123717. * @returns The loaded plugin
  123718. */
  123719. 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>;
  123720. /**
  123721. * Import meshes into a scene
  123722. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  123723. * @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)
  123724. * @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)
  123725. * @param scene the instance of BABYLON.Scene to append to
  123726. * @param onProgress a callback with a progress event for each file being loaded
  123727. * @param pluginExtension the extension used to determine the plugin
  123728. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  123729. */
  123730. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  123731. meshes: AbstractMesh[];
  123732. particleSystems: IParticleSystem[];
  123733. skeletons: Skeleton[];
  123734. animationGroups: AnimationGroup[];
  123735. }>;
  123736. /**
  123737. * Load a scene
  123738. * @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)
  123739. * @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)
  123740. * @param engine is the instance of BABYLON.Engine to use to create the scene
  123741. * @param onSuccess a callback with the scene when import succeeds
  123742. * @param onProgress a callback with a progress event for each file being loaded
  123743. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  123744. * @param pluginExtension the extension used to determine the plugin
  123745. * @returns The loaded plugin
  123746. */
  123747. 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>;
  123748. /**
  123749. * Load a scene
  123750. * @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)
  123751. * @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)
  123752. * @param engine is the instance of BABYLON.Engine to use to create the scene
  123753. * @param onProgress a callback with a progress event for each file being loaded
  123754. * @param pluginExtension the extension used to determine the plugin
  123755. * @returns The loaded scene
  123756. */
  123757. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  123758. /**
  123759. * Append a scene
  123760. * @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)
  123761. * @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)
  123762. * @param scene is the instance of BABYLON.Scene to append to
  123763. * @param onSuccess a callback with the scene when import succeeds
  123764. * @param onProgress a callback with a progress event for each file being loaded
  123765. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  123766. * @param pluginExtension the extension used to determine the plugin
  123767. * @returns The loaded plugin
  123768. */
  123769. 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>;
  123770. /**
  123771. * Append a scene
  123772. * @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)
  123773. * @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)
  123774. * @param scene is the instance of BABYLON.Scene to append to
  123775. * @param onProgress a callback with a progress event for each file being loaded
  123776. * @param pluginExtension the extension used to determine the plugin
  123777. * @returns The given scene
  123778. */
  123779. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  123780. /**
  123781. * Load a scene into an asset container
  123782. * @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)
  123783. * @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)
  123784. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  123785. * @param onSuccess a callback with the scene when import succeeds
  123786. * @param onProgress a callback with a progress event for each file being loaded
  123787. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  123788. * @param pluginExtension the extension used to determine the plugin
  123789. * @returns The loaded plugin
  123790. */
  123791. 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>;
  123792. /**
  123793. * Load a scene into an asset container
  123794. * @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)
  123795. * @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)
  123796. * @param scene is the instance of Scene to append to
  123797. * @param onProgress a callback with a progress event for each file being loaded
  123798. * @param pluginExtension the extension used to determine the plugin
  123799. * @returns The loaded asset container
  123800. */
  123801. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  123802. /**
  123803. * Import animations from a file into a scene
  123804. * @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)
  123805. * @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)
  123806. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  123807. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  123808. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  123809. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  123810. * @param onSuccess a callback with the scene when import succeeds
  123811. * @param onProgress a callback with a progress event for each file being loaded
  123812. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  123813. */
  123814. 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;
  123815. /**
  123816. * Import animations from a file into a scene
  123817. * @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)
  123818. * @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)
  123819. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  123820. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  123821. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  123822. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  123823. * @param onSuccess a callback with the scene when import succeeds
  123824. * @param onProgress a callback with a progress event for each file being loaded
  123825. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  123826. * @returns the updated scene with imported animations
  123827. */
  123828. 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>;
  123829. }
  123830. }
  123831. declare module BABYLON {
  123832. /**
  123833. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  123834. */
  123835. export type MotionControllerHandedness = "none" | "left" | "right";
  123836. /**
  123837. * The type of components available in motion controllers.
  123838. * This is not the name of the component.
  123839. */
  123840. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  123841. /**
  123842. * The state of a controller component
  123843. */
  123844. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  123845. /**
  123846. * The schema of motion controller layout.
  123847. * No object will be initialized using this interface
  123848. * This is used just to define the profile.
  123849. */
  123850. export interface IMotionControllerLayout {
  123851. /**
  123852. * Path to load the assets. Usually relative to the base path
  123853. */
  123854. assetPath: string;
  123855. /**
  123856. * Available components (unsorted)
  123857. */
  123858. components: {
  123859. /**
  123860. * A map of component Ids
  123861. */
  123862. [componentId: string]: {
  123863. /**
  123864. * The type of input the component outputs
  123865. */
  123866. type: MotionControllerComponentType;
  123867. /**
  123868. * The indices of this component in the gamepad object
  123869. */
  123870. gamepadIndices: {
  123871. /**
  123872. * Index of button
  123873. */
  123874. button?: number;
  123875. /**
  123876. * If available, index of x-axis
  123877. */
  123878. xAxis?: number;
  123879. /**
  123880. * If available, index of y-axis
  123881. */
  123882. yAxis?: number;
  123883. };
  123884. /**
  123885. * The mesh's root node name
  123886. */
  123887. rootNodeName: string;
  123888. /**
  123889. * Animation definitions for this model
  123890. */
  123891. visualResponses: {
  123892. [stateKey: string]: {
  123893. /**
  123894. * What property will be animated
  123895. */
  123896. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  123897. /**
  123898. * What states influence this visual response
  123899. */
  123900. states: MotionControllerComponentStateType[];
  123901. /**
  123902. * Type of animation - movement or visibility
  123903. */
  123904. valueNodeProperty: "transform" | "visibility";
  123905. /**
  123906. * Base node name to move. Its position will be calculated according to the min and max nodes
  123907. */
  123908. valueNodeName?: string;
  123909. /**
  123910. * Minimum movement node
  123911. */
  123912. minNodeName?: string;
  123913. /**
  123914. * Max movement node
  123915. */
  123916. maxNodeName?: string;
  123917. };
  123918. };
  123919. /**
  123920. * If touch enabled, what is the name of node to display user feedback
  123921. */
  123922. touchPointNodeName?: string;
  123923. };
  123924. };
  123925. /**
  123926. * Is it xr standard mapping or not
  123927. */
  123928. gamepadMapping: "" | "xr-standard";
  123929. /**
  123930. * Base root node of this entire model
  123931. */
  123932. rootNodeName: string;
  123933. /**
  123934. * Defines the main button component id
  123935. */
  123936. selectComponentId: string;
  123937. }
  123938. /**
  123939. * A definition for the layout map in the input profile
  123940. */
  123941. export interface IMotionControllerLayoutMap {
  123942. /**
  123943. * Layouts with handedness type as a key
  123944. */
  123945. [handedness: string]: IMotionControllerLayout;
  123946. }
  123947. /**
  123948. * The XR Input profile schema
  123949. * Profiles can be found here:
  123950. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  123951. */
  123952. export interface IMotionControllerProfile {
  123953. /**
  123954. * fallback profiles for this profileId
  123955. */
  123956. fallbackProfileIds: string[];
  123957. /**
  123958. * The layout map, with handedness as key
  123959. */
  123960. layouts: IMotionControllerLayoutMap;
  123961. /**
  123962. * The id of this profile
  123963. * correlates to the profile(s) in the xrInput.profiles array
  123964. */
  123965. profileId: string;
  123966. }
  123967. /**
  123968. * A helper-interface for the 3 meshes needed for controller button animation
  123969. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  123970. */
  123971. export interface IMotionControllerButtonMeshMap {
  123972. /**
  123973. * the mesh that defines the pressed value mesh position.
  123974. * This is used to find the max-position of this button
  123975. */
  123976. pressedMesh: AbstractMesh;
  123977. /**
  123978. * the mesh that defines the unpressed value mesh position.
  123979. * This is used to find the min (or initial) position of this button
  123980. */
  123981. unpressedMesh: AbstractMesh;
  123982. /**
  123983. * The mesh that will be changed when value changes
  123984. */
  123985. valueMesh: AbstractMesh;
  123986. }
  123987. /**
  123988. * A helper-interface for the 3 meshes needed for controller axis animation.
  123989. * This will be expanded when touchpad animations are fully supported
  123990. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  123991. */
  123992. export interface IMotionControllerMeshMap {
  123993. /**
  123994. * the mesh that defines the maximum value mesh position.
  123995. */
  123996. maxMesh?: AbstractMesh;
  123997. /**
  123998. * the mesh that defines the minimum value mesh position.
  123999. */
  124000. minMesh?: AbstractMesh;
  124001. /**
  124002. * The mesh that will be changed when axis value changes
  124003. */
  124004. valueMesh: AbstractMesh;
  124005. }
  124006. /**
  124007. * The elements needed for change-detection of the gamepad objects in motion controllers
  124008. */
  124009. export interface IMinimalMotionControllerObject {
  124010. /**
  124011. * Available axes of this controller
  124012. */
  124013. axes: number[];
  124014. /**
  124015. * An array of available buttons
  124016. */
  124017. buttons: Array<{
  124018. /**
  124019. * Value of the button/trigger
  124020. */
  124021. value: number;
  124022. /**
  124023. * If the button/trigger is currently touched
  124024. */
  124025. touched: boolean;
  124026. /**
  124027. * If the button/trigger is currently pressed
  124028. */
  124029. pressed: boolean;
  124030. }>;
  124031. /**
  124032. * EXPERIMENTAL haptic support.
  124033. */
  124034. hapticActuators?: Array<{
  124035. pulse: (value: number, duration: number) => Promise<boolean>;
  124036. }>;
  124037. }
  124038. /**
  124039. * An Abstract Motion controller
  124040. * This class receives an xrInput and a profile layout and uses those to initialize the components
  124041. * Each component has an observable to check for changes in value and state
  124042. */
  124043. export abstract class WebXRAbstractMotionController implements IDisposable {
  124044. protected scene: Scene;
  124045. protected layout: IMotionControllerLayout;
  124046. /**
  124047. * The gamepad object correlating to this controller
  124048. */
  124049. gamepadObject: IMinimalMotionControllerObject;
  124050. /**
  124051. * handedness (left/right/none) of this controller
  124052. */
  124053. handedness: MotionControllerHandedness;
  124054. private _initComponent;
  124055. private _modelReady;
  124056. /**
  124057. * A map of components (WebXRControllerComponent) in this motion controller
  124058. * Components have a ComponentType and can also have both button and axis definitions
  124059. */
  124060. readonly components: {
  124061. [id: string]: WebXRControllerComponent;
  124062. };
  124063. /**
  124064. * Disable the model's animation. Can be set at any time.
  124065. */
  124066. disableAnimation: boolean;
  124067. /**
  124068. * Observers registered here will be triggered when the model of this controller is done loading
  124069. */
  124070. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  124071. /**
  124072. * The profile id of this motion controller
  124073. */
  124074. abstract profileId: string;
  124075. /**
  124076. * The root mesh of the model. It is null if the model was not yet initialized
  124077. */
  124078. rootMesh: Nullable<AbstractMesh>;
  124079. /**
  124080. * constructs a new abstract motion controller
  124081. * @param scene the scene to which the model of the controller will be added
  124082. * @param layout The profile layout to load
  124083. * @param gamepadObject The gamepad object correlating to this controller
  124084. * @param handedness handedness (left/right/none) of this controller
  124085. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  124086. */
  124087. constructor(scene: Scene, layout: IMotionControllerLayout,
  124088. /**
  124089. * The gamepad object correlating to this controller
  124090. */
  124091. gamepadObject: IMinimalMotionControllerObject,
  124092. /**
  124093. * handedness (left/right/none) of this controller
  124094. */
  124095. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  124096. /**
  124097. * Dispose this controller, the model mesh and all its components
  124098. */
  124099. dispose(): void;
  124100. /**
  124101. * Returns all components of specific type
  124102. * @param type the type to search for
  124103. * @return an array of components with this type
  124104. */
  124105. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  124106. /**
  124107. * get a component based an its component id as defined in layout.components
  124108. * @param id the id of the component
  124109. * @returns the component correlates to the id or undefined if not found
  124110. */
  124111. getComponent(id: string): WebXRControllerComponent;
  124112. /**
  124113. * Get the list of components available in this motion controller
  124114. * @returns an array of strings correlating to available components
  124115. */
  124116. getComponentIds(): string[];
  124117. /**
  124118. * Get the first component of specific type
  124119. * @param type type of component to find
  124120. * @return a controller component or null if not found
  124121. */
  124122. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  124123. /**
  124124. * Get the main (Select) component of this controller as defined in the layout
  124125. * @returns the main component of this controller
  124126. */
  124127. getMainComponent(): WebXRControllerComponent;
  124128. /**
  124129. * Loads the model correlating to this controller
  124130. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  124131. * @returns A promise fulfilled with the result of the model loading
  124132. */
  124133. loadModel(): Promise<boolean>;
  124134. /**
  124135. * Update this model using the current XRFrame
  124136. * @param xrFrame the current xr frame to use and update the model
  124137. */
  124138. updateFromXRFrame(xrFrame: XRFrame): void;
  124139. /**
  124140. * Backwards compatibility due to a deeply-integrated typo
  124141. */
  124142. get handness(): XREye;
  124143. /**
  124144. * Pulse (vibrate) this controller
  124145. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  124146. * Consecutive calls to this function will cancel the last pulse call
  124147. *
  124148. * @param value the strength of the pulse in 0.0...1.0 range
  124149. * @param duration Duration of the pulse in milliseconds
  124150. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  124151. * @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
  124152. */
  124153. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  124154. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  124155. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  124156. /**
  124157. * Moves the axis on the controller mesh based on its current state
  124158. * @param axis the index of the axis
  124159. * @param axisValue the value of the axis which determines the meshes new position
  124160. * @hidden
  124161. */
  124162. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  124163. /**
  124164. * Update the model itself with the current frame data
  124165. * @param xrFrame the frame to use for updating the model mesh
  124166. */
  124167. protected updateModel(xrFrame: XRFrame): void;
  124168. /**
  124169. * Get the filename and path for this controller's model
  124170. * @returns a map of filename and path
  124171. */
  124172. protected abstract _getFilenameAndPath(): {
  124173. filename: string;
  124174. path: string;
  124175. };
  124176. /**
  124177. * This function is called before the mesh is loaded. It checks for loading constraints.
  124178. * For example, this function can check if the GLB loader is available
  124179. * If this function returns false, the generic controller will be loaded instead
  124180. * @returns Is the client ready to load the mesh
  124181. */
  124182. protected abstract _getModelLoadingConstraints(): boolean;
  124183. /**
  124184. * This function will be called after the model was successfully loaded and can be used
  124185. * for mesh transformations before it is available for the user
  124186. * @param meshes the loaded meshes
  124187. */
  124188. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  124189. /**
  124190. * Set the root mesh for this controller. Important for the WebXR controller class
  124191. * @param meshes the loaded meshes
  124192. */
  124193. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  124194. /**
  124195. * A function executed each frame that updates the mesh (if needed)
  124196. * @param xrFrame the current xrFrame
  124197. */
  124198. protected abstract _updateModel(xrFrame: XRFrame): void;
  124199. private _getGenericFilenameAndPath;
  124200. private _getGenericParentMesh;
  124201. }
  124202. }
  124203. declare module BABYLON {
  124204. /**
  124205. * A generic trigger-only motion controller for WebXR
  124206. */
  124207. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  124208. /**
  124209. * Static version of the profile id of this controller
  124210. */
  124211. static ProfileId: string;
  124212. profileId: string;
  124213. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  124214. protected _getFilenameAndPath(): {
  124215. filename: string;
  124216. path: string;
  124217. };
  124218. protected _getModelLoadingConstraints(): boolean;
  124219. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  124220. protected _setRootMesh(meshes: AbstractMesh[]): void;
  124221. protected _updateModel(): void;
  124222. }
  124223. }
  124224. declare module BABYLON {
  124225. /**
  124226. * Class containing static functions to help procedurally build meshes
  124227. */
  124228. export class SphereBuilder {
  124229. /**
  124230. * Creates a sphere mesh
  124231. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  124232. * * 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`)
  124233. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  124234. * * 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
  124235. * * 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)
  124236. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124237. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124238. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124239. * @param name defines the name of the mesh
  124240. * @param options defines the options used to create the mesh
  124241. * @param scene defines the hosting scene
  124242. * @returns the sphere mesh
  124243. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  124244. */
  124245. static CreateSphere(name: string, options: {
  124246. segments?: number;
  124247. diameter?: number;
  124248. diameterX?: number;
  124249. diameterY?: number;
  124250. diameterZ?: number;
  124251. arc?: number;
  124252. slice?: number;
  124253. sideOrientation?: number;
  124254. frontUVs?: Vector4;
  124255. backUVs?: Vector4;
  124256. updatable?: boolean;
  124257. }, scene?: Nullable<Scene>): Mesh;
  124258. }
  124259. }
  124260. declare module BABYLON {
  124261. /**
  124262. * A profiled motion controller has its profile loaded from an online repository.
  124263. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  124264. */
  124265. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  124266. private _repositoryUrl;
  124267. private _buttonMeshMapping;
  124268. private _touchDots;
  124269. /**
  124270. * The profile ID of this controller. Will be populated when the controller initializes.
  124271. */
  124272. profileId: string;
  124273. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  124274. dispose(): void;
  124275. protected _getFilenameAndPath(): {
  124276. filename: string;
  124277. path: string;
  124278. };
  124279. protected _getModelLoadingConstraints(): boolean;
  124280. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  124281. protected _setRootMesh(meshes: AbstractMesh[]): void;
  124282. protected _updateModel(_xrFrame: XRFrame): void;
  124283. }
  124284. }
  124285. declare module BABYLON {
  124286. /**
  124287. * A construction function type to create a new controller based on an xrInput object
  124288. */
  124289. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  124290. /**
  124291. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  124292. *
  124293. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  124294. * it should be replaced with auto-loaded controllers.
  124295. *
  124296. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  124297. */
  124298. export class WebXRMotionControllerManager {
  124299. private static _AvailableControllers;
  124300. private static _Fallbacks;
  124301. private static _ProfileLoadingPromises;
  124302. private static _ProfilesList;
  124303. /**
  124304. * The base URL of the online controller repository. Can be changed at any time.
  124305. */
  124306. static BaseRepositoryUrl: string;
  124307. /**
  124308. * Which repository gets priority - local or online
  124309. */
  124310. static PrioritizeOnlineRepository: boolean;
  124311. /**
  124312. * Use the online repository, or use only locally-defined controllers
  124313. */
  124314. static UseOnlineRepository: boolean;
  124315. /**
  124316. * Clear the cache used for profile loading and reload when requested again
  124317. */
  124318. static ClearProfilesCache(): void;
  124319. /**
  124320. * Register the default fallbacks.
  124321. * This function is called automatically when this file is imported.
  124322. */
  124323. static DefaultFallbacks(): void;
  124324. /**
  124325. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  124326. * @param profileId the profile to which a fallback needs to be found
  124327. * @return an array with corresponding fallback profiles
  124328. */
  124329. static FindFallbackWithProfileId(profileId: string): string[];
  124330. /**
  124331. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  124332. * The order of search:
  124333. *
  124334. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  124335. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  124336. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  124337. * 4) return the generic trigger controller if none were found
  124338. *
  124339. * @param xrInput the xrInput to which a new controller is initialized
  124340. * @param scene the scene to which the model will be added
  124341. * @param forceProfile force a certain profile for this controller
  124342. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  124343. */
  124344. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  124345. /**
  124346. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  124347. *
  124348. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  124349. *
  124350. * @param type the profile type to register
  124351. * @param constructFunction the function to be called when loading this profile
  124352. */
  124353. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  124354. /**
  124355. * Register a fallback to a specific profile.
  124356. * @param profileId the profileId that will receive the fallbacks
  124357. * @param fallbacks A list of fallback profiles
  124358. */
  124359. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  124360. /**
  124361. * Will update the list of profiles available in the repository
  124362. * @return a promise that resolves to a map of profiles available online
  124363. */
  124364. static UpdateProfilesList(): Promise<{
  124365. [profile: string]: string;
  124366. }>;
  124367. private static _LoadProfileFromRepository;
  124368. private static _LoadProfilesFromAvailableControllers;
  124369. }
  124370. }
  124371. declare module BABYLON {
  124372. /**
  124373. * Configuration options for the WebXR controller creation
  124374. */
  124375. export interface IWebXRControllerOptions {
  124376. /**
  124377. * Should the controller mesh be animated when a user interacts with it
  124378. * The pressed buttons / thumbstick and touchpad animations will be disabled
  124379. */
  124380. disableMotionControllerAnimation?: boolean;
  124381. /**
  124382. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  124383. */
  124384. doNotLoadControllerMesh?: boolean;
  124385. /**
  124386. * Force a specific controller type for this controller.
  124387. * This can be used when creating your own profile or when testing different controllers
  124388. */
  124389. forceControllerProfile?: string;
  124390. /**
  124391. * Defines a rendering group ID for meshes that will be loaded.
  124392. * This is for the default controllers only.
  124393. */
  124394. renderingGroupId?: number;
  124395. }
  124396. /**
  124397. * Represents an XR controller
  124398. */
  124399. export class WebXRInputSource {
  124400. private _scene;
  124401. /** The underlying input source for the controller */
  124402. inputSource: XRInputSource;
  124403. private _options;
  124404. private _tmpVector;
  124405. private _uniqueId;
  124406. /**
  124407. * 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
  124408. */
  124409. grip?: AbstractMesh;
  124410. /**
  124411. * If available, this is the gamepad object related to this controller.
  124412. * Using this object it is possible to get click events and trackpad changes of the
  124413. * webxr controller that is currently being used.
  124414. */
  124415. motionController?: WebXRAbstractMotionController;
  124416. /**
  124417. * Event that fires when the controller is removed/disposed.
  124418. * The object provided as event data is this controller, after associated assets were disposed.
  124419. * uniqueId is still available.
  124420. */
  124421. onDisposeObservable: Observable<WebXRInputSource>;
  124422. /**
  124423. * Will be triggered when the mesh associated with the motion controller is done loading.
  124424. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  124425. * A shortened version of controller -> motion controller -> on mesh loaded.
  124426. */
  124427. onMeshLoadedObservable: Observable<AbstractMesh>;
  124428. /**
  124429. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  124430. */
  124431. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  124432. /**
  124433. * Pointer which can be used to select objects or attach a visible laser to
  124434. */
  124435. pointer: AbstractMesh;
  124436. /**
  124437. * Creates the controller
  124438. * @see https://doc.babylonjs.com/how_to/webxr
  124439. * @param _scene the scene which the controller should be associated to
  124440. * @param inputSource the underlying input source for the controller
  124441. * @param _options options for this controller creation
  124442. */
  124443. constructor(_scene: Scene,
  124444. /** The underlying input source for the controller */
  124445. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  124446. /**
  124447. * Get this controllers unique id
  124448. */
  124449. get uniqueId(): string;
  124450. /**
  124451. * Disposes of the object
  124452. */
  124453. dispose(): void;
  124454. /**
  124455. * Gets a world space ray coming from the pointer or grip
  124456. * @param result the resulting ray
  124457. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  124458. */
  124459. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  124460. /**
  124461. * Updates the controller pose based on the given XRFrame
  124462. * @param xrFrame xr frame to update the pose with
  124463. * @param referenceSpace reference space to use
  124464. */
  124465. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  124466. }
  124467. }
  124468. declare module BABYLON {
  124469. /**
  124470. * The schema for initialization options of the XR Input class
  124471. */
  124472. export interface IWebXRInputOptions {
  124473. /**
  124474. * If set to true no model will be automatically loaded
  124475. */
  124476. doNotLoadControllerMeshes?: boolean;
  124477. /**
  124478. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  124479. * If not found, the xr input profile data will be used.
  124480. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  124481. */
  124482. forceInputProfile?: string;
  124483. /**
  124484. * Do not send a request to the controller repository to load the profile.
  124485. *
  124486. * Instead, use the controllers available in babylon itself.
  124487. */
  124488. disableOnlineControllerRepository?: boolean;
  124489. /**
  124490. * A custom URL for the controllers repository
  124491. */
  124492. customControllersRepositoryURL?: string;
  124493. /**
  124494. * Should the controller model's components not move according to the user input
  124495. */
  124496. disableControllerAnimation?: boolean;
  124497. /**
  124498. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  124499. */
  124500. controllerOptions?: IWebXRControllerOptions;
  124501. }
  124502. /**
  124503. * XR input used to track XR inputs such as controllers/rays
  124504. */
  124505. export class WebXRInput implements IDisposable {
  124506. /**
  124507. * the xr session manager for this session
  124508. */
  124509. xrSessionManager: WebXRSessionManager;
  124510. /**
  124511. * the WebXR camera for this session. Mainly used for teleportation
  124512. */
  124513. xrCamera: WebXRCamera;
  124514. private readonly options;
  124515. /**
  124516. * XR controllers being tracked
  124517. */
  124518. controllers: Array<WebXRInputSource>;
  124519. private _frameObserver;
  124520. private _sessionEndedObserver;
  124521. private _sessionInitObserver;
  124522. /**
  124523. * Event when a controller has been connected/added
  124524. */
  124525. onControllerAddedObservable: Observable<WebXRInputSource>;
  124526. /**
  124527. * Event when a controller has been removed/disconnected
  124528. */
  124529. onControllerRemovedObservable: Observable<WebXRInputSource>;
  124530. /**
  124531. * Initializes the WebXRInput
  124532. * @param xrSessionManager the xr session manager for this session
  124533. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  124534. * @param options = initialization options for this xr input
  124535. */
  124536. constructor(
  124537. /**
  124538. * the xr session manager for this session
  124539. */
  124540. xrSessionManager: WebXRSessionManager,
  124541. /**
  124542. * the WebXR camera for this session. Mainly used for teleportation
  124543. */
  124544. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  124545. private _onInputSourcesChange;
  124546. private _addAndRemoveControllers;
  124547. /**
  124548. * Disposes of the object
  124549. */
  124550. dispose(): void;
  124551. }
  124552. }
  124553. declare module BABYLON {
  124554. /**
  124555. * This is the base class for all WebXR features.
  124556. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  124557. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  124558. */
  124559. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  124560. protected _xrSessionManager: WebXRSessionManager;
  124561. private _attached;
  124562. private _removeOnDetach;
  124563. /**
  124564. * Should auto-attach be disabled?
  124565. */
  124566. disableAutoAttach: boolean;
  124567. /**
  124568. * Construct a new (abstract) WebXR feature
  124569. * @param _xrSessionManager the xr session manager for this feature
  124570. */
  124571. constructor(_xrSessionManager: WebXRSessionManager);
  124572. /**
  124573. * Is this feature attached
  124574. */
  124575. get attached(): boolean;
  124576. /**
  124577. * attach this feature
  124578. *
  124579. * @param force should attachment be forced (even when already attached)
  124580. * @returns true if successful, false is failed or already attached
  124581. */
  124582. attach(force?: boolean): boolean;
  124583. /**
  124584. * detach this feature.
  124585. *
  124586. * @returns true if successful, false if failed or already detached
  124587. */
  124588. detach(): boolean;
  124589. /**
  124590. * Dispose this feature and all of the resources attached
  124591. */
  124592. dispose(): void;
  124593. /**
  124594. * This is used to register callbacks that will automatically be removed when detach is called.
  124595. * @param observable the observable to which the observer will be attached
  124596. * @param callback the callback to register
  124597. */
  124598. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  124599. /**
  124600. * Code in this function will be executed on each xrFrame received from the browser.
  124601. * This function will not execute after the feature is detached.
  124602. * @param _xrFrame the current frame
  124603. */
  124604. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  124605. }
  124606. }
  124607. declare module BABYLON {
  124608. /**
  124609. * Renders a layer on top of an existing scene
  124610. */
  124611. export class UtilityLayerRenderer implements IDisposable {
  124612. /** the original scene that will be rendered on top of */
  124613. originalScene: Scene;
  124614. private _pointerCaptures;
  124615. private _lastPointerEvents;
  124616. private static _DefaultUtilityLayer;
  124617. private static _DefaultKeepDepthUtilityLayer;
  124618. private _sharedGizmoLight;
  124619. private _renderCamera;
  124620. /**
  124621. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  124622. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  124623. * @returns the camera that is used when rendering the utility layer
  124624. */
  124625. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  124626. /**
  124627. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  124628. * @param cam the camera that should be used when rendering the utility layer
  124629. */
  124630. setRenderCamera(cam: Nullable<Camera>): void;
  124631. /**
  124632. * @hidden
  124633. * Light which used by gizmos to get light shading
  124634. */
  124635. _getSharedGizmoLight(): HemisphericLight;
  124636. /**
  124637. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  124638. */
  124639. pickUtilitySceneFirst: boolean;
  124640. /**
  124641. * 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)
  124642. */
  124643. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  124644. /**
  124645. * 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)
  124646. */
  124647. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  124648. /**
  124649. * The scene that is rendered on top of the original scene
  124650. */
  124651. utilityLayerScene: Scene;
  124652. /**
  124653. * If the utility layer should automatically be rendered on top of existing scene
  124654. */
  124655. shouldRender: boolean;
  124656. /**
  124657. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  124658. */
  124659. onlyCheckPointerDownEvents: boolean;
  124660. /**
  124661. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  124662. */
  124663. processAllEvents: boolean;
  124664. /**
  124665. * Observable raised when the pointer move from the utility layer scene to the main scene
  124666. */
  124667. onPointerOutObservable: Observable<number>;
  124668. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  124669. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  124670. private _afterRenderObserver;
  124671. private _sceneDisposeObserver;
  124672. private _originalPointerObserver;
  124673. /**
  124674. * Instantiates a UtilityLayerRenderer
  124675. * @param originalScene the original scene that will be rendered on top of
  124676. * @param handleEvents boolean indicating if the utility layer should handle events
  124677. */
  124678. constructor(
  124679. /** the original scene that will be rendered on top of */
  124680. originalScene: Scene, handleEvents?: boolean);
  124681. private _notifyObservers;
  124682. /**
  124683. * Renders the utility layers scene on top of the original scene
  124684. */
  124685. render(): void;
  124686. /**
  124687. * Disposes of the renderer
  124688. */
  124689. dispose(): void;
  124690. private _updateCamera;
  124691. }
  124692. }
  124693. declare module BABYLON {
  124694. /**
  124695. * Options interface for the pointer selection module
  124696. */
  124697. export interface IWebXRControllerPointerSelectionOptions {
  124698. /**
  124699. * if provided, this scene will be used to render meshes.
  124700. */
  124701. customUtilityLayerScene?: Scene;
  124702. /**
  124703. * 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)
  124704. * If not disabled, the last picked point will be used to execute a pointer up event
  124705. * If disabled, pointer up event will be triggered right after the pointer down event.
  124706. * Used in screen and gaze target ray mode only
  124707. */
  124708. disablePointerUpOnTouchOut: boolean;
  124709. /**
  124710. * For gaze mode (time to select instead of press)
  124711. */
  124712. forceGazeMode: boolean;
  124713. /**
  124714. * 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
  124715. * to start a new countdown to the pointer down event.
  124716. * Defaults to 1.
  124717. */
  124718. gazeModePointerMovedFactor?: number;
  124719. /**
  124720. * Different button type to use instead of the main component
  124721. */
  124722. overrideButtonId?: string;
  124723. /**
  124724. * use this rendering group id for the meshes (optional)
  124725. */
  124726. renderingGroupId?: number;
  124727. /**
  124728. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  124729. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  124730. * 3000 means 3 seconds between pointing at something and selecting it
  124731. */
  124732. timeToSelect?: number;
  124733. /**
  124734. * Should meshes created here be added to a utility layer or the main scene
  124735. */
  124736. useUtilityLayer?: boolean;
  124737. /**
  124738. * the xr input to use with this pointer selection
  124739. */
  124740. xrInput: WebXRInput;
  124741. }
  124742. /**
  124743. * A module that will enable pointer selection for motion controllers of XR Input Sources
  124744. */
  124745. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  124746. private readonly _options;
  124747. private static _idCounter;
  124748. private _attachController;
  124749. private _controllers;
  124750. private _scene;
  124751. private _tmpVectorForPickCompare;
  124752. /**
  124753. * The module's name
  124754. */
  124755. static readonly Name: string;
  124756. /**
  124757. * The (Babylon) version of this module.
  124758. * This is an integer representing the implementation version.
  124759. * This number does not correspond to the WebXR specs version
  124760. */
  124761. static readonly Version: number;
  124762. /**
  124763. * Disable lighting on the laser pointer (so it will always be visible)
  124764. */
  124765. disablePointerLighting: boolean;
  124766. /**
  124767. * Disable lighting on the selection mesh (so it will always be visible)
  124768. */
  124769. disableSelectionMeshLighting: boolean;
  124770. /**
  124771. * Should the laser pointer be displayed
  124772. */
  124773. displayLaserPointer: boolean;
  124774. /**
  124775. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  124776. */
  124777. displaySelectionMesh: boolean;
  124778. /**
  124779. * This color will be set to the laser pointer when selection is triggered
  124780. */
  124781. laserPointerPickedColor: Color3;
  124782. /**
  124783. * Default color of the laser pointer
  124784. */
  124785. lasterPointerDefaultColor: Color3;
  124786. /**
  124787. * default color of the selection ring
  124788. */
  124789. selectionMeshDefaultColor: Color3;
  124790. /**
  124791. * This color will be applied to the selection ring when selection is triggered
  124792. */
  124793. selectionMeshPickedColor: Color3;
  124794. /**
  124795. * Optional filter to be used for ray selection. This predicate shares behavior with
  124796. * scene.pointerMovePredicate which takes priority if it is also assigned.
  124797. */
  124798. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  124799. /**
  124800. * constructs a new background remover module
  124801. * @param _xrSessionManager the session manager for this module
  124802. * @param _options read-only options to be used in this module
  124803. */
  124804. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  124805. /**
  124806. * attach this feature
  124807. * Will usually be called by the features manager
  124808. *
  124809. * @returns true if successful.
  124810. */
  124811. attach(): boolean;
  124812. /**
  124813. * detach this feature.
  124814. * Will usually be called by the features manager
  124815. *
  124816. * @returns true if successful.
  124817. */
  124818. detach(): boolean;
  124819. /**
  124820. * Will get the mesh under a specific pointer.
  124821. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  124822. * @param controllerId the controllerId to check
  124823. * @returns The mesh under pointer or null if no mesh is under the pointer
  124824. */
  124825. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  124826. /**
  124827. * Get the xr controller that correlates to the pointer id in the pointer event
  124828. *
  124829. * @param id the pointer id to search for
  124830. * @returns the controller that correlates to this id or null if not found
  124831. */
  124832. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  124833. protected _onXRFrame(_xrFrame: XRFrame): void;
  124834. private _attachGazeMode;
  124835. private _attachScreenRayMode;
  124836. private _attachTrackedPointerRayMode;
  124837. private _convertNormalToDirectionOfRay;
  124838. private _detachController;
  124839. private _generateNewMeshPair;
  124840. private _pickingMoved;
  124841. private _updatePointerDistance;
  124842. }
  124843. }
  124844. declare module BABYLON {
  124845. /**
  124846. * Button which can be used to enter a different mode of XR
  124847. */
  124848. export class WebXREnterExitUIButton {
  124849. /** button element */
  124850. element: HTMLElement;
  124851. /** XR initialization options for the button */
  124852. sessionMode: XRSessionMode;
  124853. /** Reference space type */
  124854. referenceSpaceType: XRReferenceSpaceType;
  124855. /**
  124856. * Creates a WebXREnterExitUIButton
  124857. * @param element button element
  124858. * @param sessionMode XR initialization session mode
  124859. * @param referenceSpaceType the type of reference space to be used
  124860. */
  124861. constructor(
  124862. /** button element */
  124863. element: HTMLElement,
  124864. /** XR initialization options for the button */
  124865. sessionMode: XRSessionMode,
  124866. /** Reference space type */
  124867. referenceSpaceType: XRReferenceSpaceType);
  124868. /**
  124869. * Extendable function which can be used to update the button's visuals when the state changes
  124870. * @param activeButton the current active button in the UI
  124871. */
  124872. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  124873. }
  124874. /**
  124875. * Options to create the webXR UI
  124876. */
  124877. export class WebXREnterExitUIOptions {
  124878. /**
  124879. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  124880. */
  124881. customButtons?: Array<WebXREnterExitUIButton>;
  124882. /**
  124883. * A reference space type to use when creating the default button.
  124884. * Default is local-floor
  124885. */
  124886. referenceSpaceType?: XRReferenceSpaceType;
  124887. /**
  124888. * Context to enter xr with
  124889. */
  124890. renderTarget?: Nullable<WebXRRenderTarget>;
  124891. /**
  124892. * A session mode to use when creating the default button.
  124893. * Default is immersive-vr
  124894. */
  124895. sessionMode?: XRSessionMode;
  124896. /**
  124897. * A list of optional features to init the session with
  124898. */
  124899. optionalFeatures?: string[];
  124900. }
  124901. /**
  124902. * UI to allow the user to enter/exit XR mode
  124903. */
  124904. export class WebXREnterExitUI implements IDisposable {
  124905. private scene;
  124906. /** version of the options passed to this UI */
  124907. options: WebXREnterExitUIOptions;
  124908. private _activeButton;
  124909. private _buttons;
  124910. private _overlay;
  124911. /**
  124912. * Fired every time the active button is changed.
  124913. *
  124914. * When xr is entered via a button that launches xr that button will be the callback parameter
  124915. *
  124916. * When exiting xr the callback parameter will be null)
  124917. */
  124918. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  124919. /**
  124920. *
  124921. * @param scene babylon scene object to use
  124922. * @param options (read-only) version of the options passed to this UI
  124923. */
  124924. private constructor();
  124925. /**
  124926. * Creates UI to allow the user to enter/exit XR mode
  124927. * @param scene the scene to add the ui to
  124928. * @param helper the xr experience helper to enter/exit xr with
  124929. * @param options options to configure the UI
  124930. * @returns the created ui
  124931. */
  124932. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  124933. /**
  124934. * Disposes of the XR UI component
  124935. */
  124936. dispose(): void;
  124937. private _updateButtons;
  124938. }
  124939. }
  124940. declare module BABYLON {
  124941. /**
  124942. * Class containing static functions to help procedurally build meshes
  124943. */
  124944. export class LinesBuilder {
  124945. /**
  124946. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  124947. * * 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
  124948. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  124949. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  124950. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  124951. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  124952. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  124953. * * 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
  124954. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  124955. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124956. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  124957. * @param name defines the name of the new line system
  124958. * @param options defines the options used to create the line system
  124959. * @param scene defines the hosting scene
  124960. * @returns a new line system mesh
  124961. */
  124962. static CreateLineSystem(name: string, options: {
  124963. lines: Vector3[][];
  124964. updatable?: boolean;
  124965. instance?: Nullable<LinesMesh>;
  124966. colors?: Nullable<Color4[][]>;
  124967. useVertexAlpha?: boolean;
  124968. }, scene: Nullable<Scene>): LinesMesh;
  124969. /**
  124970. * Creates a line mesh
  124971. * 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
  124972. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  124973. * * The parameter `points` is an array successive Vector3
  124974. * * 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
  124975. * * The optional parameter `colors` is an array of successive Color4, one per line point
  124976. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  124977. * * When updating an instance, remember that only point positions can change, not the number of points
  124978. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124979. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  124980. * @param name defines the name of the new line system
  124981. * @param options defines the options used to create the line system
  124982. * @param scene defines the hosting scene
  124983. * @returns a new line mesh
  124984. */
  124985. static CreateLines(name: string, options: {
  124986. points: Vector3[];
  124987. updatable?: boolean;
  124988. instance?: Nullable<LinesMesh>;
  124989. colors?: Color4[];
  124990. useVertexAlpha?: boolean;
  124991. }, scene?: Nullable<Scene>): LinesMesh;
  124992. /**
  124993. * Creates a dashed line mesh
  124994. * * 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
  124995. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  124996. * * The parameter `points` is an array successive Vector3
  124997. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  124998. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  124999. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  125000. * * 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
  125001. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  125002. * * When updating an instance, remember that only point positions can change, not the number of points
  125003. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125004. * @param name defines the name of the mesh
  125005. * @param options defines the options used to create the mesh
  125006. * @param scene defines the hosting scene
  125007. * @returns the dashed line mesh
  125008. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  125009. */
  125010. static CreateDashedLines(name: string, options: {
  125011. points: Vector3[];
  125012. dashSize?: number;
  125013. gapSize?: number;
  125014. dashNb?: number;
  125015. updatable?: boolean;
  125016. instance?: LinesMesh;
  125017. useVertexAlpha?: boolean;
  125018. }, scene?: Nullable<Scene>): LinesMesh;
  125019. }
  125020. }
  125021. declare module BABYLON {
  125022. /**
  125023. * The options container for the teleportation module
  125024. */
  125025. export interface IWebXRTeleportationOptions {
  125026. /**
  125027. * if provided, this scene will be used to render meshes.
  125028. */
  125029. customUtilityLayerScene?: Scene;
  125030. /**
  125031. * Values to configure the default target mesh
  125032. */
  125033. defaultTargetMeshOptions?: {
  125034. /**
  125035. * Fill color of the teleportation area
  125036. */
  125037. teleportationFillColor?: string;
  125038. /**
  125039. * Border color for the teleportation area
  125040. */
  125041. teleportationBorderColor?: string;
  125042. /**
  125043. * Disable the mesh's animation sequence
  125044. */
  125045. disableAnimation?: boolean;
  125046. /**
  125047. * Disable lighting on the material or the ring and arrow
  125048. */
  125049. disableLighting?: boolean;
  125050. /**
  125051. * Override the default material of the torus and arrow
  125052. */
  125053. torusArrowMaterial?: Material;
  125054. };
  125055. /**
  125056. * A list of meshes to use as floor meshes.
  125057. * Meshes can be added and removed after initializing the feature using the
  125058. * addFloorMesh and removeFloorMesh functions
  125059. * If empty, rotation will still work
  125060. */
  125061. floorMeshes?: AbstractMesh[];
  125062. /**
  125063. * use this rendering group id for the meshes (optional)
  125064. */
  125065. renderingGroupId?: number;
  125066. /**
  125067. * Should teleportation move only to snap points
  125068. */
  125069. snapPointsOnly?: boolean;
  125070. /**
  125071. * An array of points to which the teleportation will snap to.
  125072. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  125073. */
  125074. snapPositions?: Vector3[];
  125075. /**
  125076. * How close should the teleportation ray be in order to snap to position.
  125077. * Default to 0.8 units (meters)
  125078. */
  125079. snapToPositionRadius?: number;
  125080. /**
  125081. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  125082. * If you want to support rotation, make sure your mesh has a direction indicator.
  125083. *
  125084. * When left untouched, the default mesh will be initialized.
  125085. */
  125086. teleportationTargetMesh?: AbstractMesh;
  125087. /**
  125088. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  125089. */
  125090. timeToTeleport?: number;
  125091. /**
  125092. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  125093. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  125094. */
  125095. useMainComponentOnly?: boolean;
  125096. /**
  125097. * Should meshes created here be added to a utility layer or the main scene
  125098. */
  125099. useUtilityLayer?: boolean;
  125100. /**
  125101. * Babylon XR Input class for controller
  125102. */
  125103. xrInput: WebXRInput;
  125104. }
  125105. /**
  125106. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  125107. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  125108. * the input of the attached controllers.
  125109. */
  125110. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  125111. private _options;
  125112. private _controllers;
  125113. private _currentTeleportationControllerId;
  125114. private _floorMeshes;
  125115. private _quadraticBezierCurve;
  125116. private _selectionFeature;
  125117. private _snapToPositions;
  125118. private _snappedToPoint;
  125119. private _teleportationRingMaterial?;
  125120. private _tmpRay;
  125121. private _tmpVector;
  125122. /**
  125123. * The module's name
  125124. */
  125125. static readonly Name: string;
  125126. /**
  125127. * The (Babylon) version of this module.
  125128. * This is an integer representing the implementation version.
  125129. * This number does not correspond to the webxr specs version
  125130. */
  125131. static readonly Version: number;
  125132. /**
  125133. * Is movement backwards enabled
  125134. */
  125135. backwardsMovementEnabled: boolean;
  125136. /**
  125137. * Distance to travel when moving backwards
  125138. */
  125139. backwardsTeleportationDistance: number;
  125140. /**
  125141. * The distance from the user to the inspection point in the direction of the controller
  125142. * A higher number will allow the user to move further
  125143. * defaults to 5 (meters, in xr units)
  125144. */
  125145. parabolicCheckRadius: number;
  125146. /**
  125147. * Should the module support parabolic ray on top of direct ray
  125148. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  125149. * Very helpful when moving between floors / different heights
  125150. */
  125151. parabolicRayEnabled: boolean;
  125152. /**
  125153. * How much rotation should be applied when rotating right and left
  125154. */
  125155. rotationAngle: number;
  125156. /**
  125157. * Is rotation enabled when moving forward?
  125158. * Disabling this feature will prevent the user from deciding the direction when teleporting
  125159. */
  125160. rotationEnabled: boolean;
  125161. /**
  125162. * constructs a new anchor system
  125163. * @param _xrSessionManager an instance of WebXRSessionManager
  125164. * @param _options configuration object for this feature
  125165. */
  125166. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  125167. /**
  125168. * Get the snapPointsOnly flag
  125169. */
  125170. get snapPointsOnly(): boolean;
  125171. /**
  125172. * Sets the snapPointsOnly flag
  125173. * @param snapToPoints should teleportation be exclusively to snap points
  125174. */
  125175. set snapPointsOnly(snapToPoints: boolean);
  125176. /**
  125177. * Add a new mesh to the floor meshes array
  125178. * @param mesh the mesh to use as floor mesh
  125179. */
  125180. addFloorMesh(mesh: AbstractMesh): void;
  125181. /**
  125182. * Add a new snap-to point to fix teleportation to this position
  125183. * @param newSnapPoint The new Snap-To point
  125184. */
  125185. addSnapPoint(newSnapPoint: Vector3): void;
  125186. attach(): boolean;
  125187. detach(): boolean;
  125188. dispose(): void;
  125189. /**
  125190. * Remove a mesh from the floor meshes array
  125191. * @param mesh the mesh to remove
  125192. */
  125193. removeFloorMesh(mesh: AbstractMesh): void;
  125194. /**
  125195. * Remove a mesh from the floor meshes array using its name
  125196. * @param name the mesh name to remove
  125197. */
  125198. removeFloorMeshByName(name: string): void;
  125199. /**
  125200. * 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
  125201. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  125202. * @returns was the point found and removed or not
  125203. */
  125204. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  125205. /**
  125206. * This function sets a selection feature that will be disabled when
  125207. * the forward ray is shown and will be reattached when hidden.
  125208. * This is used to remove the selection rays when moving.
  125209. * @param selectionFeature the feature to disable when forward movement is enabled
  125210. */
  125211. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  125212. protected _onXRFrame(_xrFrame: XRFrame): void;
  125213. private _attachController;
  125214. private _createDefaultTargetMesh;
  125215. private _detachController;
  125216. private _findClosestSnapPointWithRadius;
  125217. private _setTargetMeshPosition;
  125218. private _setTargetMeshVisibility;
  125219. private _showParabolicPath;
  125220. private _teleportForward;
  125221. }
  125222. }
  125223. declare module BABYLON {
  125224. /**
  125225. * Options for the default xr helper
  125226. */
  125227. export class WebXRDefaultExperienceOptions {
  125228. /**
  125229. * Enable or disable default UI to enter XR
  125230. */
  125231. disableDefaultUI?: boolean;
  125232. /**
  125233. * Should teleportation not initialize. defaults to false.
  125234. */
  125235. disableTeleportation?: boolean;
  125236. /**
  125237. * Floor meshes that will be used for teleport
  125238. */
  125239. floorMeshes?: Array<AbstractMesh>;
  125240. /**
  125241. * If set to true, the first frame will not be used to reset position
  125242. * The first frame is mainly used when copying transformation from the old camera
  125243. * Mainly used in AR
  125244. */
  125245. ignoreNativeCameraTransformation?: boolean;
  125246. /**
  125247. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  125248. */
  125249. inputOptions?: IWebXRInputOptions;
  125250. /**
  125251. * optional configuration for the output canvas
  125252. */
  125253. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  125254. /**
  125255. * optional UI options. This can be used among other to change session mode and reference space type
  125256. */
  125257. uiOptions?: WebXREnterExitUIOptions;
  125258. /**
  125259. * When loading teleportation and pointer select, use stable versions instead of latest.
  125260. */
  125261. useStablePlugins?: boolean;
  125262. /**
  125263. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  125264. */
  125265. renderingGroupId?: number;
  125266. /**
  125267. * A list of optional features to init the session with
  125268. * If set to true, all features we support will be added
  125269. */
  125270. optionalFeatures?: boolean | string[];
  125271. }
  125272. /**
  125273. * Default experience which provides a similar setup to the previous webVRExperience
  125274. */
  125275. export class WebXRDefaultExperience {
  125276. /**
  125277. * Base experience
  125278. */
  125279. baseExperience: WebXRExperienceHelper;
  125280. /**
  125281. * Enables ui for entering/exiting xr
  125282. */
  125283. enterExitUI: WebXREnterExitUI;
  125284. /**
  125285. * Input experience extension
  125286. */
  125287. input: WebXRInput;
  125288. /**
  125289. * Enables laser pointer and selection
  125290. */
  125291. pointerSelection: WebXRControllerPointerSelection;
  125292. /**
  125293. * Default target xr should render to
  125294. */
  125295. renderTarget: WebXRRenderTarget;
  125296. /**
  125297. * Enables teleportation
  125298. */
  125299. teleportation: WebXRMotionControllerTeleportation;
  125300. private constructor();
  125301. /**
  125302. * Creates the default xr experience
  125303. * @param scene scene
  125304. * @param options options for basic configuration
  125305. * @returns resulting WebXRDefaultExperience
  125306. */
  125307. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  125308. /**
  125309. * DIsposes of the experience helper
  125310. */
  125311. dispose(): void;
  125312. }
  125313. }
  125314. declare module BABYLON {
  125315. /**
  125316. * Options to modify the vr teleportation behavior.
  125317. */
  125318. export interface VRTeleportationOptions {
  125319. /**
  125320. * The name of the mesh which should be used as the teleportation floor. (default: null)
  125321. */
  125322. floorMeshName?: string;
  125323. /**
  125324. * A list of meshes to be used as the teleportation floor. (default: empty)
  125325. */
  125326. floorMeshes?: Mesh[];
  125327. /**
  125328. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  125329. */
  125330. teleportationMode?: number;
  125331. /**
  125332. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  125333. */
  125334. teleportationTime?: number;
  125335. /**
  125336. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  125337. */
  125338. teleportationSpeed?: number;
  125339. /**
  125340. * The easing function used in the animation or null for Linear. (default CircleEase)
  125341. */
  125342. easingFunction?: EasingFunction;
  125343. }
  125344. /**
  125345. * Options to modify the vr experience helper's behavior.
  125346. */
  125347. export interface VRExperienceHelperOptions extends WebVROptions {
  125348. /**
  125349. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  125350. */
  125351. createDeviceOrientationCamera?: boolean;
  125352. /**
  125353. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  125354. */
  125355. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  125356. /**
  125357. * Uses the main button on the controller to toggle the laser casted. (default: true)
  125358. */
  125359. laserToggle?: boolean;
  125360. /**
  125361. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  125362. */
  125363. floorMeshes?: Mesh[];
  125364. /**
  125365. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  125366. */
  125367. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  125368. /**
  125369. * Defines if WebXR should be used instead of WebVR (if available)
  125370. */
  125371. useXR?: boolean;
  125372. }
  125373. /**
  125374. * Event containing information after VR has been entered
  125375. */
  125376. export class OnAfterEnteringVRObservableEvent {
  125377. /**
  125378. * If entering vr was successful
  125379. */
  125380. success: boolean;
  125381. }
  125382. /**
  125383. * Helps to quickly add VR support to an existing scene.
  125384. * See http://doc.babylonjs.com/how_to/webvr_helper
  125385. */
  125386. export class VRExperienceHelper {
  125387. /** Options to modify the vr experience helper's behavior. */
  125388. webVROptions: VRExperienceHelperOptions;
  125389. private _scene;
  125390. private _position;
  125391. private _btnVR;
  125392. private _btnVRDisplayed;
  125393. private _webVRsupported;
  125394. private _webVRready;
  125395. private _webVRrequesting;
  125396. private _webVRpresenting;
  125397. private _hasEnteredVR;
  125398. private _fullscreenVRpresenting;
  125399. private _inputElement;
  125400. private _webVRCamera;
  125401. private _vrDeviceOrientationCamera;
  125402. private _deviceOrientationCamera;
  125403. private _existingCamera;
  125404. private _onKeyDown;
  125405. private _onVrDisplayPresentChange;
  125406. private _onVRDisplayChanged;
  125407. private _onVRRequestPresentStart;
  125408. private _onVRRequestPresentComplete;
  125409. /**
  125410. * 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)
  125411. */
  125412. enableGazeEvenWhenNoPointerLock: boolean;
  125413. /**
  125414. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  125415. */
  125416. exitVROnDoubleTap: boolean;
  125417. /**
  125418. * Observable raised right before entering VR.
  125419. */
  125420. onEnteringVRObservable: Observable<VRExperienceHelper>;
  125421. /**
  125422. * Observable raised when entering VR has completed.
  125423. */
  125424. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  125425. /**
  125426. * Observable raised when exiting VR.
  125427. */
  125428. onExitingVRObservable: Observable<VRExperienceHelper>;
  125429. /**
  125430. * Observable raised when controller mesh is loaded.
  125431. */
  125432. onControllerMeshLoadedObservable: Observable<WebVRController>;
  125433. /** Return this.onEnteringVRObservable
  125434. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  125435. */
  125436. get onEnteringVR(): Observable<VRExperienceHelper>;
  125437. /** Return this.onExitingVRObservable
  125438. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  125439. */
  125440. get onExitingVR(): Observable<VRExperienceHelper>;
  125441. /** Return this.onControllerMeshLoadedObservable
  125442. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  125443. */
  125444. get onControllerMeshLoaded(): Observable<WebVRController>;
  125445. private _rayLength;
  125446. private _useCustomVRButton;
  125447. private _teleportationRequested;
  125448. private _teleportActive;
  125449. private _floorMeshName;
  125450. private _floorMeshesCollection;
  125451. private _teleportationMode;
  125452. private _teleportationTime;
  125453. private _teleportationSpeed;
  125454. private _teleportationEasing;
  125455. private _rotationAllowed;
  125456. private _teleportBackwardsVector;
  125457. private _teleportationTarget;
  125458. private _isDefaultTeleportationTarget;
  125459. private _postProcessMove;
  125460. private _teleportationFillColor;
  125461. private _teleportationBorderColor;
  125462. private _rotationAngle;
  125463. private _haloCenter;
  125464. private _cameraGazer;
  125465. private _padSensibilityUp;
  125466. private _padSensibilityDown;
  125467. private _leftController;
  125468. private _rightController;
  125469. private _gazeColor;
  125470. private _laserColor;
  125471. private _pickedLaserColor;
  125472. private _pickedGazeColor;
  125473. /**
  125474. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  125475. */
  125476. onNewMeshSelected: Observable<AbstractMesh>;
  125477. /**
  125478. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  125479. * This observable will provide the mesh and the controller used to select the mesh
  125480. */
  125481. onMeshSelectedWithController: Observable<{
  125482. mesh: AbstractMesh;
  125483. controller: WebVRController;
  125484. }>;
  125485. /**
  125486. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  125487. */
  125488. onNewMeshPicked: Observable<PickingInfo>;
  125489. private _circleEase;
  125490. /**
  125491. * Observable raised before camera teleportation
  125492. */
  125493. onBeforeCameraTeleport: Observable<Vector3>;
  125494. /**
  125495. * Observable raised after camera teleportation
  125496. */
  125497. onAfterCameraTeleport: Observable<Vector3>;
  125498. /**
  125499. * Observable raised when current selected mesh gets unselected
  125500. */
  125501. onSelectedMeshUnselected: Observable<AbstractMesh>;
  125502. private _raySelectionPredicate;
  125503. /**
  125504. * To be optionaly changed by user to define custom ray selection
  125505. */
  125506. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  125507. /**
  125508. * To be optionaly changed by user to define custom selection logic (after ray selection)
  125509. */
  125510. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  125511. /**
  125512. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  125513. */
  125514. teleportationEnabled: boolean;
  125515. private _defaultHeight;
  125516. private _teleportationInitialized;
  125517. private _interactionsEnabled;
  125518. private _interactionsRequested;
  125519. private _displayGaze;
  125520. private _displayLaserPointer;
  125521. /**
  125522. * The mesh used to display where the user is going to teleport.
  125523. */
  125524. get teleportationTarget(): Mesh;
  125525. /**
  125526. * Sets the mesh to be used to display where the user is going to teleport.
  125527. */
  125528. set teleportationTarget(value: Mesh);
  125529. /**
  125530. * 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
  125531. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  125532. * See http://doc.babylonjs.com/resources/baking_transformations
  125533. */
  125534. get gazeTrackerMesh(): Mesh;
  125535. set gazeTrackerMesh(value: Mesh);
  125536. /**
  125537. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  125538. */
  125539. updateGazeTrackerScale: boolean;
  125540. /**
  125541. * If the gaze trackers color should be updated when selecting meshes
  125542. */
  125543. updateGazeTrackerColor: boolean;
  125544. /**
  125545. * If the controller laser color should be updated when selecting meshes
  125546. */
  125547. updateControllerLaserColor: boolean;
  125548. /**
  125549. * The gaze tracking mesh corresponding to the left controller
  125550. */
  125551. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  125552. /**
  125553. * The gaze tracking mesh corresponding to the right controller
  125554. */
  125555. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  125556. /**
  125557. * If the ray of the gaze should be displayed.
  125558. */
  125559. get displayGaze(): boolean;
  125560. /**
  125561. * Sets if the ray of the gaze should be displayed.
  125562. */
  125563. set displayGaze(value: boolean);
  125564. /**
  125565. * If the ray of the LaserPointer should be displayed.
  125566. */
  125567. get displayLaserPointer(): boolean;
  125568. /**
  125569. * Sets if the ray of the LaserPointer should be displayed.
  125570. */
  125571. set displayLaserPointer(value: boolean);
  125572. /**
  125573. * The deviceOrientationCamera used as the camera when not in VR.
  125574. */
  125575. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  125576. /**
  125577. * Based on the current WebVR support, returns the current VR camera used.
  125578. */
  125579. get currentVRCamera(): Nullable<Camera>;
  125580. /**
  125581. * The webVRCamera which is used when in VR.
  125582. */
  125583. get webVRCamera(): WebVRFreeCamera;
  125584. /**
  125585. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  125586. */
  125587. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  125588. /**
  125589. * The html button that is used to trigger entering into VR.
  125590. */
  125591. get vrButton(): Nullable<HTMLButtonElement>;
  125592. private get _teleportationRequestInitiated();
  125593. /**
  125594. * Defines whether or not Pointer lock should be requested when switching to
  125595. * full screen.
  125596. */
  125597. requestPointerLockOnFullScreen: boolean;
  125598. /**
  125599. * If asking to force XR, this will be populated with the default xr experience
  125600. */
  125601. xr: WebXRDefaultExperience;
  125602. /**
  125603. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  125604. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  125605. */
  125606. xrTestDone: boolean;
  125607. /**
  125608. * Instantiates a VRExperienceHelper.
  125609. * Helps to quickly add VR support to an existing scene.
  125610. * @param scene The scene the VRExperienceHelper belongs to.
  125611. * @param webVROptions Options to modify the vr experience helper's behavior.
  125612. */
  125613. constructor(scene: Scene,
  125614. /** Options to modify the vr experience helper's behavior. */
  125615. webVROptions?: VRExperienceHelperOptions);
  125616. private completeVRInit;
  125617. private _onDefaultMeshLoaded;
  125618. private _onResize;
  125619. private _onFullscreenChange;
  125620. /**
  125621. * Gets a value indicating if we are currently in VR mode.
  125622. */
  125623. get isInVRMode(): boolean;
  125624. private onVrDisplayPresentChange;
  125625. private onVRDisplayChanged;
  125626. private moveButtonToBottomRight;
  125627. private displayVRButton;
  125628. private updateButtonVisibility;
  125629. private _cachedAngularSensibility;
  125630. /**
  125631. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  125632. * Otherwise, will use the fullscreen API.
  125633. */
  125634. enterVR(): void;
  125635. /**
  125636. * Attempt to exit VR, or fullscreen.
  125637. */
  125638. exitVR(): void;
  125639. /**
  125640. * The position of the vr experience helper.
  125641. */
  125642. get position(): Vector3;
  125643. /**
  125644. * Sets the position of the vr experience helper.
  125645. */
  125646. set position(value: Vector3);
  125647. /**
  125648. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  125649. */
  125650. enableInteractions(): void;
  125651. private get _noControllerIsActive();
  125652. private beforeRender;
  125653. private _isTeleportationFloor;
  125654. /**
  125655. * Adds a floor mesh to be used for teleportation.
  125656. * @param floorMesh the mesh to be used for teleportation.
  125657. */
  125658. addFloorMesh(floorMesh: Mesh): void;
  125659. /**
  125660. * Removes a floor mesh from being used for teleportation.
  125661. * @param floorMesh the mesh to be removed.
  125662. */
  125663. removeFloorMesh(floorMesh: Mesh): void;
  125664. /**
  125665. * Enables interactions and teleportation using the VR controllers and gaze.
  125666. * @param vrTeleportationOptions options to modify teleportation behavior.
  125667. */
  125668. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  125669. private _onNewGamepadConnected;
  125670. private _tryEnableInteractionOnController;
  125671. private _onNewGamepadDisconnected;
  125672. private _enableInteractionOnController;
  125673. private _checkTeleportWithRay;
  125674. private _checkRotate;
  125675. private _checkTeleportBackwards;
  125676. private _enableTeleportationOnController;
  125677. private _createTeleportationCircles;
  125678. private _displayTeleportationTarget;
  125679. private _hideTeleportationTarget;
  125680. private _rotateCamera;
  125681. private _moveTeleportationSelectorTo;
  125682. private _workingVector;
  125683. private _workingQuaternion;
  125684. private _workingMatrix;
  125685. /**
  125686. * Time Constant Teleportation Mode
  125687. */
  125688. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  125689. /**
  125690. * Speed Constant Teleportation Mode
  125691. */
  125692. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  125693. /**
  125694. * Teleports the users feet to the desired location
  125695. * @param location The location where the user's feet should be placed
  125696. */
  125697. teleportCamera(location: Vector3): void;
  125698. private _convertNormalToDirectionOfRay;
  125699. private _castRayAndSelectObject;
  125700. private _notifySelectedMeshUnselected;
  125701. /**
  125702. * Permanently set new colors for the laser pointer
  125703. * @param color the new laser color
  125704. * @param pickedColor the new laser color when picked mesh detected
  125705. */
  125706. setLaserColor(color: Color3, pickedColor?: Color3): void;
  125707. /**
  125708. * Set lighting enabled / disabled on the laser pointer of both controllers
  125709. * @param enabled should the lighting be enabled on the laser pointer
  125710. */
  125711. setLaserLightingState(enabled?: boolean): void;
  125712. /**
  125713. * Permanently set new colors for the gaze pointer
  125714. * @param color the new gaze color
  125715. * @param pickedColor the new gaze color when picked mesh detected
  125716. */
  125717. setGazeColor(color: Color3, pickedColor?: Color3): void;
  125718. /**
  125719. * Sets the color of the laser ray from the vr controllers.
  125720. * @param color new color for the ray.
  125721. */
  125722. changeLaserColor(color: Color3): void;
  125723. /**
  125724. * Sets the color of the ray from the vr headsets gaze.
  125725. * @param color new color for the ray.
  125726. */
  125727. changeGazeColor(color: Color3): void;
  125728. /**
  125729. * Exits VR and disposes of the vr experience helper
  125730. */
  125731. dispose(): void;
  125732. /**
  125733. * Gets the name of the VRExperienceHelper class
  125734. * @returns "VRExperienceHelper"
  125735. */
  125736. getClassName(): string;
  125737. }
  125738. }
  125739. declare module BABYLON {
  125740. /**
  125741. * Contains an array of blocks representing the octree
  125742. */
  125743. export interface IOctreeContainer<T> {
  125744. /**
  125745. * Blocks within the octree
  125746. */
  125747. blocks: Array<OctreeBlock<T>>;
  125748. }
  125749. /**
  125750. * Class used to store a cell in an octree
  125751. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  125752. */
  125753. export class OctreeBlock<T> {
  125754. /**
  125755. * Gets the content of the current block
  125756. */
  125757. entries: T[];
  125758. /**
  125759. * Gets the list of block children
  125760. */
  125761. blocks: Array<OctreeBlock<T>>;
  125762. private _depth;
  125763. private _maxDepth;
  125764. private _capacity;
  125765. private _minPoint;
  125766. private _maxPoint;
  125767. private _boundingVectors;
  125768. private _creationFunc;
  125769. /**
  125770. * Creates a new block
  125771. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  125772. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  125773. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  125774. * @param depth defines the current depth of this block in the octree
  125775. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  125776. * @param creationFunc defines a callback to call when an element is added to the block
  125777. */
  125778. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  125779. /**
  125780. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  125781. */
  125782. get capacity(): number;
  125783. /**
  125784. * Gets the minimum vector (in world space) of the block's bounding box
  125785. */
  125786. get minPoint(): Vector3;
  125787. /**
  125788. * Gets the maximum vector (in world space) of the block's bounding box
  125789. */
  125790. get maxPoint(): Vector3;
  125791. /**
  125792. * Add a new element to this block
  125793. * @param entry defines the element to add
  125794. */
  125795. addEntry(entry: T): void;
  125796. /**
  125797. * Remove an element from this block
  125798. * @param entry defines the element to remove
  125799. */
  125800. removeEntry(entry: T): void;
  125801. /**
  125802. * Add an array of elements to this block
  125803. * @param entries defines the array of elements to add
  125804. */
  125805. addEntries(entries: T[]): void;
  125806. /**
  125807. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  125808. * @param frustumPlanes defines the frustum planes to test
  125809. * @param selection defines the array to store current content if selection is positive
  125810. * @param allowDuplicate defines if the selection array can contains duplicated entries
  125811. */
  125812. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  125813. /**
  125814. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  125815. * @param sphereCenter defines the bounding sphere center
  125816. * @param sphereRadius defines the bounding sphere radius
  125817. * @param selection defines the array to store current content if selection is positive
  125818. * @param allowDuplicate defines if the selection array can contains duplicated entries
  125819. */
  125820. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  125821. /**
  125822. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  125823. * @param ray defines the ray to test with
  125824. * @param selection defines the array to store current content if selection is positive
  125825. */
  125826. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  125827. /**
  125828. * Subdivide the content into child blocks (this block will then be empty)
  125829. */
  125830. createInnerBlocks(): void;
  125831. /**
  125832. * @hidden
  125833. */
  125834. 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;
  125835. }
  125836. }
  125837. declare module BABYLON {
  125838. /**
  125839. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  125840. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  125841. */
  125842. export class Octree<T> {
  125843. /** 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.) */
  125844. maxDepth: number;
  125845. /**
  125846. * Blocks within the octree containing objects
  125847. */
  125848. blocks: Array<OctreeBlock<T>>;
  125849. /**
  125850. * Content stored in the octree
  125851. */
  125852. dynamicContent: T[];
  125853. private _maxBlockCapacity;
  125854. private _selectionContent;
  125855. private _creationFunc;
  125856. /**
  125857. * Creates a octree
  125858. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  125859. * @param creationFunc function to be used to instatiate the octree
  125860. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  125861. * @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.)
  125862. */
  125863. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  125864. /** 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.) */
  125865. maxDepth?: number);
  125866. /**
  125867. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  125868. * @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);
  125869. * @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);
  125870. * @param entries meshes to be added to the octree blocks
  125871. */
  125872. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  125873. /**
  125874. * Adds a mesh to the octree
  125875. * @param entry Mesh to add to the octree
  125876. */
  125877. addMesh(entry: T): void;
  125878. /**
  125879. * Remove an element from the octree
  125880. * @param entry defines the element to remove
  125881. */
  125882. removeMesh(entry: T): void;
  125883. /**
  125884. * Selects an array of meshes within the frustum
  125885. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  125886. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  125887. * @returns array of meshes within the frustum
  125888. */
  125889. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  125890. /**
  125891. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  125892. * @param sphereCenter defines the bounding sphere center
  125893. * @param sphereRadius defines the bounding sphere radius
  125894. * @param allowDuplicate defines if the selection array can contains duplicated entries
  125895. * @returns an array of objects that intersect the sphere
  125896. */
  125897. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  125898. /**
  125899. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  125900. * @param ray defines the ray to test with
  125901. * @returns array of intersected objects
  125902. */
  125903. intersectsRay(ray: Ray): SmartArray<T>;
  125904. /**
  125905. * Adds a mesh into the octree block if it intersects the block
  125906. */
  125907. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  125908. /**
  125909. * Adds a submesh into the octree block if it intersects the block
  125910. */
  125911. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  125912. }
  125913. }
  125914. declare module BABYLON {
  125915. interface Scene {
  125916. /**
  125917. * @hidden
  125918. * Backing Filed
  125919. */
  125920. _selectionOctree: Octree<AbstractMesh>;
  125921. /**
  125922. * Gets the octree used to boost mesh selection (picking)
  125923. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  125924. */
  125925. selectionOctree: Octree<AbstractMesh>;
  125926. /**
  125927. * Creates or updates the octree used to boost selection (picking)
  125928. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  125929. * @param maxCapacity defines the maximum capacity per leaf
  125930. * @param maxDepth defines the maximum depth of the octree
  125931. * @returns an octree of AbstractMesh
  125932. */
  125933. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  125934. }
  125935. interface AbstractMesh {
  125936. /**
  125937. * @hidden
  125938. * Backing Field
  125939. */
  125940. _submeshesOctree: Octree<SubMesh>;
  125941. /**
  125942. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  125943. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  125944. * @param maxCapacity defines the maximum size of each block (64 by default)
  125945. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  125946. * @returns the new octree
  125947. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  125948. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  125949. */
  125950. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  125951. }
  125952. /**
  125953. * Defines the octree scene component responsible to manage any octrees
  125954. * in a given scene.
  125955. */
  125956. export class OctreeSceneComponent {
  125957. /**
  125958. * The component name help to identify the component in the list of scene components.
  125959. */
  125960. readonly name: string;
  125961. /**
  125962. * The scene the component belongs to.
  125963. */
  125964. scene: Scene;
  125965. /**
  125966. * Indicates if the meshes have been checked to make sure they are isEnabled()
  125967. */
  125968. readonly checksIsEnabled: boolean;
  125969. /**
  125970. * Creates a new instance of the component for the given scene
  125971. * @param scene Defines the scene to register the component in
  125972. */
  125973. constructor(scene: Scene);
  125974. /**
  125975. * Registers the component in a given scene
  125976. */
  125977. register(): void;
  125978. /**
  125979. * Return the list of active meshes
  125980. * @returns the list of active meshes
  125981. */
  125982. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  125983. /**
  125984. * Return the list of active sub meshes
  125985. * @param mesh The mesh to get the candidates sub meshes from
  125986. * @returns the list of active sub meshes
  125987. */
  125988. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  125989. private _tempRay;
  125990. /**
  125991. * Return the list of sub meshes intersecting with a given local ray
  125992. * @param mesh defines the mesh to find the submesh for
  125993. * @param localRay defines the ray in local space
  125994. * @returns the list of intersecting sub meshes
  125995. */
  125996. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  125997. /**
  125998. * Return the list of sub meshes colliding with a collider
  125999. * @param mesh defines the mesh to find the submesh for
  126000. * @param collider defines the collider to evaluate the collision against
  126001. * @returns the list of colliding sub meshes
  126002. */
  126003. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  126004. /**
  126005. * Rebuilds the elements related to this component in case of
  126006. * context lost for instance.
  126007. */
  126008. rebuild(): void;
  126009. /**
  126010. * Disposes the component and the associated ressources.
  126011. */
  126012. dispose(): void;
  126013. }
  126014. }
  126015. declare module BABYLON {
  126016. /**
  126017. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  126018. */
  126019. export class Gizmo implements IDisposable {
  126020. /** The utility layer the gizmo will be added to */
  126021. gizmoLayer: UtilityLayerRenderer;
  126022. /**
  126023. * The root mesh of the gizmo
  126024. */
  126025. _rootMesh: Mesh;
  126026. private _attachedMesh;
  126027. /**
  126028. * Ratio for the scale of the gizmo (Default: 1)
  126029. */
  126030. scaleRatio: number;
  126031. /**
  126032. * If a custom mesh has been set (Default: false)
  126033. */
  126034. protected _customMeshSet: boolean;
  126035. /**
  126036. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  126037. * * When set, interactions will be enabled
  126038. */
  126039. get attachedMesh(): Nullable<AbstractMesh>;
  126040. set attachedMesh(value: Nullable<AbstractMesh>);
  126041. /**
  126042. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  126043. * @param mesh The mesh to replace the default mesh of the gizmo
  126044. */
  126045. setCustomMesh(mesh: Mesh): void;
  126046. /**
  126047. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  126048. */
  126049. updateGizmoRotationToMatchAttachedMesh: boolean;
  126050. /**
  126051. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  126052. */
  126053. updateGizmoPositionToMatchAttachedMesh: boolean;
  126054. /**
  126055. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  126056. */
  126057. updateScale: boolean;
  126058. protected _interactionsEnabled: boolean;
  126059. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  126060. private _beforeRenderObserver;
  126061. private _tempVector;
  126062. /**
  126063. * Creates a gizmo
  126064. * @param gizmoLayer The utility layer the gizmo will be added to
  126065. */
  126066. constructor(
  126067. /** The utility layer the gizmo will be added to */
  126068. gizmoLayer?: UtilityLayerRenderer);
  126069. /**
  126070. * Updates the gizmo to match the attached mesh's position/rotation
  126071. */
  126072. protected _update(): void;
  126073. /**
  126074. * Disposes of the gizmo
  126075. */
  126076. dispose(): void;
  126077. }
  126078. }
  126079. declare module BABYLON {
  126080. /**
  126081. * Single plane drag gizmo
  126082. */
  126083. export class PlaneDragGizmo extends Gizmo {
  126084. /**
  126085. * Drag behavior responsible for the gizmos dragging interactions
  126086. */
  126087. dragBehavior: PointerDragBehavior;
  126088. private _pointerObserver;
  126089. /**
  126090. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  126091. */
  126092. snapDistance: number;
  126093. /**
  126094. * Event that fires each time the gizmo snaps to a new location.
  126095. * * snapDistance is the the change in distance
  126096. */
  126097. onSnapObservable: Observable<{
  126098. snapDistance: number;
  126099. }>;
  126100. private _plane;
  126101. private _coloredMaterial;
  126102. private _hoverMaterial;
  126103. private _isEnabled;
  126104. private _parent;
  126105. /** @hidden */
  126106. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  126107. /** @hidden */
  126108. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  126109. /**
  126110. * Creates a PlaneDragGizmo
  126111. * @param gizmoLayer The utility layer the gizmo will be added to
  126112. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  126113. * @param color The color of the gizmo
  126114. */
  126115. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  126116. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  126117. /**
  126118. * If the gizmo is enabled
  126119. */
  126120. set isEnabled(value: boolean);
  126121. get isEnabled(): boolean;
  126122. /**
  126123. * Disposes of the gizmo
  126124. */
  126125. dispose(): void;
  126126. }
  126127. }
  126128. declare module BABYLON {
  126129. /**
  126130. * Gizmo that enables dragging a mesh along 3 axis
  126131. */
  126132. export class PositionGizmo extends Gizmo {
  126133. /**
  126134. * Internal gizmo used for interactions on the x axis
  126135. */
  126136. xGizmo: AxisDragGizmo;
  126137. /**
  126138. * Internal gizmo used for interactions on the y axis
  126139. */
  126140. yGizmo: AxisDragGizmo;
  126141. /**
  126142. * Internal gizmo used for interactions on the z axis
  126143. */
  126144. zGizmo: AxisDragGizmo;
  126145. /**
  126146. * Internal gizmo used for interactions on the yz plane
  126147. */
  126148. xPlaneGizmo: PlaneDragGizmo;
  126149. /**
  126150. * Internal gizmo used for interactions on the xz plane
  126151. */
  126152. yPlaneGizmo: PlaneDragGizmo;
  126153. /**
  126154. * Internal gizmo used for interactions on the xy plane
  126155. */
  126156. zPlaneGizmo: PlaneDragGizmo;
  126157. /**
  126158. * private variables
  126159. */
  126160. private _meshAttached;
  126161. private _updateGizmoRotationToMatchAttachedMesh;
  126162. private _snapDistance;
  126163. private _scaleRatio;
  126164. /** Fires an event when any of it's sub gizmos are dragged */
  126165. onDragStartObservable: Observable<unknown>;
  126166. /** Fires an event when any of it's sub gizmos are released from dragging */
  126167. onDragEndObservable: Observable<unknown>;
  126168. /**
  126169. * If set to true, planar drag is enabled
  126170. */
  126171. private _planarGizmoEnabled;
  126172. get attachedMesh(): Nullable<AbstractMesh>;
  126173. set attachedMesh(mesh: Nullable<AbstractMesh>);
  126174. /**
  126175. * Creates a PositionGizmo
  126176. * @param gizmoLayer The utility layer the gizmo will be added to
  126177. */
  126178. constructor(gizmoLayer?: UtilityLayerRenderer);
  126179. /**
  126180. * If the planar drag gizmo is enabled
  126181. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  126182. */
  126183. set planarGizmoEnabled(value: boolean);
  126184. get planarGizmoEnabled(): boolean;
  126185. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  126186. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  126187. /**
  126188. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  126189. */
  126190. set snapDistance(value: number);
  126191. get snapDistance(): number;
  126192. /**
  126193. * Ratio for the scale of the gizmo (Default: 1)
  126194. */
  126195. set scaleRatio(value: number);
  126196. get scaleRatio(): number;
  126197. /**
  126198. * Disposes of the gizmo
  126199. */
  126200. dispose(): void;
  126201. /**
  126202. * CustomMeshes are not supported by this gizmo
  126203. * @param mesh The mesh to replace the default mesh of the gizmo
  126204. */
  126205. setCustomMesh(mesh: Mesh): void;
  126206. }
  126207. }
  126208. declare module BABYLON {
  126209. /**
  126210. * Single axis drag gizmo
  126211. */
  126212. export class AxisDragGizmo extends Gizmo {
  126213. /**
  126214. * Drag behavior responsible for the gizmos dragging interactions
  126215. */
  126216. dragBehavior: PointerDragBehavior;
  126217. private _pointerObserver;
  126218. /**
  126219. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  126220. */
  126221. snapDistance: number;
  126222. /**
  126223. * Event that fires each time the gizmo snaps to a new location.
  126224. * * snapDistance is the the change in distance
  126225. */
  126226. onSnapObservable: Observable<{
  126227. snapDistance: number;
  126228. }>;
  126229. private _isEnabled;
  126230. private _parent;
  126231. private _arrow;
  126232. private _coloredMaterial;
  126233. private _hoverMaterial;
  126234. /** @hidden */
  126235. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  126236. /** @hidden */
  126237. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  126238. /**
  126239. * Creates an AxisDragGizmo
  126240. * @param gizmoLayer The utility layer the gizmo will be added to
  126241. * @param dragAxis The axis which the gizmo will be able to drag on
  126242. * @param color The color of the gizmo
  126243. */
  126244. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  126245. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  126246. /**
  126247. * If the gizmo is enabled
  126248. */
  126249. set isEnabled(value: boolean);
  126250. get isEnabled(): boolean;
  126251. /**
  126252. * Disposes of the gizmo
  126253. */
  126254. dispose(): void;
  126255. }
  126256. }
  126257. declare module BABYLON.Debug {
  126258. /**
  126259. * The Axes viewer will show 3 axes in a specific point in space
  126260. */
  126261. export class AxesViewer {
  126262. private _xAxis;
  126263. private _yAxis;
  126264. private _zAxis;
  126265. private _scaleLinesFactor;
  126266. private _instanced;
  126267. /**
  126268. * Gets the hosting scene
  126269. */
  126270. scene: Scene;
  126271. /**
  126272. * Gets or sets a number used to scale line length
  126273. */
  126274. scaleLines: number;
  126275. /** Gets the node hierarchy used to render x-axis */
  126276. get xAxis(): TransformNode;
  126277. /** Gets the node hierarchy used to render y-axis */
  126278. get yAxis(): TransformNode;
  126279. /** Gets the node hierarchy used to render z-axis */
  126280. get zAxis(): TransformNode;
  126281. /**
  126282. * Creates a new AxesViewer
  126283. * @param scene defines the hosting scene
  126284. * @param scaleLines defines a number used to scale line length (1 by default)
  126285. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  126286. * @param xAxis defines the node hierarchy used to render the x-axis
  126287. * @param yAxis defines the node hierarchy used to render the y-axis
  126288. * @param zAxis defines the node hierarchy used to render the z-axis
  126289. */
  126290. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  126291. /**
  126292. * Force the viewer to update
  126293. * @param position defines the position of the viewer
  126294. * @param xaxis defines the x axis of the viewer
  126295. * @param yaxis defines the y axis of the viewer
  126296. * @param zaxis defines the z axis of the viewer
  126297. */
  126298. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  126299. /**
  126300. * Creates an instance of this axes viewer.
  126301. * @returns a new axes viewer with instanced meshes
  126302. */
  126303. createInstance(): AxesViewer;
  126304. /** Releases resources */
  126305. dispose(): void;
  126306. private static _SetRenderingGroupId;
  126307. }
  126308. }
  126309. declare module BABYLON.Debug {
  126310. /**
  126311. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  126312. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  126313. */
  126314. export class BoneAxesViewer extends AxesViewer {
  126315. /**
  126316. * Gets or sets the target mesh where to display the axes viewer
  126317. */
  126318. mesh: Nullable<Mesh>;
  126319. /**
  126320. * Gets or sets the target bone where to display the axes viewer
  126321. */
  126322. bone: Nullable<Bone>;
  126323. /** Gets current position */
  126324. pos: Vector3;
  126325. /** Gets direction of X axis */
  126326. xaxis: Vector3;
  126327. /** Gets direction of Y axis */
  126328. yaxis: Vector3;
  126329. /** Gets direction of Z axis */
  126330. zaxis: Vector3;
  126331. /**
  126332. * Creates a new BoneAxesViewer
  126333. * @param scene defines the hosting scene
  126334. * @param bone defines the target bone
  126335. * @param mesh defines the target mesh
  126336. * @param scaleLines defines a scaling factor for line length (1 by default)
  126337. */
  126338. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  126339. /**
  126340. * Force the viewer to update
  126341. */
  126342. update(): void;
  126343. /** Releases resources */
  126344. dispose(): void;
  126345. }
  126346. }
  126347. declare module BABYLON {
  126348. /**
  126349. * Interface used to define scene explorer extensibility option
  126350. */
  126351. export interface IExplorerExtensibilityOption {
  126352. /**
  126353. * Define the option label
  126354. */
  126355. label: string;
  126356. /**
  126357. * Defines the action to execute on click
  126358. */
  126359. action: (entity: any) => void;
  126360. }
  126361. /**
  126362. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  126363. */
  126364. export interface IExplorerExtensibilityGroup {
  126365. /**
  126366. * Defines a predicate to test if a given type mut be extended
  126367. */
  126368. predicate: (entity: any) => boolean;
  126369. /**
  126370. * Gets the list of options added to a type
  126371. */
  126372. entries: IExplorerExtensibilityOption[];
  126373. }
  126374. /**
  126375. * Interface used to define the options to use to create the Inspector
  126376. */
  126377. export interface IInspectorOptions {
  126378. /**
  126379. * Display in overlay mode (default: false)
  126380. */
  126381. overlay?: boolean;
  126382. /**
  126383. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  126384. */
  126385. globalRoot?: HTMLElement;
  126386. /**
  126387. * Display the Scene explorer
  126388. */
  126389. showExplorer?: boolean;
  126390. /**
  126391. * Display the property inspector
  126392. */
  126393. showInspector?: boolean;
  126394. /**
  126395. * Display in embed mode (both panes on the right)
  126396. */
  126397. embedMode?: boolean;
  126398. /**
  126399. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  126400. */
  126401. handleResize?: boolean;
  126402. /**
  126403. * Allow the panes to popup (default: true)
  126404. */
  126405. enablePopup?: boolean;
  126406. /**
  126407. * Allow the panes to be closed by users (default: true)
  126408. */
  126409. enableClose?: boolean;
  126410. /**
  126411. * Optional list of extensibility entries
  126412. */
  126413. explorerExtensibility?: IExplorerExtensibilityGroup[];
  126414. /**
  126415. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  126416. */
  126417. inspectorURL?: string;
  126418. /**
  126419. * Optional initial tab (default to DebugLayerTab.Properties)
  126420. */
  126421. initialTab?: DebugLayerTab;
  126422. }
  126423. interface Scene {
  126424. /**
  126425. * @hidden
  126426. * Backing field
  126427. */
  126428. _debugLayer: DebugLayer;
  126429. /**
  126430. * Gets the debug layer (aka Inspector) associated with the scene
  126431. * @see http://doc.babylonjs.com/features/playground_debuglayer
  126432. */
  126433. debugLayer: DebugLayer;
  126434. }
  126435. /**
  126436. * Enum of inspector action tab
  126437. */
  126438. export enum DebugLayerTab {
  126439. /**
  126440. * Properties tag (default)
  126441. */
  126442. Properties = 0,
  126443. /**
  126444. * Debug tab
  126445. */
  126446. Debug = 1,
  126447. /**
  126448. * Statistics tab
  126449. */
  126450. Statistics = 2,
  126451. /**
  126452. * Tools tab
  126453. */
  126454. Tools = 3,
  126455. /**
  126456. * Settings tab
  126457. */
  126458. Settings = 4
  126459. }
  126460. /**
  126461. * The debug layer (aka Inspector) is the go to tool in order to better understand
  126462. * what is happening in your scene
  126463. * @see http://doc.babylonjs.com/features/playground_debuglayer
  126464. */
  126465. export class DebugLayer {
  126466. /**
  126467. * Define the url to get the inspector script from.
  126468. * By default it uses the babylonjs CDN.
  126469. * @ignoreNaming
  126470. */
  126471. static InspectorURL: string;
  126472. private _scene;
  126473. private BJSINSPECTOR;
  126474. private _onPropertyChangedObservable?;
  126475. /**
  126476. * Observable triggered when a property is changed through the inspector.
  126477. */
  126478. get onPropertyChangedObservable(): any;
  126479. /**
  126480. * Instantiates a new debug layer.
  126481. * The debug layer (aka Inspector) is the go to tool in order to better understand
  126482. * what is happening in your scene
  126483. * @see http://doc.babylonjs.com/features/playground_debuglayer
  126484. * @param scene Defines the scene to inspect
  126485. */
  126486. constructor(scene: Scene);
  126487. /** Creates the inspector window. */
  126488. private _createInspector;
  126489. /**
  126490. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  126491. * @param entity defines the entity to select
  126492. * @param lineContainerTitle defines the specific block to highlight
  126493. */
  126494. select(entity: any, lineContainerTitle?: string): void;
  126495. /** Get the inspector from bundle or global */
  126496. private _getGlobalInspector;
  126497. /**
  126498. * Get if the inspector is visible or not.
  126499. * @returns true if visible otherwise, false
  126500. */
  126501. isVisible(): boolean;
  126502. /**
  126503. * Hide the inspector and close its window.
  126504. */
  126505. hide(): void;
  126506. /**
  126507. * Update the scene in the inspector
  126508. */
  126509. setAsActiveScene(): void;
  126510. /**
  126511. * Launch the debugLayer.
  126512. * @param config Define the configuration of the inspector
  126513. * @return a promise fulfilled when the debug layer is visible
  126514. */
  126515. show(config?: IInspectorOptions): Promise<DebugLayer>;
  126516. }
  126517. }
  126518. declare module BABYLON {
  126519. /**
  126520. * Class containing static functions to help procedurally build meshes
  126521. */
  126522. export class BoxBuilder {
  126523. /**
  126524. * Creates a box mesh
  126525. * * The parameter `size` sets the size (float) of each box side (default 1)
  126526. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  126527. * * 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)
  126528. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  126529. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126530. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126531. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126532. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  126533. * @param name defines the name of the mesh
  126534. * @param options defines the options used to create the mesh
  126535. * @param scene defines the hosting scene
  126536. * @returns the box mesh
  126537. */
  126538. static CreateBox(name: string, options: {
  126539. size?: number;
  126540. width?: number;
  126541. height?: number;
  126542. depth?: number;
  126543. faceUV?: Vector4[];
  126544. faceColors?: Color4[];
  126545. sideOrientation?: number;
  126546. frontUVs?: Vector4;
  126547. backUVs?: Vector4;
  126548. wrap?: boolean;
  126549. topBaseAt?: number;
  126550. bottomBaseAt?: number;
  126551. updatable?: boolean;
  126552. }, scene?: Nullable<Scene>): Mesh;
  126553. }
  126554. }
  126555. declare module BABYLON.Debug {
  126556. /**
  126557. * Used to show the physics impostor around the specific mesh
  126558. */
  126559. export class PhysicsViewer {
  126560. /** @hidden */
  126561. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  126562. /** @hidden */
  126563. protected _meshes: Array<Nullable<AbstractMesh>>;
  126564. /** @hidden */
  126565. protected _scene: Nullable<Scene>;
  126566. /** @hidden */
  126567. protected _numMeshes: number;
  126568. /** @hidden */
  126569. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  126570. private _renderFunction;
  126571. private _utilityLayer;
  126572. private _debugBoxMesh;
  126573. private _debugSphereMesh;
  126574. private _debugCylinderMesh;
  126575. private _debugMaterial;
  126576. private _debugMeshMeshes;
  126577. /**
  126578. * Creates a new PhysicsViewer
  126579. * @param scene defines the hosting scene
  126580. */
  126581. constructor(scene: Scene);
  126582. /** @hidden */
  126583. protected _updateDebugMeshes(): void;
  126584. /**
  126585. * Renders a specified physic impostor
  126586. * @param impostor defines the impostor to render
  126587. * @param targetMesh defines the mesh represented by the impostor
  126588. * @returns the new debug mesh used to render the impostor
  126589. */
  126590. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  126591. /**
  126592. * Hides a specified physic impostor
  126593. * @param impostor defines the impostor to hide
  126594. */
  126595. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  126596. private _getDebugMaterial;
  126597. private _getDebugBoxMesh;
  126598. private _getDebugSphereMesh;
  126599. private _getDebugCylinderMesh;
  126600. private _getDebugMeshMesh;
  126601. private _getDebugMesh;
  126602. /** Releases all resources */
  126603. dispose(): void;
  126604. }
  126605. }
  126606. declare module BABYLON {
  126607. /**
  126608. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  126609. * in order to better appreciate the issue one might have.
  126610. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  126611. */
  126612. export class RayHelper {
  126613. /**
  126614. * Defines the ray we are currently tryin to visualize.
  126615. */
  126616. ray: Nullable<Ray>;
  126617. private _renderPoints;
  126618. private _renderLine;
  126619. private _renderFunction;
  126620. private _scene;
  126621. private _updateToMeshFunction;
  126622. private _attachedToMesh;
  126623. private _meshSpaceDirection;
  126624. private _meshSpaceOrigin;
  126625. /**
  126626. * Helper function to create a colored helper in a scene in one line.
  126627. * @param ray Defines the ray we are currently tryin to visualize
  126628. * @param scene Defines the scene the ray is used in
  126629. * @param color Defines the color we want to see the ray in
  126630. * @returns The newly created ray helper.
  126631. */
  126632. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  126633. /**
  126634. * Instantiate a new ray helper.
  126635. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  126636. * in order to better appreciate the issue one might have.
  126637. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  126638. * @param ray Defines the ray we are currently tryin to visualize
  126639. */
  126640. constructor(ray: Ray);
  126641. /**
  126642. * Shows the ray we are willing to debug.
  126643. * @param scene Defines the scene the ray needs to be rendered in
  126644. * @param color Defines the color the ray needs to be rendered in
  126645. */
  126646. show(scene: Scene, color?: Color3): void;
  126647. /**
  126648. * Hides the ray we are debugging.
  126649. */
  126650. hide(): void;
  126651. private _render;
  126652. /**
  126653. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  126654. * @param mesh Defines the mesh we want the helper attached to
  126655. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  126656. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  126657. * @param length Defines the length of the ray
  126658. */
  126659. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  126660. /**
  126661. * Detach the ray helper from the mesh it has previously been attached to.
  126662. */
  126663. detachFromMesh(): void;
  126664. private _updateToMesh;
  126665. /**
  126666. * Dispose the helper and release its associated resources.
  126667. */
  126668. dispose(): void;
  126669. }
  126670. }
  126671. declare module BABYLON.Debug {
  126672. /**
  126673. * Class used to render a debug view of a given skeleton
  126674. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  126675. */
  126676. export class SkeletonViewer {
  126677. /** defines the skeleton to render */
  126678. skeleton: Skeleton;
  126679. /** defines the mesh attached to the skeleton */
  126680. mesh: AbstractMesh;
  126681. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  126682. autoUpdateBonesMatrices: boolean;
  126683. /** defines the rendering group id to use with the viewer */
  126684. renderingGroupId: number;
  126685. /** Gets or sets the color used to render the skeleton */
  126686. color: Color3;
  126687. private _scene;
  126688. private _debugLines;
  126689. private _debugMesh;
  126690. private _isEnabled;
  126691. private _renderFunction;
  126692. private _utilityLayer;
  126693. /**
  126694. * Returns the mesh used to render the bones
  126695. */
  126696. get debugMesh(): Nullable<LinesMesh>;
  126697. /**
  126698. * Creates a new SkeletonViewer
  126699. * @param skeleton defines the skeleton to render
  126700. * @param mesh defines the mesh attached to the skeleton
  126701. * @param scene defines the hosting scene
  126702. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  126703. * @param renderingGroupId defines the rendering group id to use with the viewer
  126704. */
  126705. constructor(
  126706. /** defines the skeleton to render */
  126707. skeleton: Skeleton,
  126708. /** defines the mesh attached to the skeleton */
  126709. mesh: AbstractMesh, scene: Scene,
  126710. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  126711. autoUpdateBonesMatrices?: boolean,
  126712. /** defines the rendering group id to use with the viewer */
  126713. renderingGroupId?: number);
  126714. /** Gets or sets a boolean indicating if the viewer is enabled */
  126715. set isEnabled(value: boolean);
  126716. get isEnabled(): boolean;
  126717. private _getBonePosition;
  126718. private _getLinesForBonesWithLength;
  126719. private _getLinesForBonesNoLength;
  126720. /** Update the viewer to sync with current skeleton state */
  126721. update(): void;
  126722. /** Release associated resources */
  126723. dispose(): void;
  126724. }
  126725. }
  126726. declare module BABYLON {
  126727. /**
  126728. * Enum for Device Types
  126729. */
  126730. export enum DeviceType {
  126731. /** Generic */
  126732. Generic = 0,
  126733. /** Keyboard */
  126734. Keyboard = 1,
  126735. /** Mouse */
  126736. Mouse = 2,
  126737. /** Touch Pointers */
  126738. Touch = 3,
  126739. /** PS4 Dual Shock */
  126740. DualShock = 4,
  126741. /** Xbox */
  126742. Xbox = 5,
  126743. /** Switch Controller */
  126744. Switch = 6
  126745. }
  126746. /**
  126747. * Enum for All Pointers (Touch/Mouse)
  126748. */
  126749. export enum PointerInput {
  126750. /** Horizontal Axis */
  126751. Horizontal = 0,
  126752. /** Vertical Axis */
  126753. Vertical = 1,
  126754. /** Left Click or Touch */
  126755. LeftClick = 2,
  126756. /** Middle Click */
  126757. MiddleClick = 3,
  126758. /** Right Click */
  126759. RightClick = 4,
  126760. /** Browser Back */
  126761. BrowserBack = 5,
  126762. /** Browser Forward */
  126763. BrowserForward = 6
  126764. }
  126765. /**
  126766. * Enum for Dual Shock Gamepad
  126767. */
  126768. export enum DualShockInput {
  126769. /** Cross */
  126770. Cross = 0,
  126771. /** Circle */
  126772. Circle = 1,
  126773. /** Square */
  126774. Square = 2,
  126775. /** Triangle */
  126776. Triangle = 3,
  126777. /** L1 */
  126778. L1 = 4,
  126779. /** R1 */
  126780. R1 = 5,
  126781. /** L2 */
  126782. L2 = 6,
  126783. /** R2 */
  126784. R2 = 7,
  126785. /** Share */
  126786. Share = 8,
  126787. /** Options */
  126788. Options = 9,
  126789. /** L3 */
  126790. L3 = 10,
  126791. /** R3 */
  126792. R3 = 11,
  126793. /** DPadUp */
  126794. DPadUp = 12,
  126795. /** DPadDown */
  126796. DPadDown = 13,
  126797. /** DPadLeft */
  126798. DPadLeft = 14,
  126799. /** DRight */
  126800. DPadRight = 15,
  126801. /** Home */
  126802. Home = 16,
  126803. /** TouchPad */
  126804. TouchPad = 17,
  126805. /** LStickXAxis */
  126806. LStickXAxis = 18,
  126807. /** LStickYAxis */
  126808. LStickYAxis = 19,
  126809. /** RStickXAxis */
  126810. RStickXAxis = 20,
  126811. /** RStickYAxis */
  126812. RStickYAxis = 21
  126813. }
  126814. /**
  126815. * Enum for Xbox Gamepad
  126816. */
  126817. export enum XboxInput {
  126818. /** A */
  126819. A = 0,
  126820. /** B */
  126821. B = 1,
  126822. /** X */
  126823. X = 2,
  126824. /** Y */
  126825. Y = 3,
  126826. /** LB */
  126827. LB = 4,
  126828. /** RB */
  126829. RB = 5,
  126830. /** LT */
  126831. LT = 6,
  126832. /** RT */
  126833. RT = 7,
  126834. /** Back */
  126835. Back = 8,
  126836. /** Start */
  126837. Start = 9,
  126838. /** LS */
  126839. LS = 10,
  126840. /** RS */
  126841. RS = 11,
  126842. /** DPadUp */
  126843. DPadUp = 12,
  126844. /** DPadDown */
  126845. DPadDown = 13,
  126846. /** DPadLeft */
  126847. DPadLeft = 14,
  126848. /** DRight */
  126849. DPadRight = 15,
  126850. /** Home */
  126851. Home = 16,
  126852. /** LStickXAxis */
  126853. LStickXAxis = 17,
  126854. /** LStickYAxis */
  126855. LStickYAxis = 18,
  126856. /** RStickXAxis */
  126857. RStickXAxis = 19,
  126858. /** RStickYAxis */
  126859. RStickYAxis = 20
  126860. }
  126861. /**
  126862. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  126863. */
  126864. export enum SwitchInput {
  126865. /** B */
  126866. B = 0,
  126867. /** A */
  126868. A = 1,
  126869. /** Y */
  126870. Y = 2,
  126871. /** X */
  126872. X = 3,
  126873. /** L */
  126874. L = 4,
  126875. /** R */
  126876. R = 5,
  126877. /** ZL */
  126878. ZL = 6,
  126879. /** ZR */
  126880. ZR = 7,
  126881. /** Minus */
  126882. Minus = 8,
  126883. /** Plus */
  126884. Plus = 9,
  126885. /** LS */
  126886. LS = 10,
  126887. /** RS */
  126888. RS = 11,
  126889. /** DPadUp */
  126890. DPadUp = 12,
  126891. /** DPadDown */
  126892. DPadDown = 13,
  126893. /** DPadLeft */
  126894. DPadLeft = 14,
  126895. /** DRight */
  126896. DPadRight = 15,
  126897. /** Home */
  126898. Home = 16,
  126899. /** Capture */
  126900. Capture = 17,
  126901. /** LStickXAxis */
  126902. LStickXAxis = 18,
  126903. /** LStickYAxis */
  126904. LStickYAxis = 19,
  126905. /** RStickXAxis */
  126906. RStickXAxis = 20,
  126907. /** RStickYAxis */
  126908. RStickYAxis = 21
  126909. }
  126910. }
  126911. declare module BABYLON {
  126912. /**
  126913. * This class will take all inputs from Keyboard, Pointer, and
  126914. * any Gamepads and provide a polling system that all devices
  126915. * will use. This class assumes that there will only be one
  126916. * pointer device and one keyboard.
  126917. */
  126918. export class DeviceInputSystem implements IDisposable {
  126919. /**
  126920. * Callback to be triggered when a device is connected
  126921. */
  126922. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  126923. /**
  126924. * Callback to be triggered when a device is disconnected
  126925. */
  126926. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  126927. /**
  126928. * Callback to be triggered when event driven input is updated
  126929. */
  126930. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  126931. private _inputs;
  126932. private _gamepads;
  126933. private _keyboardActive;
  126934. private _pointerActive;
  126935. private _elementToAttachTo;
  126936. private _keyboardDownEvent;
  126937. private _keyboardUpEvent;
  126938. private _pointerMoveEvent;
  126939. private _pointerDownEvent;
  126940. private _pointerUpEvent;
  126941. private _gamepadConnectedEvent;
  126942. private _gamepadDisconnectedEvent;
  126943. private static _MAX_KEYCODES;
  126944. private static _MAX_POINTER_INPUTS;
  126945. private constructor();
  126946. /**
  126947. * Creates a new DeviceInputSystem instance
  126948. * @param engine Engine to pull input element from
  126949. * @returns The new instance
  126950. */
  126951. static Create(engine: Engine): DeviceInputSystem;
  126952. /**
  126953. * Checks for current device input value, given an id and input index
  126954. * @param deviceName Id of connected device
  126955. * @param inputIndex Index of device input
  126956. * @returns Current value of input
  126957. */
  126958. /**
  126959. * Checks for current device input value, given an id and input index
  126960. * @param deviceType Enum specifiying device type
  126961. * @param deviceSlot "Slot" or index that device is referenced in
  126962. * @param inputIndex Id of input to be checked
  126963. * @returns Current value of input
  126964. */
  126965. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): Nullable<number>;
  126966. /**
  126967. * Dispose of all the eventlisteners
  126968. */
  126969. dispose(): void;
  126970. /**
  126971. * Add device and inputs to device array
  126972. * @param deviceType Enum specifiying device type
  126973. * @param deviceSlot "Slot" or index that device is referenced in
  126974. * @param numberOfInputs Number of input entries to create for given device
  126975. */
  126976. private _registerDevice;
  126977. /**
  126978. * Given a specific device name, remove that device from the device map
  126979. * @param deviceType Enum specifiying device type
  126980. * @param deviceSlot "Slot" or index that device is referenced in
  126981. */
  126982. private _unregisterDevice;
  126983. /**
  126984. * Handle all actions that come from keyboard interaction
  126985. */
  126986. private _handleKeyActions;
  126987. /**
  126988. * Handle all actions that come from pointer interaction
  126989. */
  126990. private _handlePointerActions;
  126991. /**
  126992. * Handle all actions that come from gamepad interaction
  126993. */
  126994. private _handleGamepadActions;
  126995. /**
  126996. * Update all non-event based devices with each frame
  126997. * @param deviceType Enum specifiying device type
  126998. * @param deviceSlot "Slot" or index that device is referenced in
  126999. * @param inputIndex Id of input to be checked
  127000. */
  127001. private _updateDevice;
  127002. /**
  127003. * Gets DeviceType from the device name
  127004. * @param deviceName Name of Device from DeviceInputSystem
  127005. * @returns DeviceType enum value
  127006. */
  127007. private _getGamepadDeviceType;
  127008. }
  127009. }
  127010. declare module BABYLON {
  127011. /**
  127012. * Type to handle enforcement of inputs
  127013. */
  127014. 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;
  127015. }
  127016. declare module BABYLON {
  127017. /**
  127018. * Class that handles all input for a specific device
  127019. */
  127020. export class DeviceSource<T extends DeviceType> {
  127021. /** Type of device */
  127022. readonly deviceType: DeviceType;
  127023. /** "Slot" or index that device is referenced in */
  127024. readonly deviceSlot: number;
  127025. /**
  127026. * Observable to handle device input changes per device
  127027. */
  127028. readonly onInputChangedObservable: Observable<{
  127029. inputIndex: DeviceInput<T>;
  127030. previousState: Nullable<number>;
  127031. currentState: Nullable<number>;
  127032. }>;
  127033. private readonly _deviceInputSystem;
  127034. /**
  127035. * Default Constructor
  127036. * @param deviceInputSystem Reference to DeviceInputSystem
  127037. * @param deviceType Type of device
  127038. * @param deviceSlot "Slot" or index that device is referenced in
  127039. */
  127040. constructor(deviceInputSystem: DeviceInputSystem,
  127041. /** Type of device */
  127042. deviceType: DeviceType,
  127043. /** "Slot" or index that device is referenced in */
  127044. deviceSlot?: number);
  127045. /**
  127046. * Get input for specific input
  127047. * @param inputIndex index of specific input on device
  127048. * @returns Input value from DeviceInputSystem
  127049. */
  127050. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  127051. }
  127052. /**
  127053. * Class to keep track of devices
  127054. */
  127055. export class DeviceSourceManager implements IDisposable {
  127056. /**
  127057. * Observable to be triggered when before a device is connected
  127058. */
  127059. readonly onBeforeDeviceConnectedObservable: Observable<{
  127060. deviceType: DeviceType;
  127061. deviceSlot: number;
  127062. }>;
  127063. /**
  127064. * Observable to be triggered when before a device is disconnected
  127065. */
  127066. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  127067. deviceType: DeviceType;
  127068. deviceSlot: number;
  127069. }>;
  127070. /**
  127071. * Observable to be triggered when after a device is connected
  127072. */
  127073. readonly onAfterDeviceConnectedObservable: Observable<{
  127074. deviceType: DeviceType;
  127075. deviceSlot: number;
  127076. }>;
  127077. /**
  127078. * Observable to be triggered when after a device is disconnected
  127079. */
  127080. readonly onAfterDeviceDisconnectedObservable: Observable<{
  127081. deviceType: DeviceType;
  127082. deviceSlot: number;
  127083. }>;
  127084. private readonly _devices;
  127085. private readonly _firstDevice;
  127086. private readonly _deviceInputSystem;
  127087. /**
  127088. * Default Constructor
  127089. * @param engine engine to pull input element from
  127090. */
  127091. constructor(engine: Engine);
  127092. /**
  127093. * Gets a DeviceSource, given a type and slot
  127094. * @param deviceType Enum specifying device type
  127095. * @param deviceSlot "Slot" or index that device is referenced in
  127096. * @returns DeviceSource object
  127097. */
  127098. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  127099. /**
  127100. * Gets an array of DeviceSource objects for a given device type
  127101. * @param deviceType Enum specifying device type
  127102. * @returns Array of DeviceSource objects
  127103. */
  127104. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  127105. /**
  127106. * Dispose of DeviceInputSystem and other parts
  127107. */
  127108. dispose(): void;
  127109. /**
  127110. * Function to add device name to device list
  127111. * @param deviceType Enum specifying device type
  127112. * @param deviceSlot "Slot" or index that device is referenced in
  127113. */
  127114. private _addDevice;
  127115. /**
  127116. * Function to remove device name to device list
  127117. * @param deviceType Enum specifying device type
  127118. * @param deviceSlot "Slot" or index that device is referenced in
  127119. */
  127120. private _removeDevice;
  127121. /**
  127122. * Updates array storing first connected device of each type
  127123. * @param type Type of Device
  127124. */
  127125. private _updateFirstDevices;
  127126. }
  127127. }
  127128. declare module BABYLON {
  127129. /**
  127130. * Options to create the null engine
  127131. */
  127132. export class NullEngineOptions {
  127133. /**
  127134. * Render width (Default: 512)
  127135. */
  127136. renderWidth: number;
  127137. /**
  127138. * Render height (Default: 256)
  127139. */
  127140. renderHeight: number;
  127141. /**
  127142. * Texture size (Default: 512)
  127143. */
  127144. textureSize: number;
  127145. /**
  127146. * If delta time between frames should be constant
  127147. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  127148. */
  127149. deterministicLockstep: boolean;
  127150. /**
  127151. * Maximum about of steps between frames (Default: 4)
  127152. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  127153. */
  127154. lockstepMaxSteps: number;
  127155. }
  127156. /**
  127157. * The null engine class provides support for headless version of babylon.js.
  127158. * This can be used in server side scenario or for testing purposes
  127159. */
  127160. export class NullEngine extends Engine {
  127161. private _options;
  127162. /**
  127163. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  127164. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  127165. * @returns true if engine is in deterministic lock step mode
  127166. */
  127167. isDeterministicLockStep(): boolean;
  127168. /**
  127169. * Gets the max steps when engine is running in deterministic lock step
  127170. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  127171. * @returns the max steps
  127172. */
  127173. getLockstepMaxSteps(): number;
  127174. /**
  127175. * Gets the current hardware scaling level.
  127176. * By default the hardware scaling level is computed from the window device ratio.
  127177. * 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.
  127178. * @returns a number indicating the current hardware scaling level
  127179. */
  127180. getHardwareScalingLevel(): number;
  127181. constructor(options?: NullEngineOptions);
  127182. /**
  127183. * Creates a vertex buffer
  127184. * @param vertices the data for the vertex buffer
  127185. * @returns the new WebGL static buffer
  127186. */
  127187. createVertexBuffer(vertices: FloatArray): DataBuffer;
  127188. /**
  127189. * Creates a new index buffer
  127190. * @param indices defines the content of the index buffer
  127191. * @param updatable defines if the index buffer must be updatable
  127192. * @returns a new webGL buffer
  127193. */
  127194. createIndexBuffer(indices: IndicesArray): DataBuffer;
  127195. /**
  127196. * Clear the current render buffer or the current render target (if any is set up)
  127197. * @param color defines the color to use
  127198. * @param backBuffer defines if the back buffer must be cleared
  127199. * @param depth defines if the depth buffer must be cleared
  127200. * @param stencil defines if the stencil buffer must be cleared
  127201. */
  127202. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  127203. /**
  127204. * Gets the current render width
  127205. * @param useScreen defines if screen size must be used (or the current render target if any)
  127206. * @returns a number defining the current render width
  127207. */
  127208. getRenderWidth(useScreen?: boolean): number;
  127209. /**
  127210. * Gets the current render height
  127211. * @param useScreen defines if screen size must be used (or the current render target if any)
  127212. * @returns a number defining the current render height
  127213. */
  127214. getRenderHeight(useScreen?: boolean): number;
  127215. /**
  127216. * Set the WebGL's viewport
  127217. * @param viewport defines the viewport element to be used
  127218. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  127219. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  127220. */
  127221. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  127222. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  127223. /**
  127224. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  127225. * @param pipelineContext defines the pipeline context to use
  127226. * @param uniformsNames defines the list of uniform names
  127227. * @returns an array of webGL uniform locations
  127228. */
  127229. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  127230. /**
  127231. * Gets the lsit of active attributes for a given webGL program
  127232. * @param pipelineContext defines the pipeline context to use
  127233. * @param attributesNames defines the list of attribute names to get
  127234. * @returns an array of indices indicating the offset of each attribute
  127235. */
  127236. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  127237. /**
  127238. * Binds an effect to the webGL context
  127239. * @param effect defines the effect to bind
  127240. */
  127241. bindSamplers(effect: Effect): void;
  127242. /**
  127243. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  127244. * @param effect defines the effect to activate
  127245. */
  127246. enableEffect(effect: Effect): void;
  127247. /**
  127248. * Set various states to the webGL context
  127249. * @param culling defines backface culling state
  127250. * @param zOffset defines the value to apply to zOffset (0 by default)
  127251. * @param force defines if states must be applied even if cache is up to date
  127252. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  127253. */
  127254. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  127255. /**
  127256. * Set the value of an uniform to an array of int32
  127257. * @param uniform defines the webGL uniform location where to store the value
  127258. * @param array defines the array of int32 to store
  127259. */
  127260. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  127261. /**
  127262. * Set the value of an uniform to an array of int32 (stored as vec2)
  127263. * @param uniform defines the webGL uniform location where to store the value
  127264. * @param array defines the array of int32 to store
  127265. */
  127266. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  127267. /**
  127268. * Set the value of an uniform to an array of int32 (stored as vec3)
  127269. * @param uniform defines the webGL uniform location where to store the value
  127270. * @param array defines the array of int32 to store
  127271. */
  127272. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  127273. /**
  127274. * Set the value of an uniform to an array of int32 (stored as vec4)
  127275. * @param uniform defines the webGL uniform location where to store the value
  127276. * @param array defines the array of int32 to store
  127277. */
  127278. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  127279. /**
  127280. * Set the value of an uniform to an array of float32
  127281. * @param uniform defines the webGL uniform location where to store the value
  127282. * @param array defines the array of float32 to store
  127283. */
  127284. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  127285. /**
  127286. * Set the value of an uniform to an array of float32 (stored as vec2)
  127287. * @param uniform defines the webGL uniform location where to store the value
  127288. * @param array defines the array of float32 to store
  127289. */
  127290. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  127291. /**
  127292. * Set the value of an uniform to an array of float32 (stored as vec3)
  127293. * @param uniform defines the webGL uniform location where to store the value
  127294. * @param array defines the array of float32 to store
  127295. */
  127296. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  127297. /**
  127298. * Set the value of an uniform to an array of float32 (stored as vec4)
  127299. * @param uniform defines the webGL uniform location where to store the value
  127300. * @param array defines the array of float32 to store
  127301. */
  127302. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  127303. /**
  127304. * Set the value of an uniform to an array of number
  127305. * @param uniform defines the webGL uniform location where to store the value
  127306. * @param array defines the array of number to store
  127307. */
  127308. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  127309. /**
  127310. * Set the value of an uniform to an array of number (stored as vec2)
  127311. * @param uniform defines the webGL uniform location where to store the value
  127312. * @param array defines the array of number to store
  127313. */
  127314. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  127315. /**
  127316. * Set the value of an uniform to an array of number (stored as vec3)
  127317. * @param uniform defines the webGL uniform location where to store the value
  127318. * @param array defines the array of number to store
  127319. */
  127320. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  127321. /**
  127322. * Set the value of an uniform to an array of number (stored as vec4)
  127323. * @param uniform defines the webGL uniform location where to store the value
  127324. * @param array defines the array of number to store
  127325. */
  127326. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  127327. /**
  127328. * Set the value of an uniform to an array of float32 (stored as matrices)
  127329. * @param uniform defines the webGL uniform location where to store the value
  127330. * @param matrices defines the array of float32 to store
  127331. */
  127332. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  127333. /**
  127334. * Set the value of an uniform to a matrix (3x3)
  127335. * @param uniform defines the webGL uniform location where to store the value
  127336. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  127337. */
  127338. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  127339. /**
  127340. * Set the value of an uniform to a matrix (2x2)
  127341. * @param uniform defines the webGL uniform location where to store the value
  127342. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  127343. */
  127344. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  127345. /**
  127346. * Set the value of an uniform to a number (float)
  127347. * @param uniform defines the webGL uniform location where to store the value
  127348. * @param value defines the float number to store
  127349. */
  127350. setFloat(uniform: WebGLUniformLocation, value: number): void;
  127351. /**
  127352. * Set the value of an uniform to a vec2
  127353. * @param uniform defines the webGL uniform location where to store the value
  127354. * @param x defines the 1st component of the value
  127355. * @param y defines the 2nd component of the value
  127356. */
  127357. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  127358. /**
  127359. * Set the value of an uniform to a vec3
  127360. * @param uniform defines the webGL uniform location where to store the value
  127361. * @param x defines the 1st component of the value
  127362. * @param y defines the 2nd component of the value
  127363. * @param z defines the 3rd component of the value
  127364. */
  127365. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  127366. /**
  127367. * Set the value of an uniform to a boolean
  127368. * @param uniform defines the webGL uniform location where to store the value
  127369. * @param bool defines the boolean to store
  127370. */
  127371. setBool(uniform: WebGLUniformLocation, bool: number): void;
  127372. /**
  127373. * Set the value of an uniform to a vec4
  127374. * @param uniform defines the webGL uniform location where to store the value
  127375. * @param x defines the 1st component of the value
  127376. * @param y defines the 2nd component of the value
  127377. * @param z defines the 3rd component of the value
  127378. * @param w defines the 4th component of the value
  127379. */
  127380. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  127381. /**
  127382. * Sets the current alpha mode
  127383. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  127384. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  127385. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  127386. */
  127387. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  127388. /**
  127389. * Bind webGl buffers directly to the webGL context
  127390. * @param vertexBuffers defines the vertex buffer to bind
  127391. * @param indexBuffer defines the index buffer to bind
  127392. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  127393. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  127394. * @param effect defines the effect associated with the vertex buffer
  127395. */
  127396. bindBuffers(vertexBuffers: {
  127397. [key: string]: VertexBuffer;
  127398. }, indexBuffer: DataBuffer, effect: Effect): void;
  127399. /**
  127400. * Force the entire cache to be cleared
  127401. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  127402. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  127403. */
  127404. wipeCaches(bruteForce?: boolean): void;
  127405. /**
  127406. * Send a draw order
  127407. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  127408. * @param indexStart defines the starting index
  127409. * @param indexCount defines the number of index to draw
  127410. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  127411. */
  127412. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  127413. /**
  127414. * Draw a list of indexed primitives
  127415. * @param fillMode defines the primitive to use
  127416. * @param indexStart defines the starting index
  127417. * @param indexCount defines the number of index to draw
  127418. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  127419. */
  127420. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  127421. /**
  127422. * Draw a list of unindexed primitives
  127423. * @param fillMode defines the primitive to use
  127424. * @param verticesStart defines the index of first vertex to draw
  127425. * @param verticesCount defines the count of vertices to draw
  127426. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  127427. */
  127428. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  127429. /** @hidden */
  127430. _createTexture(): WebGLTexture;
  127431. /** @hidden */
  127432. _releaseTexture(texture: InternalTexture): void;
  127433. /**
  127434. * Usually called from Texture.ts.
  127435. * Passed information to create a WebGLTexture
  127436. * @param urlArg defines a value which contains one of the following:
  127437. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  127438. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  127439. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  127440. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  127441. * @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)
  127442. * @param scene needed for loading to the correct scene
  127443. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  127444. * @param onLoad optional callback to be called upon successful completion
  127445. * @param onError optional callback to be called upon failure
  127446. * @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
  127447. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  127448. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  127449. * @param forcedExtension defines the extension to use to pick the right loader
  127450. * @param mimeType defines an optional mime type
  127451. * @returns a InternalTexture for assignment back into BABYLON.Texture
  127452. */
  127453. 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;
  127454. /**
  127455. * Creates a new render target texture
  127456. * @param size defines the size of the texture
  127457. * @param options defines the options used to create the texture
  127458. * @returns a new render target texture stored in an InternalTexture
  127459. */
  127460. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  127461. /**
  127462. * Update the sampling mode of a given texture
  127463. * @param samplingMode defines the required sampling mode
  127464. * @param texture defines the texture to update
  127465. */
  127466. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  127467. /**
  127468. * Binds the frame buffer to the specified texture.
  127469. * @param texture The texture to render to or null for the default canvas
  127470. * @param faceIndex The face of the texture to render to in case of cube texture
  127471. * @param requiredWidth The width of the target to render to
  127472. * @param requiredHeight The height of the target to render to
  127473. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  127474. * @param lodLevel defines le lod level to bind to the frame buffer
  127475. */
  127476. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  127477. /**
  127478. * Unbind the current render target texture from the webGL context
  127479. * @param texture defines the render target texture to unbind
  127480. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  127481. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  127482. */
  127483. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  127484. /**
  127485. * Creates a dynamic vertex buffer
  127486. * @param vertices the data for the dynamic vertex buffer
  127487. * @returns the new WebGL dynamic buffer
  127488. */
  127489. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  127490. /**
  127491. * Update the content of a dynamic texture
  127492. * @param texture defines the texture to update
  127493. * @param canvas defines the canvas containing the source
  127494. * @param invertY defines if data must be stored with Y axis inverted
  127495. * @param premulAlpha defines if alpha is stored as premultiplied
  127496. * @param format defines the format of the data
  127497. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  127498. */
  127499. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  127500. /**
  127501. * Gets a boolean indicating if all created effects are ready
  127502. * @returns true if all effects are ready
  127503. */
  127504. areAllEffectsReady(): boolean;
  127505. /**
  127506. * @hidden
  127507. * Get the current error code of the webGL context
  127508. * @returns the error code
  127509. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  127510. */
  127511. getError(): number;
  127512. /** @hidden */
  127513. _getUnpackAlignement(): number;
  127514. /** @hidden */
  127515. _unpackFlipY(value: boolean): void;
  127516. /**
  127517. * Update a dynamic index buffer
  127518. * @param indexBuffer defines the target index buffer
  127519. * @param indices defines the data to update
  127520. * @param offset defines the offset in the target index buffer where update should start
  127521. */
  127522. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  127523. /**
  127524. * Updates a dynamic vertex buffer.
  127525. * @param vertexBuffer the vertex buffer to update
  127526. * @param vertices the data used to update the vertex buffer
  127527. * @param byteOffset the byte offset of the data (optional)
  127528. * @param byteLength the byte length of the data (optional)
  127529. */
  127530. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  127531. /** @hidden */
  127532. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  127533. /** @hidden */
  127534. _bindTexture(channel: number, texture: InternalTexture): void;
  127535. protected _deleteBuffer(buffer: WebGLBuffer): void;
  127536. /**
  127537. * 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
  127538. */
  127539. releaseEffects(): void;
  127540. displayLoadingUI(): void;
  127541. hideLoadingUI(): void;
  127542. /** @hidden */
  127543. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  127544. /** @hidden */
  127545. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  127546. /** @hidden */
  127547. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  127548. /** @hidden */
  127549. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  127550. }
  127551. }
  127552. declare module BABYLON {
  127553. /**
  127554. * @hidden
  127555. **/
  127556. export class _TimeToken {
  127557. _startTimeQuery: Nullable<WebGLQuery>;
  127558. _endTimeQuery: Nullable<WebGLQuery>;
  127559. _timeElapsedQuery: Nullable<WebGLQuery>;
  127560. _timeElapsedQueryEnded: boolean;
  127561. }
  127562. }
  127563. declare module BABYLON {
  127564. /** @hidden */
  127565. export class _OcclusionDataStorage {
  127566. /** @hidden */
  127567. occlusionInternalRetryCounter: number;
  127568. /** @hidden */
  127569. isOcclusionQueryInProgress: boolean;
  127570. /** @hidden */
  127571. isOccluded: boolean;
  127572. /** @hidden */
  127573. occlusionRetryCount: number;
  127574. /** @hidden */
  127575. occlusionType: number;
  127576. /** @hidden */
  127577. occlusionQueryAlgorithmType: number;
  127578. }
  127579. interface Engine {
  127580. /**
  127581. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  127582. * @return the new query
  127583. */
  127584. createQuery(): WebGLQuery;
  127585. /**
  127586. * Delete and release a webGL query
  127587. * @param query defines the query to delete
  127588. * @return the current engine
  127589. */
  127590. deleteQuery(query: WebGLQuery): Engine;
  127591. /**
  127592. * Check if a given query has resolved and got its value
  127593. * @param query defines the query to check
  127594. * @returns true if the query got its value
  127595. */
  127596. isQueryResultAvailable(query: WebGLQuery): boolean;
  127597. /**
  127598. * Gets the value of a given query
  127599. * @param query defines the query to check
  127600. * @returns the value of the query
  127601. */
  127602. getQueryResult(query: WebGLQuery): number;
  127603. /**
  127604. * Initiates an occlusion query
  127605. * @param algorithmType defines the algorithm to use
  127606. * @param query defines the query to use
  127607. * @returns the current engine
  127608. * @see http://doc.babylonjs.com/features/occlusionquery
  127609. */
  127610. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  127611. /**
  127612. * Ends an occlusion query
  127613. * @see http://doc.babylonjs.com/features/occlusionquery
  127614. * @param algorithmType defines the algorithm to use
  127615. * @returns the current engine
  127616. */
  127617. endOcclusionQuery(algorithmType: number): Engine;
  127618. /**
  127619. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  127620. * Please note that only one query can be issued at a time
  127621. * @returns a time token used to track the time span
  127622. */
  127623. startTimeQuery(): Nullable<_TimeToken>;
  127624. /**
  127625. * Ends a time query
  127626. * @param token defines the token used to measure the time span
  127627. * @returns the time spent (in ns)
  127628. */
  127629. endTimeQuery(token: _TimeToken): int;
  127630. /** @hidden */
  127631. _currentNonTimestampToken: Nullable<_TimeToken>;
  127632. /** @hidden */
  127633. _createTimeQuery(): WebGLQuery;
  127634. /** @hidden */
  127635. _deleteTimeQuery(query: WebGLQuery): void;
  127636. /** @hidden */
  127637. _getGlAlgorithmType(algorithmType: number): number;
  127638. /** @hidden */
  127639. _getTimeQueryResult(query: WebGLQuery): any;
  127640. /** @hidden */
  127641. _getTimeQueryAvailability(query: WebGLQuery): any;
  127642. }
  127643. interface AbstractMesh {
  127644. /**
  127645. * Backing filed
  127646. * @hidden
  127647. */
  127648. __occlusionDataStorage: _OcclusionDataStorage;
  127649. /**
  127650. * Access property
  127651. * @hidden
  127652. */
  127653. _occlusionDataStorage: _OcclusionDataStorage;
  127654. /**
  127655. * 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.
  127656. * The default value is -1 which means don't break the query and wait till the result
  127657. * @see http://doc.babylonjs.com/features/occlusionquery
  127658. */
  127659. occlusionRetryCount: number;
  127660. /**
  127661. * 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:
  127662. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  127663. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  127664. * * 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.
  127665. * @see http://doc.babylonjs.com/features/occlusionquery
  127666. */
  127667. occlusionType: number;
  127668. /**
  127669. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  127670. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  127671. * * 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.
  127672. * @see http://doc.babylonjs.com/features/occlusionquery
  127673. */
  127674. occlusionQueryAlgorithmType: number;
  127675. /**
  127676. * 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
  127677. * @see http://doc.babylonjs.com/features/occlusionquery
  127678. */
  127679. isOccluded: boolean;
  127680. /**
  127681. * Flag to check the progress status of the query
  127682. * @see http://doc.babylonjs.com/features/occlusionquery
  127683. */
  127684. isOcclusionQueryInProgress: boolean;
  127685. }
  127686. }
  127687. declare module BABYLON {
  127688. /** @hidden */
  127689. export var _forceTransformFeedbackToBundle: boolean;
  127690. interface Engine {
  127691. /**
  127692. * Creates a webGL transform feedback object
  127693. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  127694. * @returns the webGL transform feedback object
  127695. */
  127696. createTransformFeedback(): WebGLTransformFeedback;
  127697. /**
  127698. * Delete a webGL transform feedback object
  127699. * @param value defines the webGL transform feedback object to delete
  127700. */
  127701. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  127702. /**
  127703. * Bind a webGL transform feedback object to the webgl context
  127704. * @param value defines the webGL transform feedback object to bind
  127705. */
  127706. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  127707. /**
  127708. * Begins a transform feedback operation
  127709. * @param usePoints defines if points or triangles must be used
  127710. */
  127711. beginTransformFeedback(usePoints: boolean): void;
  127712. /**
  127713. * Ends a transform feedback operation
  127714. */
  127715. endTransformFeedback(): void;
  127716. /**
  127717. * Specify the varyings to use with transform feedback
  127718. * @param program defines the associated webGL program
  127719. * @param value defines the list of strings representing the varying names
  127720. */
  127721. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  127722. /**
  127723. * Bind a webGL buffer for a transform feedback operation
  127724. * @param value defines the webGL buffer to bind
  127725. */
  127726. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  127727. }
  127728. }
  127729. declare module BABYLON {
  127730. /**
  127731. * Creation options of the multi render target texture.
  127732. */
  127733. export interface IMultiRenderTargetOptions {
  127734. /**
  127735. * Define if the texture needs to create mip maps after render.
  127736. */
  127737. generateMipMaps?: boolean;
  127738. /**
  127739. * Define the types of all the draw buffers we want to create
  127740. */
  127741. types?: number[];
  127742. /**
  127743. * Define the sampling modes of all the draw buffers we want to create
  127744. */
  127745. samplingModes?: number[];
  127746. /**
  127747. * Define if a depth buffer is required
  127748. */
  127749. generateDepthBuffer?: boolean;
  127750. /**
  127751. * Define if a stencil buffer is required
  127752. */
  127753. generateStencilBuffer?: boolean;
  127754. /**
  127755. * Define if a depth texture is required instead of a depth buffer
  127756. */
  127757. generateDepthTexture?: boolean;
  127758. /**
  127759. * Define the number of desired draw buffers
  127760. */
  127761. textureCount?: number;
  127762. /**
  127763. * Define if aspect ratio should be adapted to the texture or stay the scene one
  127764. */
  127765. doNotChangeAspectRatio?: boolean;
  127766. /**
  127767. * Define the default type of the buffers we are creating
  127768. */
  127769. defaultType?: number;
  127770. }
  127771. /**
  127772. * A multi render target, like a render target provides the ability to render to a texture.
  127773. * Unlike the render target, it can render to several draw buffers in one draw.
  127774. * This is specially interesting in deferred rendering or for any effects requiring more than
  127775. * just one color from a single pass.
  127776. */
  127777. export class MultiRenderTarget extends RenderTargetTexture {
  127778. private _internalTextures;
  127779. private _textures;
  127780. private _multiRenderTargetOptions;
  127781. /**
  127782. * Get if draw buffers are currently supported by the used hardware and browser.
  127783. */
  127784. get isSupported(): boolean;
  127785. /**
  127786. * Get the list of textures generated by the multi render target.
  127787. */
  127788. get textures(): Texture[];
  127789. /**
  127790. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  127791. */
  127792. get depthTexture(): Texture;
  127793. /**
  127794. * Set the wrapping mode on U of all the textures we are rendering to.
  127795. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  127796. */
  127797. set wrapU(wrap: number);
  127798. /**
  127799. * Set the wrapping mode on V of all the textures we are rendering to.
  127800. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  127801. */
  127802. set wrapV(wrap: number);
  127803. /**
  127804. * Instantiate a new multi render target texture.
  127805. * A multi render target, like a render target provides the ability to render to a texture.
  127806. * Unlike the render target, it can render to several draw buffers in one draw.
  127807. * This is specially interesting in deferred rendering or for any effects requiring more than
  127808. * just one color from a single pass.
  127809. * @param name Define the name of the texture
  127810. * @param size Define the size of the buffers to render to
  127811. * @param count Define the number of target we are rendering into
  127812. * @param scene Define the scene the texture belongs to
  127813. * @param options Define the options used to create the multi render target
  127814. */
  127815. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  127816. /** @hidden */
  127817. _rebuild(): void;
  127818. private _createInternalTextures;
  127819. private _createTextures;
  127820. /**
  127821. * Define the number of samples used if MSAA is enabled.
  127822. */
  127823. get samples(): number;
  127824. set samples(value: number);
  127825. /**
  127826. * Resize all the textures in the multi render target.
  127827. * Be carrefull as it will recreate all the data in the new texture.
  127828. * @param size Define the new size
  127829. */
  127830. resize(size: any): void;
  127831. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  127832. /**
  127833. * Dispose the render targets and their associated resources
  127834. */
  127835. dispose(): void;
  127836. /**
  127837. * Release all the underlying texture used as draw buffers.
  127838. */
  127839. releaseInternalTextures(): void;
  127840. }
  127841. }
  127842. declare module BABYLON {
  127843. interface ThinEngine {
  127844. /**
  127845. * Unbind a list of render target textures from the webGL context
  127846. * This is used only when drawBuffer extension or webGL2 are active
  127847. * @param textures defines the render target textures to unbind
  127848. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  127849. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  127850. */
  127851. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  127852. /**
  127853. * Create a multi render target texture
  127854. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  127855. * @param size defines the size of the texture
  127856. * @param options defines the creation options
  127857. * @returns the cube texture as an InternalTexture
  127858. */
  127859. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  127860. /**
  127861. * Update the sample count for a given multiple render target texture
  127862. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  127863. * @param textures defines the textures to update
  127864. * @param samples defines the sample count to set
  127865. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  127866. */
  127867. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  127868. }
  127869. }
  127870. declare module BABYLON {
  127871. /**
  127872. * Class used to define an additional view for the engine
  127873. * @see https://doc.babylonjs.com/how_to/multi_canvases
  127874. */
  127875. export class EngineView {
  127876. /** Defines the canvas where to render the view */
  127877. target: HTMLCanvasElement;
  127878. /** Defines an optional camera used to render the view (will use active camera else) */
  127879. camera?: Camera;
  127880. }
  127881. interface Engine {
  127882. /**
  127883. * Gets or sets the HTML element to use for attaching events
  127884. */
  127885. inputElement: Nullable<HTMLElement>;
  127886. /**
  127887. * Gets the current engine view
  127888. * @see https://doc.babylonjs.com/how_to/multi_canvases
  127889. */
  127890. activeView: Nullable<EngineView>;
  127891. /** Gets or sets the list of views */
  127892. views: EngineView[];
  127893. /**
  127894. * Register a new child canvas
  127895. * @param canvas defines the canvas to register
  127896. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  127897. * @returns the associated view
  127898. */
  127899. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  127900. /**
  127901. * Remove a registered child canvas
  127902. * @param canvas defines the canvas to remove
  127903. * @returns the current engine
  127904. */
  127905. unRegisterView(canvas: HTMLCanvasElement): Engine;
  127906. }
  127907. }
  127908. declare module BABYLON {
  127909. interface Engine {
  127910. /** @hidden */
  127911. _excludedCompressedTextures: string[];
  127912. /** @hidden */
  127913. _textureFormatInUse: string;
  127914. /**
  127915. * Gets the list of texture formats supported
  127916. */
  127917. readonly texturesSupported: Array<string>;
  127918. /**
  127919. * Gets the texture format in use
  127920. */
  127921. readonly textureFormatInUse: Nullable<string>;
  127922. /**
  127923. * Set the compressed texture extensions or file names to skip.
  127924. *
  127925. * @param skippedFiles defines the list of those texture files you want to skip
  127926. * Example: [".dds", ".env", "myfile.png"]
  127927. */
  127928. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  127929. /**
  127930. * Set the compressed texture format to use, based on the formats you have, and the formats
  127931. * supported by the hardware / browser.
  127932. *
  127933. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  127934. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  127935. * to API arguments needed to compressed textures. This puts the burden on the container
  127936. * generator to house the arcane code for determining these for current & future formats.
  127937. *
  127938. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  127939. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  127940. *
  127941. * Note: The result of this call is not taken into account when a texture is base64.
  127942. *
  127943. * @param formatsAvailable defines the list of those format families you have created
  127944. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  127945. *
  127946. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  127947. * @returns The extension selected.
  127948. */
  127949. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  127950. }
  127951. }
  127952. declare module BABYLON {
  127953. /**
  127954. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  127955. */
  127956. export interface CubeMapInfo {
  127957. /**
  127958. * The pixel array for the front face.
  127959. * This is stored in format, left to right, up to down format.
  127960. */
  127961. front: Nullable<ArrayBufferView>;
  127962. /**
  127963. * The pixel array for the back face.
  127964. * This is stored in format, left to right, up to down format.
  127965. */
  127966. back: Nullable<ArrayBufferView>;
  127967. /**
  127968. * The pixel array for the left face.
  127969. * This is stored in format, left to right, up to down format.
  127970. */
  127971. left: Nullable<ArrayBufferView>;
  127972. /**
  127973. * The pixel array for the right face.
  127974. * This is stored in format, left to right, up to down format.
  127975. */
  127976. right: Nullable<ArrayBufferView>;
  127977. /**
  127978. * The pixel array for the up face.
  127979. * This is stored in format, left to right, up to down format.
  127980. */
  127981. up: Nullable<ArrayBufferView>;
  127982. /**
  127983. * The pixel array for the down face.
  127984. * This is stored in format, left to right, up to down format.
  127985. */
  127986. down: Nullable<ArrayBufferView>;
  127987. /**
  127988. * The size of the cubemap stored.
  127989. *
  127990. * Each faces will be size * size pixels.
  127991. */
  127992. size: number;
  127993. /**
  127994. * The format of the texture.
  127995. *
  127996. * RGBA, RGB.
  127997. */
  127998. format: number;
  127999. /**
  128000. * The type of the texture data.
  128001. *
  128002. * UNSIGNED_INT, FLOAT.
  128003. */
  128004. type: number;
  128005. /**
  128006. * Specifies whether the texture is in gamma space.
  128007. */
  128008. gammaSpace: boolean;
  128009. }
  128010. /**
  128011. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  128012. */
  128013. export class PanoramaToCubeMapTools {
  128014. private static FACE_LEFT;
  128015. private static FACE_RIGHT;
  128016. private static FACE_FRONT;
  128017. private static FACE_BACK;
  128018. private static FACE_DOWN;
  128019. private static FACE_UP;
  128020. /**
  128021. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  128022. *
  128023. * @param float32Array The source data.
  128024. * @param inputWidth The width of the input panorama.
  128025. * @param inputHeight The height of the input panorama.
  128026. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  128027. * @return The cubemap data
  128028. */
  128029. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  128030. private static CreateCubemapTexture;
  128031. private static CalcProjectionSpherical;
  128032. }
  128033. }
  128034. declare module BABYLON {
  128035. /**
  128036. * Helper class dealing with the extraction of spherical polynomial dataArray
  128037. * from a cube map.
  128038. */
  128039. export class CubeMapToSphericalPolynomialTools {
  128040. private static FileFaces;
  128041. /**
  128042. * Converts a texture to the according Spherical Polynomial data.
  128043. * This extracts the first 3 orders only as they are the only one used in the lighting.
  128044. *
  128045. * @param texture The texture to extract the information from.
  128046. * @return The Spherical Polynomial data.
  128047. */
  128048. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  128049. /**
  128050. * Converts a cubemap to the according Spherical Polynomial data.
  128051. * This extracts the first 3 orders only as they are the only one used in the lighting.
  128052. *
  128053. * @param cubeInfo The Cube map to extract the information from.
  128054. * @return The Spherical Polynomial data.
  128055. */
  128056. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  128057. }
  128058. }
  128059. declare module BABYLON {
  128060. interface BaseTexture {
  128061. /**
  128062. * Get the polynomial representation of the texture data.
  128063. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  128064. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  128065. */
  128066. sphericalPolynomial: Nullable<SphericalPolynomial>;
  128067. }
  128068. }
  128069. declare module BABYLON {
  128070. /** @hidden */
  128071. export var rgbdEncodePixelShader: {
  128072. name: string;
  128073. shader: string;
  128074. };
  128075. }
  128076. declare module BABYLON {
  128077. /** @hidden */
  128078. export var rgbdDecodePixelShader: {
  128079. name: string;
  128080. shader: string;
  128081. };
  128082. }
  128083. declare module BABYLON {
  128084. /**
  128085. * Raw texture data and descriptor sufficient for WebGL texture upload
  128086. */
  128087. export interface EnvironmentTextureInfo {
  128088. /**
  128089. * Version of the environment map
  128090. */
  128091. version: number;
  128092. /**
  128093. * Width of image
  128094. */
  128095. width: number;
  128096. /**
  128097. * Irradiance information stored in the file.
  128098. */
  128099. irradiance: any;
  128100. /**
  128101. * Specular information stored in the file.
  128102. */
  128103. specular: any;
  128104. }
  128105. /**
  128106. * Defines One Image in the file. It requires only the position in the file
  128107. * as well as the length.
  128108. */
  128109. interface BufferImageData {
  128110. /**
  128111. * Length of the image data.
  128112. */
  128113. length: number;
  128114. /**
  128115. * Position of the data from the null terminator delimiting the end of the JSON.
  128116. */
  128117. position: number;
  128118. }
  128119. /**
  128120. * Defines the specular data enclosed in the file.
  128121. * This corresponds to the version 1 of the data.
  128122. */
  128123. export interface EnvironmentTextureSpecularInfoV1 {
  128124. /**
  128125. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  128126. */
  128127. specularDataPosition?: number;
  128128. /**
  128129. * This contains all the images data needed to reconstruct the cubemap.
  128130. */
  128131. mipmaps: Array<BufferImageData>;
  128132. /**
  128133. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  128134. */
  128135. lodGenerationScale: number;
  128136. }
  128137. /**
  128138. * Sets of helpers addressing the serialization and deserialization of environment texture
  128139. * stored in a BabylonJS env file.
  128140. * Those files are usually stored as .env files.
  128141. */
  128142. export class EnvironmentTextureTools {
  128143. /**
  128144. * Magic number identifying the env file.
  128145. */
  128146. private static _MagicBytes;
  128147. /**
  128148. * Gets the environment info from an env file.
  128149. * @param data The array buffer containing the .env bytes.
  128150. * @returns the environment file info (the json header) if successfully parsed.
  128151. */
  128152. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  128153. /**
  128154. * Creates an environment texture from a loaded cube texture.
  128155. * @param texture defines the cube texture to convert in env file
  128156. * @return a promise containing the environment data if succesfull.
  128157. */
  128158. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  128159. /**
  128160. * Creates a JSON representation of the spherical data.
  128161. * @param texture defines the texture containing the polynomials
  128162. * @return the JSON representation of the spherical info
  128163. */
  128164. private static _CreateEnvTextureIrradiance;
  128165. /**
  128166. * Creates the ArrayBufferViews used for initializing environment texture image data.
  128167. * @param data the image data
  128168. * @param info parameters that determine what views will be created for accessing the underlying buffer
  128169. * @return the views described by info providing access to the underlying buffer
  128170. */
  128171. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  128172. /**
  128173. * Uploads the texture info contained in the env file to the GPU.
  128174. * @param texture defines the internal texture to upload to
  128175. * @param data defines the data to load
  128176. * @param info defines the texture info retrieved through the GetEnvInfo method
  128177. * @returns a promise
  128178. */
  128179. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  128180. private static _OnImageReadyAsync;
  128181. /**
  128182. * Uploads the levels of image data to the GPU.
  128183. * @param texture defines the internal texture to upload to
  128184. * @param imageData defines the array buffer views of image data [mipmap][face]
  128185. * @returns a promise
  128186. */
  128187. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  128188. /**
  128189. * Uploads spherical polynomials information to the texture.
  128190. * @param texture defines the texture we are trying to upload the information to
  128191. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  128192. */
  128193. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  128194. /** @hidden */
  128195. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  128196. }
  128197. }
  128198. declare module BABYLON {
  128199. /** @hidden */
  128200. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  128201. private _genericAttributeLocation;
  128202. private _varyingLocationCount;
  128203. private _varyingLocationMap;
  128204. private _replacements;
  128205. private _textureCount;
  128206. private _uniforms;
  128207. lineProcessor(line: string): string;
  128208. attributeProcessor(attribute: string): string;
  128209. varyingProcessor(varying: string, isFragment: boolean): string;
  128210. uniformProcessor(uniform: string): string;
  128211. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  128212. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  128213. }
  128214. }
  128215. declare module BABYLON {
  128216. /**
  128217. * Class used to inline functions in shader code
  128218. */
  128219. export class ShaderCodeInliner {
  128220. private static readonly _RegexpFindFunctionNameAndType;
  128221. private _sourceCode;
  128222. private _functionDescr;
  128223. private _numMaxIterations;
  128224. /** Gets or sets the token used to mark the functions to inline */
  128225. inlineToken: string;
  128226. /** Gets or sets the debug mode */
  128227. debug: boolean;
  128228. /** Gets the code after the inlining process */
  128229. get code(): string;
  128230. /**
  128231. * Initializes the inliner
  128232. * @param sourceCode shader code source to inline
  128233. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  128234. */
  128235. constructor(sourceCode: string, numMaxIterations?: number);
  128236. /**
  128237. * Start the processing of the shader code
  128238. */
  128239. processCode(): void;
  128240. private _collectFunctions;
  128241. private _processInlining;
  128242. private _extractBetweenMarkers;
  128243. private _skipWhitespaces;
  128244. private _removeComments;
  128245. private _replaceFunctionCallsByCode;
  128246. private _findBackward;
  128247. private _escapeRegExp;
  128248. private _replaceNames;
  128249. }
  128250. }
  128251. declare module BABYLON {
  128252. /**
  128253. * Container for accessors for natively-stored mesh data buffers.
  128254. */
  128255. class NativeDataBuffer extends DataBuffer {
  128256. /**
  128257. * Accessor value used to identify/retrieve a natively-stored index buffer.
  128258. */
  128259. nativeIndexBuffer?: any;
  128260. /**
  128261. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  128262. */
  128263. nativeVertexBuffer?: any;
  128264. }
  128265. /** @hidden */
  128266. class NativeTexture extends InternalTexture {
  128267. getInternalTexture(): InternalTexture;
  128268. getViewCount(): number;
  128269. }
  128270. /** @hidden */
  128271. export class NativeEngine extends Engine {
  128272. private readonly _native;
  128273. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  128274. private readonly INVALID_HANDLE;
  128275. getHardwareScalingLevel(): number;
  128276. constructor();
  128277. dispose(): void;
  128278. /**
  128279. * Can be used to override the current requestAnimationFrame requester.
  128280. * @hidden
  128281. */
  128282. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  128283. /**
  128284. * Override default engine behavior.
  128285. * @param color
  128286. * @param backBuffer
  128287. * @param depth
  128288. * @param stencil
  128289. */
  128290. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  128291. /**
  128292. * Gets host document
  128293. * @returns the host document object
  128294. */
  128295. getHostDocument(): Nullable<Document>;
  128296. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  128297. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  128298. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  128299. recordVertexArrayObject(vertexBuffers: {
  128300. [key: string]: VertexBuffer;
  128301. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  128302. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  128303. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  128304. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  128305. /**
  128306. * Draw a list of indexed primitives
  128307. * @param fillMode defines the primitive to use
  128308. * @param indexStart defines the starting index
  128309. * @param indexCount defines the number of index to draw
  128310. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  128311. */
  128312. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  128313. /**
  128314. * Draw a list of unindexed primitives
  128315. * @param fillMode defines the primitive to use
  128316. * @param verticesStart defines the index of first vertex to draw
  128317. * @param verticesCount defines the count of vertices to draw
  128318. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  128319. */
  128320. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  128321. createPipelineContext(): IPipelineContext;
  128322. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  128323. /** @hidden */
  128324. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  128325. /** @hidden */
  128326. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  128327. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  128328. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  128329. protected _setProgram(program: WebGLProgram): void;
  128330. _releaseEffect(effect: Effect): void;
  128331. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  128332. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  128333. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  128334. bindSamplers(effect: Effect): void;
  128335. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  128336. getRenderWidth(useScreen?: boolean): number;
  128337. getRenderHeight(useScreen?: boolean): number;
  128338. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  128339. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  128340. /**
  128341. * Set the z offset to apply to current rendering
  128342. * @param value defines the offset to apply
  128343. */
  128344. setZOffset(value: number): void;
  128345. /**
  128346. * Gets the current value of the zOffset
  128347. * @returns the current zOffset state
  128348. */
  128349. getZOffset(): number;
  128350. /**
  128351. * Enable or disable depth buffering
  128352. * @param enable defines the state to set
  128353. */
  128354. setDepthBuffer(enable: boolean): void;
  128355. /**
  128356. * Gets a boolean indicating if depth writing is enabled
  128357. * @returns the current depth writing state
  128358. */
  128359. getDepthWrite(): boolean;
  128360. /**
  128361. * Enable or disable depth writing
  128362. * @param enable defines the state to set
  128363. */
  128364. setDepthWrite(enable: boolean): void;
  128365. /**
  128366. * Enable or disable color writing
  128367. * @param enable defines the state to set
  128368. */
  128369. setColorWrite(enable: boolean): void;
  128370. /**
  128371. * Gets a boolean indicating if color writing is enabled
  128372. * @returns the current color writing state
  128373. */
  128374. getColorWrite(): boolean;
  128375. /**
  128376. * Sets alpha constants used by some alpha blending modes
  128377. * @param r defines the red component
  128378. * @param g defines the green component
  128379. * @param b defines the blue component
  128380. * @param a defines the alpha component
  128381. */
  128382. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  128383. /**
  128384. * Sets the current alpha mode
  128385. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  128386. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  128387. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  128388. */
  128389. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  128390. /**
  128391. * Gets the current alpha mode
  128392. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  128393. * @returns the current alpha mode
  128394. */
  128395. getAlphaMode(): number;
  128396. setInt(uniform: WebGLUniformLocation, int: number): void;
  128397. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  128398. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  128399. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  128400. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  128401. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  128402. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  128403. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  128404. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  128405. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  128406. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  128407. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  128408. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  128409. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  128410. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  128411. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  128412. setFloat(uniform: WebGLUniformLocation, value: number): void;
  128413. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  128414. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  128415. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  128416. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  128417. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  128418. wipeCaches(bruteForce?: boolean): void;
  128419. _createTexture(): WebGLTexture;
  128420. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  128421. /**
  128422. * Usually called from Texture.ts.
  128423. * Passed information to create a WebGLTexture
  128424. * @param url defines a value which contains one of the following:
  128425. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  128426. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  128427. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  128428. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  128429. * @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)
  128430. * @param scene needed for loading to the correct scene
  128431. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  128432. * @param onLoad optional callback to be called upon successful completion
  128433. * @param onError optional callback to be called upon failure
  128434. * @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
  128435. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  128436. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  128437. * @param forcedExtension defines the extension to use to pick the right loader
  128438. * @param mimeType defines an optional mime type
  128439. * @returns a InternalTexture for assignment back into BABYLON.Texture
  128440. */
  128441. 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;
  128442. /**
  128443. * Creates a cube texture
  128444. * @param rootUrl defines the url where the files to load is located
  128445. * @param scene defines the current scene
  128446. * @param files defines the list of files to load (1 per face)
  128447. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  128448. * @param onLoad defines an optional callback raised when the texture is loaded
  128449. * @param onError defines an optional callback raised if there is an issue to load the texture
  128450. * @param format defines the format of the data
  128451. * @param forcedExtension defines the extension to use to pick the right loader
  128452. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  128453. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  128454. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  128455. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  128456. * @returns the cube texture as an InternalTexture
  128457. */
  128458. 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;
  128459. private _getSamplingFilter;
  128460. private static _GetNativeTextureFormat;
  128461. createRenderTargetTexture(size: number | {
  128462. width: number;
  128463. height: number;
  128464. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  128465. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  128466. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  128467. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  128468. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  128469. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  128470. /**
  128471. * Updates a dynamic vertex buffer.
  128472. * @param vertexBuffer the vertex buffer to update
  128473. * @param data the data used to update the vertex buffer
  128474. * @param byteOffset the byte offset of the data (optional)
  128475. * @param byteLength the byte length of the data (optional)
  128476. */
  128477. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  128478. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  128479. private _updateAnisotropicLevel;
  128480. private _getAddressMode;
  128481. /** @hidden */
  128482. _bindTexture(channel: number, texture: InternalTexture): void;
  128483. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  128484. releaseEffects(): void;
  128485. /** @hidden */
  128486. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  128487. /** @hidden */
  128488. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  128489. /** @hidden */
  128490. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  128491. /** @hidden */
  128492. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  128493. }
  128494. }
  128495. declare module BABYLON {
  128496. /**
  128497. * Gather the list of clipboard event types as constants.
  128498. */
  128499. export class ClipboardEventTypes {
  128500. /**
  128501. * The clipboard event is fired when a copy command is active (pressed).
  128502. */
  128503. static readonly COPY: number;
  128504. /**
  128505. * The clipboard event is fired when a cut command is active (pressed).
  128506. */
  128507. static readonly CUT: number;
  128508. /**
  128509. * The clipboard event is fired when a paste command is active (pressed).
  128510. */
  128511. static readonly PASTE: number;
  128512. }
  128513. /**
  128514. * This class is used to store clipboard related info for the onClipboardObservable event.
  128515. */
  128516. export class ClipboardInfo {
  128517. /**
  128518. * Defines the type of event (BABYLON.ClipboardEventTypes)
  128519. */
  128520. type: number;
  128521. /**
  128522. * Defines the related dom event
  128523. */
  128524. event: ClipboardEvent;
  128525. /**
  128526. *Creates an instance of ClipboardInfo.
  128527. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  128528. * @param event Defines the related dom event
  128529. */
  128530. constructor(
  128531. /**
  128532. * Defines the type of event (BABYLON.ClipboardEventTypes)
  128533. */
  128534. type: number,
  128535. /**
  128536. * Defines the related dom event
  128537. */
  128538. event: ClipboardEvent);
  128539. /**
  128540. * Get the clipboard event's type from the keycode.
  128541. * @param keyCode Defines the keyCode for the current keyboard event.
  128542. * @return {number}
  128543. */
  128544. static GetTypeFromCharacter(keyCode: number): number;
  128545. }
  128546. }
  128547. declare module BABYLON {
  128548. /**
  128549. * Google Daydream controller
  128550. */
  128551. export class DaydreamController extends WebVRController {
  128552. /**
  128553. * Base Url for the controller model.
  128554. */
  128555. static MODEL_BASE_URL: string;
  128556. /**
  128557. * File name for the controller model.
  128558. */
  128559. static MODEL_FILENAME: string;
  128560. /**
  128561. * Gamepad Id prefix used to identify Daydream Controller.
  128562. */
  128563. static readonly GAMEPAD_ID_PREFIX: string;
  128564. /**
  128565. * Creates a new DaydreamController from a gamepad
  128566. * @param vrGamepad the gamepad that the controller should be created from
  128567. */
  128568. constructor(vrGamepad: any);
  128569. /**
  128570. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  128571. * @param scene scene in which to add meshes
  128572. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  128573. */
  128574. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  128575. /**
  128576. * Called once for each button that changed state since the last frame
  128577. * @param buttonIdx Which button index changed
  128578. * @param state New state of the button
  128579. * @param changes Which properties on the state changed since last frame
  128580. */
  128581. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  128582. }
  128583. }
  128584. declare module BABYLON {
  128585. /**
  128586. * Gear VR Controller
  128587. */
  128588. export class GearVRController extends WebVRController {
  128589. /**
  128590. * Base Url for the controller model.
  128591. */
  128592. static MODEL_BASE_URL: string;
  128593. /**
  128594. * File name for the controller model.
  128595. */
  128596. static MODEL_FILENAME: string;
  128597. /**
  128598. * Gamepad Id prefix used to identify this controller.
  128599. */
  128600. static readonly GAMEPAD_ID_PREFIX: string;
  128601. private readonly _buttonIndexToObservableNameMap;
  128602. /**
  128603. * Creates a new GearVRController from a gamepad
  128604. * @param vrGamepad the gamepad that the controller should be created from
  128605. */
  128606. constructor(vrGamepad: any);
  128607. /**
  128608. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  128609. * @param scene scene in which to add meshes
  128610. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  128611. */
  128612. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  128613. /**
  128614. * Called once for each button that changed state since the last frame
  128615. * @param buttonIdx Which button index changed
  128616. * @param state New state of the button
  128617. * @param changes Which properties on the state changed since last frame
  128618. */
  128619. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  128620. }
  128621. }
  128622. declare module BABYLON {
  128623. /**
  128624. * Generic Controller
  128625. */
  128626. export class GenericController extends WebVRController {
  128627. /**
  128628. * Base Url for the controller model.
  128629. */
  128630. static readonly MODEL_BASE_URL: string;
  128631. /**
  128632. * File name for the controller model.
  128633. */
  128634. static readonly MODEL_FILENAME: string;
  128635. /**
  128636. * Creates a new GenericController from a gamepad
  128637. * @param vrGamepad the gamepad that the controller should be created from
  128638. */
  128639. constructor(vrGamepad: any);
  128640. /**
  128641. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  128642. * @param scene scene in which to add meshes
  128643. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  128644. */
  128645. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  128646. /**
  128647. * Called once for each button that changed state since the last frame
  128648. * @param buttonIdx Which button index changed
  128649. * @param state New state of the button
  128650. * @param changes Which properties on the state changed since last frame
  128651. */
  128652. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  128653. }
  128654. }
  128655. declare module BABYLON {
  128656. /**
  128657. * Oculus Touch Controller
  128658. */
  128659. export class OculusTouchController extends WebVRController {
  128660. /**
  128661. * Base Url for the controller model.
  128662. */
  128663. static MODEL_BASE_URL: string;
  128664. /**
  128665. * File name for the left controller model.
  128666. */
  128667. static MODEL_LEFT_FILENAME: string;
  128668. /**
  128669. * File name for the right controller model.
  128670. */
  128671. static MODEL_RIGHT_FILENAME: string;
  128672. /**
  128673. * Base Url for the Quest controller model.
  128674. */
  128675. static QUEST_MODEL_BASE_URL: string;
  128676. /**
  128677. * @hidden
  128678. * If the controllers are running on a device that needs the updated Quest controller models
  128679. */
  128680. static _IsQuest: boolean;
  128681. /**
  128682. * Fired when the secondary trigger on this controller is modified
  128683. */
  128684. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  128685. /**
  128686. * Fired when the thumb rest on this controller is modified
  128687. */
  128688. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  128689. /**
  128690. * Creates a new OculusTouchController from a gamepad
  128691. * @param vrGamepad the gamepad that the controller should be created from
  128692. */
  128693. constructor(vrGamepad: any);
  128694. /**
  128695. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  128696. * @param scene scene in which to add meshes
  128697. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  128698. */
  128699. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  128700. /**
  128701. * Fired when the A button on this controller is modified
  128702. */
  128703. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  128704. /**
  128705. * Fired when the B button on this controller is modified
  128706. */
  128707. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  128708. /**
  128709. * Fired when the X button on this controller is modified
  128710. */
  128711. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  128712. /**
  128713. * Fired when the Y button on this controller is modified
  128714. */
  128715. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  128716. /**
  128717. * Called once for each button that changed state since the last frame
  128718. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  128719. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  128720. * 2) secondary trigger (same)
  128721. * 3) A (right) X (left), touch, pressed = value
  128722. * 4) B / Y
  128723. * 5) thumb rest
  128724. * @param buttonIdx Which button index changed
  128725. * @param state New state of the button
  128726. * @param changes Which properties on the state changed since last frame
  128727. */
  128728. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  128729. }
  128730. }
  128731. declare module BABYLON {
  128732. /**
  128733. * Vive Controller
  128734. */
  128735. export class ViveController extends WebVRController {
  128736. /**
  128737. * Base Url for the controller model.
  128738. */
  128739. static MODEL_BASE_URL: string;
  128740. /**
  128741. * File name for the controller model.
  128742. */
  128743. static MODEL_FILENAME: string;
  128744. /**
  128745. * Creates a new ViveController from a gamepad
  128746. * @param vrGamepad the gamepad that the controller should be created from
  128747. */
  128748. constructor(vrGamepad: any);
  128749. /**
  128750. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  128751. * @param scene scene in which to add meshes
  128752. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  128753. */
  128754. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  128755. /**
  128756. * Fired when the left button on this controller is modified
  128757. */
  128758. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  128759. /**
  128760. * Fired when the right button on this controller is modified
  128761. */
  128762. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  128763. /**
  128764. * Fired when the menu button on this controller is modified
  128765. */
  128766. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  128767. /**
  128768. * Called once for each button that changed state since the last frame
  128769. * Vive mapping:
  128770. * 0: touchpad
  128771. * 1: trigger
  128772. * 2: left AND right buttons
  128773. * 3: menu button
  128774. * @param buttonIdx Which button index changed
  128775. * @param state New state of the button
  128776. * @param changes Which properties on the state changed since last frame
  128777. */
  128778. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  128779. }
  128780. }
  128781. declare module BABYLON {
  128782. /**
  128783. * Defines the WindowsMotionController object that the state of the windows motion controller
  128784. */
  128785. export class WindowsMotionController extends WebVRController {
  128786. /**
  128787. * The base url used to load the left and right controller models
  128788. */
  128789. static MODEL_BASE_URL: string;
  128790. /**
  128791. * The name of the left controller model file
  128792. */
  128793. static MODEL_LEFT_FILENAME: string;
  128794. /**
  128795. * The name of the right controller model file
  128796. */
  128797. static MODEL_RIGHT_FILENAME: string;
  128798. /**
  128799. * The controller name prefix for this controller type
  128800. */
  128801. static readonly GAMEPAD_ID_PREFIX: string;
  128802. /**
  128803. * The controller id pattern for this controller type
  128804. */
  128805. private static readonly GAMEPAD_ID_PATTERN;
  128806. private _loadedMeshInfo;
  128807. protected readonly _mapping: {
  128808. buttons: string[];
  128809. buttonMeshNames: {
  128810. trigger: string;
  128811. menu: string;
  128812. grip: string;
  128813. thumbstick: string;
  128814. trackpad: string;
  128815. };
  128816. buttonObservableNames: {
  128817. trigger: string;
  128818. menu: string;
  128819. grip: string;
  128820. thumbstick: string;
  128821. trackpad: string;
  128822. };
  128823. axisMeshNames: string[];
  128824. pointingPoseMeshName: string;
  128825. };
  128826. /**
  128827. * Fired when the trackpad on this controller is clicked
  128828. */
  128829. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  128830. /**
  128831. * Fired when the trackpad on this controller is modified
  128832. */
  128833. onTrackpadValuesChangedObservable: Observable<StickValues>;
  128834. /**
  128835. * The current x and y values of this controller's trackpad
  128836. */
  128837. trackpad: StickValues;
  128838. /**
  128839. * Creates a new WindowsMotionController from a gamepad
  128840. * @param vrGamepad the gamepad that the controller should be created from
  128841. */
  128842. constructor(vrGamepad: any);
  128843. /**
  128844. * Fired when the trigger on this controller is modified
  128845. */
  128846. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  128847. /**
  128848. * Fired when the menu button on this controller is modified
  128849. */
  128850. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  128851. /**
  128852. * Fired when the grip button on this controller is modified
  128853. */
  128854. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  128855. /**
  128856. * Fired when the thumbstick button on this controller is modified
  128857. */
  128858. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  128859. /**
  128860. * Fired when the touchpad button on this controller is modified
  128861. */
  128862. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  128863. /**
  128864. * Fired when the touchpad values on this controller are modified
  128865. */
  128866. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  128867. protected _updateTrackpad(): void;
  128868. /**
  128869. * Called once per frame by the engine.
  128870. */
  128871. update(): void;
  128872. /**
  128873. * Called once for each button that changed state since the last frame
  128874. * @param buttonIdx Which button index changed
  128875. * @param state New state of the button
  128876. * @param changes Which properties on the state changed since last frame
  128877. */
  128878. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  128879. /**
  128880. * Moves the buttons on the controller mesh based on their current state
  128881. * @param buttonName the name of the button to move
  128882. * @param buttonValue the value of the button which determines the buttons new position
  128883. */
  128884. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  128885. /**
  128886. * Moves the axis on the controller mesh based on its current state
  128887. * @param axis the index of the axis
  128888. * @param axisValue the value of the axis which determines the meshes new position
  128889. * @hidden
  128890. */
  128891. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  128892. /**
  128893. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  128894. * @param scene scene in which to add meshes
  128895. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  128896. */
  128897. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  128898. /**
  128899. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  128900. * can be transformed by button presses and axes values, based on this._mapping.
  128901. *
  128902. * @param scene scene in which the meshes exist
  128903. * @param meshes list of meshes that make up the controller model to process
  128904. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  128905. */
  128906. private processModel;
  128907. private createMeshInfo;
  128908. /**
  128909. * Gets the ray of the controller in the direction the controller is pointing
  128910. * @param length the length the resulting ray should be
  128911. * @returns a ray in the direction the controller is pointing
  128912. */
  128913. getForwardRay(length?: number): Ray;
  128914. /**
  128915. * Disposes of the controller
  128916. */
  128917. dispose(): void;
  128918. }
  128919. /**
  128920. * This class represents a new windows motion controller in XR.
  128921. */
  128922. export class XRWindowsMotionController extends WindowsMotionController {
  128923. /**
  128924. * Changing the original WIndowsMotionController mapping to fir the new mapping
  128925. */
  128926. protected readonly _mapping: {
  128927. buttons: string[];
  128928. buttonMeshNames: {
  128929. trigger: string;
  128930. menu: string;
  128931. grip: string;
  128932. thumbstick: string;
  128933. trackpad: string;
  128934. };
  128935. buttonObservableNames: {
  128936. trigger: string;
  128937. menu: string;
  128938. grip: string;
  128939. thumbstick: string;
  128940. trackpad: string;
  128941. };
  128942. axisMeshNames: string[];
  128943. pointingPoseMeshName: string;
  128944. };
  128945. /**
  128946. * Construct a new XR-Based windows motion controller
  128947. *
  128948. * @param gamepadInfo the gamepad object from the browser
  128949. */
  128950. constructor(gamepadInfo: any);
  128951. /**
  128952. * holds the thumbstick values (X,Y)
  128953. */
  128954. thumbstickValues: StickValues;
  128955. /**
  128956. * Fired when the thumbstick on this controller is clicked
  128957. */
  128958. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  128959. /**
  128960. * Fired when the thumbstick on this controller is modified
  128961. */
  128962. onThumbstickValuesChangedObservable: Observable<StickValues>;
  128963. /**
  128964. * Fired when the touchpad button on this controller is modified
  128965. */
  128966. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  128967. /**
  128968. * Fired when the touchpad values on this controller are modified
  128969. */
  128970. onTrackpadValuesChangedObservable: Observable<StickValues>;
  128971. /**
  128972. * Fired when the thumbstick button on this controller is modified
  128973. * here to prevent breaking changes
  128974. */
  128975. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  128976. /**
  128977. * updating the thumbstick(!) and not the trackpad.
  128978. * This is named this way due to the difference between WebVR and XR and to avoid
  128979. * changing the parent class.
  128980. */
  128981. protected _updateTrackpad(): void;
  128982. /**
  128983. * Disposes the class with joy
  128984. */
  128985. dispose(): void;
  128986. }
  128987. }
  128988. declare module BABYLON {
  128989. /**
  128990. * Class containing static functions to help procedurally build meshes
  128991. */
  128992. export class PolyhedronBuilder {
  128993. /**
  128994. * Creates a polyhedron mesh
  128995. * * 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
  128996. * * The parameter `size` (positive float, default 1) sets the polygon size
  128997. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  128998. * * 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`
  128999. * * 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
  129000. * * 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)`)
  129001. * * 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
  129002. * * 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
  129003. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129004. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129005. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129006. * @param name defines the name of the mesh
  129007. * @param options defines the options used to create the mesh
  129008. * @param scene defines the hosting scene
  129009. * @returns the polyhedron mesh
  129010. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  129011. */
  129012. static CreatePolyhedron(name: string, options: {
  129013. type?: number;
  129014. size?: number;
  129015. sizeX?: number;
  129016. sizeY?: number;
  129017. sizeZ?: number;
  129018. custom?: any;
  129019. faceUV?: Vector4[];
  129020. faceColors?: Color4[];
  129021. flat?: boolean;
  129022. updatable?: boolean;
  129023. sideOrientation?: number;
  129024. frontUVs?: Vector4;
  129025. backUVs?: Vector4;
  129026. }, scene?: Nullable<Scene>): Mesh;
  129027. }
  129028. }
  129029. declare module BABYLON {
  129030. /**
  129031. * Gizmo that enables scaling a mesh along 3 axis
  129032. */
  129033. export class ScaleGizmo extends Gizmo {
  129034. /**
  129035. * Internal gizmo used for interactions on the x axis
  129036. */
  129037. xGizmo: AxisScaleGizmo;
  129038. /**
  129039. * Internal gizmo used for interactions on the y axis
  129040. */
  129041. yGizmo: AxisScaleGizmo;
  129042. /**
  129043. * Internal gizmo used for interactions on the z axis
  129044. */
  129045. zGizmo: AxisScaleGizmo;
  129046. /**
  129047. * Internal gizmo used to scale all axis equally
  129048. */
  129049. uniformScaleGizmo: AxisScaleGizmo;
  129050. private _meshAttached;
  129051. private _updateGizmoRotationToMatchAttachedMesh;
  129052. private _snapDistance;
  129053. private _scaleRatio;
  129054. private _uniformScalingMesh;
  129055. private _octahedron;
  129056. private _sensitivity;
  129057. /** Fires an event when any of it's sub gizmos are dragged */
  129058. onDragStartObservable: Observable<unknown>;
  129059. /** Fires an event when any of it's sub gizmos are released from dragging */
  129060. onDragEndObservable: Observable<unknown>;
  129061. get attachedMesh(): Nullable<AbstractMesh>;
  129062. set attachedMesh(mesh: Nullable<AbstractMesh>);
  129063. /**
  129064. * Creates a ScaleGizmo
  129065. * @param gizmoLayer The utility layer the gizmo will be added to
  129066. */
  129067. constructor(gizmoLayer?: UtilityLayerRenderer);
  129068. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  129069. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  129070. /**
  129071. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  129072. */
  129073. set snapDistance(value: number);
  129074. get snapDistance(): number;
  129075. /**
  129076. * Ratio for the scale of the gizmo (Default: 1)
  129077. */
  129078. set scaleRatio(value: number);
  129079. get scaleRatio(): number;
  129080. /**
  129081. * Sensitivity factor for dragging (Default: 1)
  129082. */
  129083. set sensitivity(value: number);
  129084. get sensitivity(): number;
  129085. /**
  129086. * Disposes of the gizmo
  129087. */
  129088. dispose(): void;
  129089. }
  129090. }
  129091. declare module BABYLON {
  129092. /**
  129093. * Single axis scale gizmo
  129094. */
  129095. export class AxisScaleGizmo extends Gizmo {
  129096. /**
  129097. * Drag behavior responsible for the gizmos dragging interactions
  129098. */
  129099. dragBehavior: PointerDragBehavior;
  129100. private _pointerObserver;
  129101. /**
  129102. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  129103. */
  129104. snapDistance: number;
  129105. /**
  129106. * Event that fires each time the gizmo snaps to a new location.
  129107. * * snapDistance is the the change in distance
  129108. */
  129109. onSnapObservable: Observable<{
  129110. snapDistance: number;
  129111. }>;
  129112. /**
  129113. * If the scaling operation should be done on all axis (default: false)
  129114. */
  129115. uniformScaling: boolean;
  129116. /**
  129117. * Custom sensitivity value for the drag strength
  129118. */
  129119. sensitivity: number;
  129120. private _isEnabled;
  129121. private _parent;
  129122. private _arrow;
  129123. private _coloredMaterial;
  129124. private _hoverMaterial;
  129125. /**
  129126. * Creates an AxisScaleGizmo
  129127. * @param gizmoLayer The utility layer the gizmo will be added to
  129128. * @param dragAxis The axis which the gizmo will be able to scale on
  129129. * @param color The color of the gizmo
  129130. */
  129131. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  129132. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  129133. /**
  129134. * If the gizmo is enabled
  129135. */
  129136. set isEnabled(value: boolean);
  129137. get isEnabled(): boolean;
  129138. /**
  129139. * Disposes of the gizmo
  129140. */
  129141. dispose(): void;
  129142. /**
  129143. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  129144. * @param mesh The mesh to replace the default mesh of the gizmo
  129145. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  129146. */
  129147. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  129148. }
  129149. }
  129150. declare module BABYLON {
  129151. /**
  129152. * Bounding box gizmo
  129153. */
  129154. export class BoundingBoxGizmo extends Gizmo {
  129155. private _lineBoundingBox;
  129156. private _rotateSpheresParent;
  129157. private _scaleBoxesParent;
  129158. private _boundingDimensions;
  129159. private _renderObserver;
  129160. private _pointerObserver;
  129161. private _scaleDragSpeed;
  129162. private _tmpQuaternion;
  129163. private _tmpVector;
  129164. private _tmpRotationMatrix;
  129165. /**
  129166. * 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)
  129167. */
  129168. ignoreChildren: boolean;
  129169. /**
  129170. * 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)
  129171. */
  129172. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  129173. /**
  129174. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  129175. */
  129176. rotationSphereSize: number;
  129177. /**
  129178. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  129179. */
  129180. scaleBoxSize: number;
  129181. /**
  129182. * 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)
  129183. */
  129184. fixedDragMeshScreenSize: boolean;
  129185. /**
  129186. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  129187. */
  129188. fixedDragMeshScreenSizeDistanceFactor: number;
  129189. /**
  129190. * Fired when a rotation sphere or scale box is dragged
  129191. */
  129192. onDragStartObservable: Observable<{}>;
  129193. /**
  129194. * Fired when a scale box is dragged
  129195. */
  129196. onScaleBoxDragObservable: Observable<{}>;
  129197. /**
  129198. * Fired when a scale box drag is ended
  129199. */
  129200. onScaleBoxDragEndObservable: Observable<{}>;
  129201. /**
  129202. * Fired when a rotation sphere is dragged
  129203. */
  129204. onRotationSphereDragObservable: Observable<{}>;
  129205. /**
  129206. * Fired when a rotation sphere drag is ended
  129207. */
  129208. onRotationSphereDragEndObservable: Observable<{}>;
  129209. /**
  129210. * 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)
  129211. */
  129212. scalePivot: Nullable<Vector3>;
  129213. /**
  129214. * Mesh used as a pivot to rotate the attached mesh
  129215. */
  129216. private _anchorMesh;
  129217. private _existingMeshScale;
  129218. private _dragMesh;
  129219. private pointerDragBehavior;
  129220. private coloredMaterial;
  129221. private hoverColoredMaterial;
  129222. /**
  129223. * Sets the color of the bounding box gizmo
  129224. * @param color the color to set
  129225. */
  129226. setColor(color: Color3): void;
  129227. /**
  129228. * Creates an BoundingBoxGizmo
  129229. * @param gizmoLayer The utility layer the gizmo will be added to
  129230. * @param color The color of the gizmo
  129231. */
  129232. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  129233. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  129234. private _selectNode;
  129235. /**
  129236. * Updates the bounding box information for the Gizmo
  129237. */
  129238. updateBoundingBox(): void;
  129239. private _updateRotationSpheres;
  129240. private _updateScaleBoxes;
  129241. /**
  129242. * Enables rotation on the specified axis and disables rotation on the others
  129243. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  129244. */
  129245. setEnabledRotationAxis(axis: string): void;
  129246. /**
  129247. * Enables/disables scaling
  129248. * @param enable if scaling should be enabled
  129249. * @param homogeneousScaling defines if scaling should only be homogeneous
  129250. */
  129251. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  129252. private _updateDummy;
  129253. /**
  129254. * Enables a pointer drag behavior on the bounding box of the gizmo
  129255. */
  129256. enableDragBehavior(): void;
  129257. /**
  129258. * Disposes of the gizmo
  129259. */
  129260. dispose(): void;
  129261. /**
  129262. * 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)
  129263. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  129264. * @returns the bounding box mesh with the passed in mesh as a child
  129265. */
  129266. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  129267. /**
  129268. * CustomMeshes are not supported by this gizmo
  129269. * @param mesh The mesh to replace the default mesh of the gizmo
  129270. */
  129271. setCustomMesh(mesh: Mesh): void;
  129272. }
  129273. }
  129274. declare module BABYLON {
  129275. /**
  129276. * Single plane rotation gizmo
  129277. */
  129278. export class PlaneRotationGizmo extends Gizmo {
  129279. /**
  129280. * Drag behavior responsible for the gizmos dragging interactions
  129281. */
  129282. dragBehavior: PointerDragBehavior;
  129283. private _pointerObserver;
  129284. /**
  129285. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  129286. */
  129287. snapDistance: number;
  129288. /**
  129289. * Event that fires each time the gizmo snaps to a new location.
  129290. * * snapDistance is the the change in distance
  129291. */
  129292. onSnapObservable: Observable<{
  129293. snapDistance: number;
  129294. }>;
  129295. private _isEnabled;
  129296. private _parent;
  129297. /**
  129298. * Creates a PlaneRotationGizmo
  129299. * @param gizmoLayer The utility layer the gizmo will be added to
  129300. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  129301. * @param color The color of the gizmo
  129302. * @param tessellation Amount of tessellation to be used when creating rotation circles
  129303. * @param useEulerRotation Use and update Euler angle instead of quaternion
  129304. */
  129305. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  129306. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  129307. /**
  129308. * If the gizmo is enabled
  129309. */
  129310. set isEnabled(value: boolean);
  129311. get isEnabled(): boolean;
  129312. /**
  129313. * Disposes of the gizmo
  129314. */
  129315. dispose(): void;
  129316. }
  129317. }
  129318. declare module BABYLON {
  129319. /**
  129320. * Gizmo that enables rotating a mesh along 3 axis
  129321. */
  129322. export class RotationGizmo extends Gizmo {
  129323. /**
  129324. * Internal gizmo used for interactions on the x axis
  129325. */
  129326. xGizmo: PlaneRotationGizmo;
  129327. /**
  129328. * Internal gizmo used for interactions on the y axis
  129329. */
  129330. yGizmo: PlaneRotationGizmo;
  129331. /**
  129332. * Internal gizmo used for interactions on the z axis
  129333. */
  129334. zGizmo: PlaneRotationGizmo;
  129335. /** Fires an event when any of it's sub gizmos are dragged */
  129336. onDragStartObservable: Observable<unknown>;
  129337. /** Fires an event when any of it's sub gizmos are released from dragging */
  129338. onDragEndObservable: Observable<unknown>;
  129339. private _meshAttached;
  129340. get attachedMesh(): Nullable<AbstractMesh>;
  129341. set attachedMesh(mesh: Nullable<AbstractMesh>);
  129342. /**
  129343. * Creates a RotationGizmo
  129344. * @param gizmoLayer The utility layer the gizmo will be added to
  129345. * @param tessellation Amount of tessellation to be used when creating rotation circles
  129346. * @param useEulerRotation Use and update Euler angle instead of quaternion
  129347. */
  129348. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  129349. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  129350. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  129351. /**
  129352. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  129353. */
  129354. set snapDistance(value: number);
  129355. get snapDistance(): number;
  129356. /**
  129357. * Ratio for the scale of the gizmo (Default: 1)
  129358. */
  129359. set scaleRatio(value: number);
  129360. get scaleRatio(): number;
  129361. /**
  129362. * Disposes of the gizmo
  129363. */
  129364. dispose(): void;
  129365. /**
  129366. * CustomMeshes are not supported by this gizmo
  129367. * @param mesh The mesh to replace the default mesh of the gizmo
  129368. */
  129369. setCustomMesh(mesh: Mesh): void;
  129370. }
  129371. }
  129372. declare module BABYLON {
  129373. /**
  129374. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  129375. */
  129376. export class GizmoManager implements IDisposable {
  129377. private scene;
  129378. /**
  129379. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  129380. */
  129381. gizmos: {
  129382. positionGizmo: Nullable<PositionGizmo>;
  129383. rotationGizmo: Nullable<RotationGizmo>;
  129384. scaleGizmo: Nullable<ScaleGizmo>;
  129385. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  129386. };
  129387. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  129388. clearGizmoOnEmptyPointerEvent: boolean;
  129389. /** Fires an event when the manager is attached to a mesh */
  129390. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  129391. private _gizmosEnabled;
  129392. private _pointerObserver;
  129393. private _attachedMesh;
  129394. private _boundingBoxColor;
  129395. private _defaultUtilityLayer;
  129396. private _defaultKeepDepthUtilityLayer;
  129397. /**
  129398. * When bounding box gizmo is enabled, this can be used to track drag/end events
  129399. */
  129400. boundingBoxDragBehavior: SixDofDragBehavior;
  129401. /**
  129402. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  129403. */
  129404. attachableMeshes: Nullable<Array<AbstractMesh>>;
  129405. /**
  129406. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  129407. */
  129408. usePointerToAttachGizmos: boolean;
  129409. /**
  129410. * Utility layer that the bounding box gizmo belongs to
  129411. */
  129412. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  129413. /**
  129414. * Utility layer that all gizmos besides bounding box belong to
  129415. */
  129416. get utilityLayer(): UtilityLayerRenderer;
  129417. /**
  129418. * Instatiates a gizmo manager
  129419. * @param scene the scene to overlay the gizmos on top of
  129420. */
  129421. constructor(scene: Scene);
  129422. /**
  129423. * Attaches a set of gizmos to the specified mesh
  129424. * @param mesh The mesh the gizmo's should be attached to
  129425. */
  129426. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  129427. /**
  129428. * If the position gizmo is enabled
  129429. */
  129430. set positionGizmoEnabled(value: boolean);
  129431. get positionGizmoEnabled(): boolean;
  129432. /**
  129433. * If the rotation gizmo is enabled
  129434. */
  129435. set rotationGizmoEnabled(value: boolean);
  129436. get rotationGizmoEnabled(): boolean;
  129437. /**
  129438. * If the scale gizmo is enabled
  129439. */
  129440. set scaleGizmoEnabled(value: boolean);
  129441. get scaleGizmoEnabled(): boolean;
  129442. /**
  129443. * If the boundingBox gizmo is enabled
  129444. */
  129445. set boundingBoxGizmoEnabled(value: boolean);
  129446. get boundingBoxGizmoEnabled(): boolean;
  129447. /**
  129448. * Disposes of the gizmo manager
  129449. */
  129450. dispose(): void;
  129451. }
  129452. }
  129453. declare module BABYLON {
  129454. /**
  129455. * A directional light is defined by a direction (what a surprise!).
  129456. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  129457. * 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.
  129458. * Documentation: https://doc.babylonjs.com/babylon101/lights
  129459. */
  129460. export class DirectionalLight extends ShadowLight {
  129461. private _shadowFrustumSize;
  129462. /**
  129463. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  129464. */
  129465. get shadowFrustumSize(): number;
  129466. /**
  129467. * Specifies a fix frustum size for the shadow generation.
  129468. */
  129469. set shadowFrustumSize(value: number);
  129470. private _shadowOrthoScale;
  129471. /**
  129472. * Gets the shadow projection scale against the optimal computed one.
  129473. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  129474. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  129475. */
  129476. get shadowOrthoScale(): number;
  129477. /**
  129478. * Sets the shadow projection scale against the optimal computed one.
  129479. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  129480. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  129481. */
  129482. set shadowOrthoScale(value: number);
  129483. /**
  129484. * Automatically compute the projection matrix to best fit (including all the casters)
  129485. * on each frame.
  129486. */
  129487. autoUpdateExtends: boolean;
  129488. /**
  129489. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  129490. * on each frame. autoUpdateExtends must be set to true for this to work
  129491. */
  129492. autoCalcShadowZBounds: boolean;
  129493. private _orthoLeft;
  129494. private _orthoRight;
  129495. private _orthoTop;
  129496. private _orthoBottom;
  129497. /**
  129498. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  129499. * The directional light is emitted from everywhere in the given direction.
  129500. * It can cast shadows.
  129501. * Documentation : https://doc.babylonjs.com/babylon101/lights
  129502. * @param name The friendly name of the light
  129503. * @param direction The direction of the light
  129504. * @param scene The scene the light belongs to
  129505. */
  129506. constructor(name: string, direction: Vector3, scene: Scene);
  129507. /**
  129508. * Returns the string "DirectionalLight".
  129509. * @return The class name
  129510. */
  129511. getClassName(): string;
  129512. /**
  129513. * Returns the integer 1.
  129514. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  129515. */
  129516. getTypeID(): number;
  129517. /**
  129518. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  129519. * Returns the DirectionalLight Shadow projection matrix.
  129520. */
  129521. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  129522. /**
  129523. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  129524. * Returns the DirectionalLight Shadow projection matrix.
  129525. */
  129526. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  129527. /**
  129528. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  129529. * Returns the DirectionalLight Shadow projection matrix.
  129530. */
  129531. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  129532. protected _buildUniformLayout(): void;
  129533. /**
  129534. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  129535. * @param effect The effect to update
  129536. * @param lightIndex The index of the light in the effect to update
  129537. * @returns The directional light
  129538. */
  129539. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  129540. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  129541. /**
  129542. * Gets the minZ used for shadow according to both the scene and the light.
  129543. *
  129544. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  129545. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  129546. * @param activeCamera The camera we are returning the min for
  129547. * @returns the depth min z
  129548. */
  129549. getDepthMinZ(activeCamera: Camera): number;
  129550. /**
  129551. * Gets the maxZ used for shadow according to both the scene and the light.
  129552. *
  129553. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  129554. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  129555. * @param activeCamera The camera we are returning the max for
  129556. * @returns the depth max z
  129557. */
  129558. getDepthMaxZ(activeCamera: Camera): number;
  129559. /**
  129560. * Prepares the list of defines specific to the light type.
  129561. * @param defines the list of defines
  129562. * @param lightIndex defines the index of the light for the effect
  129563. */
  129564. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  129565. }
  129566. }
  129567. declare module BABYLON {
  129568. /**
  129569. * Class containing static functions to help procedurally build meshes
  129570. */
  129571. export class HemisphereBuilder {
  129572. /**
  129573. * Creates a hemisphere mesh
  129574. * @param name defines the name of the mesh
  129575. * @param options defines the options used to create the mesh
  129576. * @param scene defines the hosting scene
  129577. * @returns the hemisphere mesh
  129578. */
  129579. static CreateHemisphere(name: string, options: {
  129580. segments?: number;
  129581. diameter?: number;
  129582. sideOrientation?: number;
  129583. }, scene: any): Mesh;
  129584. }
  129585. }
  129586. declare module BABYLON {
  129587. /**
  129588. * A spot light is defined by a position, a direction, an angle, and an exponent.
  129589. * These values define a cone of light starting from the position, emitting toward the direction.
  129590. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  129591. * and the exponent defines the speed of the decay of the light with distance (reach).
  129592. * Documentation: https://doc.babylonjs.com/babylon101/lights
  129593. */
  129594. export class SpotLight extends ShadowLight {
  129595. private _angle;
  129596. private _innerAngle;
  129597. private _cosHalfAngle;
  129598. private _lightAngleScale;
  129599. private _lightAngleOffset;
  129600. /**
  129601. * Gets the cone angle of the spot light in Radians.
  129602. */
  129603. get angle(): number;
  129604. /**
  129605. * Sets the cone angle of the spot light in Radians.
  129606. */
  129607. set angle(value: number);
  129608. /**
  129609. * Only used in gltf falloff mode, this defines the angle where
  129610. * the directional falloff will start before cutting at angle which could be seen
  129611. * as outer angle.
  129612. */
  129613. get innerAngle(): number;
  129614. /**
  129615. * Only used in gltf falloff mode, this defines the angle where
  129616. * the directional falloff will start before cutting at angle which could be seen
  129617. * as outer angle.
  129618. */
  129619. set innerAngle(value: number);
  129620. private _shadowAngleScale;
  129621. /**
  129622. * Allows scaling the angle of the light for shadow generation only.
  129623. */
  129624. get shadowAngleScale(): number;
  129625. /**
  129626. * Allows scaling the angle of the light for shadow generation only.
  129627. */
  129628. set shadowAngleScale(value: number);
  129629. /**
  129630. * The light decay speed with the distance from the emission spot.
  129631. */
  129632. exponent: number;
  129633. private _projectionTextureMatrix;
  129634. /**
  129635. * Allows reading the projecton texture
  129636. */
  129637. get projectionTextureMatrix(): Matrix;
  129638. protected _projectionTextureLightNear: number;
  129639. /**
  129640. * Gets the near clip of the Spotlight for texture projection.
  129641. */
  129642. get projectionTextureLightNear(): number;
  129643. /**
  129644. * Sets the near clip of the Spotlight for texture projection.
  129645. */
  129646. set projectionTextureLightNear(value: number);
  129647. protected _projectionTextureLightFar: number;
  129648. /**
  129649. * Gets the far clip of the Spotlight for texture projection.
  129650. */
  129651. get projectionTextureLightFar(): number;
  129652. /**
  129653. * Sets the far clip of the Spotlight for texture projection.
  129654. */
  129655. set projectionTextureLightFar(value: number);
  129656. protected _projectionTextureUpDirection: Vector3;
  129657. /**
  129658. * Gets the Up vector of the Spotlight for texture projection.
  129659. */
  129660. get projectionTextureUpDirection(): Vector3;
  129661. /**
  129662. * Sets the Up vector of the Spotlight for texture projection.
  129663. */
  129664. set projectionTextureUpDirection(value: Vector3);
  129665. private _projectionTexture;
  129666. /**
  129667. * Gets the projection texture of the light.
  129668. */
  129669. get projectionTexture(): Nullable<BaseTexture>;
  129670. /**
  129671. * Sets the projection texture of the light.
  129672. */
  129673. set projectionTexture(value: Nullable<BaseTexture>);
  129674. private _projectionTextureViewLightDirty;
  129675. private _projectionTextureProjectionLightDirty;
  129676. private _projectionTextureDirty;
  129677. private _projectionTextureViewTargetVector;
  129678. private _projectionTextureViewLightMatrix;
  129679. private _projectionTextureProjectionLightMatrix;
  129680. private _projectionTextureScalingMatrix;
  129681. /**
  129682. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  129683. * It can cast shadows.
  129684. * Documentation : https://doc.babylonjs.com/babylon101/lights
  129685. * @param name The light friendly name
  129686. * @param position The position of the spot light in the scene
  129687. * @param direction The direction of the light in the scene
  129688. * @param angle The cone angle of the light in Radians
  129689. * @param exponent The light decay speed with the distance from the emission spot
  129690. * @param scene The scene the lights belongs to
  129691. */
  129692. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  129693. /**
  129694. * Returns the string "SpotLight".
  129695. * @returns the class name
  129696. */
  129697. getClassName(): string;
  129698. /**
  129699. * Returns the integer 2.
  129700. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  129701. */
  129702. getTypeID(): number;
  129703. /**
  129704. * Overrides the direction setter to recompute the projection texture view light Matrix.
  129705. */
  129706. protected _setDirection(value: Vector3): void;
  129707. /**
  129708. * Overrides the position setter to recompute the projection texture view light Matrix.
  129709. */
  129710. protected _setPosition(value: Vector3): void;
  129711. /**
  129712. * 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.
  129713. * Returns the SpotLight.
  129714. */
  129715. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  129716. protected _computeProjectionTextureViewLightMatrix(): void;
  129717. protected _computeProjectionTextureProjectionLightMatrix(): void;
  129718. /**
  129719. * Main function for light texture projection matrix computing.
  129720. */
  129721. protected _computeProjectionTextureMatrix(): void;
  129722. protected _buildUniformLayout(): void;
  129723. private _computeAngleValues;
  129724. /**
  129725. * Sets the passed Effect "effect" with the Light textures.
  129726. * @param effect The effect to update
  129727. * @param lightIndex The index of the light in the effect to update
  129728. * @returns The light
  129729. */
  129730. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  129731. /**
  129732. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  129733. * @param effect The effect to update
  129734. * @param lightIndex The index of the light in the effect to update
  129735. * @returns The spot light
  129736. */
  129737. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  129738. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  129739. /**
  129740. * Disposes the light and the associated resources.
  129741. */
  129742. dispose(): void;
  129743. /**
  129744. * Prepares the list of defines specific to the light type.
  129745. * @param defines the list of defines
  129746. * @param lightIndex defines the index of the light for the effect
  129747. */
  129748. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  129749. }
  129750. }
  129751. declare module BABYLON {
  129752. /**
  129753. * Gizmo that enables viewing a light
  129754. */
  129755. export class LightGizmo extends Gizmo {
  129756. private _lightMesh;
  129757. private _material;
  129758. private _cachedPosition;
  129759. private _cachedForward;
  129760. private _attachedMeshParent;
  129761. /**
  129762. * Creates a LightGizmo
  129763. * @param gizmoLayer The utility layer the gizmo will be added to
  129764. */
  129765. constructor(gizmoLayer?: UtilityLayerRenderer);
  129766. private _light;
  129767. /**
  129768. * The light that the gizmo is attached to
  129769. */
  129770. set light(light: Nullable<Light>);
  129771. get light(): Nullable<Light>;
  129772. /**
  129773. * Gets the material used to render the light gizmo
  129774. */
  129775. get material(): StandardMaterial;
  129776. /**
  129777. * @hidden
  129778. * Updates the gizmo to match the attached mesh's position/rotation
  129779. */
  129780. protected _update(): void;
  129781. private static _Scale;
  129782. /**
  129783. * Creates the lines for a light mesh
  129784. */
  129785. private static _CreateLightLines;
  129786. /**
  129787. * Disposes of the light gizmo
  129788. */
  129789. dispose(): void;
  129790. private static _CreateHemisphericLightMesh;
  129791. private static _CreatePointLightMesh;
  129792. private static _CreateSpotLightMesh;
  129793. private static _CreateDirectionalLightMesh;
  129794. }
  129795. }
  129796. declare module BABYLON {
  129797. /** @hidden */
  129798. export var backgroundFragmentDeclaration: {
  129799. name: string;
  129800. shader: string;
  129801. };
  129802. }
  129803. declare module BABYLON {
  129804. /** @hidden */
  129805. export var backgroundUboDeclaration: {
  129806. name: string;
  129807. shader: string;
  129808. };
  129809. }
  129810. declare module BABYLON {
  129811. /** @hidden */
  129812. export var backgroundPixelShader: {
  129813. name: string;
  129814. shader: string;
  129815. };
  129816. }
  129817. declare module BABYLON {
  129818. /** @hidden */
  129819. export var backgroundVertexDeclaration: {
  129820. name: string;
  129821. shader: string;
  129822. };
  129823. }
  129824. declare module BABYLON {
  129825. /** @hidden */
  129826. export var backgroundVertexShader: {
  129827. name: string;
  129828. shader: string;
  129829. };
  129830. }
  129831. declare module BABYLON {
  129832. /**
  129833. * Background material used to create an efficient environement around your scene.
  129834. */
  129835. export class BackgroundMaterial extends PushMaterial {
  129836. /**
  129837. * Standard reflectance value at parallel view angle.
  129838. */
  129839. static StandardReflectance0: number;
  129840. /**
  129841. * Standard reflectance value at grazing angle.
  129842. */
  129843. static StandardReflectance90: number;
  129844. protected _primaryColor: Color3;
  129845. /**
  129846. * Key light Color (multiply against the environement texture)
  129847. */
  129848. primaryColor: Color3;
  129849. protected __perceptualColor: Nullable<Color3>;
  129850. /**
  129851. * Experimental Internal Use Only.
  129852. *
  129853. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  129854. * This acts as a helper to set the primary color to a more "human friendly" value.
  129855. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  129856. * output color as close as possible from the chosen value.
  129857. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  129858. * part of lighting setup.)
  129859. */
  129860. get _perceptualColor(): Nullable<Color3>;
  129861. set _perceptualColor(value: Nullable<Color3>);
  129862. protected _primaryColorShadowLevel: float;
  129863. /**
  129864. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  129865. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  129866. */
  129867. get primaryColorShadowLevel(): float;
  129868. set primaryColorShadowLevel(value: float);
  129869. protected _primaryColorHighlightLevel: float;
  129870. /**
  129871. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  129872. * The primary color is used at the level chosen to define what the white area would look.
  129873. */
  129874. get primaryColorHighlightLevel(): float;
  129875. set primaryColorHighlightLevel(value: float);
  129876. protected _reflectionTexture: Nullable<BaseTexture>;
  129877. /**
  129878. * Reflection Texture used in the material.
  129879. * Should be author in a specific way for the best result (refer to the documentation).
  129880. */
  129881. reflectionTexture: Nullable<BaseTexture>;
  129882. protected _reflectionBlur: float;
  129883. /**
  129884. * Reflection Texture level of blur.
  129885. *
  129886. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  129887. * texture twice.
  129888. */
  129889. reflectionBlur: float;
  129890. protected _diffuseTexture: Nullable<BaseTexture>;
  129891. /**
  129892. * Diffuse Texture used in the material.
  129893. * Should be author in a specific way for the best result (refer to the documentation).
  129894. */
  129895. diffuseTexture: Nullable<BaseTexture>;
  129896. protected _shadowLights: Nullable<IShadowLight[]>;
  129897. /**
  129898. * Specify the list of lights casting shadow on the material.
  129899. * All scene shadow lights will be included if null.
  129900. */
  129901. shadowLights: Nullable<IShadowLight[]>;
  129902. protected _shadowLevel: float;
  129903. /**
  129904. * Helps adjusting the shadow to a softer level if required.
  129905. * 0 means black shadows and 1 means no shadows.
  129906. */
  129907. shadowLevel: float;
  129908. protected _sceneCenter: Vector3;
  129909. /**
  129910. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  129911. * It is usually zero but might be interesting to modify according to your setup.
  129912. */
  129913. sceneCenter: Vector3;
  129914. protected _opacityFresnel: boolean;
  129915. /**
  129916. * This helps specifying that the material is falling off to the sky box at grazing angle.
  129917. * This helps ensuring a nice transition when the camera goes under the ground.
  129918. */
  129919. opacityFresnel: boolean;
  129920. protected _reflectionFresnel: boolean;
  129921. /**
  129922. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  129923. * This helps adding a mirror texture on the ground.
  129924. */
  129925. reflectionFresnel: boolean;
  129926. protected _reflectionFalloffDistance: number;
  129927. /**
  129928. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  129929. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  129930. */
  129931. reflectionFalloffDistance: number;
  129932. protected _reflectionAmount: number;
  129933. /**
  129934. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  129935. */
  129936. reflectionAmount: number;
  129937. protected _reflectionReflectance0: number;
  129938. /**
  129939. * This specifies the weight of the reflection at grazing angle.
  129940. */
  129941. reflectionReflectance0: number;
  129942. protected _reflectionReflectance90: number;
  129943. /**
  129944. * This specifies the weight of the reflection at a perpendicular point of view.
  129945. */
  129946. reflectionReflectance90: number;
  129947. /**
  129948. * Sets the reflection reflectance fresnel values according to the default standard
  129949. * empirically know to work well :-)
  129950. */
  129951. set reflectionStandardFresnelWeight(value: number);
  129952. protected _useRGBColor: boolean;
  129953. /**
  129954. * Helps to directly use the maps channels instead of their level.
  129955. */
  129956. useRGBColor: boolean;
  129957. protected _enableNoise: boolean;
  129958. /**
  129959. * This helps reducing the banding effect that could occur on the background.
  129960. */
  129961. enableNoise: boolean;
  129962. /**
  129963. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  129964. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  129965. * Recommended to be keep at 1.0 except for special cases.
  129966. */
  129967. get fovMultiplier(): number;
  129968. set fovMultiplier(value: number);
  129969. private _fovMultiplier;
  129970. /**
  129971. * Enable the FOV adjustment feature controlled by fovMultiplier.
  129972. */
  129973. useEquirectangularFOV: boolean;
  129974. private _maxSimultaneousLights;
  129975. /**
  129976. * Number of Simultaneous lights allowed on the material.
  129977. */
  129978. maxSimultaneousLights: int;
  129979. /**
  129980. * Default configuration related to image processing available in the Background Material.
  129981. */
  129982. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  129983. /**
  129984. * Keep track of the image processing observer to allow dispose and replace.
  129985. */
  129986. private _imageProcessingObserver;
  129987. /**
  129988. * Attaches a new image processing configuration to the PBR Material.
  129989. * @param configuration (if null the scene configuration will be use)
  129990. */
  129991. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  129992. /**
  129993. * Gets the image processing configuration used either in this material.
  129994. */
  129995. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  129996. /**
  129997. * Sets the Default image processing configuration used either in the this material.
  129998. *
  129999. * If sets to null, the scene one is in use.
  130000. */
  130001. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  130002. /**
  130003. * Gets wether the color curves effect is enabled.
  130004. */
  130005. get cameraColorCurvesEnabled(): boolean;
  130006. /**
  130007. * Sets wether the color curves effect is enabled.
  130008. */
  130009. set cameraColorCurvesEnabled(value: boolean);
  130010. /**
  130011. * Gets wether the color grading effect is enabled.
  130012. */
  130013. get cameraColorGradingEnabled(): boolean;
  130014. /**
  130015. * Gets wether the color grading effect is enabled.
  130016. */
  130017. set cameraColorGradingEnabled(value: boolean);
  130018. /**
  130019. * Gets wether tonemapping is enabled or not.
  130020. */
  130021. get cameraToneMappingEnabled(): boolean;
  130022. /**
  130023. * Sets wether tonemapping is enabled or not
  130024. */
  130025. set cameraToneMappingEnabled(value: boolean);
  130026. /**
  130027. * The camera exposure used on this material.
  130028. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  130029. * This corresponds to a photographic exposure.
  130030. */
  130031. get cameraExposure(): float;
  130032. /**
  130033. * The camera exposure used on this material.
  130034. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  130035. * This corresponds to a photographic exposure.
  130036. */
  130037. set cameraExposure(value: float);
  130038. /**
  130039. * Gets The camera contrast used on this material.
  130040. */
  130041. get cameraContrast(): float;
  130042. /**
  130043. * Sets The camera contrast used on this material.
  130044. */
  130045. set cameraContrast(value: float);
  130046. /**
  130047. * Gets the Color Grading 2D Lookup Texture.
  130048. */
  130049. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  130050. /**
  130051. * Sets the Color Grading 2D Lookup Texture.
  130052. */
  130053. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  130054. /**
  130055. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  130056. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  130057. * 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;
  130058. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  130059. */
  130060. get cameraColorCurves(): Nullable<ColorCurves>;
  130061. /**
  130062. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  130063. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  130064. * 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;
  130065. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  130066. */
  130067. set cameraColorCurves(value: Nullable<ColorCurves>);
  130068. /**
  130069. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  130070. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  130071. */
  130072. switchToBGR: boolean;
  130073. private _renderTargets;
  130074. private _reflectionControls;
  130075. private _white;
  130076. private _primaryShadowColor;
  130077. private _primaryHighlightColor;
  130078. /**
  130079. * Instantiates a Background Material in the given scene
  130080. * @param name The friendly name of the material
  130081. * @param scene The scene to add the material to
  130082. */
  130083. constructor(name: string, scene: Scene);
  130084. /**
  130085. * Gets a boolean indicating that current material needs to register RTT
  130086. */
  130087. get hasRenderTargetTextures(): boolean;
  130088. /**
  130089. * The entire material has been created in order to prevent overdraw.
  130090. * @returns false
  130091. */
  130092. needAlphaTesting(): boolean;
  130093. /**
  130094. * The entire material has been created in order to prevent overdraw.
  130095. * @returns true if blending is enable
  130096. */
  130097. needAlphaBlending(): boolean;
  130098. /**
  130099. * Checks wether the material is ready to be rendered for a given mesh.
  130100. * @param mesh The mesh to render
  130101. * @param subMesh The submesh to check against
  130102. * @param useInstances Specify wether or not the material is used with instances
  130103. * @returns true if all the dependencies are ready (Textures, Effects...)
  130104. */
  130105. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  130106. /**
  130107. * Compute the primary color according to the chosen perceptual color.
  130108. */
  130109. private _computePrimaryColorFromPerceptualColor;
  130110. /**
  130111. * Compute the highlights and shadow colors according to their chosen levels.
  130112. */
  130113. private _computePrimaryColors;
  130114. /**
  130115. * Build the uniform buffer used in the material.
  130116. */
  130117. buildUniformLayout(): void;
  130118. /**
  130119. * Unbind the material.
  130120. */
  130121. unbind(): void;
  130122. /**
  130123. * Bind only the world matrix to the material.
  130124. * @param world The world matrix to bind.
  130125. */
  130126. bindOnlyWorldMatrix(world: Matrix): void;
  130127. /**
  130128. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  130129. * @param world The world matrix to bind.
  130130. * @param subMesh The submesh to bind for.
  130131. */
  130132. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  130133. /**
  130134. * Checks to see if a texture is used in the material.
  130135. * @param texture - Base texture to use.
  130136. * @returns - Boolean specifying if a texture is used in the material.
  130137. */
  130138. hasTexture(texture: BaseTexture): boolean;
  130139. /**
  130140. * Dispose the material.
  130141. * @param forceDisposeEffect Force disposal of the associated effect.
  130142. * @param forceDisposeTextures Force disposal of the associated textures.
  130143. */
  130144. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  130145. /**
  130146. * Clones the material.
  130147. * @param name The cloned name.
  130148. * @returns The cloned material.
  130149. */
  130150. clone(name: string): BackgroundMaterial;
  130151. /**
  130152. * Serializes the current material to its JSON representation.
  130153. * @returns The JSON representation.
  130154. */
  130155. serialize(): any;
  130156. /**
  130157. * Gets the class name of the material
  130158. * @returns "BackgroundMaterial"
  130159. */
  130160. getClassName(): string;
  130161. /**
  130162. * Parse a JSON input to create back a background material.
  130163. * @param source The JSON data to parse
  130164. * @param scene The scene to create the parsed material in
  130165. * @param rootUrl The root url of the assets the material depends upon
  130166. * @returns the instantiated BackgroundMaterial.
  130167. */
  130168. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  130169. }
  130170. }
  130171. declare module BABYLON {
  130172. /**
  130173. * Represents the different options available during the creation of
  130174. * a Environment helper.
  130175. *
  130176. * This can control the default ground, skybox and image processing setup of your scene.
  130177. */
  130178. export interface IEnvironmentHelperOptions {
  130179. /**
  130180. * Specifies whether or not to create a ground.
  130181. * True by default.
  130182. */
  130183. createGround: boolean;
  130184. /**
  130185. * Specifies the ground size.
  130186. * 15 by default.
  130187. */
  130188. groundSize: number;
  130189. /**
  130190. * The texture used on the ground for the main color.
  130191. * Comes from the BabylonJS CDN by default.
  130192. *
  130193. * Remarks: Can be either a texture or a url.
  130194. */
  130195. groundTexture: string | BaseTexture;
  130196. /**
  130197. * The color mixed in the ground texture by default.
  130198. * BabylonJS clearColor by default.
  130199. */
  130200. groundColor: Color3;
  130201. /**
  130202. * Specifies the ground opacity.
  130203. * 1 by default.
  130204. */
  130205. groundOpacity: number;
  130206. /**
  130207. * Enables the ground to receive shadows.
  130208. * True by default.
  130209. */
  130210. enableGroundShadow: boolean;
  130211. /**
  130212. * Helps preventing the shadow to be fully black on the ground.
  130213. * 0.5 by default.
  130214. */
  130215. groundShadowLevel: number;
  130216. /**
  130217. * Creates a mirror texture attach to the ground.
  130218. * false by default.
  130219. */
  130220. enableGroundMirror: boolean;
  130221. /**
  130222. * Specifies the ground mirror size ratio.
  130223. * 0.3 by default as the default kernel is 64.
  130224. */
  130225. groundMirrorSizeRatio: number;
  130226. /**
  130227. * Specifies the ground mirror blur kernel size.
  130228. * 64 by default.
  130229. */
  130230. groundMirrorBlurKernel: number;
  130231. /**
  130232. * Specifies the ground mirror visibility amount.
  130233. * 1 by default
  130234. */
  130235. groundMirrorAmount: number;
  130236. /**
  130237. * Specifies the ground mirror reflectance weight.
  130238. * This uses the standard weight of the background material to setup the fresnel effect
  130239. * of the mirror.
  130240. * 1 by default.
  130241. */
  130242. groundMirrorFresnelWeight: number;
  130243. /**
  130244. * Specifies the ground mirror Falloff distance.
  130245. * This can helps reducing the size of the reflection.
  130246. * 0 by Default.
  130247. */
  130248. groundMirrorFallOffDistance: number;
  130249. /**
  130250. * Specifies the ground mirror texture type.
  130251. * Unsigned Int by Default.
  130252. */
  130253. groundMirrorTextureType: number;
  130254. /**
  130255. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  130256. * the shown objects.
  130257. */
  130258. groundYBias: number;
  130259. /**
  130260. * Specifies whether or not to create a skybox.
  130261. * True by default.
  130262. */
  130263. createSkybox: boolean;
  130264. /**
  130265. * Specifies the skybox size.
  130266. * 20 by default.
  130267. */
  130268. skyboxSize: number;
  130269. /**
  130270. * The texture used on the skybox for the main color.
  130271. * Comes from the BabylonJS CDN by default.
  130272. *
  130273. * Remarks: Can be either a texture or a url.
  130274. */
  130275. skyboxTexture: string | BaseTexture;
  130276. /**
  130277. * The color mixed in the skybox texture by default.
  130278. * BabylonJS clearColor by default.
  130279. */
  130280. skyboxColor: Color3;
  130281. /**
  130282. * The background rotation around the Y axis of the scene.
  130283. * This helps aligning the key lights of your scene with the background.
  130284. * 0 by default.
  130285. */
  130286. backgroundYRotation: number;
  130287. /**
  130288. * Compute automatically the size of the elements to best fit with the scene.
  130289. */
  130290. sizeAuto: boolean;
  130291. /**
  130292. * Default position of the rootMesh if autoSize is not true.
  130293. */
  130294. rootPosition: Vector3;
  130295. /**
  130296. * Sets up the image processing in the scene.
  130297. * true by default.
  130298. */
  130299. setupImageProcessing: boolean;
  130300. /**
  130301. * The texture used as your environment texture in the scene.
  130302. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  130303. *
  130304. * Remarks: Can be either a texture or a url.
  130305. */
  130306. environmentTexture: string | BaseTexture;
  130307. /**
  130308. * The value of the exposure to apply to the scene.
  130309. * 0.6 by default if setupImageProcessing is true.
  130310. */
  130311. cameraExposure: number;
  130312. /**
  130313. * The value of the contrast to apply to the scene.
  130314. * 1.6 by default if setupImageProcessing is true.
  130315. */
  130316. cameraContrast: number;
  130317. /**
  130318. * Specifies whether or not tonemapping should be enabled in the scene.
  130319. * true by default if setupImageProcessing is true.
  130320. */
  130321. toneMappingEnabled: boolean;
  130322. }
  130323. /**
  130324. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  130325. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  130326. * It also helps with the default setup of your imageProcessing configuration.
  130327. */
  130328. export class EnvironmentHelper {
  130329. /**
  130330. * Default ground texture URL.
  130331. */
  130332. private static _groundTextureCDNUrl;
  130333. /**
  130334. * Default skybox texture URL.
  130335. */
  130336. private static _skyboxTextureCDNUrl;
  130337. /**
  130338. * Default environment texture URL.
  130339. */
  130340. private static _environmentTextureCDNUrl;
  130341. /**
  130342. * Creates the default options for the helper.
  130343. */
  130344. private static _getDefaultOptions;
  130345. private _rootMesh;
  130346. /**
  130347. * Gets the root mesh created by the helper.
  130348. */
  130349. get rootMesh(): Mesh;
  130350. private _skybox;
  130351. /**
  130352. * Gets the skybox created by the helper.
  130353. */
  130354. get skybox(): Nullable<Mesh>;
  130355. private _skyboxTexture;
  130356. /**
  130357. * Gets the skybox texture created by the helper.
  130358. */
  130359. get skyboxTexture(): Nullable<BaseTexture>;
  130360. private _skyboxMaterial;
  130361. /**
  130362. * Gets the skybox material created by the helper.
  130363. */
  130364. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  130365. private _ground;
  130366. /**
  130367. * Gets the ground mesh created by the helper.
  130368. */
  130369. get ground(): Nullable<Mesh>;
  130370. private _groundTexture;
  130371. /**
  130372. * Gets the ground texture created by the helper.
  130373. */
  130374. get groundTexture(): Nullable<BaseTexture>;
  130375. private _groundMirror;
  130376. /**
  130377. * Gets the ground mirror created by the helper.
  130378. */
  130379. get groundMirror(): Nullable<MirrorTexture>;
  130380. /**
  130381. * Gets the ground mirror render list to helps pushing the meshes
  130382. * you wish in the ground reflection.
  130383. */
  130384. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  130385. private _groundMaterial;
  130386. /**
  130387. * Gets the ground material created by the helper.
  130388. */
  130389. get groundMaterial(): Nullable<BackgroundMaterial>;
  130390. /**
  130391. * Stores the creation options.
  130392. */
  130393. private readonly _scene;
  130394. private _options;
  130395. /**
  130396. * This observable will be notified with any error during the creation of the environment,
  130397. * mainly texture creation errors.
  130398. */
  130399. onErrorObservable: Observable<{
  130400. message?: string;
  130401. exception?: any;
  130402. }>;
  130403. /**
  130404. * constructor
  130405. * @param options Defines the options we want to customize the helper
  130406. * @param scene The scene to add the material to
  130407. */
  130408. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  130409. /**
  130410. * Updates the background according to the new options
  130411. * @param options
  130412. */
  130413. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  130414. /**
  130415. * Sets the primary color of all the available elements.
  130416. * @param color the main color to affect to the ground and the background
  130417. */
  130418. setMainColor(color: Color3): void;
  130419. /**
  130420. * Setup the image processing according to the specified options.
  130421. */
  130422. private _setupImageProcessing;
  130423. /**
  130424. * Setup the environment texture according to the specified options.
  130425. */
  130426. private _setupEnvironmentTexture;
  130427. /**
  130428. * Setup the background according to the specified options.
  130429. */
  130430. private _setupBackground;
  130431. /**
  130432. * Get the scene sizes according to the setup.
  130433. */
  130434. private _getSceneSize;
  130435. /**
  130436. * Setup the ground according to the specified options.
  130437. */
  130438. private _setupGround;
  130439. /**
  130440. * Setup the ground material according to the specified options.
  130441. */
  130442. private _setupGroundMaterial;
  130443. /**
  130444. * Setup the ground diffuse texture according to the specified options.
  130445. */
  130446. private _setupGroundDiffuseTexture;
  130447. /**
  130448. * Setup the ground mirror texture according to the specified options.
  130449. */
  130450. private _setupGroundMirrorTexture;
  130451. /**
  130452. * Setup the ground to receive the mirror texture.
  130453. */
  130454. private _setupMirrorInGroundMaterial;
  130455. /**
  130456. * Setup the skybox according to the specified options.
  130457. */
  130458. private _setupSkybox;
  130459. /**
  130460. * Setup the skybox material according to the specified options.
  130461. */
  130462. private _setupSkyboxMaterial;
  130463. /**
  130464. * Setup the skybox reflection texture according to the specified options.
  130465. */
  130466. private _setupSkyboxReflectionTexture;
  130467. private _errorHandler;
  130468. /**
  130469. * Dispose all the elements created by the Helper.
  130470. */
  130471. dispose(): void;
  130472. }
  130473. }
  130474. declare module BABYLON {
  130475. /**
  130476. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  130477. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  130478. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  130479. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  130480. */
  130481. export class PhotoDome extends TransformNode {
  130482. /**
  130483. * Define the image as a Monoscopic panoramic 360 image.
  130484. */
  130485. static readonly MODE_MONOSCOPIC: number;
  130486. /**
  130487. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  130488. */
  130489. static readonly MODE_TOPBOTTOM: number;
  130490. /**
  130491. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  130492. */
  130493. static readonly MODE_SIDEBYSIDE: number;
  130494. private _useDirectMapping;
  130495. /**
  130496. * The texture being displayed on the sphere
  130497. */
  130498. protected _photoTexture: Texture;
  130499. /**
  130500. * Gets or sets the texture being displayed on the sphere
  130501. */
  130502. get photoTexture(): Texture;
  130503. set photoTexture(value: Texture);
  130504. /**
  130505. * Observable raised when an error occured while loading the 360 image
  130506. */
  130507. onLoadErrorObservable: Observable<string>;
  130508. /**
  130509. * The skybox material
  130510. */
  130511. protected _material: BackgroundMaterial;
  130512. /**
  130513. * The surface used for the skybox
  130514. */
  130515. protected _mesh: Mesh;
  130516. /**
  130517. * Gets the mesh used for the skybox.
  130518. */
  130519. get mesh(): Mesh;
  130520. /**
  130521. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  130522. * Also see the options.resolution property.
  130523. */
  130524. get fovMultiplier(): number;
  130525. set fovMultiplier(value: number);
  130526. private _imageMode;
  130527. /**
  130528. * Gets or set the current video mode for the video. It can be:
  130529. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  130530. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  130531. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  130532. */
  130533. get imageMode(): number;
  130534. set imageMode(value: number);
  130535. /**
  130536. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  130537. * @param name Element's name, child elements will append suffixes for their own names.
  130538. * @param urlsOfPhoto defines the url of the photo to display
  130539. * @param options defines an object containing optional or exposed sub element properties
  130540. * @param onError defines a callback called when an error occured while loading the texture
  130541. */
  130542. constructor(name: string, urlOfPhoto: string, options: {
  130543. resolution?: number;
  130544. size?: number;
  130545. useDirectMapping?: boolean;
  130546. faceForward?: boolean;
  130547. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  130548. private _onBeforeCameraRenderObserver;
  130549. private _changeImageMode;
  130550. /**
  130551. * Releases resources associated with this node.
  130552. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  130553. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  130554. */
  130555. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  130556. }
  130557. }
  130558. declare module BABYLON {
  130559. /**
  130560. * Class used to host RGBD texture specific utilities
  130561. */
  130562. export class RGBDTextureTools {
  130563. /**
  130564. * Expand the RGBD Texture from RGBD to Half Float if possible.
  130565. * @param texture the texture to expand.
  130566. */
  130567. static ExpandRGBDTexture(texture: Texture): void;
  130568. }
  130569. }
  130570. declare module BABYLON {
  130571. /**
  130572. * Class used to host texture specific utilities
  130573. */
  130574. export class BRDFTextureTools {
  130575. /**
  130576. * Prevents texture cache collision
  130577. */
  130578. private static _instanceNumber;
  130579. /**
  130580. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  130581. * @param scene defines the hosting scene
  130582. * @returns the environment BRDF texture
  130583. */
  130584. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  130585. private static _environmentBRDFBase64Texture;
  130586. }
  130587. }
  130588. declare module BABYLON {
  130589. /**
  130590. * @hidden
  130591. */
  130592. export interface IMaterialClearCoatDefines {
  130593. CLEARCOAT: boolean;
  130594. CLEARCOAT_DEFAULTIOR: boolean;
  130595. CLEARCOAT_TEXTURE: boolean;
  130596. CLEARCOAT_TEXTUREDIRECTUV: number;
  130597. CLEARCOAT_BUMP: boolean;
  130598. CLEARCOAT_BUMPDIRECTUV: number;
  130599. CLEARCOAT_TINT: boolean;
  130600. CLEARCOAT_TINT_TEXTURE: boolean;
  130601. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  130602. /** @hidden */
  130603. _areTexturesDirty: boolean;
  130604. }
  130605. /**
  130606. * Define the code related to the clear coat parameters of the pbr material.
  130607. */
  130608. export class PBRClearCoatConfiguration {
  130609. /**
  130610. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  130611. * The default fits with a polyurethane material.
  130612. */
  130613. private static readonly _DefaultIndexOfRefraction;
  130614. private _isEnabled;
  130615. /**
  130616. * Defines if the clear coat is enabled in the material.
  130617. */
  130618. isEnabled: boolean;
  130619. /**
  130620. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  130621. */
  130622. intensity: number;
  130623. /**
  130624. * Defines the clear coat layer roughness.
  130625. */
  130626. roughness: number;
  130627. private _indexOfRefraction;
  130628. /**
  130629. * Defines the index of refraction of the clear coat.
  130630. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  130631. * The default fits with a polyurethane material.
  130632. * Changing the default value is more performance intensive.
  130633. */
  130634. indexOfRefraction: number;
  130635. private _texture;
  130636. /**
  130637. * Stores the clear coat values in a texture.
  130638. */
  130639. texture: Nullable<BaseTexture>;
  130640. private _bumpTexture;
  130641. /**
  130642. * Define the clear coat specific bump texture.
  130643. */
  130644. bumpTexture: Nullable<BaseTexture>;
  130645. private _isTintEnabled;
  130646. /**
  130647. * Defines if the clear coat tint is enabled in the material.
  130648. */
  130649. isTintEnabled: boolean;
  130650. /**
  130651. * Defines the clear coat tint of the material.
  130652. * This is only use if tint is enabled
  130653. */
  130654. tintColor: Color3;
  130655. /**
  130656. * Defines the distance at which the tint color should be found in the
  130657. * clear coat media.
  130658. * This is only use if tint is enabled
  130659. */
  130660. tintColorAtDistance: number;
  130661. /**
  130662. * Defines the clear coat layer thickness.
  130663. * This is only use if tint is enabled
  130664. */
  130665. tintThickness: number;
  130666. private _tintTexture;
  130667. /**
  130668. * Stores the clear tint values in a texture.
  130669. * rgb is tint
  130670. * a is a thickness factor
  130671. */
  130672. tintTexture: Nullable<BaseTexture>;
  130673. /** @hidden */
  130674. private _internalMarkAllSubMeshesAsTexturesDirty;
  130675. /** @hidden */
  130676. _markAllSubMeshesAsTexturesDirty(): void;
  130677. /**
  130678. * Instantiate a new istance of clear coat configuration.
  130679. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  130680. */
  130681. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  130682. /**
  130683. * Gets wehter the submesh is ready to be used or not.
  130684. * @param defines the list of "defines" to update.
  130685. * @param scene defines the scene the material belongs to.
  130686. * @param engine defines the engine the material belongs to.
  130687. * @param disableBumpMap defines wether the material disables bump or not.
  130688. * @returns - boolean indicating that the submesh is ready or not.
  130689. */
  130690. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  130691. /**
  130692. * Checks to see if a texture is used in the material.
  130693. * @param defines the list of "defines" to update.
  130694. * @param scene defines the scene to the material belongs to.
  130695. */
  130696. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  130697. /**
  130698. * Binds the material data.
  130699. * @param uniformBuffer defines the Uniform buffer to fill in.
  130700. * @param scene defines the scene the material belongs to.
  130701. * @param engine defines the engine the material belongs to.
  130702. * @param disableBumpMap defines wether the material disables bump or not.
  130703. * @param isFrozen defines wether the material is frozen or not.
  130704. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  130705. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  130706. */
  130707. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  130708. /**
  130709. * Checks to see if a texture is used in the material.
  130710. * @param texture - Base texture to use.
  130711. * @returns - Boolean specifying if a texture is used in the material.
  130712. */
  130713. hasTexture(texture: BaseTexture): boolean;
  130714. /**
  130715. * Returns an array of the actively used textures.
  130716. * @param activeTextures Array of BaseTextures
  130717. */
  130718. getActiveTextures(activeTextures: BaseTexture[]): void;
  130719. /**
  130720. * Returns the animatable textures.
  130721. * @param animatables Array of animatable textures.
  130722. */
  130723. getAnimatables(animatables: IAnimatable[]): void;
  130724. /**
  130725. * Disposes the resources of the material.
  130726. * @param forceDisposeTextures - Forces the disposal of all textures.
  130727. */
  130728. dispose(forceDisposeTextures?: boolean): void;
  130729. /**
  130730. * Get the current class name of the texture useful for serialization or dynamic coding.
  130731. * @returns "PBRClearCoatConfiguration"
  130732. */
  130733. getClassName(): string;
  130734. /**
  130735. * Add fallbacks to the effect fallbacks list.
  130736. * @param defines defines the Base texture to use.
  130737. * @param fallbacks defines the current fallback list.
  130738. * @param currentRank defines the current fallback rank.
  130739. * @returns the new fallback rank.
  130740. */
  130741. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  130742. /**
  130743. * Add the required uniforms to the current list.
  130744. * @param uniforms defines the current uniform list.
  130745. */
  130746. static AddUniforms(uniforms: string[]): void;
  130747. /**
  130748. * Add the required samplers to the current list.
  130749. * @param samplers defines the current sampler list.
  130750. */
  130751. static AddSamplers(samplers: string[]): void;
  130752. /**
  130753. * Add the required uniforms to the current buffer.
  130754. * @param uniformBuffer defines the current uniform buffer.
  130755. */
  130756. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  130757. /**
  130758. * Makes a duplicate of the current configuration into another one.
  130759. * @param clearCoatConfiguration define the config where to copy the info
  130760. */
  130761. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  130762. /**
  130763. * Serializes this clear coat configuration.
  130764. * @returns - An object with the serialized config.
  130765. */
  130766. serialize(): any;
  130767. /**
  130768. * Parses a anisotropy Configuration from a serialized object.
  130769. * @param source - Serialized object.
  130770. * @param scene Defines the scene we are parsing for
  130771. * @param rootUrl Defines the rootUrl to load from
  130772. */
  130773. parse(source: any, scene: Scene, rootUrl: string): void;
  130774. }
  130775. }
  130776. declare module BABYLON {
  130777. /**
  130778. * @hidden
  130779. */
  130780. export interface IMaterialAnisotropicDefines {
  130781. ANISOTROPIC: boolean;
  130782. ANISOTROPIC_TEXTURE: boolean;
  130783. ANISOTROPIC_TEXTUREDIRECTUV: number;
  130784. MAINUV1: boolean;
  130785. _areTexturesDirty: boolean;
  130786. _needUVs: boolean;
  130787. }
  130788. /**
  130789. * Define the code related to the anisotropic parameters of the pbr material.
  130790. */
  130791. export class PBRAnisotropicConfiguration {
  130792. private _isEnabled;
  130793. /**
  130794. * Defines if the anisotropy is enabled in the material.
  130795. */
  130796. isEnabled: boolean;
  130797. /**
  130798. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  130799. */
  130800. intensity: number;
  130801. /**
  130802. * Defines if the effect is along the tangents, bitangents or in between.
  130803. * By default, the effect is "strectching" the highlights along the tangents.
  130804. */
  130805. direction: Vector2;
  130806. private _texture;
  130807. /**
  130808. * Stores the anisotropy values in a texture.
  130809. * rg is direction (like normal from -1 to 1)
  130810. * b is a intensity
  130811. */
  130812. texture: Nullable<BaseTexture>;
  130813. /** @hidden */
  130814. private _internalMarkAllSubMeshesAsTexturesDirty;
  130815. /** @hidden */
  130816. _markAllSubMeshesAsTexturesDirty(): void;
  130817. /**
  130818. * Instantiate a new istance of anisotropy configuration.
  130819. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  130820. */
  130821. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  130822. /**
  130823. * Specifies that the submesh is ready to be used.
  130824. * @param defines the list of "defines" to update.
  130825. * @param scene defines the scene the material belongs to.
  130826. * @returns - boolean indicating that the submesh is ready or not.
  130827. */
  130828. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  130829. /**
  130830. * Checks to see if a texture is used in the material.
  130831. * @param defines the list of "defines" to update.
  130832. * @param mesh the mesh we are preparing the defines for.
  130833. * @param scene defines the scene the material belongs to.
  130834. */
  130835. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  130836. /**
  130837. * Binds the material data.
  130838. * @param uniformBuffer defines the Uniform buffer to fill in.
  130839. * @param scene defines the scene the material belongs to.
  130840. * @param isFrozen defines wether the material is frozen or not.
  130841. */
  130842. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  130843. /**
  130844. * Checks to see if a texture is used in the material.
  130845. * @param texture - Base texture to use.
  130846. * @returns - Boolean specifying if a texture is used in the material.
  130847. */
  130848. hasTexture(texture: BaseTexture): boolean;
  130849. /**
  130850. * Returns an array of the actively used textures.
  130851. * @param activeTextures Array of BaseTextures
  130852. */
  130853. getActiveTextures(activeTextures: BaseTexture[]): void;
  130854. /**
  130855. * Returns the animatable textures.
  130856. * @param animatables Array of animatable textures.
  130857. */
  130858. getAnimatables(animatables: IAnimatable[]): void;
  130859. /**
  130860. * Disposes the resources of the material.
  130861. * @param forceDisposeTextures - Forces the disposal of all textures.
  130862. */
  130863. dispose(forceDisposeTextures?: boolean): void;
  130864. /**
  130865. * Get the current class name of the texture useful for serialization or dynamic coding.
  130866. * @returns "PBRAnisotropicConfiguration"
  130867. */
  130868. getClassName(): string;
  130869. /**
  130870. * Add fallbacks to the effect fallbacks list.
  130871. * @param defines defines the Base texture to use.
  130872. * @param fallbacks defines the current fallback list.
  130873. * @param currentRank defines the current fallback rank.
  130874. * @returns the new fallback rank.
  130875. */
  130876. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  130877. /**
  130878. * Add the required uniforms to the current list.
  130879. * @param uniforms defines the current uniform list.
  130880. */
  130881. static AddUniforms(uniforms: string[]): void;
  130882. /**
  130883. * Add the required uniforms to the current buffer.
  130884. * @param uniformBuffer defines the current uniform buffer.
  130885. */
  130886. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  130887. /**
  130888. * Add the required samplers to the current list.
  130889. * @param samplers defines the current sampler list.
  130890. */
  130891. static AddSamplers(samplers: string[]): void;
  130892. /**
  130893. * Makes a duplicate of the current configuration into another one.
  130894. * @param anisotropicConfiguration define the config where to copy the info
  130895. */
  130896. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  130897. /**
  130898. * Serializes this anisotropy configuration.
  130899. * @returns - An object with the serialized config.
  130900. */
  130901. serialize(): any;
  130902. /**
  130903. * Parses a anisotropy Configuration from a serialized object.
  130904. * @param source - Serialized object.
  130905. * @param scene Defines the scene we are parsing for
  130906. * @param rootUrl Defines the rootUrl to load from
  130907. */
  130908. parse(source: any, scene: Scene, rootUrl: string): void;
  130909. }
  130910. }
  130911. declare module BABYLON {
  130912. /**
  130913. * @hidden
  130914. */
  130915. export interface IMaterialBRDFDefines {
  130916. BRDF_V_HEIGHT_CORRELATED: boolean;
  130917. MS_BRDF_ENERGY_CONSERVATION: boolean;
  130918. SPHERICAL_HARMONICS: boolean;
  130919. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  130920. /** @hidden */
  130921. _areMiscDirty: boolean;
  130922. }
  130923. /**
  130924. * Define the code related to the BRDF parameters of the pbr material.
  130925. */
  130926. export class PBRBRDFConfiguration {
  130927. /**
  130928. * Default value used for the energy conservation.
  130929. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  130930. */
  130931. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  130932. /**
  130933. * Default value used for the Smith Visibility Height Correlated mode.
  130934. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  130935. */
  130936. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  130937. /**
  130938. * Default value used for the IBL diffuse part.
  130939. * This can help switching back to the polynomials mode globally which is a tiny bit
  130940. * less GPU intensive at the drawback of a lower quality.
  130941. */
  130942. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  130943. /**
  130944. * Default value used for activating energy conservation for the specular workflow.
  130945. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  130946. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  130947. */
  130948. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  130949. private _useEnergyConservation;
  130950. /**
  130951. * Defines if the material uses energy conservation.
  130952. */
  130953. useEnergyConservation: boolean;
  130954. private _useSmithVisibilityHeightCorrelated;
  130955. /**
  130956. * LEGACY Mode set to false
  130957. * Defines if the material uses height smith correlated visibility term.
  130958. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  130959. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  130960. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  130961. * Not relying on height correlated will also disable energy conservation.
  130962. */
  130963. useSmithVisibilityHeightCorrelated: boolean;
  130964. private _useSphericalHarmonics;
  130965. /**
  130966. * LEGACY Mode set to false
  130967. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  130968. * diffuse part of the IBL.
  130969. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  130970. * to the ground truth.
  130971. */
  130972. useSphericalHarmonics: boolean;
  130973. private _useSpecularGlossinessInputEnergyConservation;
  130974. /**
  130975. * Defines if the material uses energy conservation, when the specular workflow is active.
  130976. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  130977. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  130978. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  130979. */
  130980. useSpecularGlossinessInputEnergyConservation: boolean;
  130981. /** @hidden */
  130982. private _internalMarkAllSubMeshesAsMiscDirty;
  130983. /** @hidden */
  130984. _markAllSubMeshesAsMiscDirty(): void;
  130985. /**
  130986. * Instantiate a new istance of clear coat configuration.
  130987. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  130988. */
  130989. constructor(markAllSubMeshesAsMiscDirty: () => void);
  130990. /**
  130991. * Checks to see if a texture is used in the material.
  130992. * @param defines the list of "defines" to update.
  130993. */
  130994. prepareDefines(defines: IMaterialBRDFDefines): void;
  130995. /**
  130996. * Get the current class name of the texture useful for serialization or dynamic coding.
  130997. * @returns "PBRClearCoatConfiguration"
  130998. */
  130999. getClassName(): string;
  131000. /**
  131001. * Makes a duplicate of the current configuration into another one.
  131002. * @param brdfConfiguration define the config where to copy the info
  131003. */
  131004. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  131005. /**
  131006. * Serializes this BRDF configuration.
  131007. * @returns - An object with the serialized config.
  131008. */
  131009. serialize(): any;
  131010. /**
  131011. * Parses a anisotropy Configuration from a serialized object.
  131012. * @param source - Serialized object.
  131013. * @param scene Defines the scene we are parsing for
  131014. * @param rootUrl Defines the rootUrl to load from
  131015. */
  131016. parse(source: any, scene: Scene, rootUrl: string): void;
  131017. }
  131018. }
  131019. declare module BABYLON {
  131020. /**
  131021. * @hidden
  131022. */
  131023. export interface IMaterialSheenDefines {
  131024. SHEEN: boolean;
  131025. SHEEN_TEXTURE: boolean;
  131026. SHEEN_TEXTUREDIRECTUV: number;
  131027. SHEEN_LINKWITHALBEDO: boolean;
  131028. SHEEN_ROUGHNESS: boolean;
  131029. SHEEN_ALBEDOSCALING: boolean;
  131030. /** @hidden */
  131031. _areTexturesDirty: boolean;
  131032. }
  131033. /**
  131034. * Define the code related to the Sheen parameters of the pbr material.
  131035. */
  131036. export class PBRSheenConfiguration {
  131037. private _isEnabled;
  131038. /**
  131039. * Defines if the material uses sheen.
  131040. */
  131041. isEnabled: boolean;
  131042. private _linkSheenWithAlbedo;
  131043. /**
  131044. * Defines if the sheen is linked to the sheen color.
  131045. */
  131046. linkSheenWithAlbedo: boolean;
  131047. /**
  131048. * Defines the sheen intensity.
  131049. */
  131050. intensity: number;
  131051. /**
  131052. * Defines the sheen color.
  131053. */
  131054. color: Color3;
  131055. private _texture;
  131056. /**
  131057. * Stores the sheen tint values in a texture.
  131058. * rgb is tint
  131059. * a is a intensity
  131060. */
  131061. texture: Nullable<BaseTexture>;
  131062. private _roughness;
  131063. /**
  131064. * Defines the sheen roughness.
  131065. * It is not taken into account if linkSheenWithAlbedo is true.
  131066. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  131067. */
  131068. roughness: Nullable<number>;
  131069. private _albedoScaling;
  131070. /**
  131071. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  131072. * It allows the strength of the sheen effect to not depend on the base color of the material,
  131073. * making it easier to setup and tweak the effect
  131074. */
  131075. albedoScaling: boolean;
  131076. /** @hidden */
  131077. private _internalMarkAllSubMeshesAsTexturesDirty;
  131078. /** @hidden */
  131079. _markAllSubMeshesAsTexturesDirty(): void;
  131080. /**
  131081. * Instantiate a new istance of clear coat configuration.
  131082. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  131083. */
  131084. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  131085. /**
  131086. * Specifies that the submesh is ready to be used.
  131087. * @param defines the list of "defines" to update.
  131088. * @param scene defines the scene the material belongs to.
  131089. * @returns - boolean indicating that the submesh is ready or not.
  131090. */
  131091. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  131092. /**
  131093. * Checks to see if a texture is used in the material.
  131094. * @param defines the list of "defines" to update.
  131095. * @param scene defines the scene the material belongs to.
  131096. */
  131097. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  131098. /**
  131099. * Binds the material data.
  131100. * @param uniformBuffer defines the Uniform buffer to fill in.
  131101. * @param scene defines the scene the material belongs to.
  131102. * @param isFrozen defines wether the material is frozen or not.
  131103. */
  131104. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  131105. /**
  131106. * Checks to see if a texture is used in the material.
  131107. * @param texture - Base texture to use.
  131108. * @returns - Boolean specifying if a texture is used in the material.
  131109. */
  131110. hasTexture(texture: BaseTexture): boolean;
  131111. /**
  131112. * Returns an array of the actively used textures.
  131113. * @param activeTextures Array of BaseTextures
  131114. */
  131115. getActiveTextures(activeTextures: BaseTexture[]): void;
  131116. /**
  131117. * Returns the animatable textures.
  131118. * @param animatables Array of animatable textures.
  131119. */
  131120. getAnimatables(animatables: IAnimatable[]): void;
  131121. /**
  131122. * Disposes the resources of the material.
  131123. * @param forceDisposeTextures - Forces the disposal of all textures.
  131124. */
  131125. dispose(forceDisposeTextures?: boolean): void;
  131126. /**
  131127. * Get the current class name of the texture useful for serialization or dynamic coding.
  131128. * @returns "PBRSheenConfiguration"
  131129. */
  131130. getClassName(): string;
  131131. /**
  131132. * Add fallbacks to the effect fallbacks list.
  131133. * @param defines defines the Base texture to use.
  131134. * @param fallbacks defines the current fallback list.
  131135. * @param currentRank defines the current fallback rank.
  131136. * @returns the new fallback rank.
  131137. */
  131138. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  131139. /**
  131140. * Add the required uniforms to the current list.
  131141. * @param uniforms defines the current uniform list.
  131142. */
  131143. static AddUniforms(uniforms: string[]): void;
  131144. /**
  131145. * Add the required uniforms to the current buffer.
  131146. * @param uniformBuffer defines the current uniform buffer.
  131147. */
  131148. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  131149. /**
  131150. * Add the required samplers to the current list.
  131151. * @param samplers defines the current sampler list.
  131152. */
  131153. static AddSamplers(samplers: string[]): void;
  131154. /**
  131155. * Makes a duplicate of the current configuration into another one.
  131156. * @param sheenConfiguration define the config where to copy the info
  131157. */
  131158. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  131159. /**
  131160. * Serializes this BRDF configuration.
  131161. * @returns - An object with the serialized config.
  131162. */
  131163. serialize(): any;
  131164. /**
  131165. * Parses a anisotropy Configuration from a serialized object.
  131166. * @param source - Serialized object.
  131167. * @param scene Defines the scene we are parsing for
  131168. * @param rootUrl Defines the rootUrl to load from
  131169. */
  131170. parse(source: any, scene: Scene, rootUrl: string): void;
  131171. }
  131172. }
  131173. declare module BABYLON {
  131174. /**
  131175. * @hidden
  131176. */
  131177. export interface IMaterialSubSurfaceDefines {
  131178. SUBSURFACE: boolean;
  131179. SS_REFRACTION: boolean;
  131180. SS_TRANSLUCENCY: boolean;
  131181. SS_SCATERRING: boolean;
  131182. SS_THICKNESSANDMASK_TEXTURE: boolean;
  131183. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  131184. SS_REFRACTIONMAP_3D: boolean;
  131185. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  131186. SS_LODINREFRACTIONALPHA: boolean;
  131187. SS_GAMMAREFRACTION: boolean;
  131188. SS_RGBDREFRACTION: boolean;
  131189. SS_LINEARSPECULARREFRACTION: boolean;
  131190. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  131191. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  131192. /** @hidden */
  131193. _areTexturesDirty: boolean;
  131194. }
  131195. /**
  131196. * Define the code related to the sub surface parameters of the pbr material.
  131197. */
  131198. export class PBRSubSurfaceConfiguration {
  131199. private _isRefractionEnabled;
  131200. /**
  131201. * Defines if the refraction is enabled in the material.
  131202. */
  131203. isRefractionEnabled: boolean;
  131204. private _isTranslucencyEnabled;
  131205. /**
  131206. * Defines if the translucency is enabled in the material.
  131207. */
  131208. isTranslucencyEnabled: boolean;
  131209. private _isScatteringEnabled;
  131210. /**
  131211. * Defines the refraction intensity of the material.
  131212. * The refraction when enabled replaces the Diffuse part of the material.
  131213. * The intensity helps transitionning between diffuse and refraction.
  131214. */
  131215. refractionIntensity: number;
  131216. /**
  131217. * Defines the translucency intensity of the material.
  131218. * When translucency has been enabled, this defines how much of the "translucency"
  131219. * is addded to the diffuse part of the material.
  131220. */
  131221. translucencyIntensity: number;
  131222. /**
  131223. * Defines the scattering intensity of the material.
  131224. * When scattering has been enabled, this defines how much of the "scattered light"
  131225. * is addded to the diffuse part of the material.
  131226. */
  131227. scatteringIntensity: number;
  131228. private _thicknessTexture;
  131229. /**
  131230. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  131231. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  131232. * 0 would mean minimumThickness
  131233. * 1 would mean maximumThickness
  131234. * The other channels might be use as a mask to vary the different effects intensity.
  131235. */
  131236. thicknessTexture: Nullable<BaseTexture>;
  131237. private _refractionTexture;
  131238. /**
  131239. * Defines the texture to use for refraction.
  131240. */
  131241. refractionTexture: Nullable<BaseTexture>;
  131242. private _indexOfRefraction;
  131243. /**
  131244. * Index of refraction of the material base layer.
  131245. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  131246. *
  131247. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  131248. *
  131249. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  131250. */
  131251. indexOfRefraction: number;
  131252. private _invertRefractionY;
  131253. /**
  131254. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  131255. */
  131256. invertRefractionY: boolean;
  131257. private _linkRefractionWithTransparency;
  131258. /**
  131259. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  131260. * Materials half opaque for instance using refraction could benefit from this control.
  131261. */
  131262. linkRefractionWithTransparency: boolean;
  131263. /**
  131264. * Defines the minimum thickness stored in the thickness map.
  131265. * If no thickness map is defined, this value will be used to simulate thickness.
  131266. */
  131267. minimumThickness: number;
  131268. /**
  131269. * Defines the maximum thickness stored in the thickness map.
  131270. */
  131271. maximumThickness: number;
  131272. /**
  131273. * Defines the volume tint of the material.
  131274. * This is used for both translucency and scattering.
  131275. */
  131276. tintColor: Color3;
  131277. /**
  131278. * Defines the distance at which the tint color should be found in the media.
  131279. * This is used for refraction only.
  131280. */
  131281. tintColorAtDistance: number;
  131282. /**
  131283. * Defines how far each channel transmit through the media.
  131284. * It is defined as a color to simplify it selection.
  131285. */
  131286. diffusionDistance: Color3;
  131287. private _useMaskFromThicknessTexture;
  131288. /**
  131289. * Stores the intensity of the different subsurface effects in the thickness texture.
  131290. * * the green channel is the translucency intensity.
  131291. * * the blue channel is the scattering intensity.
  131292. * * the alpha channel is the refraction intensity.
  131293. */
  131294. useMaskFromThicknessTexture: boolean;
  131295. /** @hidden */
  131296. private _internalMarkAllSubMeshesAsTexturesDirty;
  131297. /** @hidden */
  131298. _markAllSubMeshesAsTexturesDirty(): void;
  131299. /**
  131300. * Instantiate a new istance of sub surface configuration.
  131301. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  131302. */
  131303. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  131304. /**
  131305. * Gets wehter the submesh is ready to be used or not.
  131306. * @param defines the list of "defines" to update.
  131307. * @param scene defines the scene the material belongs to.
  131308. * @returns - boolean indicating that the submesh is ready or not.
  131309. */
  131310. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  131311. /**
  131312. * Checks to see if a texture is used in the material.
  131313. * @param defines the list of "defines" to update.
  131314. * @param scene defines the scene to the material belongs to.
  131315. */
  131316. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  131317. /**
  131318. * Binds the material data.
  131319. * @param uniformBuffer defines the Uniform buffer to fill in.
  131320. * @param scene defines the scene the material belongs to.
  131321. * @param engine defines the engine the material belongs to.
  131322. * @param isFrozen defines whether the material is frozen or not.
  131323. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  131324. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  131325. */
  131326. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  131327. /**
  131328. * Unbinds the material from the mesh.
  131329. * @param activeEffect defines the effect that should be unbound from.
  131330. * @returns true if unbound, otherwise false
  131331. */
  131332. unbind(activeEffect: Effect): boolean;
  131333. /**
  131334. * Returns the texture used for refraction or null if none is used.
  131335. * @param scene defines the scene the material belongs to.
  131336. * @returns - Refraction texture if present. If no refraction texture and refraction
  131337. * is linked with transparency, returns environment texture. Otherwise, returns null.
  131338. */
  131339. private _getRefractionTexture;
  131340. /**
  131341. * Returns true if alpha blending should be disabled.
  131342. */
  131343. get disableAlphaBlending(): boolean;
  131344. /**
  131345. * Fills the list of render target textures.
  131346. * @param renderTargets the list of render targets to update
  131347. */
  131348. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  131349. /**
  131350. * Checks to see if a texture is used in the material.
  131351. * @param texture - Base texture to use.
  131352. * @returns - Boolean specifying if a texture is used in the material.
  131353. */
  131354. hasTexture(texture: BaseTexture): boolean;
  131355. /**
  131356. * Gets a boolean indicating that current material needs to register RTT
  131357. * @returns true if this uses a render target otherwise false.
  131358. */
  131359. hasRenderTargetTextures(): boolean;
  131360. /**
  131361. * Returns an array of the actively used textures.
  131362. * @param activeTextures Array of BaseTextures
  131363. */
  131364. getActiveTextures(activeTextures: BaseTexture[]): void;
  131365. /**
  131366. * Returns the animatable textures.
  131367. * @param animatables Array of animatable textures.
  131368. */
  131369. getAnimatables(animatables: IAnimatable[]): void;
  131370. /**
  131371. * Disposes the resources of the material.
  131372. * @param forceDisposeTextures - Forces the disposal of all textures.
  131373. */
  131374. dispose(forceDisposeTextures?: boolean): void;
  131375. /**
  131376. * Get the current class name of the texture useful for serialization or dynamic coding.
  131377. * @returns "PBRSubSurfaceConfiguration"
  131378. */
  131379. getClassName(): string;
  131380. /**
  131381. * Add fallbacks to the effect fallbacks list.
  131382. * @param defines defines the Base texture to use.
  131383. * @param fallbacks defines the current fallback list.
  131384. * @param currentRank defines the current fallback rank.
  131385. * @returns the new fallback rank.
  131386. */
  131387. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  131388. /**
  131389. * Add the required uniforms to the current list.
  131390. * @param uniforms defines the current uniform list.
  131391. */
  131392. static AddUniforms(uniforms: string[]): void;
  131393. /**
  131394. * Add the required samplers to the current list.
  131395. * @param samplers defines the current sampler list.
  131396. */
  131397. static AddSamplers(samplers: string[]): void;
  131398. /**
  131399. * Add the required uniforms to the current buffer.
  131400. * @param uniformBuffer defines the current uniform buffer.
  131401. */
  131402. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  131403. /**
  131404. * Makes a duplicate of the current configuration into another one.
  131405. * @param configuration define the config where to copy the info
  131406. */
  131407. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  131408. /**
  131409. * Serializes this Sub Surface configuration.
  131410. * @returns - An object with the serialized config.
  131411. */
  131412. serialize(): any;
  131413. /**
  131414. * Parses a anisotropy Configuration from a serialized object.
  131415. * @param source - Serialized object.
  131416. * @param scene Defines the scene we are parsing for
  131417. * @param rootUrl Defines the rootUrl to load from
  131418. */
  131419. parse(source: any, scene: Scene, rootUrl: string): void;
  131420. }
  131421. }
  131422. declare module BABYLON {
  131423. /** @hidden */
  131424. export var pbrFragmentDeclaration: {
  131425. name: string;
  131426. shader: string;
  131427. };
  131428. }
  131429. declare module BABYLON {
  131430. /** @hidden */
  131431. export var pbrUboDeclaration: {
  131432. name: string;
  131433. shader: string;
  131434. };
  131435. }
  131436. declare module BABYLON {
  131437. /** @hidden */
  131438. export var pbrFragmentExtraDeclaration: {
  131439. name: string;
  131440. shader: string;
  131441. };
  131442. }
  131443. declare module BABYLON {
  131444. /** @hidden */
  131445. export var pbrFragmentSamplersDeclaration: {
  131446. name: string;
  131447. shader: string;
  131448. };
  131449. }
  131450. declare module BABYLON {
  131451. /** @hidden */
  131452. export var importanceSampling: {
  131453. name: string;
  131454. shader: string;
  131455. };
  131456. }
  131457. declare module BABYLON {
  131458. /** @hidden */
  131459. export var pbrHelperFunctions: {
  131460. name: string;
  131461. shader: string;
  131462. };
  131463. }
  131464. declare module BABYLON {
  131465. /** @hidden */
  131466. export var harmonicsFunctions: {
  131467. name: string;
  131468. shader: string;
  131469. };
  131470. }
  131471. declare module BABYLON {
  131472. /** @hidden */
  131473. export var pbrDirectLightingSetupFunctions: {
  131474. name: string;
  131475. shader: string;
  131476. };
  131477. }
  131478. declare module BABYLON {
  131479. /** @hidden */
  131480. export var pbrDirectLightingFalloffFunctions: {
  131481. name: string;
  131482. shader: string;
  131483. };
  131484. }
  131485. declare module BABYLON {
  131486. /** @hidden */
  131487. export var pbrBRDFFunctions: {
  131488. name: string;
  131489. shader: string;
  131490. };
  131491. }
  131492. declare module BABYLON {
  131493. /** @hidden */
  131494. export var hdrFilteringFunctions: {
  131495. name: string;
  131496. shader: string;
  131497. };
  131498. }
  131499. declare module BABYLON {
  131500. /** @hidden */
  131501. export var pbrDirectLightingFunctions: {
  131502. name: string;
  131503. shader: string;
  131504. };
  131505. }
  131506. declare module BABYLON {
  131507. /** @hidden */
  131508. export var pbrIBLFunctions: {
  131509. name: string;
  131510. shader: string;
  131511. };
  131512. }
  131513. declare module BABYLON {
  131514. /** @hidden */
  131515. export var pbrBlockAlbedoOpacity: {
  131516. name: string;
  131517. shader: string;
  131518. };
  131519. }
  131520. declare module BABYLON {
  131521. /** @hidden */
  131522. export var pbrBlockReflectivity: {
  131523. name: string;
  131524. shader: string;
  131525. };
  131526. }
  131527. declare module BABYLON {
  131528. /** @hidden */
  131529. export var pbrBlockAmbientOcclusion: {
  131530. name: string;
  131531. shader: string;
  131532. };
  131533. }
  131534. declare module BABYLON {
  131535. /** @hidden */
  131536. export var pbrBlockAlphaFresnel: {
  131537. name: string;
  131538. shader: string;
  131539. };
  131540. }
  131541. declare module BABYLON {
  131542. /** @hidden */
  131543. export var pbrBlockAnisotropic: {
  131544. name: string;
  131545. shader: string;
  131546. };
  131547. }
  131548. declare module BABYLON {
  131549. /** @hidden */
  131550. export var pbrBlockReflection: {
  131551. name: string;
  131552. shader: string;
  131553. };
  131554. }
  131555. declare module BABYLON {
  131556. /** @hidden */
  131557. export var pbrBlockSheen: {
  131558. name: string;
  131559. shader: string;
  131560. };
  131561. }
  131562. declare module BABYLON {
  131563. /** @hidden */
  131564. export var pbrBlockClearcoat: {
  131565. name: string;
  131566. shader: string;
  131567. };
  131568. }
  131569. declare module BABYLON {
  131570. /** @hidden */
  131571. export var pbrBlockSubSurface: {
  131572. name: string;
  131573. shader: string;
  131574. };
  131575. }
  131576. declare module BABYLON {
  131577. /** @hidden */
  131578. export var pbrBlockNormalGeometric: {
  131579. name: string;
  131580. shader: string;
  131581. };
  131582. }
  131583. declare module BABYLON {
  131584. /** @hidden */
  131585. export var pbrBlockNormalFinal: {
  131586. name: string;
  131587. shader: string;
  131588. };
  131589. }
  131590. declare module BABYLON {
  131591. /** @hidden */
  131592. export var pbrBlockGeometryInfo: {
  131593. name: string;
  131594. shader: string;
  131595. };
  131596. }
  131597. declare module BABYLON {
  131598. /** @hidden */
  131599. export var pbrBlockReflectance0: {
  131600. name: string;
  131601. shader: string;
  131602. };
  131603. }
  131604. declare module BABYLON {
  131605. /** @hidden */
  131606. export var pbrBlockReflectance: {
  131607. name: string;
  131608. shader: string;
  131609. };
  131610. }
  131611. declare module BABYLON {
  131612. /** @hidden */
  131613. export var pbrBlockDirectLighting: {
  131614. name: string;
  131615. shader: string;
  131616. };
  131617. }
  131618. declare module BABYLON {
  131619. /** @hidden */
  131620. export var pbrBlockFinalLitComponents: {
  131621. name: string;
  131622. shader: string;
  131623. };
  131624. }
  131625. declare module BABYLON {
  131626. /** @hidden */
  131627. export var pbrBlockFinalUnlitComponents: {
  131628. name: string;
  131629. shader: string;
  131630. };
  131631. }
  131632. declare module BABYLON {
  131633. /** @hidden */
  131634. export var pbrBlockFinalColorComposition: {
  131635. name: string;
  131636. shader: string;
  131637. };
  131638. }
  131639. declare module BABYLON {
  131640. /** @hidden */
  131641. export var pbrBlockImageProcessing: {
  131642. name: string;
  131643. shader: string;
  131644. };
  131645. }
  131646. declare module BABYLON {
  131647. /** @hidden */
  131648. export var pbrDebug: {
  131649. name: string;
  131650. shader: string;
  131651. };
  131652. }
  131653. declare module BABYLON {
  131654. /** @hidden */
  131655. export var pbrPixelShader: {
  131656. name: string;
  131657. shader: string;
  131658. };
  131659. }
  131660. declare module BABYLON {
  131661. /** @hidden */
  131662. export var pbrVertexDeclaration: {
  131663. name: string;
  131664. shader: string;
  131665. };
  131666. }
  131667. declare module BABYLON {
  131668. /** @hidden */
  131669. export var pbrVertexShader: {
  131670. name: string;
  131671. shader: string;
  131672. };
  131673. }
  131674. declare module BABYLON {
  131675. /**
  131676. * Manages the defines for the PBR Material.
  131677. * @hidden
  131678. */
  131679. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  131680. PBR: boolean;
  131681. NUM_SAMPLES: string;
  131682. REALTIME_FILTERING: boolean;
  131683. MAINUV1: boolean;
  131684. MAINUV2: boolean;
  131685. UV1: boolean;
  131686. UV2: boolean;
  131687. ALBEDO: boolean;
  131688. GAMMAALBEDO: boolean;
  131689. ALBEDODIRECTUV: number;
  131690. VERTEXCOLOR: boolean;
  131691. AMBIENT: boolean;
  131692. AMBIENTDIRECTUV: number;
  131693. AMBIENTINGRAYSCALE: boolean;
  131694. OPACITY: boolean;
  131695. VERTEXALPHA: boolean;
  131696. OPACITYDIRECTUV: number;
  131697. OPACITYRGB: boolean;
  131698. ALPHATEST: boolean;
  131699. DEPTHPREPASS: boolean;
  131700. ALPHABLEND: boolean;
  131701. ALPHAFROMALBEDO: boolean;
  131702. ALPHATESTVALUE: string;
  131703. SPECULAROVERALPHA: boolean;
  131704. RADIANCEOVERALPHA: boolean;
  131705. ALPHAFRESNEL: boolean;
  131706. LINEARALPHAFRESNEL: boolean;
  131707. PREMULTIPLYALPHA: boolean;
  131708. EMISSIVE: boolean;
  131709. EMISSIVEDIRECTUV: number;
  131710. REFLECTIVITY: boolean;
  131711. REFLECTIVITYDIRECTUV: number;
  131712. SPECULARTERM: boolean;
  131713. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  131714. MICROSURFACEAUTOMATIC: boolean;
  131715. LODBASEDMICROSFURACE: boolean;
  131716. MICROSURFACEMAP: boolean;
  131717. MICROSURFACEMAPDIRECTUV: number;
  131718. METALLICWORKFLOW: boolean;
  131719. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  131720. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  131721. METALLNESSSTOREINMETALMAPBLUE: boolean;
  131722. AOSTOREINMETALMAPRED: boolean;
  131723. METALLIC_REFLECTANCE: boolean;
  131724. METALLIC_REFLECTANCEDIRECTUV: number;
  131725. ENVIRONMENTBRDF: boolean;
  131726. ENVIRONMENTBRDF_RGBD: boolean;
  131727. NORMAL: boolean;
  131728. TANGENT: boolean;
  131729. BUMP: boolean;
  131730. BUMPDIRECTUV: number;
  131731. OBJECTSPACE_NORMALMAP: boolean;
  131732. PARALLAX: boolean;
  131733. PARALLAXOCCLUSION: boolean;
  131734. NORMALXYSCALE: boolean;
  131735. LIGHTMAP: boolean;
  131736. LIGHTMAPDIRECTUV: number;
  131737. USELIGHTMAPASSHADOWMAP: boolean;
  131738. GAMMALIGHTMAP: boolean;
  131739. RGBDLIGHTMAP: boolean;
  131740. REFLECTION: boolean;
  131741. REFLECTIONMAP_3D: boolean;
  131742. REFLECTIONMAP_SPHERICAL: boolean;
  131743. REFLECTIONMAP_PLANAR: boolean;
  131744. REFLECTIONMAP_CUBIC: boolean;
  131745. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  131746. REFLECTIONMAP_PROJECTION: boolean;
  131747. REFLECTIONMAP_SKYBOX: boolean;
  131748. REFLECTIONMAP_EXPLICIT: boolean;
  131749. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  131750. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  131751. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  131752. INVERTCUBICMAP: boolean;
  131753. USESPHERICALFROMREFLECTIONMAP: boolean;
  131754. USEIRRADIANCEMAP: boolean;
  131755. SPHERICAL_HARMONICS: boolean;
  131756. USESPHERICALINVERTEX: boolean;
  131757. REFLECTIONMAP_OPPOSITEZ: boolean;
  131758. LODINREFLECTIONALPHA: boolean;
  131759. GAMMAREFLECTION: boolean;
  131760. RGBDREFLECTION: boolean;
  131761. LINEARSPECULARREFLECTION: boolean;
  131762. RADIANCEOCCLUSION: boolean;
  131763. HORIZONOCCLUSION: boolean;
  131764. INSTANCES: boolean;
  131765. THIN_INSTANCES: boolean;
  131766. NUM_BONE_INFLUENCERS: number;
  131767. BonesPerMesh: number;
  131768. BONETEXTURE: boolean;
  131769. NONUNIFORMSCALING: boolean;
  131770. MORPHTARGETS: boolean;
  131771. MORPHTARGETS_NORMAL: boolean;
  131772. MORPHTARGETS_TANGENT: boolean;
  131773. MORPHTARGETS_UV: boolean;
  131774. NUM_MORPH_INFLUENCERS: number;
  131775. IMAGEPROCESSING: boolean;
  131776. VIGNETTE: boolean;
  131777. VIGNETTEBLENDMODEMULTIPLY: boolean;
  131778. VIGNETTEBLENDMODEOPAQUE: boolean;
  131779. TONEMAPPING: boolean;
  131780. TONEMAPPING_ACES: boolean;
  131781. CONTRAST: boolean;
  131782. COLORCURVES: boolean;
  131783. COLORGRADING: boolean;
  131784. COLORGRADING3D: boolean;
  131785. SAMPLER3DGREENDEPTH: boolean;
  131786. SAMPLER3DBGRMAP: boolean;
  131787. IMAGEPROCESSINGPOSTPROCESS: boolean;
  131788. EXPOSURE: boolean;
  131789. MULTIVIEW: boolean;
  131790. USEPHYSICALLIGHTFALLOFF: boolean;
  131791. USEGLTFLIGHTFALLOFF: boolean;
  131792. TWOSIDEDLIGHTING: boolean;
  131793. SHADOWFLOAT: boolean;
  131794. CLIPPLANE: boolean;
  131795. CLIPPLANE2: boolean;
  131796. CLIPPLANE3: boolean;
  131797. CLIPPLANE4: boolean;
  131798. CLIPPLANE5: boolean;
  131799. CLIPPLANE6: boolean;
  131800. POINTSIZE: boolean;
  131801. FOG: boolean;
  131802. LOGARITHMICDEPTH: boolean;
  131803. FORCENORMALFORWARD: boolean;
  131804. SPECULARAA: boolean;
  131805. CLEARCOAT: boolean;
  131806. CLEARCOAT_DEFAULTIOR: boolean;
  131807. CLEARCOAT_TEXTURE: boolean;
  131808. CLEARCOAT_TEXTUREDIRECTUV: number;
  131809. CLEARCOAT_BUMP: boolean;
  131810. CLEARCOAT_BUMPDIRECTUV: number;
  131811. CLEARCOAT_TINT: boolean;
  131812. CLEARCOAT_TINT_TEXTURE: boolean;
  131813. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  131814. ANISOTROPIC: boolean;
  131815. ANISOTROPIC_TEXTURE: boolean;
  131816. ANISOTROPIC_TEXTUREDIRECTUV: number;
  131817. BRDF_V_HEIGHT_CORRELATED: boolean;
  131818. MS_BRDF_ENERGY_CONSERVATION: boolean;
  131819. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  131820. SHEEN: boolean;
  131821. SHEEN_TEXTURE: boolean;
  131822. SHEEN_TEXTUREDIRECTUV: number;
  131823. SHEEN_LINKWITHALBEDO: boolean;
  131824. SHEEN_ROUGHNESS: boolean;
  131825. SHEEN_ALBEDOSCALING: boolean;
  131826. SUBSURFACE: boolean;
  131827. SS_REFRACTION: boolean;
  131828. SS_TRANSLUCENCY: boolean;
  131829. SS_SCATERRING: boolean;
  131830. SS_THICKNESSANDMASK_TEXTURE: boolean;
  131831. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  131832. SS_REFRACTIONMAP_3D: boolean;
  131833. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  131834. SS_LODINREFRACTIONALPHA: boolean;
  131835. SS_GAMMAREFRACTION: boolean;
  131836. SS_RGBDREFRACTION: boolean;
  131837. SS_LINEARSPECULARREFRACTION: boolean;
  131838. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  131839. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  131840. UNLIT: boolean;
  131841. DEBUGMODE: number;
  131842. /**
  131843. * Initializes the PBR Material defines.
  131844. */
  131845. constructor();
  131846. /**
  131847. * Resets the PBR Material defines.
  131848. */
  131849. reset(): void;
  131850. }
  131851. /**
  131852. * The Physically based material base class of BJS.
  131853. *
  131854. * This offers the main features of a standard PBR material.
  131855. * For more information, please refer to the documentation :
  131856. * https://doc.babylonjs.com/how_to/physically_based_rendering
  131857. */
  131858. export abstract class PBRBaseMaterial extends PushMaterial {
  131859. /**
  131860. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  131861. */
  131862. static readonly PBRMATERIAL_OPAQUE: number;
  131863. /**
  131864. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  131865. */
  131866. static readonly PBRMATERIAL_ALPHATEST: number;
  131867. /**
  131868. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  131869. */
  131870. static readonly PBRMATERIAL_ALPHABLEND: number;
  131871. /**
  131872. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  131873. * They are also discarded below the alpha cutoff threshold to improve performances.
  131874. */
  131875. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  131876. /**
  131877. * Defines the default value of how much AO map is occluding the analytical lights
  131878. * (point spot...).
  131879. */
  131880. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  131881. /**
  131882. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  131883. */
  131884. static readonly LIGHTFALLOFF_PHYSICAL: number;
  131885. /**
  131886. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  131887. * to enhance interoperability with other engines.
  131888. */
  131889. static readonly LIGHTFALLOFF_GLTF: number;
  131890. /**
  131891. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  131892. * to enhance interoperability with other materials.
  131893. */
  131894. static readonly LIGHTFALLOFF_STANDARD: number;
  131895. /**
  131896. * Intensity of the direct lights e.g. the four lights available in your scene.
  131897. * This impacts both the direct diffuse and specular highlights.
  131898. */
  131899. protected _directIntensity: number;
  131900. /**
  131901. * Intensity of the emissive part of the material.
  131902. * This helps controlling the emissive effect without modifying the emissive color.
  131903. */
  131904. protected _emissiveIntensity: number;
  131905. /**
  131906. * Intensity of the environment e.g. how much the environment will light the object
  131907. * either through harmonics for rough material or through the refelction for shiny ones.
  131908. */
  131909. protected _environmentIntensity: number;
  131910. /**
  131911. * This is a special control allowing the reduction of the specular highlights coming from the
  131912. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  131913. */
  131914. protected _specularIntensity: number;
  131915. /**
  131916. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  131917. */
  131918. private _lightingInfos;
  131919. /**
  131920. * Debug Control allowing disabling the bump map on this material.
  131921. */
  131922. protected _disableBumpMap: boolean;
  131923. /**
  131924. * AKA Diffuse Texture in standard nomenclature.
  131925. */
  131926. protected _albedoTexture: Nullable<BaseTexture>;
  131927. /**
  131928. * AKA Occlusion Texture in other nomenclature.
  131929. */
  131930. protected _ambientTexture: Nullable<BaseTexture>;
  131931. /**
  131932. * AKA Occlusion Texture Intensity in other nomenclature.
  131933. */
  131934. protected _ambientTextureStrength: number;
  131935. /**
  131936. * Defines how much the AO map is occluding the analytical lights (point spot...).
  131937. * 1 means it completely occludes it
  131938. * 0 mean it has no impact
  131939. */
  131940. protected _ambientTextureImpactOnAnalyticalLights: number;
  131941. /**
  131942. * Stores the alpha values in a texture.
  131943. */
  131944. protected _opacityTexture: Nullable<BaseTexture>;
  131945. /**
  131946. * Stores the reflection values in a texture.
  131947. */
  131948. protected _reflectionTexture: Nullable<BaseTexture>;
  131949. /**
  131950. * Stores the emissive values in a texture.
  131951. */
  131952. protected _emissiveTexture: Nullable<BaseTexture>;
  131953. /**
  131954. * AKA Specular texture in other nomenclature.
  131955. */
  131956. protected _reflectivityTexture: Nullable<BaseTexture>;
  131957. /**
  131958. * Used to switch from specular/glossiness to metallic/roughness workflow.
  131959. */
  131960. protected _metallicTexture: Nullable<BaseTexture>;
  131961. /**
  131962. * Specifies the metallic scalar of the metallic/roughness workflow.
  131963. * Can also be used to scale the metalness values of the metallic texture.
  131964. */
  131965. protected _metallic: Nullable<number>;
  131966. /**
  131967. * Specifies the roughness scalar of the metallic/roughness workflow.
  131968. * Can also be used to scale the roughness values of the metallic texture.
  131969. */
  131970. protected _roughness: Nullable<number>;
  131971. /**
  131972. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  131973. * By default the indexOfrefraction is used to compute F0;
  131974. *
  131975. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  131976. *
  131977. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  131978. * F90 = metallicReflectanceColor;
  131979. */
  131980. protected _metallicF0Factor: number;
  131981. /**
  131982. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  131983. * By default the F90 is always 1;
  131984. *
  131985. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  131986. *
  131987. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  131988. * F90 = metallicReflectanceColor;
  131989. */
  131990. protected _metallicReflectanceColor: Color3;
  131991. /**
  131992. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  131993. * This is multiply against the scalar values defined in the material.
  131994. */
  131995. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  131996. /**
  131997. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  131998. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  131999. */
  132000. protected _microSurfaceTexture: Nullable<BaseTexture>;
  132001. /**
  132002. * Stores surface normal data used to displace a mesh in a texture.
  132003. */
  132004. protected _bumpTexture: Nullable<BaseTexture>;
  132005. /**
  132006. * Stores the pre-calculated light information of a mesh in a texture.
  132007. */
  132008. protected _lightmapTexture: Nullable<BaseTexture>;
  132009. /**
  132010. * The color of a material in ambient lighting.
  132011. */
  132012. protected _ambientColor: Color3;
  132013. /**
  132014. * AKA Diffuse Color in other nomenclature.
  132015. */
  132016. protected _albedoColor: Color3;
  132017. /**
  132018. * AKA Specular Color in other nomenclature.
  132019. */
  132020. protected _reflectivityColor: Color3;
  132021. /**
  132022. * The color applied when light is reflected from a material.
  132023. */
  132024. protected _reflectionColor: Color3;
  132025. /**
  132026. * The color applied when light is emitted from a material.
  132027. */
  132028. protected _emissiveColor: Color3;
  132029. /**
  132030. * AKA Glossiness in other nomenclature.
  132031. */
  132032. protected _microSurface: number;
  132033. /**
  132034. * Specifies that the material will use the light map as a show map.
  132035. */
  132036. protected _useLightmapAsShadowmap: boolean;
  132037. /**
  132038. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  132039. * makes the reflect vector face the model (under horizon).
  132040. */
  132041. protected _useHorizonOcclusion: boolean;
  132042. /**
  132043. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  132044. * too much the area relying on ambient texture to define their ambient occlusion.
  132045. */
  132046. protected _useRadianceOcclusion: boolean;
  132047. /**
  132048. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  132049. */
  132050. protected _useAlphaFromAlbedoTexture: boolean;
  132051. /**
  132052. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  132053. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  132054. */
  132055. protected _useSpecularOverAlpha: boolean;
  132056. /**
  132057. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  132058. */
  132059. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  132060. /**
  132061. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  132062. */
  132063. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  132064. /**
  132065. * Specifies if the metallic texture contains the roughness information in its green channel.
  132066. */
  132067. protected _useRoughnessFromMetallicTextureGreen: boolean;
  132068. /**
  132069. * Specifies if the metallic texture contains the metallness information in its blue channel.
  132070. */
  132071. protected _useMetallnessFromMetallicTextureBlue: boolean;
  132072. /**
  132073. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  132074. */
  132075. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  132076. /**
  132077. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  132078. */
  132079. protected _useAmbientInGrayScale: boolean;
  132080. /**
  132081. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  132082. * The material will try to infer what glossiness each pixel should be.
  132083. */
  132084. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  132085. /**
  132086. * Defines the falloff type used in this material.
  132087. * It by default is Physical.
  132088. */
  132089. protected _lightFalloff: number;
  132090. /**
  132091. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  132092. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  132093. */
  132094. protected _useRadianceOverAlpha: boolean;
  132095. /**
  132096. * Allows using an object space normal map (instead of tangent space).
  132097. */
  132098. protected _useObjectSpaceNormalMap: boolean;
  132099. /**
  132100. * Allows using the bump map in parallax mode.
  132101. */
  132102. protected _useParallax: boolean;
  132103. /**
  132104. * Allows using the bump map in parallax occlusion mode.
  132105. */
  132106. protected _useParallaxOcclusion: boolean;
  132107. /**
  132108. * Controls the scale bias of the parallax mode.
  132109. */
  132110. protected _parallaxScaleBias: number;
  132111. /**
  132112. * If sets to true, disables all the lights affecting the material.
  132113. */
  132114. protected _disableLighting: boolean;
  132115. /**
  132116. * Number of Simultaneous lights allowed on the material.
  132117. */
  132118. protected _maxSimultaneousLights: number;
  132119. /**
  132120. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  132121. */
  132122. protected _invertNormalMapX: boolean;
  132123. /**
  132124. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  132125. */
  132126. protected _invertNormalMapY: boolean;
  132127. /**
  132128. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  132129. */
  132130. protected _twoSidedLighting: boolean;
  132131. /**
  132132. * Defines the alpha limits in alpha test mode.
  132133. */
  132134. protected _alphaCutOff: number;
  132135. /**
  132136. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  132137. */
  132138. protected _forceAlphaTest: boolean;
  132139. /**
  132140. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  132141. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  132142. */
  132143. protected _useAlphaFresnel: boolean;
  132144. /**
  132145. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  132146. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  132147. */
  132148. protected _useLinearAlphaFresnel: boolean;
  132149. /**
  132150. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  132151. * from cos thetav and roughness:
  132152. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  132153. */
  132154. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  132155. /**
  132156. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  132157. */
  132158. protected _forceIrradianceInFragment: boolean;
  132159. private _realTimeFiltering;
  132160. /**
  132161. * Enables realtime filtering on the texture.
  132162. */
  132163. get realTimeFiltering(): boolean;
  132164. set realTimeFiltering(b: boolean);
  132165. private _realTimeFilteringQuality;
  132166. /**
  132167. * Quality switch for realtime filtering
  132168. */
  132169. get realTimeFilteringQuality(): number;
  132170. set realTimeFilteringQuality(n: number);
  132171. /**
  132172. * Force normal to face away from face.
  132173. */
  132174. protected _forceNormalForward: boolean;
  132175. /**
  132176. * Enables specular anti aliasing in the PBR shader.
  132177. * It will both interacts on the Geometry for analytical and IBL lighting.
  132178. * It also prefilter the roughness map based on the bump values.
  132179. */
  132180. protected _enableSpecularAntiAliasing: boolean;
  132181. /**
  132182. * Default configuration related to image processing available in the PBR Material.
  132183. */
  132184. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  132185. /**
  132186. * Keep track of the image processing observer to allow dispose and replace.
  132187. */
  132188. private _imageProcessingObserver;
  132189. /**
  132190. * Attaches a new image processing configuration to the PBR Material.
  132191. * @param configuration
  132192. */
  132193. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  132194. /**
  132195. * Stores the available render targets.
  132196. */
  132197. private _renderTargets;
  132198. /**
  132199. * Sets the global ambient color for the material used in lighting calculations.
  132200. */
  132201. private _globalAmbientColor;
  132202. /**
  132203. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  132204. */
  132205. private _useLogarithmicDepth;
  132206. /**
  132207. * If set to true, no lighting calculations will be applied.
  132208. */
  132209. private _unlit;
  132210. private _debugMode;
  132211. /**
  132212. * @hidden
  132213. * This is reserved for the inspector.
  132214. * Defines the material debug mode.
  132215. * It helps seeing only some components of the material while troubleshooting.
  132216. */
  132217. debugMode: number;
  132218. /**
  132219. * @hidden
  132220. * This is reserved for the inspector.
  132221. * Specify from where on screen the debug mode should start.
  132222. * The value goes from -1 (full screen) to 1 (not visible)
  132223. * It helps with side by side comparison against the final render
  132224. * This defaults to -1
  132225. */
  132226. private debugLimit;
  132227. /**
  132228. * @hidden
  132229. * This is reserved for the inspector.
  132230. * As the default viewing range might not be enough (if the ambient is really small for instance)
  132231. * You can use the factor to better multiply the final value.
  132232. */
  132233. private debugFactor;
  132234. /**
  132235. * Defines the clear coat layer parameters for the material.
  132236. */
  132237. readonly clearCoat: PBRClearCoatConfiguration;
  132238. /**
  132239. * Defines the anisotropic parameters for the material.
  132240. */
  132241. readonly anisotropy: PBRAnisotropicConfiguration;
  132242. /**
  132243. * Defines the BRDF parameters for the material.
  132244. */
  132245. readonly brdf: PBRBRDFConfiguration;
  132246. /**
  132247. * Defines the Sheen parameters for the material.
  132248. */
  132249. readonly sheen: PBRSheenConfiguration;
  132250. /**
  132251. * Defines the SubSurface parameters for the material.
  132252. */
  132253. readonly subSurface: PBRSubSurfaceConfiguration;
  132254. protected _rebuildInParallel: boolean;
  132255. /**
  132256. * Instantiates a new PBRMaterial instance.
  132257. *
  132258. * @param name The material name
  132259. * @param scene The scene the material will be use in.
  132260. */
  132261. constructor(name: string, scene: Scene);
  132262. /**
  132263. * Gets a boolean indicating that current material needs to register RTT
  132264. */
  132265. get hasRenderTargetTextures(): boolean;
  132266. /**
  132267. * Gets the name of the material class.
  132268. */
  132269. getClassName(): string;
  132270. /**
  132271. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  132272. */
  132273. get useLogarithmicDepth(): boolean;
  132274. /**
  132275. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  132276. */
  132277. set useLogarithmicDepth(value: boolean);
  132278. /**
  132279. * Returns true if alpha blending should be disabled.
  132280. */
  132281. protected get _disableAlphaBlending(): boolean;
  132282. /**
  132283. * Specifies whether or not this material should be rendered in alpha blend mode.
  132284. */
  132285. needAlphaBlending(): boolean;
  132286. /**
  132287. * Specifies whether or not this material should be rendered in alpha test mode.
  132288. */
  132289. needAlphaTesting(): boolean;
  132290. /**
  132291. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  132292. */
  132293. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  132294. /**
  132295. * Gets the texture used for the alpha test.
  132296. */
  132297. getAlphaTestTexture(): Nullable<BaseTexture>;
  132298. /**
  132299. * Specifies that the submesh is ready to be used.
  132300. * @param mesh - BJS mesh.
  132301. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  132302. * @param useInstances - Specifies that instances should be used.
  132303. * @returns - boolean indicating that the submesh is ready or not.
  132304. */
  132305. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  132306. /**
  132307. * Specifies if the material uses metallic roughness workflow.
  132308. * @returns boolean specifiying if the material uses metallic roughness workflow.
  132309. */
  132310. isMetallicWorkflow(): boolean;
  132311. private _prepareEffect;
  132312. private _prepareDefines;
  132313. /**
  132314. * Force shader compilation
  132315. */
  132316. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  132317. /**
  132318. * Initializes the uniform buffer layout for the shader.
  132319. */
  132320. buildUniformLayout(): void;
  132321. /**
  132322. * Unbinds the material from the mesh
  132323. */
  132324. unbind(): void;
  132325. /**
  132326. * Binds the submesh data.
  132327. * @param world - The world matrix.
  132328. * @param mesh - The BJS mesh.
  132329. * @param subMesh - A submesh of the BJS mesh.
  132330. */
  132331. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  132332. /**
  132333. * Returns the animatable textures.
  132334. * @returns - Array of animatable textures.
  132335. */
  132336. getAnimatables(): IAnimatable[];
  132337. /**
  132338. * Returns the texture used for reflections.
  132339. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  132340. */
  132341. private _getReflectionTexture;
  132342. /**
  132343. * Returns an array of the actively used textures.
  132344. * @returns - Array of BaseTextures
  132345. */
  132346. getActiveTextures(): BaseTexture[];
  132347. /**
  132348. * Checks to see if a texture is used in the material.
  132349. * @param texture - Base texture to use.
  132350. * @returns - Boolean specifying if a texture is used in the material.
  132351. */
  132352. hasTexture(texture: BaseTexture): boolean;
  132353. /**
  132354. * Disposes the resources of the material.
  132355. * @param forceDisposeEffect - Forces the disposal of effects.
  132356. * @param forceDisposeTextures - Forces the disposal of all textures.
  132357. */
  132358. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  132359. }
  132360. }
  132361. declare module BABYLON {
  132362. /**
  132363. * The Physically based material of BJS.
  132364. *
  132365. * This offers the main features of a standard PBR material.
  132366. * For more information, please refer to the documentation :
  132367. * https://doc.babylonjs.com/how_to/physically_based_rendering
  132368. */
  132369. export class PBRMaterial extends PBRBaseMaterial {
  132370. /**
  132371. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  132372. */
  132373. static readonly PBRMATERIAL_OPAQUE: number;
  132374. /**
  132375. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  132376. */
  132377. static readonly PBRMATERIAL_ALPHATEST: number;
  132378. /**
  132379. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  132380. */
  132381. static readonly PBRMATERIAL_ALPHABLEND: number;
  132382. /**
  132383. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  132384. * They are also discarded below the alpha cutoff threshold to improve performances.
  132385. */
  132386. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  132387. /**
  132388. * Defines the default value of how much AO map is occluding the analytical lights
  132389. * (point spot...).
  132390. */
  132391. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  132392. /**
  132393. * Intensity of the direct lights e.g. the four lights available in your scene.
  132394. * This impacts both the direct diffuse and specular highlights.
  132395. */
  132396. directIntensity: number;
  132397. /**
  132398. * Intensity of the emissive part of the material.
  132399. * This helps controlling the emissive effect without modifying the emissive color.
  132400. */
  132401. emissiveIntensity: number;
  132402. /**
  132403. * Intensity of the environment e.g. how much the environment will light the object
  132404. * either through harmonics for rough material or through the refelction for shiny ones.
  132405. */
  132406. environmentIntensity: number;
  132407. /**
  132408. * This is a special control allowing the reduction of the specular highlights coming from the
  132409. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  132410. */
  132411. specularIntensity: number;
  132412. /**
  132413. * Debug Control allowing disabling the bump map on this material.
  132414. */
  132415. disableBumpMap: boolean;
  132416. /**
  132417. * AKA Diffuse Texture in standard nomenclature.
  132418. */
  132419. albedoTexture: BaseTexture;
  132420. /**
  132421. * AKA Occlusion Texture in other nomenclature.
  132422. */
  132423. ambientTexture: BaseTexture;
  132424. /**
  132425. * AKA Occlusion Texture Intensity in other nomenclature.
  132426. */
  132427. ambientTextureStrength: number;
  132428. /**
  132429. * Defines how much the AO map is occluding the analytical lights (point spot...).
  132430. * 1 means it completely occludes it
  132431. * 0 mean it has no impact
  132432. */
  132433. ambientTextureImpactOnAnalyticalLights: number;
  132434. /**
  132435. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  132436. */
  132437. opacityTexture: BaseTexture;
  132438. /**
  132439. * Stores the reflection values in a texture.
  132440. */
  132441. reflectionTexture: Nullable<BaseTexture>;
  132442. /**
  132443. * Stores the emissive values in a texture.
  132444. */
  132445. emissiveTexture: BaseTexture;
  132446. /**
  132447. * AKA Specular texture in other nomenclature.
  132448. */
  132449. reflectivityTexture: BaseTexture;
  132450. /**
  132451. * Used to switch from specular/glossiness to metallic/roughness workflow.
  132452. */
  132453. metallicTexture: BaseTexture;
  132454. /**
  132455. * Specifies the metallic scalar of the metallic/roughness workflow.
  132456. * Can also be used to scale the metalness values of the metallic texture.
  132457. */
  132458. metallic: Nullable<number>;
  132459. /**
  132460. * Specifies the roughness scalar of the metallic/roughness workflow.
  132461. * Can also be used to scale the roughness values of the metallic texture.
  132462. */
  132463. roughness: Nullable<number>;
  132464. /**
  132465. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  132466. * By default the indexOfrefraction is used to compute F0;
  132467. *
  132468. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  132469. *
  132470. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  132471. * F90 = metallicReflectanceColor;
  132472. */
  132473. metallicF0Factor: number;
  132474. /**
  132475. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  132476. * By default the F90 is always 1;
  132477. *
  132478. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  132479. *
  132480. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  132481. * F90 = metallicReflectanceColor;
  132482. */
  132483. metallicReflectanceColor: Color3;
  132484. /**
  132485. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  132486. * This is multiply against the scalar values defined in the material.
  132487. */
  132488. metallicReflectanceTexture: Nullable<BaseTexture>;
  132489. /**
  132490. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  132491. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  132492. */
  132493. microSurfaceTexture: BaseTexture;
  132494. /**
  132495. * Stores surface normal data used to displace a mesh in a texture.
  132496. */
  132497. bumpTexture: BaseTexture;
  132498. /**
  132499. * Stores the pre-calculated light information of a mesh in a texture.
  132500. */
  132501. lightmapTexture: BaseTexture;
  132502. /**
  132503. * Stores the refracted light information in a texture.
  132504. */
  132505. get refractionTexture(): Nullable<BaseTexture>;
  132506. set refractionTexture(value: Nullable<BaseTexture>);
  132507. /**
  132508. * The color of a material in ambient lighting.
  132509. */
  132510. ambientColor: Color3;
  132511. /**
  132512. * AKA Diffuse Color in other nomenclature.
  132513. */
  132514. albedoColor: Color3;
  132515. /**
  132516. * AKA Specular Color in other nomenclature.
  132517. */
  132518. reflectivityColor: Color3;
  132519. /**
  132520. * The color reflected from the material.
  132521. */
  132522. reflectionColor: Color3;
  132523. /**
  132524. * The color emitted from the material.
  132525. */
  132526. emissiveColor: Color3;
  132527. /**
  132528. * AKA Glossiness in other nomenclature.
  132529. */
  132530. microSurface: number;
  132531. /**
  132532. * Index of refraction of the material base layer.
  132533. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  132534. *
  132535. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  132536. *
  132537. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  132538. */
  132539. get indexOfRefraction(): number;
  132540. set indexOfRefraction(value: number);
  132541. /**
  132542. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  132543. */
  132544. get invertRefractionY(): boolean;
  132545. set invertRefractionY(value: boolean);
  132546. /**
  132547. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  132548. * Materials half opaque for instance using refraction could benefit from this control.
  132549. */
  132550. get linkRefractionWithTransparency(): boolean;
  132551. set linkRefractionWithTransparency(value: boolean);
  132552. /**
  132553. * If true, the light map contains occlusion information instead of lighting info.
  132554. */
  132555. useLightmapAsShadowmap: boolean;
  132556. /**
  132557. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  132558. */
  132559. useAlphaFromAlbedoTexture: boolean;
  132560. /**
  132561. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  132562. */
  132563. forceAlphaTest: boolean;
  132564. /**
  132565. * Defines the alpha limits in alpha test mode.
  132566. */
  132567. alphaCutOff: number;
  132568. /**
  132569. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  132570. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  132571. */
  132572. useSpecularOverAlpha: boolean;
  132573. /**
  132574. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  132575. */
  132576. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  132577. /**
  132578. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  132579. */
  132580. useRoughnessFromMetallicTextureAlpha: boolean;
  132581. /**
  132582. * Specifies if the metallic texture contains the roughness information in its green channel.
  132583. */
  132584. useRoughnessFromMetallicTextureGreen: boolean;
  132585. /**
  132586. * Specifies if the metallic texture contains the metallness information in its blue channel.
  132587. */
  132588. useMetallnessFromMetallicTextureBlue: boolean;
  132589. /**
  132590. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  132591. */
  132592. useAmbientOcclusionFromMetallicTextureRed: boolean;
  132593. /**
  132594. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  132595. */
  132596. useAmbientInGrayScale: boolean;
  132597. /**
  132598. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  132599. * The material will try to infer what glossiness each pixel should be.
  132600. */
  132601. useAutoMicroSurfaceFromReflectivityMap: boolean;
  132602. /**
  132603. * BJS is using an harcoded light falloff based on a manually sets up range.
  132604. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  132605. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  132606. */
  132607. get usePhysicalLightFalloff(): boolean;
  132608. /**
  132609. * BJS is using an harcoded light falloff based on a manually sets up range.
  132610. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  132611. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  132612. */
  132613. set usePhysicalLightFalloff(value: boolean);
  132614. /**
  132615. * In order to support the falloff compatibility with gltf, a special mode has been added
  132616. * to reproduce the gltf light falloff.
  132617. */
  132618. get useGLTFLightFalloff(): boolean;
  132619. /**
  132620. * In order to support the falloff compatibility with gltf, a special mode has been added
  132621. * to reproduce the gltf light falloff.
  132622. */
  132623. set useGLTFLightFalloff(value: boolean);
  132624. /**
  132625. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  132626. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  132627. */
  132628. useRadianceOverAlpha: boolean;
  132629. /**
  132630. * Allows using an object space normal map (instead of tangent space).
  132631. */
  132632. useObjectSpaceNormalMap: boolean;
  132633. /**
  132634. * Allows using the bump map in parallax mode.
  132635. */
  132636. useParallax: boolean;
  132637. /**
  132638. * Allows using the bump map in parallax occlusion mode.
  132639. */
  132640. useParallaxOcclusion: boolean;
  132641. /**
  132642. * Controls the scale bias of the parallax mode.
  132643. */
  132644. parallaxScaleBias: number;
  132645. /**
  132646. * If sets to true, disables all the lights affecting the material.
  132647. */
  132648. disableLighting: boolean;
  132649. /**
  132650. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  132651. */
  132652. forceIrradianceInFragment: boolean;
  132653. /**
  132654. * Number of Simultaneous lights allowed on the material.
  132655. */
  132656. maxSimultaneousLights: number;
  132657. /**
  132658. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  132659. */
  132660. invertNormalMapX: boolean;
  132661. /**
  132662. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  132663. */
  132664. invertNormalMapY: boolean;
  132665. /**
  132666. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  132667. */
  132668. twoSidedLighting: boolean;
  132669. /**
  132670. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  132671. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  132672. */
  132673. useAlphaFresnel: boolean;
  132674. /**
  132675. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  132676. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  132677. */
  132678. useLinearAlphaFresnel: boolean;
  132679. /**
  132680. * Let user defines the brdf lookup texture used for IBL.
  132681. * A default 8bit version is embedded but you could point at :
  132682. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  132683. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  132684. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  132685. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  132686. */
  132687. environmentBRDFTexture: Nullable<BaseTexture>;
  132688. /**
  132689. * Force normal to face away from face.
  132690. */
  132691. forceNormalForward: boolean;
  132692. /**
  132693. * Enables specular anti aliasing in the PBR shader.
  132694. * It will both interacts on the Geometry for analytical and IBL lighting.
  132695. * It also prefilter the roughness map based on the bump values.
  132696. */
  132697. enableSpecularAntiAliasing: boolean;
  132698. /**
  132699. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  132700. * makes the reflect vector face the model (under horizon).
  132701. */
  132702. useHorizonOcclusion: boolean;
  132703. /**
  132704. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  132705. * too much the area relying on ambient texture to define their ambient occlusion.
  132706. */
  132707. useRadianceOcclusion: boolean;
  132708. /**
  132709. * If set to true, no lighting calculations will be applied.
  132710. */
  132711. unlit: boolean;
  132712. /**
  132713. * Gets the image processing configuration used either in this material.
  132714. */
  132715. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  132716. /**
  132717. * Sets the Default image processing configuration used either in the this material.
  132718. *
  132719. * If sets to null, the scene one is in use.
  132720. */
  132721. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  132722. /**
  132723. * Gets wether the color curves effect is enabled.
  132724. */
  132725. get cameraColorCurvesEnabled(): boolean;
  132726. /**
  132727. * Sets wether the color curves effect is enabled.
  132728. */
  132729. set cameraColorCurvesEnabled(value: boolean);
  132730. /**
  132731. * Gets wether the color grading effect is enabled.
  132732. */
  132733. get cameraColorGradingEnabled(): boolean;
  132734. /**
  132735. * Gets wether the color grading effect is enabled.
  132736. */
  132737. set cameraColorGradingEnabled(value: boolean);
  132738. /**
  132739. * Gets wether tonemapping is enabled or not.
  132740. */
  132741. get cameraToneMappingEnabled(): boolean;
  132742. /**
  132743. * Sets wether tonemapping is enabled or not
  132744. */
  132745. set cameraToneMappingEnabled(value: boolean);
  132746. /**
  132747. * The camera exposure used on this material.
  132748. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  132749. * This corresponds to a photographic exposure.
  132750. */
  132751. get cameraExposure(): number;
  132752. /**
  132753. * The camera exposure used on this material.
  132754. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  132755. * This corresponds to a photographic exposure.
  132756. */
  132757. set cameraExposure(value: number);
  132758. /**
  132759. * Gets The camera contrast used on this material.
  132760. */
  132761. get cameraContrast(): number;
  132762. /**
  132763. * Sets The camera contrast used on this material.
  132764. */
  132765. set cameraContrast(value: number);
  132766. /**
  132767. * Gets the Color Grading 2D Lookup Texture.
  132768. */
  132769. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  132770. /**
  132771. * Sets the Color Grading 2D Lookup Texture.
  132772. */
  132773. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  132774. /**
  132775. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  132776. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  132777. * 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;
  132778. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  132779. */
  132780. get cameraColorCurves(): Nullable<ColorCurves>;
  132781. /**
  132782. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  132783. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  132784. * 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;
  132785. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  132786. */
  132787. set cameraColorCurves(value: Nullable<ColorCurves>);
  132788. /**
  132789. * Instantiates a new PBRMaterial instance.
  132790. *
  132791. * @param name The material name
  132792. * @param scene The scene the material will be use in.
  132793. */
  132794. constructor(name: string, scene: Scene);
  132795. /**
  132796. * Returns the name of this material class.
  132797. */
  132798. getClassName(): string;
  132799. /**
  132800. * Makes a duplicate of the current material.
  132801. * @param name - name to use for the new material.
  132802. */
  132803. clone(name: string): PBRMaterial;
  132804. /**
  132805. * Serializes this PBR Material.
  132806. * @returns - An object with the serialized material.
  132807. */
  132808. serialize(): any;
  132809. /**
  132810. * Parses a PBR Material from a serialized object.
  132811. * @param source - Serialized object.
  132812. * @param scene - BJS scene instance.
  132813. * @param rootUrl - url for the scene object
  132814. * @returns - PBRMaterial
  132815. */
  132816. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  132817. }
  132818. }
  132819. declare module BABYLON {
  132820. /**
  132821. * Direct draw surface info
  132822. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  132823. */
  132824. export interface DDSInfo {
  132825. /**
  132826. * Width of the texture
  132827. */
  132828. width: number;
  132829. /**
  132830. * Width of the texture
  132831. */
  132832. height: number;
  132833. /**
  132834. * Number of Mipmaps for the texture
  132835. * @see https://en.wikipedia.org/wiki/Mipmap
  132836. */
  132837. mipmapCount: number;
  132838. /**
  132839. * If the textures format is a known fourCC format
  132840. * @see https://www.fourcc.org/
  132841. */
  132842. isFourCC: boolean;
  132843. /**
  132844. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  132845. */
  132846. isRGB: boolean;
  132847. /**
  132848. * If the texture is a lumincance format
  132849. */
  132850. isLuminance: boolean;
  132851. /**
  132852. * If this is a cube texture
  132853. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  132854. */
  132855. isCube: boolean;
  132856. /**
  132857. * If the texture is a compressed format eg. FOURCC_DXT1
  132858. */
  132859. isCompressed: boolean;
  132860. /**
  132861. * The dxgiFormat of the texture
  132862. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  132863. */
  132864. dxgiFormat: number;
  132865. /**
  132866. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  132867. */
  132868. textureType: number;
  132869. /**
  132870. * Sphericle polynomial created for the dds texture
  132871. */
  132872. sphericalPolynomial?: SphericalPolynomial;
  132873. }
  132874. /**
  132875. * Class used to provide DDS decompression tools
  132876. */
  132877. export class DDSTools {
  132878. /**
  132879. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  132880. */
  132881. static StoreLODInAlphaChannel: boolean;
  132882. /**
  132883. * Gets DDS information from an array buffer
  132884. * @param data defines the array buffer view to read data from
  132885. * @returns the DDS information
  132886. */
  132887. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  132888. private static _FloatView;
  132889. private static _Int32View;
  132890. private static _ToHalfFloat;
  132891. private static _FromHalfFloat;
  132892. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  132893. private static _GetHalfFloatRGBAArrayBuffer;
  132894. private static _GetFloatRGBAArrayBuffer;
  132895. private static _GetFloatAsUIntRGBAArrayBuffer;
  132896. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  132897. private static _GetRGBAArrayBuffer;
  132898. private static _ExtractLongWordOrder;
  132899. private static _GetRGBArrayBuffer;
  132900. private static _GetLuminanceArrayBuffer;
  132901. /**
  132902. * Uploads DDS Levels to a Babylon Texture
  132903. * @hidden
  132904. */
  132905. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  132906. }
  132907. interface ThinEngine {
  132908. /**
  132909. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  132910. * @param rootUrl defines the url where the file to load is located
  132911. * @param scene defines the current scene
  132912. * @param lodScale defines scale to apply to the mip map selection
  132913. * @param lodOffset defines offset to apply to the mip map selection
  132914. * @param onLoad defines an optional callback raised when the texture is loaded
  132915. * @param onError defines an optional callback raised if there is an issue to load the texture
  132916. * @param format defines the format of the data
  132917. * @param forcedExtension defines the extension to use to pick the right loader
  132918. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  132919. * @returns the cube texture as an InternalTexture
  132920. */
  132921. 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;
  132922. }
  132923. }
  132924. declare module BABYLON {
  132925. /**
  132926. * Implementation of the DDS Texture Loader.
  132927. * @hidden
  132928. */
  132929. export class _DDSTextureLoader implements IInternalTextureLoader {
  132930. /**
  132931. * Defines wether the loader supports cascade loading the different faces.
  132932. */
  132933. readonly supportCascades: boolean;
  132934. /**
  132935. * This returns if the loader support the current file information.
  132936. * @param extension defines the file extension of the file being loaded
  132937. * @returns true if the loader can load the specified file
  132938. */
  132939. canLoad(extension: string): boolean;
  132940. /**
  132941. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  132942. * @param data contains the texture data
  132943. * @param texture defines the BabylonJS internal texture
  132944. * @param createPolynomials will be true if polynomials have been requested
  132945. * @param onLoad defines the callback to trigger once the texture is ready
  132946. * @param onError defines the callback to trigger in case of error
  132947. */
  132948. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  132949. /**
  132950. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  132951. * @param data contains the texture data
  132952. * @param texture defines the BabylonJS internal texture
  132953. * @param callback defines the method to call once ready to upload
  132954. */
  132955. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  132956. }
  132957. }
  132958. declare module BABYLON {
  132959. /**
  132960. * Implementation of the ENV Texture Loader.
  132961. * @hidden
  132962. */
  132963. export class _ENVTextureLoader implements IInternalTextureLoader {
  132964. /**
  132965. * Defines wether the loader supports cascade loading the different faces.
  132966. */
  132967. readonly supportCascades: boolean;
  132968. /**
  132969. * This returns if the loader support the current file information.
  132970. * @param extension defines the file extension of the file being loaded
  132971. * @returns true if the loader can load the specified file
  132972. */
  132973. canLoad(extension: string): boolean;
  132974. /**
  132975. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  132976. * @param data contains the texture data
  132977. * @param texture defines the BabylonJS internal texture
  132978. * @param createPolynomials will be true if polynomials have been requested
  132979. * @param onLoad defines the callback to trigger once the texture is ready
  132980. * @param onError defines the callback to trigger in case of error
  132981. */
  132982. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  132983. /**
  132984. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  132985. * @param data contains the texture data
  132986. * @param texture defines the BabylonJS internal texture
  132987. * @param callback defines the method to call once ready to upload
  132988. */
  132989. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  132990. }
  132991. }
  132992. declare module BABYLON {
  132993. /**
  132994. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  132995. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  132996. */
  132997. export class KhronosTextureContainer {
  132998. /** contents of the KTX container file */
  132999. data: ArrayBufferView;
  133000. private static HEADER_LEN;
  133001. private static COMPRESSED_2D;
  133002. private static COMPRESSED_3D;
  133003. private static TEX_2D;
  133004. private static TEX_3D;
  133005. /**
  133006. * Gets the openGL type
  133007. */
  133008. glType: number;
  133009. /**
  133010. * Gets the openGL type size
  133011. */
  133012. glTypeSize: number;
  133013. /**
  133014. * Gets the openGL format
  133015. */
  133016. glFormat: number;
  133017. /**
  133018. * Gets the openGL internal format
  133019. */
  133020. glInternalFormat: number;
  133021. /**
  133022. * Gets the base internal format
  133023. */
  133024. glBaseInternalFormat: number;
  133025. /**
  133026. * Gets image width in pixel
  133027. */
  133028. pixelWidth: number;
  133029. /**
  133030. * Gets image height in pixel
  133031. */
  133032. pixelHeight: number;
  133033. /**
  133034. * Gets image depth in pixels
  133035. */
  133036. pixelDepth: number;
  133037. /**
  133038. * Gets the number of array elements
  133039. */
  133040. numberOfArrayElements: number;
  133041. /**
  133042. * Gets the number of faces
  133043. */
  133044. numberOfFaces: number;
  133045. /**
  133046. * Gets the number of mipmap levels
  133047. */
  133048. numberOfMipmapLevels: number;
  133049. /**
  133050. * Gets the bytes of key value data
  133051. */
  133052. bytesOfKeyValueData: number;
  133053. /**
  133054. * Gets the load type
  133055. */
  133056. loadType: number;
  133057. /**
  133058. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  133059. */
  133060. isInvalid: boolean;
  133061. /**
  133062. * Creates a new KhronosTextureContainer
  133063. * @param data contents of the KTX container file
  133064. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  133065. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  133066. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  133067. */
  133068. constructor(
  133069. /** contents of the KTX container file */
  133070. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  133071. /**
  133072. * Uploads KTX content to a Babylon Texture.
  133073. * It is assumed that the texture has already been created & is currently bound
  133074. * @hidden
  133075. */
  133076. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  133077. private _upload2DCompressedLevels;
  133078. /**
  133079. * Checks if the given data starts with a KTX file identifier.
  133080. * @param data the data to check
  133081. * @returns true if the data is a KTX file or false otherwise
  133082. */
  133083. static IsValid(data: ArrayBufferView): boolean;
  133084. }
  133085. }
  133086. declare module BABYLON {
  133087. /**
  133088. * Class for loading KTX2 files
  133089. * !!! Experimental Extension Subject to Changes !!!
  133090. * @hidden
  133091. */
  133092. export class KhronosTextureContainer2 {
  133093. private static _ModulePromise;
  133094. private static _TranscodeFormat;
  133095. constructor(engine: ThinEngine);
  133096. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  133097. private _determineTranscodeFormat;
  133098. /**
  133099. * Checks if the given data starts with a KTX2 file identifier.
  133100. * @param data the data to check
  133101. * @returns true if the data is a KTX2 file or false otherwise
  133102. */
  133103. static IsValid(data: ArrayBufferView): boolean;
  133104. }
  133105. }
  133106. declare module BABYLON {
  133107. /**
  133108. * Implementation of the KTX Texture Loader.
  133109. * @hidden
  133110. */
  133111. export class _KTXTextureLoader implements IInternalTextureLoader {
  133112. /**
  133113. * Defines wether the loader supports cascade loading the different faces.
  133114. */
  133115. readonly supportCascades: boolean;
  133116. /**
  133117. * This returns if the loader support the current file information.
  133118. * @param extension defines the file extension of the file being loaded
  133119. * @returns true if the loader can load the specified file
  133120. */
  133121. canLoad(extension: string): boolean;
  133122. /**
  133123. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  133124. * @param data contains the texture data
  133125. * @param texture defines the BabylonJS internal texture
  133126. * @param createPolynomials will be true if polynomials have been requested
  133127. * @param onLoad defines the callback to trigger once the texture is ready
  133128. * @param onError defines the callback to trigger in case of error
  133129. */
  133130. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  133131. /**
  133132. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  133133. * @param data contains the texture data
  133134. * @param texture defines the BabylonJS internal texture
  133135. * @param callback defines the method to call once ready to upload
  133136. */
  133137. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  133138. }
  133139. }
  133140. declare module BABYLON {
  133141. /** @hidden */
  133142. export var _forceSceneHelpersToBundle: boolean;
  133143. interface Scene {
  133144. /**
  133145. * Creates a default light for the scene.
  133146. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  133147. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  133148. */
  133149. createDefaultLight(replace?: boolean): void;
  133150. /**
  133151. * Creates a default camera for the scene.
  133152. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  133153. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  133154. * @param replace has default false, when true replaces the active camera in the scene
  133155. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  133156. */
  133157. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  133158. /**
  133159. * Creates a default camera and a default light.
  133160. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  133161. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  133162. * @param replace has the default false, when true replaces the active camera/light in the scene
  133163. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  133164. */
  133165. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  133166. /**
  133167. * Creates a new sky box
  133168. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  133169. * @param environmentTexture defines the texture to use as environment texture
  133170. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  133171. * @param scale defines the overall scale of the skybox
  133172. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  133173. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  133174. * @returns a new mesh holding the sky box
  133175. */
  133176. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  133177. /**
  133178. * Creates a new environment
  133179. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  133180. * @param options defines the options you can use to configure the environment
  133181. * @returns the new EnvironmentHelper
  133182. */
  133183. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  133184. /**
  133185. * Creates a new VREXperienceHelper
  133186. * @see http://doc.babylonjs.com/how_to/webvr_helper
  133187. * @param webVROptions defines the options used to create the new VREXperienceHelper
  133188. * @returns a new VREXperienceHelper
  133189. */
  133190. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  133191. /**
  133192. * Creates a new WebXRDefaultExperience
  133193. * @see http://doc.babylonjs.com/how_to/webxr
  133194. * @param options experience options
  133195. * @returns a promise for a new WebXRDefaultExperience
  133196. */
  133197. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  133198. }
  133199. }
  133200. declare module BABYLON {
  133201. /**
  133202. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  133203. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  133204. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  133205. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  133206. */
  133207. export class VideoDome extends TransformNode {
  133208. /**
  133209. * Define the video source as a Monoscopic panoramic 360 video.
  133210. */
  133211. static readonly MODE_MONOSCOPIC: number;
  133212. /**
  133213. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  133214. */
  133215. static readonly MODE_TOPBOTTOM: number;
  133216. /**
  133217. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  133218. */
  133219. static readonly MODE_SIDEBYSIDE: number;
  133220. private _halfDome;
  133221. private _useDirectMapping;
  133222. /**
  133223. * The video texture being displayed on the sphere
  133224. */
  133225. protected _videoTexture: VideoTexture;
  133226. /**
  133227. * Gets the video texture being displayed on the sphere
  133228. */
  133229. get videoTexture(): VideoTexture;
  133230. /**
  133231. * The skybox material
  133232. */
  133233. protected _material: BackgroundMaterial;
  133234. /**
  133235. * The surface used for the skybox
  133236. */
  133237. protected _mesh: Mesh;
  133238. /**
  133239. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  133240. */
  133241. private _halfDomeMask;
  133242. /**
  133243. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  133244. * Also see the options.resolution property.
  133245. */
  133246. get fovMultiplier(): number;
  133247. set fovMultiplier(value: number);
  133248. private _videoMode;
  133249. /**
  133250. * Gets or set the current video mode for the video. It can be:
  133251. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  133252. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  133253. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  133254. */
  133255. get videoMode(): number;
  133256. set videoMode(value: number);
  133257. /**
  133258. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  133259. *
  133260. */
  133261. get halfDome(): boolean;
  133262. /**
  133263. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  133264. */
  133265. set halfDome(enabled: boolean);
  133266. /**
  133267. * Oberserver used in Stereoscopic VR Mode.
  133268. */
  133269. private _onBeforeCameraRenderObserver;
  133270. /**
  133271. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  133272. * @param name Element's name, child elements will append suffixes for their own names.
  133273. * @param urlsOrVideo defines the url(s) or the video element to use
  133274. * @param options An object containing optional or exposed sub element properties
  133275. */
  133276. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  133277. resolution?: number;
  133278. clickToPlay?: boolean;
  133279. autoPlay?: boolean;
  133280. loop?: boolean;
  133281. size?: number;
  133282. poster?: string;
  133283. faceForward?: boolean;
  133284. useDirectMapping?: boolean;
  133285. halfDomeMode?: boolean;
  133286. }, scene: Scene);
  133287. private _changeVideoMode;
  133288. /**
  133289. * Releases resources associated with this node.
  133290. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  133291. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  133292. */
  133293. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  133294. }
  133295. }
  133296. declare module BABYLON {
  133297. /**
  133298. * This class can be used to get instrumentation data from a Babylon engine
  133299. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  133300. */
  133301. export class EngineInstrumentation implements IDisposable {
  133302. /**
  133303. * Define the instrumented engine.
  133304. */
  133305. engine: Engine;
  133306. private _captureGPUFrameTime;
  133307. private _gpuFrameTimeToken;
  133308. private _gpuFrameTime;
  133309. private _captureShaderCompilationTime;
  133310. private _shaderCompilationTime;
  133311. private _onBeginFrameObserver;
  133312. private _onEndFrameObserver;
  133313. private _onBeforeShaderCompilationObserver;
  133314. private _onAfterShaderCompilationObserver;
  133315. /**
  133316. * Gets the perf counter used for GPU frame time
  133317. */
  133318. get gpuFrameTimeCounter(): PerfCounter;
  133319. /**
  133320. * Gets the GPU frame time capture status
  133321. */
  133322. get captureGPUFrameTime(): boolean;
  133323. /**
  133324. * Enable or disable the GPU frame time capture
  133325. */
  133326. set captureGPUFrameTime(value: boolean);
  133327. /**
  133328. * Gets the perf counter used for shader compilation time
  133329. */
  133330. get shaderCompilationTimeCounter(): PerfCounter;
  133331. /**
  133332. * Gets the shader compilation time capture status
  133333. */
  133334. get captureShaderCompilationTime(): boolean;
  133335. /**
  133336. * Enable or disable the shader compilation time capture
  133337. */
  133338. set captureShaderCompilationTime(value: boolean);
  133339. /**
  133340. * Instantiates a new engine instrumentation.
  133341. * This class can be used to get instrumentation data from a Babylon engine
  133342. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  133343. * @param engine Defines the engine to instrument
  133344. */
  133345. constructor(
  133346. /**
  133347. * Define the instrumented engine.
  133348. */
  133349. engine: Engine);
  133350. /**
  133351. * Dispose and release associated resources.
  133352. */
  133353. dispose(): void;
  133354. }
  133355. }
  133356. declare module BABYLON {
  133357. /**
  133358. * This class can be used to get instrumentation data from a Babylon engine
  133359. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  133360. */
  133361. export class SceneInstrumentation implements IDisposable {
  133362. /**
  133363. * Defines the scene to instrument
  133364. */
  133365. scene: Scene;
  133366. private _captureActiveMeshesEvaluationTime;
  133367. private _activeMeshesEvaluationTime;
  133368. private _captureRenderTargetsRenderTime;
  133369. private _renderTargetsRenderTime;
  133370. private _captureFrameTime;
  133371. private _frameTime;
  133372. private _captureRenderTime;
  133373. private _renderTime;
  133374. private _captureInterFrameTime;
  133375. private _interFrameTime;
  133376. private _captureParticlesRenderTime;
  133377. private _particlesRenderTime;
  133378. private _captureSpritesRenderTime;
  133379. private _spritesRenderTime;
  133380. private _capturePhysicsTime;
  133381. private _physicsTime;
  133382. private _captureAnimationsTime;
  133383. private _animationsTime;
  133384. private _captureCameraRenderTime;
  133385. private _cameraRenderTime;
  133386. private _onBeforeActiveMeshesEvaluationObserver;
  133387. private _onAfterActiveMeshesEvaluationObserver;
  133388. private _onBeforeRenderTargetsRenderObserver;
  133389. private _onAfterRenderTargetsRenderObserver;
  133390. private _onAfterRenderObserver;
  133391. private _onBeforeDrawPhaseObserver;
  133392. private _onAfterDrawPhaseObserver;
  133393. private _onBeforeAnimationsObserver;
  133394. private _onBeforeParticlesRenderingObserver;
  133395. private _onAfterParticlesRenderingObserver;
  133396. private _onBeforeSpritesRenderingObserver;
  133397. private _onAfterSpritesRenderingObserver;
  133398. private _onBeforePhysicsObserver;
  133399. private _onAfterPhysicsObserver;
  133400. private _onAfterAnimationsObserver;
  133401. private _onBeforeCameraRenderObserver;
  133402. private _onAfterCameraRenderObserver;
  133403. /**
  133404. * Gets the perf counter used for active meshes evaluation time
  133405. */
  133406. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  133407. /**
  133408. * Gets the active meshes evaluation time capture status
  133409. */
  133410. get captureActiveMeshesEvaluationTime(): boolean;
  133411. /**
  133412. * Enable or disable the active meshes evaluation time capture
  133413. */
  133414. set captureActiveMeshesEvaluationTime(value: boolean);
  133415. /**
  133416. * Gets the perf counter used for render targets render time
  133417. */
  133418. get renderTargetsRenderTimeCounter(): PerfCounter;
  133419. /**
  133420. * Gets the render targets render time capture status
  133421. */
  133422. get captureRenderTargetsRenderTime(): boolean;
  133423. /**
  133424. * Enable or disable the render targets render time capture
  133425. */
  133426. set captureRenderTargetsRenderTime(value: boolean);
  133427. /**
  133428. * Gets the perf counter used for particles render time
  133429. */
  133430. get particlesRenderTimeCounter(): PerfCounter;
  133431. /**
  133432. * Gets the particles render time capture status
  133433. */
  133434. get captureParticlesRenderTime(): boolean;
  133435. /**
  133436. * Enable or disable the particles render time capture
  133437. */
  133438. set captureParticlesRenderTime(value: boolean);
  133439. /**
  133440. * Gets the perf counter used for sprites render time
  133441. */
  133442. get spritesRenderTimeCounter(): PerfCounter;
  133443. /**
  133444. * Gets the sprites render time capture status
  133445. */
  133446. get captureSpritesRenderTime(): boolean;
  133447. /**
  133448. * Enable or disable the sprites render time capture
  133449. */
  133450. set captureSpritesRenderTime(value: boolean);
  133451. /**
  133452. * Gets the perf counter used for physics time
  133453. */
  133454. get physicsTimeCounter(): PerfCounter;
  133455. /**
  133456. * Gets the physics time capture status
  133457. */
  133458. get capturePhysicsTime(): boolean;
  133459. /**
  133460. * Enable or disable the physics time capture
  133461. */
  133462. set capturePhysicsTime(value: boolean);
  133463. /**
  133464. * Gets the perf counter used for animations time
  133465. */
  133466. get animationsTimeCounter(): PerfCounter;
  133467. /**
  133468. * Gets the animations time capture status
  133469. */
  133470. get captureAnimationsTime(): boolean;
  133471. /**
  133472. * Enable or disable the animations time capture
  133473. */
  133474. set captureAnimationsTime(value: boolean);
  133475. /**
  133476. * Gets the perf counter used for frame time capture
  133477. */
  133478. get frameTimeCounter(): PerfCounter;
  133479. /**
  133480. * Gets the frame time capture status
  133481. */
  133482. get captureFrameTime(): boolean;
  133483. /**
  133484. * Enable or disable the frame time capture
  133485. */
  133486. set captureFrameTime(value: boolean);
  133487. /**
  133488. * Gets the perf counter used for inter-frames time capture
  133489. */
  133490. get interFrameTimeCounter(): PerfCounter;
  133491. /**
  133492. * Gets the inter-frames time capture status
  133493. */
  133494. get captureInterFrameTime(): boolean;
  133495. /**
  133496. * Enable or disable the inter-frames time capture
  133497. */
  133498. set captureInterFrameTime(value: boolean);
  133499. /**
  133500. * Gets the perf counter used for render time capture
  133501. */
  133502. get renderTimeCounter(): PerfCounter;
  133503. /**
  133504. * Gets the render time capture status
  133505. */
  133506. get captureRenderTime(): boolean;
  133507. /**
  133508. * Enable or disable the render time capture
  133509. */
  133510. set captureRenderTime(value: boolean);
  133511. /**
  133512. * Gets the perf counter used for camera render time capture
  133513. */
  133514. get cameraRenderTimeCounter(): PerfCounter;
  133515. /**
  133516. * Gets the camera render time capture status
  133517. */
  133518. get captureCameraRenderTime(): boolean;
  133519. /**
  133520. * Enable or disable the camera render time capture
  133521. */
  133522. set captureCameraRenderTime(value: boolean);
  133523. /**
  133524. * Gets the perf counter used for draw calls
  133525. */
  133526. get drawCallsCounter(): PerfCounter;
  133527. /**
  133528. * Instantiates a new scene instrumentation.
  133529. * This class can be used to get instrumentation data from a Babylon engine
  133530. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  133531. * @param scene Defines the scene to instrument
  133532. */
  133533. constructor(
  133534. /**
  133535. * Defines the scene to instrument
  133536. */
  133537. scene: Scene);
  133538. /**
  133539. * Dispose and release associated resources.
  133540. */
  133541. dispose(): void;
  133542. }
  133543. }
  133544. declare module BABYLON {
  133545. /** @hidden */
  133546. export var glowMapGenerationPixelShader: {
  133547. name: string;
  133548. shader: string;
  133549. };
  133550. }
  133551. declare module BABYLON {
  133552. /** @hidden */
  133553. export var glowMapGenerationVertexShader: {
  133554. name: string;
  133555. shader: string;
  133556. };
  133557. }
  133558. declare module BABYLON {
  133559. /**
  133560. * Effect layer options. This helps customizing the behaviour
  133561. * of the effect layer.
  133562. */
  133563. export interface IEffectLayerOptions {
  133564. /**
  133565. * Multiplication factor apply to the canvas size to compute the render target size
  133566. * used to generated the objects (the smaller the faster).
  133567. */
  133568. mainTextureRatio: number;
  133569. /**
  133570. * Enforces a fixed size texture to ensure effect stability across devices.
  133571. */
  133572. mainTextureFixedSize?: number;
  133573. /**
  133574. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  133575. */
  133576. alphaBlendingMode: number;
  133577. /**
  133578. * The camera attached to the layer.
  133579. */
  133580. camera: Nullable<Camera>;
  133581. /**
  133582. * The rendering group to draw the layer in.
  133583. */
  133584. renderingGroupId: number;
  133585. }
  133586. /**
  133587. * The effect layer Helps adding post process effect blended with the main pass.
  133588. *
  133589. * This can be for instance use to generate glow or higlight effects on the scene.
  133590. *
  133591. * The effect layer class can not be used directly and is intented to inherited from to be
  133592. * customized per effects.
  133593. */
  133594. export abstract class EffectLayer {
  133595. private _vertexBuffers;
  133596. private _indexBuffer;
  133597. private _cachedDefines;
  133598. private _effectLayerMapGenerationEffect;
  133599. private _effectLayerOptions;
  133600. private _mergeEffect;
  133601. protected _scene: Scene;
  133602. protected _engine: Engine;
  133603. protected _maxSize: number;
  133604. protected _mainTextureDesiredSize: ISize;
  133605. protected _mainTexture: RenderTargetTexture;
  133606. protected _shouldRender: boolean;
  133607. protected _postProcesses: PostProcess[];
  133608. protected _textures: BaseTexture[];
  133609. protected _emissiveTextureAndColor: {
  133610. texture: Nullable<BaseTexture>;
  133611. color: Color4;
  133612. };
  133613. /**
  133614. * The name of the layer
  133615. */
  133616. name: string;
  133617. /**
  133618. * The clear color of the texture used to generate the glow map.
  133619. */
  133620. neutralColor: Color4;
  133621. /**
  133622. * Specifies whether the highlight layer is enabled or not.
  133623. */
  133624. isEnabled: boolean;
  133625. /**
  133626. * Gets the camera attached to the layer.
  133627. */
  133628. get camera(): Nullable<Camera>;
  133629. /**
  133630. * Gets the rendering group id the layer should render in.
  133631. */
  133632. get renderingGroupId(): number;
  133633. set renderingGroupId(renderingGroupId: number);
  133634. /**
  133635. * An event triggered when the effect layer has been disposed.
  133636. */
  133637. onDisposeObservable: Observable<EffectLayer>;
  133638. /**
  133639. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  133640. */
  133641. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  133642. /**
  133643. * An event triggered when the generated texture is being merged in the scene.
  133644. */
  133645. onBeforeComposeObservable: Observable<EffectLayer>;
  133646. /**
  133647. * An event triggered when the mesh is rendered into the effect render target.
  133648. */
  133649. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  133650. /**
  133651. * An event triggered after the mesh has been rendered into the effect render target.
  133652. */
  133653. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  133654. /**
  133655. * An event triggered when the generated texture has been merged in the scene.
  133656. */
  133657. onAfterComposeObservable: Observable<EffectLayer>;
  133658. /**
  133659. * An event triggered when the efffect layer changes its size.
  133660. */
  133661. onSizeChangedObservable: Observable<EffectLayer>;
  133662. /** @hidden */
  133663. static _SceneComponentInitialization: (scene: Scene) => void;
  133664. /**
  133665. * Instantiates a new effect Layer and references it in the scene.
  133666. * @param name The name of the layer
  133667. * @param scene The scene to use the layer in
  133668. */
  133669. constructor(
  133670. /** The Friendly of the effect in the scene */
  133671. name: string, scene: Scene);
  133672. /**
  133673. * Get the effect name of the layer.
  133674. * @return The effect name
  133675. */
  133676. abstract getEffectName(): string;
  133677. /**
  133678. * Checks for the readiness of the element composing the layer.
  133679. * @param subMesh the mesh to check for
  133680. * @param useInstances specify whether or not to use instances to render the mesh
  133681. * @return true if ready otherwise, false
  133682. */
  133683. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  133684. /**
  133685. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  133686. * @returns true if the effect requires stencil during the main canvas render pass.
  133687. */
  133688. abstract needStencil(): boolean;
  133689. /**
  133690. * Create the merge effect. This is the shader use to blit the information back
  133691. * to the main canvas at the end of the scene rendering.
  133692. * @returns The effect containing the shader used to merge the effect on the main canvas
  133693. */
  133694. protected abstract _createMergeEffect(): Effect;
  133695. /**
  133696. * Creates the render target textures and post processes used in the effect layer.
  133697. */
  133698. protected abstract _createTextureAndPostProcesses(): void;
  133699. /**
  133700. * Implementation specific of rendering the generating effect on the main canvas.
  133701. * @param effect The effect used to render through
  133702. */
  133703. protected abstract _internalRender(effect: Effect): void;
  133704. /**
  133705. * Sets the required values for both the emissive texture and and the main color.
  133706. */
  133707. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  133708. /**
  133709. * Free any resources and references associated to a mesh.
  133710. * Internal use
  133711. * @param mesh The mesh to free.
  133712. */
  133713. abstract _disposeMesh(mesh: Mesh): void;
  133714. /**
  133715. * Serializes this layer (Glow or Highlight for example)
  133716. * @returns a serialized layer object
  133717. */
  133718. abstract serialize?(): any;
  133719. /**
  133720. * Initializes the effect layer with the required options.
  133721. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  133722. */
  133723. protected _init(options: Partial<IEffectLayerOptions>): void;
  133724. /**
  133725. * Generates the index buffer of the full screen quad blending to the main canvas.
  133726. */
  133727. private _generateIndexBuffer;
  133728. /**
  133729. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  133730. */
  133731. private _generateVertexBuffer;
  133732. /**
  133733. * Sets the main texture desired size which is the closest power of two
  133734. * of the engine canvas size.
  133735. */
  133736. private _setMainTextureSize;
  133737. /**
  133738. * Creates the main texture for the effect layer.
  133739. */
  133740. protected _createMainTexture(): void;
  133741. /**
  133742. * Adds specific effects defines.
  133743. * @param defines The defines to add specifics to.
  133744. */
  133745. protected _addCustomEffectDefines(defines: string[]): void;
  133746. /**
  133747. * Checks for the readiness of the element composing the layer.
  133748. * @param subMesh the mesh to check for
  133749. * @param useInstances specify whether or not to use instances to render the mesh
  133750. * @param emissiveTexture the associated emissive texture used to generate the glow
  133751. * @return true if ready otherwise, false
  133752. */
  133753. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  133754. /**
  133755. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  133756. */
  133757. render(): void;
  133758. /**
  133759. * Determine if a given mesh will be used in the current effect.
  133760. * @param mesh mesh to test
  133761. * @returns true if the mesh will be used
  133762. */
  133763. hasMesh(mesh: AbstractMesh): boolean;
  133764. /**
  133765. * Returns true if the layer contains information to display, otherwise false.
  133766. * @returns true if the glow layer should be rendered
  133767. */
  133768. shouldRender(): boolean;
  133769. /**
  133770. * Returns true if the mesh should render, otherwise false.
  133771. * @param mesh The mesh to render
  133772. * @returns true if it should render otherwise false
  133773. */
  133774. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  133775. /**
  133776. * Returns true if the mesh can be rendered, otherwise false.
  133777. * @param mesh The mesh to render
  133778. * @param material The material used on the mesh
  133779. * @returns true if it can be rendered otherwise false
  133780. */
  133781. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  133782. /**
  133783. * Returns true if the mesh should render, otherwise false.
  133784. * @param mesh The mesh to render
  133785. * @returns true if it should render otherwise false
  133786. */
  133787. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  133788. /**
  133789. * Renders the submesh passed in parameter to the generation map.
  133790. */
  133791. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  133792. /**
  133793. * Defines whether the current material of the mesh should be use to render the effect.
  133794. * @param mesh defines the current mesh to render
  133795. */
  133796. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  133797. /**
  133798. * Rebuild the required buffers.
  133799. * @hidden Internal use only.
  133800. */
  133801. _rebuild(): void;
  133802. /**
  133803. * Dispose only the render target textures and post process.
  133804. */
  133805. private _disposeTextureAndPostProcesses;
  133806. /**
  133807. * Dispose the highlight layer and free resources.
  133808. */
  133809. dispose(): void;
  133810. /**
  133811. * Gets the class name of the effect layer
  133812. * @returns the string with the class name of the effect layer
  133813. */
  133814. getClassName(): string;
  133815. /**
  133816. * Creates an effect layer from parsed effect layer data
  133817. * @param parsedEffectLayer defines effect layer data
  133818. * @param scene defines the current scene
  133819. * @param rootUrl defines the root URL containing the effect layer information
  133820. * @returns a parsed effect Layer
  133821. */
  133822. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  133823. }
  133824. }
  133825. declare module BABYLON {
  133826. interface AbstractScene {
  133827. /**
  133828. * The list of effect layers (highlights/glow) added to the scene
  133829. * @see http://doc.babylonjs.com/how_to/highlight_layer
  133830. * @see http://doc.babylonjs.com/how_to/glow_layer
  133831. */
  133832. effectLayers: Array<EffectLayer>;
  133833. /**
  133834. * Removes the given effect layer from this scene.
  133835. * @param toRemove defines the effect layer to remove
  133836. * @returns the index of the removed effect layer
  133837. */
  133838. removeEffectLayer(toRemove: EffectLayer): number;
  133839. /**
  133840. * Adds the given effect layer to this scene
  133841. * @param newEffectLayer defines the effect layer to add
  133842. */
  133843. addEffectLayer(newEffectLayer: EffectLayer): void;
  133844. }
  133845. /**
  133846. * Defines the layer scene component responsible to manage any effect layers
  133847. * in a given scene.
  133848. */
  133849. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  133850. /**
  133851. * The component name helpfull to identify the component in the list of scene components.
  133852. */
  133853. readonly name: string;
  133854. /**
  133855. * The scene the component belongs to.
  133856. */
  133857. scene: Scene;
  133858. private _engine;
  133859. private _renderEffects;
  133860. private _needStencil;
  133861. private _previousStencilState;
  133862. /**
  133863. * Creates a new instance of the component for the given scene
  133864. * @param scene Defines the scene to register the component in
  133865. */
  133866. constructor(scene: Scene);
  133867. /**
  133868. * Registers the component in a given scene
  133869. */
  133870. register(): void;
  133871. /**
  133872. * Rebuilds the elements related to this component in case of
  133873. * context lost for instance.
  133874. */
  133875. rebuild(): void;
  133876. /**
  133877. * Serializes the component data to the specified json object
  133878. * @param serializationObject The object to serialize to
  133879. */
  133880. serialize(serializationObject: any): void;
  133881. /**
  133882. * Adds all the elements from the container to the scene
  133883. * @param container the container holding the elements
  133884. */
  133885. addFromContainer(container: AbstractScene): void;
  133886. /**
  133887. * Removes all the elements in the container from the scene
  133888. * @param container contains the elements to remove
  133889. * @param dispose if the removed element should be disposed (default: false)
  133890. */
  133891. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  133892. /**
  133893. * Disposes the component and the associated ressources.
  133894. */
  133895. dispose(): void;
  133896. private _isReadyForMesh;
  133897. private _renderMainTexture;
  133898. private _setStencil;
  133899. private _setStencilBack;
  133900. private _draw;
  133901. private _drawCamera;
  133902. private _drawRenderingGroup;
  133903. }
  133904. }
  133905. declare module BABYLON {
  133906. /** @hidden */
  133907. export var glowMapMergePixelShader: {
  133908. name: string;
  133909. shader: string;
  133910. };
  133911. }
  133912. declare module BABYLON {
  133913. /** @hidden */
  133914. export var glowMapMergeVertexShader: {
  133915. name: string;
  133916. shader: string;
  133917. };
  133918. }
  133919. declare module BABYLON {
  133920. interface AbstractScene {
  133921. /**
  133922. * Return a the first highlight layer of the scene with a given name.
  133923. * @param name The name of the highlight layer to look for.
  133924. * @return The highlight layer if found otherwise null.
  133925. */
  133926. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  133927. }
  133928. /**
  133929. * Glow layer options. This helps customizing the behaviour
  133930. * of the glow layer.
  133931. */
  133932. export interface IGlowLayerOptions {
  133933. /**
  133934. * Multiplication factor apply to the canvas size to compute the render target size
  133935. * used to generated the glowing objects (the smaller the faster).
  133936. */
  133937. mainTextureRatio: number;
  133938. /**
  133939. * Enforces a fixed size texture to ensure resize independant blur.
  133940. */
  133941. mainTextureFixedSize?: number;
  133942. /**
  133943. * How big is the kernel of the blur texture.
  133944. */
  133945. blurKernelSize: number;
  133946. /**
  133947. * The camera attached to the layer.
  133948. */
  133949. camera: Nullable<Camera>;
  133950. /**
  133951. * Enable MSAA by chosing the number of samples.
  133952. */
  133953. mainTextureSamples?: number;
  133954. /**
  133955. * The rendering group to draw the layer in.
  133956. */
  133957. renderingGroupId: number;
  133958. }
  133959. /**
  133960. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  133961. *
  133962. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  133963. *
  133964. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  133965. */
  133966. export class GlowLayer extends EffectLayer {
  133967. /**
  133968. * Effect Name of the layer.
  133969. */
  133970. static readonly EffectName: string;
  133971. /**
  133972. * The default blur kernel size used for the glow.
  133973. */
  133974. static DefaultBlurKernelSize: number;
  133975. /**
  133976. * The default texture size ratio used for the glow.
  133977. */
  133978. static DefaultTextureRatio: number;
  133979. /**
  133980. * Sets the kernel size of the blur.
  133981. */
  133982. set blurKernelSize(value: number);
  133983. /**
  133984. * Gets the kernel size of the blur.
  133985. */
  133986. get blurKernelSize(): number;
  133987. /**
  133988. * Sets the glow intensity.
  133989. */
  133990. set intensity(value: number);
  133991. /**
  133992. * Gets the glow intensity.
  133993. */
  133994. get intensity(): number;
  133995. private _options;
  133996. private _intensity;
  133997. private _horizontalBlurPostprocess1;
  133998. private _verticalBlurPostprocess1;
  133999. private _horizontalBlurPostprocess2;
  134000. private _verticalBlurPostprocess2;
  134001. private _blurTexture1;
  134002. private _blurTexture2;
  134003. private _postProcesses1;
  134004. private _postProcesses2;
  134005. private _includedOnlyMeshes;
  134006. private _excludedMeshes;
  134007. private _meshesUsingTheirOwnMaterials;
  134008. /**
  134009. * Callback used to let the user override the color selection on a per mesh basis
  134010. */
  134011. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  134012. /**
  134013. * Callback used to let the user override the texture selection on a per mesh basis
  134014. */
  134015. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  134016. /**
  134017. * Instantiates a new glow Layer and references it to the scene.
  134018. * @param name The name of the layer
  134019. * @param scene The scene to use the layer in
  134020. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  134021. */
  134022. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  134023. /**
  134024. * Get the effect name of the layer.
  134025. * @return The effect name
  134026. */
  134027. getEffectName(): string;
  134028. /**
  134029. * Create the merge effect. This is the shader use to blit the information back
  134030. * to the main canvas at the end of the scene rendering.
  134031. */
  134032. protected _createMergeEffect(): Effect;
  134033. /**
  134034. * Creates the render target textures and post processes used in the glow layer.
  134035. */
  134036. protected _createTextureAndPostProcesses(): void;
  134037. /**
  134038. * Checks for the readiness of the element composing the layer.
  134039. * @param subMesh the mesh to check for
  134040. * @param useInstances specify wether or not to use instances to render the mesh
  134041. * @param emissiveTexture the associated emissive texture used to generate the glow
  134042. * @return true if ready otherwise, false
  134043. */
  134044. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  134045. /**
  134046. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  134047. */
  134048. needStencil(): boolean;
  134049. /**
  134050. * Returns true if the mesh can be rendered, otherwise false.
  134051. * @param mesh The mesh to render
  134052. * @param material The material used on the mesh
  134053. * @returns true if it can be rendered otherwise false
  134054. */
  134055. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  134056. /**
  134057. * Implementation specific of rendering the generating effect on the main canvas.
  134058. * @param effect The effect used to render through
  134059. */
  134060. protected _internalRender(effect: Effect): void;
  134061. /**
  134062. * Sets the required values for both the emissive texture and and the main color.
  134063. */
  134064. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  134065. /**
  134066. * Returns true if the mesh should render, otherwise false.
  134067. * @param mesh The mesh to render
  134068. * @returns true if it should render otherwise false
  134069. */
  134070. protected _shouldRenderMesh(mesh: Mesh): boolean;
  134071. /**
  134072. * Adds specific effects defines.
  134073. * @param defines The defines to add specifics to.
  134074. */
  134075. protected _addCustomEffectDefines(defines: string[]): void;
  134076. /**
  134077. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  134078. * @param mesh The mesh to exclude from the glow layer
  134079. */
  134080. addExcludedMesh(mesh: Mesh): void;
  134081. /**
  134082. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  134083. * @param mesh The mesh to remove
  134084. */
  134085. removeExcludedMesh(mesh: Mesh): void;
  134086. /**
  134087. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  134088. * @param mesh The mesh to include in the glow layer
  134089. */
  134090. addIncludedOnlyMesh(mesh: Mesh): void;
  134091. /**
  134092. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  134093. * @param mesh The mesh to remove
  134094. */
  134095. removeIncludedOnlyMesh(mesh: Mesh): void;
  134096. /**
  134097. * Determine if a given mesh will be used in the glow layer
  134098. * @param mesh The mesh to test
  134099. * @returns true if the mesh will be highlighted by the current glow layer
  134100. */
  134101. hasMesh(mesh: AbstractMesh): boolean;
  134102. /**
  134103. * Defines whether the current material of the mesh should be use to render the effect.
  134104. * @param mesh defines the current mesh to render
  134105. */
  134106. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  134107. /**
  134108. * Add a mesh to be rendered through its own material and not with emissive only.
  134109. * @param mesh The mesh for which we need to use its material
  134110. */
  134111. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  134112. /**
  134113. * Remove a mesh from being rendered through its own material and not with emissive only.
  134114. * @param mesh The mesh for which we need to not use its material
  134115. */
  134116. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  134117. /**
  134118. * Free any resources and references associated to a mesh.
  134119. * Internal use
  134120. * @param mesh The mesh to free.
  134121. * @hidden
  134122. */
  134123. _disposeMesh(mesh: Mesh): void;
  134124. /**
  134125. * Gets the class name of the effect layer
  134126. * @returns the string with the class name of the effect layer
  134127. */
  134128. getClassName(): string;
  134129. /**
  134130. * Serializes this glow layer
  134131. * @returns a serialized glow layer object
  134132. */
  134133. serialize(): any;
  134134. /**
  134135. * Creates a Glow Layer from parsed glow layer data
  134136. * @param parsedGlowLayer defines glow layer data
  134137. * @param scene defines the current scene
  134138. * @param rootUrl defines the root URL containing the glow layer information
  134139. * @returns a parsed Glow Layer
  134140. */
  134141. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  134142. }
  134143. }
  134144. declare module BABYLON {
  134145. /** @hidden */
  134146. export var glowBlurPostProcessPixelShader: {
  134147. name: string;
  134148. shader: string;
  134149. };
  134150. }
  134151. declare module BABYLON {
  134152. interface AbstractScene {
  134153. /**
  134154. * Return a the first highlight layer of the scene with a given name.
  134155. * @param name The name of the highlight layer to look for.
  134156. * @return The highlight layer if found otherwise null.
  134157. */
  134158. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  134159. }
  134160. /**
  134161. * Highlight layer options. This helps customizing the behaviour
  134162. * of the highlight layer.
  134163. */
  134164. export interface IHighlightLayerOptions {
  134165. /**
  134166. * Multiplication factor apply to the canvas size to compute the render target size
  134167. * used to generated the glowing objects (the smaller the faster).
  134168. */
  134169. mainTextureRatio: number;
  134170. /**
  134171. * Enforces a fixed size texture to ensure resize independant blur.
  134172. */
  134173. mainTextureFixedSize?: number;
  134174. /**
  134175. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  134176. * of the picture to blur (the smaller the faster).
  134177. */
  134178. blurTextureSizeRatio: number;
  134179. /**
  134180. * How big in texel of the blur texture is the vertical blur.
  134181. */
  134182. blurVerticalSize: number;
  134183. /**
  134184. * How big in texel of the blur texture is the horizontal blur.
  134185. */
  134186. blurHorizontalSize: number;
  134187. /**
  134188. * Alpha blending mode used to apply the blur. Default is combine.
  134189. */
  134190. alphaBlendingMode: number;
  134191. /**
  134192. * The camera attached to the layer.
  134193. */
  134194. camera: Nullable<Camera>;
  134195. /**
  134196. * Should we display highlight as a solid stroke?
  134197. */
  134198. isStroke?: boolean;
  134199. /**
  134200. * The rendering group to draw the layer in.
  134201. */
  134202. renderingGroupId: number;
  134203. }
  134204. /**
  134205. * The highlight layer Helps adding a glow effect around a mesh.
  134206. *
  134207. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  134208. * glowy meshes to your scene.
  134209. *
  134210. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  134211. */
  134212. export class HighlightLayer extends EffectLayer {
  134213. name: string;
  134214. /**
  134215. * Effect Name of the highlight layer.
  134216. */
  134217. static readonly EffectName: string;
  134218. /**
  134219. * The neutral color used during the preparation of the glow effect.
  134220. * This is black by default as the blend operation is a blend operation.
  134221. */
  134222. static NeutralColor: Color4;
  134223. /**
  134224. * Stencil value used for glowing meshes.
  134225. */
  134226. static GlowingMeshStencilReference: number;
  134227. /**
  134228. * Stencil value used for the other meshes in the scene.
  134229. */
  134230. static NormalMeshStencilReference: number;
  134231. /**
  134232. * Specifies whether or not the inner glow is ACTIVE in the layer.
  134233. */
  134234. innerGlow: boolean;
  134235. /**
  134236. * Specifies whether or not the outer glow is ACTIVE in the layer.
  134237. */
  134238. outerGlow: boolean;
  134239. /**
  134240. * Specifies the horizontal size of the blur.
  134241. */
  134242. set blurHorizontalSize(value: number);
  134243. /**
  134244. * Specifies the vertical size of the blur.
  134245. */
  134246. set blurVerticalSize(value: number);
  134247. /**
  134248. * Gets the horizontal size of the blur.
  134249. */
  134250. get blurHorizontalSize(): number;
  134251. /**
  134252. * Gets the vertical size of the blur.
  134253. */
  134254. get blurVerticalSize(): number;
  134255. /**
  134256. * An event triggered when the highlight layer is being blurred.
  134257. */
  134258. onBeforeBlurObservable: Observable<HighlightLayer>;
  134259. /**
  134260. * An event triggered when the highlight layer has been blurred.
  134261. */
  134262. onAfterBlurObservable: Observable<HighlightLayer>;
  134263. private _instanceGlowingMeshStencilReference;
  134264. private _options;
  134265. private _downSamplePostprocess;
  134266. private _horizontalBlurPostprocess;
  134267. private _verticalBlurPostprocess;
  134268. private _blurTexture;
  134269. private _meshes;
  134270. private _excludedMeshes;
  134271. /**
  134272. * Instantiates a new highlight Layer and references it to the scene..
  134273. * @param name The name of the layer
  134274. * @param scene The scene to use the layer in
  134275. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  134276. */
  134277. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  134278. /**
  134279. * Get the effect name of the layer.
  134280. * @return The effect name
  134281. */
  134282. getEffectName(): string;
  134283. /**
  134284. * Create the merge effect. This is the shader use to blit the information back
  134285. * to the main canvas at the end of the scene rendering.
  134286. */
  134287. protected _createMergeEffect(): Effect;
  134288. /**
  134289. * Creates the render target textures and post processes used in the highlight layer.
  134290. */
  134291. protected _createTextureAndPostProcesses(): void;
  134292. /**
  134293. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  134294. */
  134295. needStencil(): boolean;
  134296. /**
  134297. * Checks for the readiness of the element composing the layer.
  134298. * @param subMesh the mesh to check for
  134299. * @param useInstances specify wether or not to use instances to render the mesh
  134300. * @param emissiveTexture the associated emissive texture used to generate the glow
  134301. * @return true if ready otherwise, false
  134302. */
  134303. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  134304. /**
  134305. * Implementation specific of rendering the generating effect on the main canvas.
  134306. * @param effect The effect used to render through
  134307. */
  134308. protected _internalRender(effect: Effect): void;
  134309. /**
  134310. * Returns true if the layer contains information to display, otherwise false.
  134311. */
  134312. shouldRender(): boolean;
  134313. /**
  134314. * Returns true if the mesh should render, otherwise false.
  134315. * @param mesh The mesh to render
  134316. * @returns true if it should render otherwise false
  134317. */
  134318. protected _shouldRenderMesh(mesh: Mesh): boolean;
  134319. /**
  134320. * Adds specific effects defines.
  134321. * @param defines The defines to add specifics to.
  134322. */
  134323. protected _addCustomEffectDefines(defines: string[]): void;
  134324. /**
  134325. * Sets the required values for both the emissive texture and and the main color.
  134326. */
  134327. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  134328. /**
  134329. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  134330. * @param mesh The mesh to exclude from the highlight layer
  134331. */
  134332. addExcludedMesh(mesh: Mesh): void;
  134333. /**
  134334. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  134335. * @param mesh The mesh to highlight
  134336. */
  134337. removeExcludedMesh(mesh: Mesh): void;
  134338. /**
  134339. * Determine if a given mesh will be highlighted by the current HighlightLayer
  134340. * @param mesh mesh to test
  134341. * @returns true if the mesh will be highlighted by the current HighlightLayer
  134342. */
  134343. hasMesh(mesh: AbstractMesh): boolean;
  134344. /**
  134345. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  134346. * @param mesh The mesh to highlight
  134347. * @param color The color of the highlight
  134348. * @param glowEmissiveOnly Extract the glow from the emissive texture
  134349. */
  134350. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  134351. /**
  134352. * Remove a mesh from the highlight layer in order to make it stop glowing.
  134353. * @param mesh The mesh to highlight
  134354. */
  134355. removeMesh(mesh: Mesh): void;
  134356. /**
  134357. * Remove all the meshes currently referenced in the highlight layer
  134358. */
  134359. removeAllMeshes(): void;
  134360. /**
  134361. * Force the stencil to the normal expected value for none glowing parts
  134362. */
  134363. private _defaultStencilReference;
  134364. /**
  134365. * Free any resources and references associated to a mesh.
  134366. * Internal use
  134367. * @param mesh The mesh to free.
  134368. * @hidden
  134369. */
  134370. _disposeMesh(mesh: Mesh): void;
  134371. /**
  134372. * Dispose the highlight layer and free resources.
  134373. */
  134374. dispose(): void;
  134375. /**
  134376. * Gets the class name of the effect layer
  134377. * @returns the string with the class name of the effect layer
  134378. */
  134379. getClassName(): string;
  134380. /**
  134381. * Serializes this Highlight layer
  134382. * @returns a serialized Highlight layer object
  134383. */
  134384. serialize(): any;
  134385. /**
  134386. * Creates a Highlight layer from parsed Highlight layer data
  134387. * @param parsedHightlightLayer defines the Highlight layer data
  134388. * @param scene defines the current scene
  134389. * @param rootUrl defines the root URL containing the Highlight layer information
  134390. * @returns a parsed Highlight layer
  134391. */
  134392. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  134393. }
  134394. }
  134395. declare module BABYLON {
  134396. interface AbstractScene {
  134397. /**
  134398. * The list of layers (background and foreground) of the scene
  134399. */
  134400. layers: Array<Layer>;
  134401. }
  134402. /**
  134403. * Defines the layer scene component responsible to manage any layers
  134404. * in a given scene.
  134405. */
  134406. export class LayerSceneComponent implements ISceneComponent {
  134407. /**
  134408. * The component name helpfull to identify the component in the list of scene components.
  134409. */
  134410. readonly name: string;
  134411. /**
  134412. * The scene the component belongs to.
  134413. */
  134414. scene: Scene;
  134415. private _engine;
  134416. /**
  134417. * Creates a new instance of the component for the given scene
  134418. * @param scene Defines the scene to register the component in
  134419. */
  134420. constructor(scene: Scene);
  134421. /**
  134422. * Registers the component in a given scene
  134423. */
  134424. register(): void;
  134425. /**
  134426. * Rebuilds the elements related to this component in case of
  134427. * context lost for instance.
  134428. */
  134429. rebuild(): void;
  134430. /**
  134431. * Disposes the component and the associated ressources.
  134432. */
  134433. dispose(): void;
  134434. private _draw;
  134435. private _drawCameraPredicate;
  134436. private _drawCameraBackground;
  134437. private _drawCameraForeground;
  134438. private _drawRenderTargetPredicate;
  134439. private _drawRenderTargetBackground;
  134440. private _drawRenderTargetForeground;
  134441. /**
  134442. * Adds all the elements from the container to the scene
  134443. * @param container the container holding the elements
  134444. */
  134445. addFromContainer(container: AbstractScene): void;
  134446. /**
  134447. * Removes all the elements in the container from the scene
  134448. * @param container contains the elements to remove
  134449. * @param dispose if the removed element should be disposed (default: false)
  134450. */
  134451. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  134452. }
  134453. }
  134454. declare module BABYLON {
  134455. /** @hidden */
  134456. export var layerPixelShader: {
  134457. name: string;
  134458. shader: string;
  134459. };
  134460. }
  134461. declare module BABYLON {
  134462. /** @hidden */
  134463. export var layerVertexShader: {
  134464. name: string;
  134465. shader: string;
  134466. };
  134467. }
  134468. declare module BABYLON {
  134469. /**
  134470. * This represents a full screen 2d layer.
  134471. * This can be useful to display a picture in the background of your scene for instance.
  134472. * @see https://www.babylonjs-playground.com/#08A2BS#1
  134473. */
  134474. export class Layer {
  134475. /**
  134476. * Define the name of the layer.
  134477. */
  134478. name: string;
  134479. /**
  134480. * Define the texture the layer should display.
  134481. */
  134482. texture: Nullable<Texture>;
  134483. /**
  134484. * Is the layer in background or foreground.
  134485. */
  134486. isBackground: boolean;
  134487. /**
  134488. * Define the color of the layer (instead of texture).
  134489. */
  134490. color: Color4;
  134491. /**
  134492. * Define the scale of the layer in order to zoom in out of the texture.
  134493. */
  134494. scale: Vector2;
  134495. /**
  134496. * Define an offset for the layer in order to shift the texture.
  134497. */
  134498. offset: Vector2;
  134499. /**
  134500. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  134501. */
  134502. alphaBlendingMode: number;
  134503. /**
  134504. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  134505. * Alpha test will not mix with the background color in case of transparency.
  134506. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  134507. */
  134508. alphaTest: boolean;
  134509. /**
  134510. * Define a mask to restrict the layer to only some of the scene cameras.
  134511. */
  134512. layerMask: number;
  134513. /**
  134514. * Define the list of render target the layer is visible into.
  134515. */
  134516. renderTargetTextures: RenderTargetTexture[];
  134517. /**
  134518. * Define if the layer is only used in renderTarget or if it also
  134519. * renders in the main frame buffer of the canvas.
  134520. */
  134521. renderOnlyInRenderTargetTextures: boolean;
  134522. private _scene;
  134523. private _vertexBuffers;
  134524. private _indexBuffer;
  134525. private _effect;
  134526. private _previousDefines;
  134527. /**
  134528. * An event triggered when the layer is disposed.
  134529. */
  134530. onDisposeObservable: Observable<Layer>;
  134531. private _onDisposeObserver;
  134532. /**
  134533. * Back compatibility with callback before the onDisposeObservable existed.
  134534. * The set callback will be triggered when the layer has been disposed.
  134535. */
  134536. set onDispose(callback: () => void);
  134537. /**
  134538. * An event triggered before rendering the scene
  134539. */
  134540. onBeforeRenderObservable: Observable<Layer>;
  134541. private _onBeforeRenderObserver;
  134542. /**
  134543. * Back compatibility with callback before the onBeforeRenderObservable existed.
  134544. * The set callback will be triggered just before rendering the layer.
  134545. */
  134546. set onBeforeRender(callback: () => void);
  134547. /**
  134548. * An event triggered after rendering the scene
  134549. */
  134550. onAfterRenderObservable: Observable<Layer>;
  134551. private _onAfterRenderObserver;
  134552. /**
  134553. * Back compatibility with callback before the onAfterRenderObservable existed.
  134554. * The set callback will be triggered just after rendering the layer.
  134555. */
  134556. set onAfterRender(callback: () => void);
  134557. /**
  134558. * Instantiates a new layer.
  134559. * This represents a full screen 2d layer.
  134560. * This can be useful to display a picture in the background of your scene for instance.
  134561. * @see https://www.babylonjs-playground.com/#08A2BS#1
  134562. * @param name Define the name of the layer in the scene
  134563. * @param imgUrl Define the url of the texture to display in the layer
  134564. * @param scene Define the scene the layer belongs to
  134565. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  134566. * @param color Defines a color for the layer
  134567. */
  134568. constructor(
  134569. /**
  134570. * Define the name of the layer.
  134571. */
  134572. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  134573. private _createIndexBuffer;
  134574. /** @hidden */
  134575. _rebuild(): void;
  134576. /**
  134577. * Renders the layer in the scene.
  134578. */
  134579. render(): void;
  134580. /**
  134581. * Disposes and releases the associated ressources.
  134582. */
  134583. dispose(): void;
  134584. }
  134585. }
  134586. declare module BABYLON {
  134587. /** @hidden */
  134588. export var lensFlarePixelShader: {
  134589. name: string;
  134590. shader: string;
  134591. };
  134592. }
  134593. declare module BABYLON {
  134594. /** @hidden */
  134595. export var lensFlareVertexShader: {
  134596. name: string;
  134597. shader: string;
  134598. };
  134599. }
  134600. declare module BABYLON {
  134601. /**
  134602. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  134603. * It is usually composed of several `lensFlare`.
  134604. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  134605. */
  134606. export class LensFlareSystem {
  134607. /**
  134608. * Define the name of the lens flare system
  134609. */
  134610. name: string;
  134611. /**
  134612. * List of lens flares used in this system.
  134613. */
  134614. lensFlares: LensFlare[];
  134615. /**
  134616. * Define a limit from the border the lens flare can be visible.
  134617. */
  134618. borderLimit: number;
  134619. /**
  134620. * Define a viewport border we do not want to see the lens flare in.
  134621. */
  134622. viewportBorder: number;
  134623. /**
  134624. * Define a predicate which could limit the list of meshes able to occlude the effect.
  134625. */
  134626. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  134627. /**
  134628. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  134629. */
  134630. layerMask: number;
  134631. /**
  134632. * Define the id of the lens flare system in the scene.
  134633. * (equal to name by default)
  134634. */
  134635. id: string;
  134636. private _scene;
  134637. private _emitter;
  134638. private _vertexBuffers;
  134639. private _indexBuffer;
  134640. private _effect;
  134641. private _positionX;
  134642. private _positionY;
  134643. private _isEnabled;
  134644. /** @hidden */
  134645. static _SceneComponentInitialization: (scene: Scene) => void;
  134646. /**
  134647. * Instantiates a lens flare system.
  134648. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  134649. * It is usually composed of several `lensFlare`.
  134650. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  134651. * @param name Define the name of the lens flare system in the scene
  134652. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  134653. * @param scene Define the scene the lens flare system belongs to
  134654. */
  134655. constructor(
  134656. /**
  134657. * Define the name of the lens flare system
  134658. */
  134659. name: string, emitter: any, scene: Scene);
  134660. /**
  134661. * Define if the lens flare system is enabled.
  134662. */
  134663. get isEnabled(): boolean;
  134664. set isEnabled(value: boolean);
  134665. /**
  134666. * Get the scene the effects belongs to.
  134667. * @returns the scene holding the lens flare system
  134668. */
  134669. getScene(): Scene;
  134670. /**
  134671. * Get the emitter of the lens flare system.
  134672. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  134673. * @returns the emitter of the lens flare system
  134674. */
  134675. getEmitter(): any;
  134676. /**
  134677. * Set the emitter of the lens flare system.
  134678. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  134679. * @param newEmitter Define the new emitter of the system
  134680. */
  134681. setEmitter(newEmitter: any): void;
  134682. /**
  134683. * Get the lens flare system emitter position.
  134684. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  134685. * @returns the position
  134686. */
  134687. getEmitterPosition(): Vector3;
  134688. /**
  134689. * @hidden
  134690. */
  134691. computeEffectivePosition(globalViewport: Viewport): boolean;
  134692. /** @hidden */
  134693. _isVisible(): boolean;
  134694. /**
  134695. * @hidden
  134696. */
  134697. render(): boolean;
  134698. /**
  134699. * Dispose and release the lens flare with its associated resources.
  134700. */
  134701. dispose(): void;
  134702. /**
  134703. * Parse a lens flare system from a JSON repressentation
  134704. * @param parsedLensFlareSystem Define the JSON to parse
  134705. * @param scene Define the scene the parsed system should be instantiated in
  134706. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  134707. * @returns the parsed system
  134708. */
  134709. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  134710. /**
  134711. * Serialize the current Lens Flare System into a JSON representation.
  134712. * @returns the serialized JSON
  134713. */
  134714. serialize(): any;
  134715. }
  134716. }
  134717. declare module BABYLON {
  134718. /**
  134719. * This represents one of the lens effect in a `lensFlareSystem`.
  134720. * It controls one of the indiviual texture used in the effect.
  134721. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  134722. */
  134723. export class LensFlare {
  134724. /**
  134725. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  134726. */
  134727. size: number;
  134728. /**
  134729. * 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.
  134730. */
  134731. position: number;
  134732. /**
  134733. * Define the lens color.
  134734. */
  134735. color: Color3;
  134736. /**
  134737. * Define the lens texture.
  134738. */
  134739. texture: Nullable<Texture>;
  134740. /**
  134741. * Define the alpha mode to render this particular lens.
  134742. */
  134743. alphaMode: number;
  134744. private _system;
  134745. /**
  134746. * Creates a new Lens Flare.
  134747. * This represents one of the lens effect in a `lensFlareSystem`.
  134748. * It controls one of the indiviual texture used in the effect.
  134749. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  134750. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  134751. * @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.
  134752. * @param color Define the lens color
  134753. * @param imgUrl Define the lens texture url
  134754. * @param system Define the `lensFlareSystem` this flare is part of
  134755. * @returns The newly created Lens Flare
  134756. */
  134757. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  134758. /**
  134759. * Instantiates a new Lens Flare.
  134760. * This represents one of the lens effect in a `lensFlareSystem`.
  134761. * It controls one of the indiviual texture used in the effect.
  134762. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  134763. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  134764. * @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.
  134765. * @param color Define the lens color
  134766. * @param imgUrl Define the lens texture url
  134767. * @param system Define the `lensFlareSystem` this flare is part of
  134768. */
  134769. constructor(
  134770. /**
  134771. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  134772. */
  134773. size: number,
  134774. /**
  134775. * 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.
  134776. */
  134777. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  134778. /**
  134779. * Dispose and release the lens flare with its associated resources.
  134780. */
  134781. dispose(): void;
  134782. }
  134783. }
  134784. declare module BABYLON {
  134785. interface AbstractScene {
  134786. /**
  134787. * The list of lens flare system added to the scene
  134788. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  134789. */
  134790. lensFlareSystems: Array<LensFlareSystem>;
  134791. /**
  134792. * Removes the given lens flare system from this scene.
  134793. * @param toRemove The lens flare system to remove
  134794. * @returns The index of the removed lens flare system
  134795. */
  134796. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  134797. /**
  134798. * Adds the given lens flare system to this scene
  134799. * @param newLensFlareSystem The lens flare system to add
  134800. */
  134801. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  134802. /**
  134803. * Gets a lens flare system using its name
  134804. * @param name defines the name to look for
  134805. * @returns the lens flare system or null if not found
  134806. */
  134807. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  134808. /**
  134809. * Gets a lens flare system using its id
  134810. * @param id defines the id to look for
  134811. * @returns the lens flare system or null if not found
  134812. */
  134813. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  134814. }
  134815. /**
  134816. * Defines the lens flare scene component responsible to manage any lens flares
  134817. * in a given scene.
  134818. */
  134819. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  134820. /**
  134821. * The component name helpfull to identify the component in the list of scene components.
  134822. */
  134823. readonly name: string;
  134824. /**
  134825. * The scene the component belongs to.
  134826. */
  134827. scene: Scene;
  134828. /**
  134829. * Creates a new instance of the component for the given scene
  134830. * @param scene Defines the scene to register the component in
  134831. */
  134832. constructor(scene: Scene);
  134833. /**
  134834. * Registers the component in a given scene
  134835. */
  134836. register(): void;
  134837. /**
  134838. * Rebuilds the elements related to this component in case of
  134839. * context lost for instance.
  134840. */
  134841. rebuild(): void;
  134842. /**
  134843. * Adds all the elements from the container to the scene
  134844. * @param container the container holding the elements
  134845. */
  134846. addFromContainer(container: AbstractScene): void;
  134847. /**
  134848. * Removes all the elements in the container from the scene
  134849. * @param container contains the elements to remove
  134850. * @param dispose if the removed element should be disposed (default: false)
  134851. */
  134852. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  134853. /**
  134854. * Serializes the component data to the specified json object
  134855. * @param serializationObject The object to serialize to
  134856. */
  134857. serialize(serializationObject: any): void;
  134858. /**
  134859. * Disposes the component and the associated ressources.
  134860. */
  134861. dispose(): void;
  134862. private _draw;
  134863. }
  134864. }
  134865. declare module BABYLON {
  134866. /** @hidden */
  134867. export var depthPixelShader: {
  134868. name: string;
  134869. shader: string;
  134870. };
  134871. }
  134872. declare module BABYLON {
  134873. /** @hidden */
  134874. export var depthVertexShader: {
  134875. name: string;
  134876. shader: string;
  134877. };
  134878. }
  134879. declare module BABYLON {
  134880. /**
  134881. * This represents a depth renderer in Babylon.
  134882. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  134883. */
  134884. export class DepthRenderer {
  134885. private _scene;
  134886. private _depthMap;
  134887. private _effect;
  134888. private readonly _storeNonLinearDepth;
  134889. private readonly _clearColor;
  134890. /** Get if the depth renderer is using packed depth or not */
  134891. readonly isPacked: boolean;
  134892. private _cachedDefines;
  134893. private _camera;
  134894. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  134895. enabled: boolean;
  134896. /**
  134897. * Specifiess that the depth renderer will only be used within
  134898. * the camera it is created for.
  134899. * This can help forcing its rendering during the camera processing.
  134900. */
  134901. useOnlyInActiveCamera: boolean;
  134902. /** @hidden */
  134903. static _SceneComponentInitialization: (scene: Scene) => void;
  134904. /**
  134905. * Instantiates a depth renderer
  134906. * @param scene The scene the renderer belongs to
  134907. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  134908. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  134909. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  134910. */
  134911. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  134912. /**
  134913. * Creates the depth rendering effect and checks if the effect is ready.
  134914. * @param subMesh The submesh to be used to render the depth map of
  134915. * @param useInstances If multiple world instances should be used
  134916. * @returns if the depth renderer is ready to render the depth map
  134917. */
  134918. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  134919. /**
  134920. * Gets the texture which the depth map will be written to.
  134921. * @returns The depth map texture
  134922. */
  134923. getDepthMap(): RenderTargetTexture;
  134924. /**
  134925. * Disposes of the depth renderer.
  134926. */
  134927. dispose(): void;
  134928. }
  134929. }
  134930. declare module BABYLON {
  134931. /** @hidden */
  134932. export var minmaxReduxPixelShader: {
  134933. name: string;
  134934. shader: string;
  134935. };
  134936. }
  134937. declare module BABYLON {
  134938. /**
  134939. * This class computes a min/max reduction from a texture: it means it computes the minimum
  134940. * and maximum values from all values of the texture.
  134941. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  134942. * The source values are read from the red channel of the texture.
  134943. */
  134944. export class MinMaxReducer {
  134945. /**
  134946. * Observable triggered when the computation has been performed
  134947. */
  134948. onAfterReductionPerformed: Observable<{
  134949. min: number;
  134950. max: number;
  134951. }>;
  134952. protected _camera: Camera;
  134953. protected _sourceTexture: Nullable<RenderTargetTexture>;
  134954. protected _reductionSteps: Nullable<Array<PostProcess>>;
  134955. protected _postProcessManager: PostProcessManager;
  134956. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  134957. protected _forceFullscreenViewport: boolean;
  134958. /**
  134959. * Creates a min/max reducer
  134960. * @param camera The camera to use for the post processes
  134961. */
  134962. constructor(camera: Camera);
  134963. /**
  134964. * Gets the texture used to read the values from.
  134965. */
  134966. get sourceTexture(): Nullable<RenderTargetTexture>;
  134967. /**
  134968. * Sets the source texture to read the values from.
  134969. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  134970. * because in such textures '1' value must not be taken into account to compute the maximum
  134971. * as this value is used to clear the texture.
  134972. * Note that the computation is not activated by calling this function, you must call activate() for that!
  134973. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  134974. * @param depthRedux Indicates if the texture is a depth texture or not
  134975. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  134976. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  134977. */
  134978. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  134979. /**
  134980. * Defines the refresh rate of the computation.
  134981. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  134982. */
  134983. get refreshRate(): number;
  134984. set refreshRate(value: number);
  134985. protected _activated: boolean;
  134986. /**
  134987. * Gets the activation status of the reducer
  134988. */
  134989. get activated(): boolean;
  134990. /**
  134991. * Activates the reduction computation.
  134992. * When activated, the observers registered in onAfterReductionPerformed are
  134993. * called after the compuation is performed
  134994. */
  134995. activate(): void;
  134996. /**
  134997. * Deactivates the reduction computation.
  134998. */
  134999. deactivate(): void;
  135000. /**
  135001. * Disposes the min/max reducer
  135002. * @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.
  135003. */
  135004. dispose(disposeAll?: boolean): void;
  135005. }
  135006. }
  135007. declare module BABYLON {
  135008. /**
  135009. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  135010. */
  135011. export class DepthReducer extends MinMaxReducer {
  135012. private _depthRenderer;
  135013. private _depthRendererId;
  135014. /**
  135015. * Gets the depth renderer used for the computation.
  135016. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  135017. */
  135018. get depthRenderer(): Nullable<DepthRenderer>;
  135019. /**
  135020. * Creates a depth reducer
  135021. * @param camera The camera used to render the depth texture
  135022. */
  135023. constructor(camera: Camera);
  135024. /**
  135025. * Sets the depth renderer to use to generate the depth map
  135026. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  135027. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  135028. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  135029. */
  135030. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  135031. /** @hidden */
  135032. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  135033. /**
  135034. * Activates the reduction computation.
  135035. * When activated, the observers registered in onAfterReductionPerformed are
  135036. * called after the compuation is performed
  135037. */
  135038. activate(): void;
  135039. /**
  135040. * Deactivates the reduction computation.
  135041. */
  135042. deactivate(): void;
  135043. /**
  135044. * Disposes the depth reducer
  135045. * @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.
  135046. */
  135047. dispose(disposeAll?: boolean): void;
  135048. }
  135049. }
  135050. declare module BABYLON {
  135051. /**
  135052. * A CSM implementation allowing casting shadows on large scenes.
  135053. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  135054. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  135055. */
  135056. export class CascadedShadowGenerator extends ShadowGenerator {
  135057. private static readonly frustumCornersNDCSpace;
  135058. /**
  135059. * Name of the CSM class
  135060. */
  135061. static CLASSNAME: string;
  135062. /**
  135063. * Defines the default number of cascades used by the CSM.
  135064. */
  135065. static readonly DEFAULT_CASCADES_COUNT: number;
  135066. /**
  135067. * Defines the minimum number of cascades used by the CSM.
  135068. */
  135069. static readonly MIN_CASCADES_COUNT: number;
  135070. /**
  135071. * Defines the maximum number of cascades used by the CSM.
  135072. */
  135073. static readonly MAX_CASCADES_COUNT: number;
  135074. protected _validateFilter(filter: number): number;
  135075. /**
  135076. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  135077. */
  135078. penumbraDarkness: number;
  135079. private _numCascades;
  135080. /**
  135081. * Gets or set the number of cascades used by the CSM.
  135082. */
  135083. get numCascades(): number;
  135084. set numCascades(value: number);
  135085. /**
  135086. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  135087. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  135088. */
  135089. stabilizeCascades: boolean;
  135090. private _freezeShadowCastersBoundingInfo;
  135091. private _freezeShadowCastersBoundingInfoObservable;
  135092. /**
  135093. * Enables or disables the shadow casters bounding info computation.
  135094. * If your shadow casters don't move, you can disable this feature.
  135095. * If it is enabled, the bounding box computation is done every frame.
  135096. */
  135097. get freezeShadowCastersBoundingInfo(): boolean;
  135098. set freezeShadowCastersBoundingInfo(freeze: boolean);
  135099. private _scbiMin;
  135100. private _scbiMax;
  135101. protected _computeShadowCastersBoundingInfo(): void;
  135102. protected _shadowCastersBoundingInfo: BoundingInfo;
  135103. /**
  135104. * Gets or sets the shadow casters bounding info.
  135105. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  135106. * so that the system won't overwrite the bounds you provide
  135107. */
  135108. get shadowCastersBoundingInfo(): BoundingInfo;
  135109. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  135110. protected _breaksAreDirty: boolean;
  135111. protected _minDistance: number;
  135112. protected _maxDistance: number;
  135113. /**
  135114. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  135115. *
  135116. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  135117. * If you don't know these values, simply leave them to their defaults and don't call this function.
  135118. * @param min minimal distance for the breaks (default to 0.)
  135119. * @param max maximal distance for the breaks (default to 1.)
  135120. */
  135121. setMinMaxDistance(min: number, max: number): void;
  135122. /** Gets the minimal distance used in the cascade break computation */
  135123. get minDistance(): number;
  135124. /** Gets the maximal distance used in the cascade break computation */
  135125. get maxDistance(): number;
  135126. /**
  135127. * Gets the class name of that object
  135128. * @returns "CascadedShadowGenerator"
  135129. */
  135130. getClassName(): string;
  135131. private _cascadeMinExtents;
  135132. private _cascadeMaxExtents;
  135133. /**
  135134. * Gets a cascade minimum extents
  135135. * @param cascadeIndex index of the cascade
  135136. * @returns the minimum cascade extents
  135137. */
  135138. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  135139. /**
  135140. * Gets a cascade maximum extents
  135141. * @param cascadeIndex index of the cascade
  135142. * @returns the maximum cascade extents
  135143. */
  135144. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  135145. private _cascades;
  135146. private _currentLayer;
  135147. private _viewSpaceFrustumsZ;
  135148. private _viewMatrices;
  135149. private _projectionMatrices;
  135150. private _transformMatrices;
  135151. private _transformMatricesAsArray;
  135152. private _frustumLengths;
  135153. private _lightSizeUVCorrection;
  135154. private _depthCorrection;
  135155. private _frustumCornersWorldSpace;
  135156. private _frustumCenter;
  135157. private _shadowCameraPos;
  135158. private _shadowMaxZ;
  135159. /**
  135160. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  135161. * It defaults to camera.maxZ
  135162. */
  135163. get shadowMaxZ(): number;
  135164. /**
  135165. * Sets the shadow max z distance.
  135166. */
  135167. set shadowMaxZ(value: number);
  135168. protected _debug: boolean;
  135169. /**
  135170. * Gets or sets the debug flag.
  135171. * When enabled, the cascades are materialized by different colors on the screen.
  135172. */
  135173. get debug(): boolean;
  135174. set debug(dbg: boolean);
  135175. private _depthClamp;
  135176. /**
  135177. * Gets or sets the depth clamping value.
  135178. *
  135179. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  135180. * to account for the shadow casters far away.
  135181. *
  135182. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  135183. */
  135184. get depthClamp(): boolean;
  135185. set depthClamp(value: boolean);
  135186. private _cascadeBlendPercentage;
  135187. /**
  135188. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  135189. * It defaults to 0.1 (10% blending).
  135190. */
  135191. get cascadeBlendPercentage(): number;
  135192. set cascadeBlendPercentage(value: number);
  135193. private _lambda;
  135194. /**
  135195. * Gets or set the lambda parameter.
  135196. * This parameter is used to split the camera frustum and create the cascades.
  135197. * 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.
  135198. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  135199. */
  135200. get lambda(): number;
  135201. set lambda(value: number);
  135202. /**
  135203. * Gets the view matrix corresponding to a given cascade
  135204. * @param cascadeNum cascade to retrieve the view matrix from
  135205. * @returns the cascade view matrix
  135206. */
  135207. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  135208. /**
  135209. * Gets the projection matrix corresponding to a given cascade
  135210. * @param cascadeNum cascade to retrieve the projection matrix from
  135211. * @returns the cascade projection matrix
  135212. */
  135213. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  135214. /**
  135215. * Gets the transformation matrix corresponding to a given cascade
  135216. * @param cascadeNum cascade to retrieve the transformation matrix from
  135217. * @returns the cascade transformation matrix
  135218. */
  135219. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  135220. private _depthRenderer;
  135221. /**
  135222. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  135223. *
  135224. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  135225. *
  135226. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  135227. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  135228. * @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
  135229. */
  135230. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  135231. private _depthReducer;
  135232. private _autoCalcDepthBounds;
  135233. /**
  135234. * Gets or sets the autoCalcDepthBounds property.
  135235. *
  135236. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  135237. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  135238. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  135239. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  135240. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  135241. */
  135242. get autoCalcDepthBounds(): boolean;
  135243. set autoCalcDepthBounds(value: boolean);
  135244. /**
  135245. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  135246. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  135247. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  135248. * for setting the refresh rate on the renderer yourself!
  135249. */
  135250. get autoCalcDepthBoundsRefreshRate(): number;
  135251. set autoCalcDepthBoundsRefreshRate(value: number);
  135252. /**
  135253. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  135254. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  135255. * you change the camera near/far planes!
  135256. */
  135257. splitFrustum(): void;
  135258. private _splitFrustum;
  135259. private _computeMatrices;
  135260. private _computeFrustumInWorldSpace;
  135261. private _computeCascadeFrustum;
  135262. /**
  135263. * Support test.
  135264. */
  135265. static get IsSupported(): boolean;
  135266. /** @hidden */
  135267. static _SceneComponentInitialization: (scene: Scene) => void;
  135268. /**
  135269. * Creates a Cascaded Shadow Generator object.
  135270. * A ShadowGenerator is the required tool to use the shadows.
  135271. * Each directional light casting shadows needs to use its own ShadowGenerator.
  135272. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  135273. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  135274. * @param light The directional light object generating the shadows.
  135275. * @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.
  135276. */
  135277. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  135278. protected _initializeGenerator(): void;
  135279. protected _createTargetRenderTexture(): void;
  135280. protected _initializeShadowMap(): void;
  135281. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  135282. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  135283. /**
  135284. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  135285. * @param defines Defines of the material we want to update
  135286. * @param lightIndex Index of the light in the enabled light list of the material
  135287. */
  135288. prepareDefines(defines: any, lightIndex: number): void;
  135289. /**
  135290. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  135291. * defined in the generator but impacting the effect).
  135292. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  135293. * @param effect The effect we are binfing the information for
  135294. */
  135295. bindShadowLight(lightIndex: string, effect: Effect): void;
  135296. /**
  135297. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  135298. * (eq to view projection * shadow projection matrices)
  135299. * @returns The transform matrix used to create the shadow map
  135300. */
  135301. getTransformMatrix(): Matrix;
  135302. /**
  135303. * Disposes the ShadowGenerator.
  135304. * Returns nothing.
  135305. */
  135306. dispose(): void;
  135307. /**
  135308. * Serializes the shadow generator setup to a json object.
  135309. * @returns The serialized JSON object
  135310. */
  135311. serialize(): any;
  135312. /**
  135313. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  135314. * @param parsedShadowGenerator The JSON object to parse
  135315. * @param scene The scene to create the shadow map for
  135316. * @returns The parsed shadow generator
  135317. */
  135318. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  135319. }
  135320. }
  135321. declare module BABYLON {
  135322. /**
  135323. * Defines the shadow generator component responsible to manage any shadow generators
  135324. * in a given scene.
  135325. */
  135326. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  135327. /**
  135328. * The component name helpfull to identify the component in the list of scene components.
  135329. */
  135330. readonly name: string;
  135331. /**
  135332. * The scene the component belongs to.
  135333. */
  135334. scene: Scene;
  135335. /**
  135336. * Creates a new instance of the component for the given scene
  135337. * @param scene Defines the scene to register the component in
  135338. */
  135339. constructor(scene: Scene);
  135340. /**
  135341. * Registers the component in a given scene
  135342. */
  135343. register(): void;
  135344. /**
  135345. * Rebuilds the elements related to this component in case of
  135346. * context lost for instance.
  135347. */
  135348. rebuild(): void;
  135349. /**
  135350. * Serializes the component data to the specified json object
  135351. * @param serializationObject The object to serialize to
  135352. */
  135353. serialize(serializationObject: any): void;
  135354. /**
  135355. * Adds all the elements from the container to the scene
  135356. * @param container the container holding the elements
  135357. */
  135358. addFromContainer(container: AbstractScene): void;
  135359. /**
  135360. * Removes all the elements in the container from the scene
  135361. * @param container contains the elements to remove
  135362. * @param dispose if the removed element should be disposed (default: false)
  135363. */
  135364. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  135365. /**
  135366. * Rebuilds the elements related to this component in case of
  135367. * context lost for instance.
  135368. */
  135369. dispose(): void;
  135370. private _gatherRenderTargets;
  135371. }
  135372. }
  135373. declare module BABYLON {
  135374. /**
  135375. * A point light is a light defined by an unique point in world space.
  135376. * The light is emitted in every direction from this point.
  135377. * A good example of a point light is a standard light bulb.
  135378. * Documentation: https://doc.babylonjs.com/babylon101/lights
  135379. */
  135380. export class PointLight extends ShadowLight {
  135381. private _shadowAngle;
  135382. /**
  135383. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  135384. * This specifies what angle the shadow will use to be created.
  135385. *
  135386. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  135387. */
  135388. get shadowAngle(): number;
  135389. /**
  135390. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  135391. * This specifies what angle the shadow will use to be created.
  135392. *
  135393. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  135394. */
  135395. set shadowAngle(value: number);
  135396. /**
  135397. * Gets the direction if it has been set.
  135398. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  135399. */
  135400. get direction(): Vector3;
  135401. /**
  135402. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  135403. */
  135404. set direction(value: Vector3);
  135405. /**
  135406. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  135407. * A PointLight emits the light in every direction.
  135408. * It can cast shadows.
  135409. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  135410. * ```javascript
  135411. * var pointLight = new PointLight("pl", camera.position, scene);
  135412. * ```
  135413. * Documentation : https://doc.babylonjs.com/babylon101/lights
  135414. * @param name The light friendly name
  135415. * @param position The position of the point light in the scene
  135416. * @param scene The scene the lights belongs to
  135417. */
  135418. constructor(name: string, position: Vector3, scene: Scene);
  135419. /**
  135420. * Returns the string "PointLight"
  135421. * @returns the class name
  135422. */
  135423. getClassName(): string;
  135424. /**
  135425. * Returns the integer 0.
  135426. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  135427. */
  135428. getTypeID(): number;
  135429. /**
  135430. * Specifies wether or not the shadowmap should be a cube texture.
  135431. * @returns true if the shadowmap needs to be a cube texture.
  135432. */
  135433. needCube(): boolean;
  135434. /**
  135435. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  135436. * @param faceIndex The index of the face we are computed the direction to generate shadow
  135437. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  135438. */
  135439. getShadowDirection(faceIndex?: number): Vector3;
  135440. /**
  135441. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  135442. * - fov = PI / 2
  135443. * - aspect ratio : 1.0
  135444. * - z-near and far equal to the active camera minZ and maxZ.
  135445. * Returns the PointLight.
  135446. */
  135447. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  135448. protected _buildUniformLayout(): void;
  135449. /**
  135450. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  135451. * @param effect The effect to update
  135452. * @param lightIndex The index of the light in the effect to update
  135453. * @returns The point light
  135454. */
  135455. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  135456. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  135457. /**
  135458. * Prepares the list of defines specific to the light type.
  135459. * @param defines the list of defines
  135460. * @param lightIndex defines the index of the light for the effect
  135461. */
  135462. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  135463. }
  135464. }
  135465. declare module BABYLON {
  135466. /**
  135467. * Header information of HDR texture files.
  135468. */
  135469. export interface HDRInfo {
  135470. /**
  135471. * The height of the texture in pixels.
  135472. */
  135473. height: number;
  135474. /**
  135475. * The width of the texture in pixels.
  135476. */
  135477. width: number;
  135478. /**
  135479. * The index of the beginning of the data in the binary file.
  135480. */
  135481. dataPosition: number;
  135482. }
  135483. /**
  135484. * This groups tools to convert HDR texture to native colors array.
  135485. */
  135486. export class HDRTools {
  135487. private static Ldexp;
  135488. private static Rgbe2float;
  135489. private static readStringLine;
  135490. /**
  135491. * Reads header information from an RGBE texture stored in a native array.
  135492. * More information on this format are available here:
  135493. * https://en.wikipedia.org/wiki/RGBE_image_format
  135494. *
  135495. * @param uint8array The binary file stored in native array.
  135496. * @return The header information.
  135497. */
  135498. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  135499. /**
  135500. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  135501. * This RGBE texture needs to store the information as a panorama.
  135502. *
  135503. * More information on this format are available here:
  135504. * https://en.wikipedia.org/wiki/RGBE_image_format
  135505. *
  135506. * @param buffer The binary file stored in an array buffer.
  135507. * @param size The expected size of the extracted cubemap.
  135508. * @return The Cube Map information.
  135509. */
  135510. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  135511. /**
  135512. * Returns the pixels data extracted from an RGBE texture.
  135513. * This pixels will be stored left to right up to down in the R G B order in one array.
  135514. *
  135515. * More information on this format are available here:
  135516. * https://en.wikipedia.org/wiki/RGBE_image_format
  135517. *
  135518. * @param uint8array The binary file stored in an array buffer.
  135519. * @param hdrInfo The header information of the file.
  135520. * @return The pixels data in RGB right to left up to down order.
  135521. */
  135522. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  135523. private static RGBE_ReadPixels_RLE;
  135524. }
  135525. }
  135526. declare module BABYLON {
  135527. /**
  135528. * Effect Render Options
  135529. */
  135530. export interface IEffectRendererOptions {
  135531. /**
  135532. * Defines the vertices positions.
  135533. */
  135534. positions?: number[];
  135535. /**
  135536. * Defines the indices.
  135537. */
  135538. indices?: number[];
  135539. }
  135540. /**
  135541. * Helper class to render one or more effects.
  135542. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  135543. */
  135544. export class EffectRenderer {
  135545. private engine;
  135546. private static _DefaultOptions;
  135547. private _vertexBuffers;
  135548. private _indexBuffer;
  135549. private _fullscreenViewport;
  135550. /**
  135551. * Creates an effect renderer
  135552. * @param engine the engine to use for rendering
  135553. * @param options defines the options of the effect renderer
  135554. */
  135555. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  135556. /**
  135557. * Sets the current viewport in normalized coordinates 0-1
  135558. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  135559. */
  135560. setViewport(viewport?: Viewport): void;
  135561. /**
  135562. * Binds the embedded attributes buffer to the effect.
  135563. * @param effect Defines the effect to bind the attributes for
  135564. */
  135565. bindBuffers(effect: Effect): void;
  135566. /**
  135567. * Sets the current effect wrapper to use during draw.
  135568. * The effect needs to be ready before calling this api.
  135569. * This also sets the default full screen position attribute.
  135570. * @param effectWrapper Defines the effect to draw with
  135571. */
  135572. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  135573. /**
  135574. * Restores engine states
  135575. */
  135576. restoreStates(): void;
  135577. /**
  135578. * Draws a full screen quad.
  135579. */
  135580. draw(): void;
  135581. private isRenderTargetTexture;
  135582. /**
  135583. * renders one or more effects to a specified texture
  135584. * @param effectWrapper the effect to renderer
  135585. * @param outputTexture texture to draw to, if null it will render to the screen.
  135586. */
  135587. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  135588. /**
  135589. * Disposes of the effect renderer
  135590. */
  135591. dispose(): void;
  135592. }
  135593. /**
  135594. * Options to create an EffectWrapper
  135595. */
  135596. interface EffectWrapperCreationOptions {
  135597. /**
  135598. * Engine to use to create the effect
  135599. */
  135600. engine: ThinEngine;
  135601. /**
  135602. * Fragment shader for the effect
  135603. */
  135604. fragmentShader: string;
  135605. /**
  135606. * Use the shader store instead of direct source code
  135607. */
  135608. useShaderStore?: boolean;
  135609. /**
  135610. * Vertex shader for the effect
  135611. */
  135612. vertexShader?: string;
  135613. /**
  135614. * Attributes to use in the shader
  135615. */
  135616. attributeNames?: Array<string>;
  135617. /**
  135618. * Uniforms to use in the shader
  135619. */
  135620. uniformNames?: Array<string>;
  135621. /**
  135622. * Texture sampler names to use in the shader
  135623. */
  135624. samplerNames?: Array<string>;
  135625. /**
  135626. * Defines to use in the shader
  135627. */
  135628. defines?: Array<string>;
  135629. /**
  135630. * Callback when effect is compiled
  135631. */
  135632. onCompiled?: Nullable<(effect: Effect) => void>;
  135633. /**
  135634. * The friendly name of the effect displayed in Spector.
  135635. */
  135636. name?: string;
  135637. }
  135638. /**
  135639. * Wraps an effect to be used for rendering
  135640. */
  135641. export class EffectWrapper {
  135642. /**
  135643. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  135644. */
  135645. onApplyObservable: Observable<{}>;
  135646. /**
  135647. * The underlying effect
  135648. */
  135649. effect: Effect;
  135650. /**
  135651. * Creates an effect to be renderer
  135652. * @param creationOptions options to create the effect
  135653. */
  135654. constructor(creationOptions: EffectWrapperCreationOptions);
  135655. /**
  135656. * Disposes of the effect wrapper
  135657. */
  135658. dispose(): void;
  135659. }
  135660. }
  135661. declare module BABYLON {
  135662. /** @hidden */
  135663. export var hdrFilteringVertexShader: {
  135664. name: string;
  135665. shader: string;
  135666. };
  135667. }
  135668. declare module BABYLON {
  135669. /** @hidden */
  135670. export var hdrFilteringPixelShader: {
  135671. name: string;
  135672. shader: string;
  135673. };
  135674. }
  135675. declare module BABYLON {
  135676. /**
  135677. * Options for texture filtering
  135678. */
  135679. interface IHDRFilteringOptions {
  135680. /**
  135681. * Scales pixel intensity for the input HDR map.
  135682. */
  135683. hdrScale?: number;
  135684. /**
  135685. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  135686. */
  135687. quality?: number;
  135688. }
  135689. /**
  135690. * Filters HDR maps to get correct renderings of PBR reflections
  135691. */
  135692. export class HDRFiltering {
  135693. private _engine;
  135694. private _effectRenderer;
  135695. private _effectWrapper;
  135696. private _lodGenerationOffset;
  135697. private _lodGenerationScale;
  135698. /**
  135699. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  135700. * you care about baking speed.
  135701. */
  135702. quality: number;
  135703. /**
  135704. * Scales pixel intensity for the input HDR map.
  135705. */
  135706. hdrScale: number;
  135707. /**
  135708. * Instantiates HDR filter for reflection maps
  135709. *
  135710. * @param engine Thin engine
  135711. * @param options Options
  135712. */
  135713. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  135714. private _createRenderTarget;
  135715. private _prefilterInternal;
  135716. private _createEffect;
  135717. /**
  135718. * Get a value indicating if the filter is ready to be used
  135719. * @param texture Texture to filter
  135720. * @returns true if the filter is ready
  135721. */
  135722. isReady(texture: BaseTexture): boolean;
  135723. /**
  135724. * Prefilters a cube texture to have mipmap levels representing roughness values.
  135725. * Prefiltering will be invoked at the end of next rendering pass.
  135726. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  135727. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  135728. * @param texture Texture to filter
  135729. * @param onFinished Callback when filtering is done
  135730. * @return Promise called when prefiltering is done
  135731. */
  135732. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  135733. }
  135734. }
  135735. declare module BABYLON {
  135736. /**
  135737. * This represents a texture coming from an HDR input.
  135738. *
  135739. * The only supported format is currently panorama picture stored in RGBE format.
  135740. * Example of such files can be found on HDRLib: http://hdrlib.com/
  135741. */
  135742. export class HDRCubeTexture extends BaseTexture {
  135743. private static _facesMapping;
  135744. private _generateHarmonics;
  135745. private _noMipmap;
  135746. private _prefilterOnLoad;
  135747. private _textureMatrix;
  135748. private _size;
  135749. private _onLoad;
  135750. private _onError;
  135751. /**
  135752. * The texture URL.
  135753. */
  135754. url: string;
  135755. /**
  135756. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  135757. */
  135758. coordinatesMode: number;
  135759. protected _isBlocking: boolean;
  135760. /**
  135761. * Sets wether or not the texture is blocking during loading.
  135762. */
  135763. set isBlocking(value: boolean);
  135764. /**
  135765. * Gets wether or not the texture is blocking during loading.
  135766. */
  135767. get isBlocking(): boolean;
  135768. protected _rotationY: number;
  135769. /**
  135770. * Sets texture matrix rotation angle around Y axis in radians.
  135771. */
  135772. set rotationY(value: number);
  135773. /**
  135774. * Gets texture matrix rotation angle around Y axis radians.
  135775. */
  135776. get rotationY(): number;
  135777. /**
  135778. * Gets or sets the center of the bounding box associated with the cube texture
  135779. * It must define where the camera used to render the texture was set
  135780. */
  135781. boundingBoxPosition: Vector3;
  135782. private _boundingBoxSize;
  135783. /**
  135784. * Gets or sets the size of the bounding box associated with the cube texture
  135785. * When defined, the cubemap will switch to local mode
  135786. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  135787. * @example https://www.babylonjs-playground.com/#RNASML
  135788. */
  135789. set boundingBoxSize(value: Vector3);
  135790. get boundingBoxSize(): Vector3;
  135791. /**
  135792. * Instantiates an HDRTexture from the following parameters.
  135793. *
  135794. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  135795. * @param sceneOrEngine The scene or engine the texture will be used in
  135796. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  135797. * @param noMipmap Forces to not generate the mipmap if true
  135798. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  135799. * @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)
  135800. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  135801. */
  135802. 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>);
  135803. /**
  135804. * Get the current class name of the texture useful for serialization or dynamic coding.
  135805. * @returns "HDRCubeTexture"
  135806. */
  135807. getClassName(): string;
  135808. /**
  135809. * Occurs when the file is raw .hdr file.
  135810. */
  135811. private loadTexture;
  135812. clone(): HDRCubeTexture;
  135813. delayLoad(): void;
  135814. /**
  135815. * Get the texture reflection matrix used to rotate/transform the reflection.
  135816. * @returns the reflection matrix
  135817. */
  135818. getReflectionTextureMatrix(): Matrix;
  135819. /**
  135820. * Set the texture reflection matrix used to rotate/transform the reflection.
  135821. * @param value Define the reflection matrix to set
  135822. */
  135823. setReflectionTextureMatrix(value: Matrix): void;
  135824. /**
  135825. * Parses a JSON representation of an HDR Texture in order to create the texture
  135826. * @param parsedTexture Define the JSON representation
  135827. * @param scene Define the scene the texture should be created in
  135828. * @param rootUrl Define the root url in case we need to load relative dependencies
  135829. * @returns the newly created texture after parsing
  135830. */
  135831. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  135832. serialize(): any;
  135833. }
  135834. }
  135835. declare module BABYLON {
  135836. /**
  135837. * Class used to control physics engine
  135838. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  135839. */
  135840. export class PhysicsEngine implements IPhysicsEngine {
  135841. private _physicsPlugin;
  135842. /**
  135843. * Global value used to control the smallest number supported by the simulation
  135844. */
  135845. static Epsilon: number;
  135846. private _impostors;
  135847. private _joints;
  135848. private _subTimeStep;
  135849. /**
  135850. * Gets the gravity vector used by the simulation
  135851. */
  135852. gravity: Vector3;
  135853. /**
  135854. * Factory used to create the default physics plugin.
  135855. * @returns The default physics plugin
  135856. */
  135857. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  135858. /**
  135859. * Creates a new Physics Engine
  135860. * @param gravity defines the gravity vector used by the simulation
  135861. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  135862. */
  135863. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  135864. /**
  135865. * Sets the gravity vector used by the simulation
  135866. * @param gravity defines the gravity vector to use
  135867. */
  135868. setGravity(gravity: Vector3): void;
  135869. /**
  135870. * Set the time step of the physics engine.
  135871. * Default is 1/60.
  135872. * To slow it down, enter 1/600 for example.
  135873. * To speed it up, 1/30
  135874. * @param newTimeStep defines the new timestep to apply to this world.
  135875. */
  135876. setTimeStep(newTimeStep?: number): void;
  135877. /**
  135878. * Get the time step of the physics engine.
  135879. * @returns the current time step
  135880. */
  135881. getTimeStep(): number;
  135882. /**
  135883. * Set the sub time step of the physics engine.
  135884. * Default is 0 meaning there is no sub steps
  135885. * To increase physics resolution precision, set a small value (like 1 ms)
  135886. * @param subTimeStep defines the new sub timestep used for physics resolution.
  135887. */
  135888. setSubTimeStep(subTimeStep?: number): void;
  135889. /**
  135890. * Get the sub time step of the physics engine.
  135891. * @returns the current sub time step
  135892. */
  135893. getSubTimeStep(): number;
  135894. /**
  135895. * Release all resources
  135896. */
  135897. dispose(): void;
  135898. /**
  135899. * Gets the name of the current physics plugin
  135900. * @returns the name of the plugin
  135901. */
  135902. getPhysicsPluginName(): string;
  135903. /**
  135904. * Adding a new impostor for the impostor tracking.
  135905. * This will be done by the impostor itself.
  135906. * @param impostor the impostor to add
  135907. */
  135908. addImpostor(impostor: PhysicsImpostor): void;
  135909. /**
  135910. * Remove an impostor from the engine.
  135911. * This impostor and its mesh will not longer be updated by the physics engine.
  135912. * @param impostor the impostor to remove
  135913. */
  135914. removeImpostor(impostor: PhysicsImpostor): void;
  135915. /**
  135916. * Add a joint to the physics engine
  135917. * @param mainImpostor defines the main impostor to which the joint is added.
  135918. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  135919. * @param joint defines the joint that will connect both impostors.
  135920. */
  135921. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  135922. /**
  135923. * Removes a joint from the simulation
  135924. * @param mainImpostor defines the impostor used with the joint
  135925. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  135926. * @param joint defines the joint to remove
  135927. */
  135928. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  135929. /**
  135930. * Called by the scene. No need to call it.
  135931. * @param delta defines the timespam between frames
  135932. */
  135933. _step(delta: number): void;
  135934. /**
  135935. * Gets the current plugin used to run the simulation
  135936. * @returns current plugin
  135937. */
  135938. getPhysicsPlugin(): IPhysicsEnginePlugin;
  135939. /**
  135940. * Gets the list of physic impostors
  135941. * @returns an array of PhysicsImpostor
  135942. */
  135943. getImpostors(): Array<PhysicsImpostor>;
  135944. /**
  135945. * Gets the impostor for a physics enabled object
  135946. * @param object defines the object impersonated by the impostor
  135947. * @returns the PhysicsImpostor or null if not found
  135948. */
  135949. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  135950. /**
  135951. * Gets the impostor for a physics body object
  135952. * @param body defines physics body used by the impostor
  135953. * @returns the PhysicsImpostor or null if not found
  135954. */
  135955. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  135956. /**
  135957. * Does a raycast in the physics world
  135958. * @param from when should the ray start?
  135959. * @param to when should the ray end?
  135960. * @returns PhysicsRaycastResult
  135961. */
  135962. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  135963. }
  135964. }
  135965. declare module BABYLON {
  135966. /** @hidden */
  135967. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  135968. private _useDeltaForWorldStep;
  135969. world: any;
  135970. name: string;
  135971. private _physicsMaterials;
  135972. private _fixedTimeStep;
  135973. private _cannonRaycastResult;
  135974. private _raycastResult;
  135975. private _physicsBodysToRemoveAfterStep;
  135976. private _firstFrame;
  135977. BJSCANNON: any;
  135978. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  135979. setGravity(gravity: Vector3): void;
  135980. setTimeStep(timeStep: number): void;
  135981. getTimeStep(): number;
  135982. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  135983. private _removeMarkedPhysicsBodiesFromWorld;
  135984. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  135985. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  135986. generatePhysicsBody(impostor: PhysicsImpostor): void;
  135987. private _processChildMeshes;
  135988. removePhysicsBody(impostor: PhysicsImpostor): void;
  135989. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  135990. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  135991. private _addMaterial;
  135992. private _checkWithEpsilon;
  135993. private _createShape;
  135994. private _createHeightmap;
  135995. private _minus90X;
  135996. private _plus90X;
  135997. private _tmpPosition;
  135998. private _tmpDeltaPosition;
  135999. private _tmpUnityRotation;
  136000. private _updatePhysicsBodyTransformation;
  136001. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  136002. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  136003. isSupported(): boolean;
  136004. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  136005. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  136006. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  136007. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  136008. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  136009. getBodyMass(impostor: PhysicsImpostor): number;
  136010. getBodyFriction(impostor: PhysicsImpostor): number;
  136011. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  136012. getBodyRestitution(impostor: PhysicsImpostor): number;
  136013. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  136014. sleepBody(impostor: PhysicsImpostor): void;
  136015. wakeUpBody(impostor: PhysicsImpostor): void;
  136016. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  136017. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  136018. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  136019. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  136020. getRadius(impostor: PhysicsImpostor): number;
  136021. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  136022. dispose(): void;
  136023. private _extendNamespace;
  136024. /**
  136025. * Does a raycast in the physics world
  136026. * @param from when should the ray start?
  136027. * @param to when should the ray end?
  136028. * @returns PhysicsRaycastResult
  136029. */
  136030. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  136031. }
  136032. }
  136033. declare module BABYLON {
  136034. /** @hidden */
  136035. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  136036. private _useDeltaForWorldStep;
  136037. world: any;
  136038. name: string;
  136039. BJSOIMO: any;
  136040. private _raycastResult;
  136041. private _fixedTimeStep;
  136042. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  136043. setGravity(gravity: Vector3): void;
  136044. setTimeStep(timeStep: number): void;
  136045. getTimeStep(): number;
  136046. private _tmpImpostorsArray;
  136047. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  136048. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  136049. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  136050. generatePhysicsBody(impostor: PhysicsImpostor): void;
  136051. private _tmpPositionVector;
  136052. removePhysicsBody(impostor: PhysicsImpostor): void;
  136053. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  136054. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  136055. isSupported(): boolean;
  136056. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  136057. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  136058. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  136059. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  136060. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  136061. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  136062. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  136063. getBodyMass(impostor: PhysicsImpostor): number;
  136064. getBodyFriction(impostor: PhysicsImpostor): number;
  136065. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  136066. getBodyRestitution(impostor: PhysicsImpostor): number;
  136067. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  136068. sleepBody(impostor: PhysicsImpostor): void;
  136069. wakeUpBody(impostor: PhysicsImpostor): void;
  136070. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  136071. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  136072. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  136073. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  136074. getRadius(impostor: PhysicsImpostor): number;
  136075. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  136076. dispose(): void;
  136077. /**
  136078. * Does a raycast in the physics world
  136079. * @param from when should the ray start?
  136080. * @param to when should the ray end?
  136081. * @returns PhysicsRaycastResult
  136082. */
  136083. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  136084. }
  136085. }
  136086. declare module BABYLON {
  136087. /**
  136088. * Class containing static functions to help procedurally build meshes
  136089. */
  136090. export class RibbonBuilder {
  136091. /**
  136092. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  136093. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  136094. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  136095. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  136096. * * 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
  136097. * * 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
  136098. * * 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
  136099. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136100. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136101. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  136102. * * 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
  136103. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  136104. * * 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
  136105. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  136106. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136107. * @param name defines the name of the mesh
  136108. * @param options defines the options used to create the mesh
  136109. * @param scene defines the hosting scene
  136110. * @returns the ribbon mesh
  136111. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  136112. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  136113. */
  136114. static CreateRibbon(name: string, options: {
  136115. pathArray: Vector3[][];
  136116. closeArray?: boolean;
  136117. closePath?: boolean;
  136118. offset?: number;
  136119. updatable?: boolean;
  136120. sideOrientation?: number;
  136121. frontUVs?: Vector4;
  136122. backUVs?: Vector4;
  136123. instance?: Mesh;
  136124. invertUV?: boolean;
  136125. uvs?: Vector2[];
  136126. colors?: Color4[];
  136127. }, scene?: Nullable<Scene>): Mesh;
  136128. }
  136129. }
  136130. declare module BABYLON {
  136131. /**
  136132. * Class containing static functions to help procedurally build meshes
  136133. */
  136134. export class ShapeBuilder {
  136135. /**
  136136. * 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.
  136137. * * 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.
  136138. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  136139. * * 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.
  136140. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  136141. * * 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
  136142. * * 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
  136143. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  136144. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136145. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136146. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  136147. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  136148. * @param name defines the name of the mesh
  136149. * @param options defines the options used to create the mesh
  136150. * @param scene defines the hosting scene
  136151. * @returns the extruded shape mesh
  136152. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  136153. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  136154. */
  136155. static ExtrudeShape(name: string, options: {
  136156. shape: Vector3[];
  136157. path: Vector3[];
  136158. scale?: number;
  136159. rotation?: number;
  136160. cap?: number;
  136161. updatable?: boolean;
  136162. sideOrientation?: number;
  136163. frontUVs?: Vector4;
  136164. backUVs?: Vector4;
  136165. instance?: Mesh;
  136166. invertUV?: boolean;
  136167. }, scene?: Nullable<Scene>): Mesh;
  136168. /**
  136169. * Creates an custom extruded shape mesh.
  136170. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  136171. * * 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.
  136172. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  136173. * * 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
  136174. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  136175. * * 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
  136176. * * It must returns a float value that will be the scale value applied to the shape on each path point
  136177. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  136178. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  136179. * * 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
  136180. * * 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
  136181. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  136182. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136183. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136184. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  136185. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136186. * @param name defines the name of the mesh
  136187. * @param options defines the options used to create the mesh
  136188. * @param scene defines the hosting scene
  136189. * @returns the custom extruded shape mesh
  136190. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  136191. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  136192. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  136193. */
  136194. static ExtrudeShapeCustom(name: string, options: {
  136195. shape: Vector3[];
  136196. path: Vector3[];
  136197. scaleFunction?: any;
  136198. rotationFunction?: any;
  136199. ribbonCloseArray?: boolean;
  136200. ribbonClosePath?: boolean;
  136201. cap?: number;
  136202. updatable?: boolean;
  136203. sideOrientation?: number;
  136204. frontUVs?: Vector4;
  136205. backUVs?: Vector4;
  136206. instance?: Mesh;
  136207. invertUV?: boolean;
  136208. }, scene?: Nullable<Scene>): Mesh;
  136209. private static _ExtrudeShapeGeneric;
  136210. }
  136211. }
  136212. declare module BABYLON {
  136213. /**
  136214. * AmmoJS Physics plugin
  136215. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  136216. * @see https://github.com/kripken/ammo.js/
  136217. */
  136218. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  136219. private _useDeltaForWorldStep;
  136220. /**
  136221. * Reference to the Ammo library
  136222. */
  136223. bjsAMMO: any;
  136224. /**
  136225. * Created ammoJS world which physics bodies are added to
  136226. */
  136227. world: any;
  136228. /**
  136229. * Name of the plugin
  136230. */
  136231. name: string;
  136232. private _timeStep;
  136233. private _fixedTimeStep;
  136234. private _maxSteps;
  136235. private _tmpQuaternion;
  136236. private _tmpAmmoTransform;
  136237. private _tmpAmmoQuaternion;
  136238. private _tmpAmmoConcreteContactResultCallback;
  136239. private _collisionConfiguration;
  136240. private _dispatcher;
  136241. private _overlappingPairCache;
  136242. private _solver;
  136243. private _softBodySolver;
  136244. private _tmpAmmoVectorA;
  136245. private _tmpAmmoVectorB;
  136246. private _tmpAmmoVectorC;
  136247. private _tmpAmmoVectorD;
  136248. private _tmpContactCallbackResult;
  136249. private _tmpAmmoVectorRCA;
  136250. private _tmpAmmoVectorRCB;
  136251. private _raycastResult;
  136252. private static readonly DISABLE_COLLISION_FLAG;
  136253. private static readonly KINEMATIC_FLAG;
  136254. private static readonly DISABLE_DEACTIVATION_FLAG;
  136255. /**
  136256. * Initializes the ammoJS plugin
  136257. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  136258. * @param ammoInjection can be used to inject your own ammo reference
  136259. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  136260. */
  136261. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  136262. /**
  136263. * Sets the gravity of the physics world (m/(s^2))
  136264. * @param gravity Gravity to set
  136265. */
  136266. setGravity(gravity: Vector3): void;
  136267. /**
  136268. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  136269. * @param timeStep timestep to use in seconds
  136270. */
  136271. setTimeStep(timeStep: number): void;
  136272. /**
  136273. * 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)
  136274. * @param fixedTimeStep fixedTimeStep to use in seconds
  136275. */
  136276. setFixedTimeStep(fixedTimeStep: number): void;
  136277. /**
  136278. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  136279. * @param maxSteps the maximum number of steps by the physics engine per frame
  136280. */
  136281. setMaxSteps(maxSteps: number): void;
  136282. /**
  136283. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  136284. * @returns the current timestep in seconds
  136285. */
  136286. getTimeStep(): number;
  136287. /**
  136288. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  136289. */
  136290. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  136291. private _isImpostorInContact;
  136292. private _isImpostorPairInContact;
  136293. private _stepSimulation;
  136294. /**
  136295. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  136296. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  136297. * After the step the babylon meshes are set to the position of the physics imposters
  136298. * @param delta amount of time to step forward
  136299. * @param impostors array of imposters to update before/after the step
  136300. */
  136301. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  136302. /**
  136303. * Update babylon mesh to match physics world object
  136304. * @param impostor imposter to match
  136305. */
  136306. private _afterSoftStep;
  136307. /**
  136308. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  136309. * @param impostor imposter to match
  136310. */
  136311. private _ropeStep;
  136312. /**
  136313. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  136314. * @param impostor imposter to match
  136315. */
  136316. private _softbodyOrClothStep;
  136317. private _tmpMatrix;
  136318. /**
  136319. * Applies an impulse on the imposter
  136320. * @param impostor imposter to apply impulse to
  136321. * @param force amount of force to be applied to the imposter
  136322. * @param contactPoint the location to apply the impulse on the imposter
  136323. */
  136324. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  136325. /**
  136326. * Applies a force on the imposter
  136327. * @param impostor imposter to apply force
  136328. * @param force amount of force to be applied to the imposter
  136329. * @param contactPoint the location to apply the force on the imposter
  136330. */
  136331. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  136332. /**
  136333. * Creates a physics body using the plugin
  136334. * @param impostor the imposter to create the physics body on
  136335. */
  136336. generatePhysicsBody(impostor: PhysicsImpostor): void;
  136337. /**
  136338. * Removes the physics body from the imposter and disposes of the body's memory
  136339. * @param impostor imposter to remove the physics body from
  136340. */
  136341. removePhysicsBody(impostor: PhysicsImpostor): void;
  136342. /**
  136343. * Generates a joint
  136344. * @param impostorJoint the imposter joint to create the joint with
  136345. */
  136346. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  136347. /**
  136348. * Removes a joint
  136349. * @param impostorJoint the imposter joint to remove the joint from
  136350. */
  136351. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  136352. private _addMeshVerts;
  136353. /**
  136354. * Initialise the soft body vertices to match its object's (mesh) vertices
  136355. * Softbody vertices (nodes) are in world space and to match this
  136356. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  136357. * @param impostor to create the softbody for
  136358. */
  136359. private _softVertexData;
  136360. /**
  136361. * Create an impostor's soft body
  136362. * @param impostor to create the softbody for
  136363. */
  136364. private _createSoftbody;
  136365. /**
  136366. * Create cloth for an impostor
  136367. * @param impostor to create the softbody for
  136368. */
  136369. private _createCloth;
  136370. /**
  136371. * Create rope for an impostor
  136372. * @param impostor to create the softbody for
  136373. */
  136374. private _createRope;
  136375. /**
  136376. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  136377. * @param impostor to create the custom physics shape for
  136378. */
  136379. private _createCustom;
  136380. private _addHullVerts;
  136381. private _createShape;
  136382. /**
  136383. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  136384. * @param impostor imposter containing the physics body and babylon object
  136385. */
  136386. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  136387. /**
  136388. * Sets the babylon object's position/rotation from the physics body's position/rotation
  136389. * @param impostor imposter containing the physics body and babylon object
  136390. * @param newPosition new position
  136391. * @param newRotation new rotation
  136392. */
  136393. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  136394. /**
  136395. * If this plugin is supported
  136396. * @returns true if its supported
  136397. */
  136398. isSupported(): boolean;
  136399. /**
  136400. * Sets the linear velocity of the physics body
  136401. * @param impostor imposter to set the velocity on
  136402. * @param velocity velocity to set
  136403. */
  136404. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  136405. /**
  136406. * Sets the angular velocity of the physics body
  136407. * @param impostor imposter to set the velocity on
  136408. * @param velocity velocity to set
  136409. */
  136410. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  136411. /**
  136412. * gets the linear velocity
  136413. * @param impostor imposter to get linear velocity from
  136414. * @returns linear velocity
  136415. */
  136416. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  136417. /**
  136418. * gets the angular velocity
  136419. * @param impostor imposter to get angular velocity from
  136420. * @returns angular velocity
  136421. */
  136422. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  136423. /**
  136424. * Sets the mass of physics body
  136425. * @param impostor imposter to set the mass on
  136426. * @param mass mass to set
  136427. */
  136428. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  136429. /**
  136430. * Gets the mass of the physics body
  136431. * @param impostor imposter to get the mass from
  136432. * @returns mass
  136433. */
  136434. getBodyMass(impostor: PhysicsImpostor): number;
  136435. /**
  136436. * Gets friction of the impostor
  136437. * @param impostor impostor to get friction from
  136438. * @returns friction value
  136439. */
  136440. getBodyFriction(impostor: PhysicsImpostor): number;
  136441. /**
  136442. * Sets friction of the impostor
  136443. * @param impostor impostor to set friction on
  136444. * @param friction friction value
  136445. */
  136446. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  136447. /**
  136448. * Gets restitution of the impostor
  136449. * @param impostor impostor to get restitution from
  136450. * @returns restitution value
  136451. */
  136452. getBodyRestitution(impostor: PhysicsImpostor): number;
  136453. /**
  136454. * Sets resitution of the impostor
  136455. * @param impostor impostor to set resitution on
  136456. * @param restitution resitution value
  136457. */
  136458. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  136459. /**
  136460. * Gets pressure inside the impostor
  136461. * @param impostor impostor to get pressure from
  136462. * @returns pressure value
  136463. */
  136464. getBodyPressure(impostor: PhysicsImpostor): number;
  136465. /**
  136466. * Sets pressure inside a soft body impostor
  136467. * Cloth and rope must remain 0 pressure
  136468. * @param impostor impostor to set pressure on
  136469. * @param pressure pressure value
  136470. */
  136471. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  136472. /**
  136473. * Gets stiffness of the impostor
  136474. * @param impostor impostor to get stiffness from
  136475. * @returns pressure value
  136476. */
  136477. getBodyStiffness(impostor: PhysicsImpostor): number;
  136478. /**
  136479. * Sets stiffness of the impostor
  136480. * @param impostor impostor to set stiffness on
  136481. * @param stiffness stiffness value from 0 to 1
  136482. */
  136483. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  136484. /**
  136485. * Gets velocityIterations of the impostor
  136486. * @param impostor impostor to get velocity iterations from
  136487. * @returns velocityIterations value
  136488. */
  136489. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  136490. /**
  136491. * Sets velocityIterations of the impostor
  136492. * @param impostor impostor to set velocity iterations on
  136493. * @param velocityIterations velocityIterations value
  136494. */
  136495. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  136496. /**
  136497. * Gets positionIterations of the impostor
  136498. * @param impostor impostor to get position iterations from
  136499. * @returns positionIterations value
  136500. */
  136501. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  136502. /**
  136503. * Sets positionIterations of the impostor
  136504. * @param impostor impostor to set position on
  136505. * @param positionIterations positionIterations value
  136506. */
  136507. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  136508. /**
  136509. * Append an anchor to a cloth object
  136510. * @param impostor is the cloth impostor to add anchor to
  136511. * @param otherImpostor is the rigid impostor to anchor to
  136512. * @param width ratio across width from 0 to 1
  136513. * @param height ratio up height from 0 to 1
  136514. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  136515. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  136516. */
  136517. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  136518. /**
  136519. * Append an hook to a rope object
  136520. * @param impostor is the rope impostor to add hook to
  136521. * @param otherImpostor is the rigid impostor to hook to
  136522. * @param length ratio along the rope from 0 to 1
  136523. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  136524. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  136525. */
  136526. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  136527. /**
  136528. * Sleeps the physics body and stops it from being active
  136529. * @param impostor impostor to sleep
  136530. */
  136531. sleepBody(impostor: PhysicsImpostor): void;
  136532. /**
  136533. * Activates the physics body
  136534. * @param impostor impostor to activate
  136535. */
  136536. wakeUpBody(impostor: PhysicsImpostor): void;
  136537. /**
  136538. * Updates the distance parameters of the joint
  136539. * @param joint joint to update
  136540. * @param maxDistance maximum distance of the joint
  136541. * @param minDistance minimum distance of the joint
  136542. */
  136543. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  136544. /**
  136545. * Sets a motor on the joint
  136546. * @param joint joint to set motor on
  136547. * @param speed speed of the motor
  136548. * @param maxForce maximum force of the motor
  136549. * @param motorIndex index of the motor
  136550. */
  136551. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  136552. /**
  136553. * Sets the motors limit
  136554. * @param joint joint to set limit on
  136555. * @param upperLimit upper limit
  136556. * @param lowerLimit lower limit
  136557. */
  136558. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  136559. /**
  136560. * Syncs the position and rotation of a mesh with the impostor
  136561. * @param mesh mesh to sync
  136562. * @param impostor impostor to update the mesh with
  136563. */
  136564. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  136565. /**
  136566. * Gets the radius of the impostor
  136567. * @param impostor impostor to get radius from
  136568. * @returns the radius
  136569. */
  136570. getRadius(impostor: PhysicsImpostor): number;
  136571. /**
  136572. * Gets the box size of the impostor
  136573. * @param impostor impostor to get box size from
  136574. * @param result the resulting box size
  136575. */
  136576. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  136577. /**
  136578. * Disposes of the impostor
  136579. */
  136580. dispose(): void;
  136581. /**
  136582. * Does a raycast in the physics world
  136583. * @param from when should the ray start?
  136584. * @param to when should the ray end?
  136585. * @returns PhysicsRaycastResult
  136586. */
  136587. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  136588. }
  136589. }
  136590. declare module BABYLON {
  136591. interface AbstractScene {
  136592. /**
  136593. * The list of reflection probes added to the scene
  136594. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  136595. */
  136596. reflectionProbes: Array<ReflectionProbe>;
  136597. /**
  136598. * Removes the given reflection probe from this scene.
  136599. * @param toRemove The reflection probe to remove
  136600. * @returns The index of the removed reflection probe
  136601. */
  136602. removeReflectionProbe(toRemove: ReflectionProbe): number;
  136603. /**
  136604. * Adds the given reflection probe to this scene.
  136605. * @param newReflectionProbe The reflection probe to add
  136606. */
  136607. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  136608. }
  136609. /**
  136610. * Class used to generate realtime reflection / refraction cube textures
  136611. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  136612. */
  136613. export class ReflectionProbe {
  136614. /** defines the name of the probe */
  136615. name: string;
  136616. private _scene;
  136617. private _renderTargetTexture;
  136618. private _projectionMatrix;
  136619. private _viewMatrix;
  136620. private _target;
  136621. private _add;
  136622. private _attachedMesh;
  136623. private _invertYAxis;
  136624. /** Gets or sets probe position (center of the cube map) */
  136625. position: Vector3;
  136626. /**
  136627. * Creates a new reflection probe
  136628. * @param name defines the name of the probe
  136629. * @param size defines the texture resolution (for each face)
  136630. * @param scene defines the hosting scene
  136631. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  136632. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  136633. */
  136634. constructor(
  136635. /** defines the name of the probe */
  136636. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  136637. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  136638. get samples(): number;
  136639. set samples(value: number);
  136640. /** Gets or sets the refresh rate to use (on every frame by default) */
  136641. get refreshRate(): number;
  136642. set refreshRate(value: number);
  136643. /**
  136644. * Gets the hosting scene
  136645. * @returns a Scene
  136646. */
  136647. getScene(): Scene;
  136648. /** Gets the internal CubeTexture used to render to */
  136649. get cubeTexture(): RenderTargetTexture;
  136650. /** Gets the list of meshes to render */
  136651. get renderList(): Nullable<AbstractMesh[]>;
  136652. /**
  136653. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  136654. * @param mesh defines the mesh to attach to
  136655. */
  136656. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  136657. /**
  136658. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  136659. * @param renderingGroupId The rendering group id corresponding to its index
  136660. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  136661. */
  136662. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  136663. /**
  136664. * Clean all associated resources
  136665. */
  136666. dispose(): void;
  136667. /**
  136668. * Converts the reflection probe information to a readable string for debug purpose.
  136669. * @param fullDetails Supports for multiple levels of logging within scene loading
  136670. * @returns the human readable reflection probe info
  136671. */
  136672. toString(fullDetails?: boolean): string;
  136673. /**
  136674. * Get the class name of the relfection probe.
  136675. * @returns "ReflectionProbe"
  136676. */
  136677. getClassName(): string;
  136678. /**
  136679. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  136680. * @returns The JSON representation of the texture
  136681. */
  136682. serialize(): any;
  136683. /**
  136684. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  136685. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  136686. * @param scene Define the scene the parsed reflection probe should be instantiated in
  136687. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  136688. * @returns The parsed reflection probe if successful
  136689. */
  136690. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  136691. }
  136692. }
  136693. declare module BABYLON {
  136694. /** @hidden */
  136695. export var _BabylonLoaderRegistered: boolean;
  136696. /**
  136697. * Helps setting up some configuration for the babylon file loader.
  136698. */
  136699. export class BabylonFileLoaderConfiguration {
  136700. /**
  136701. * The loader does not allow injecting custom physix engine into the plugins.
  136702. * Unfortunately in ES6, we need to manually inject them into the plugin.
  136703. * So you could set this variable to your engine import to make it work.
  136704. */
  136705. static LoaderInjectedPhysicsEngine: any;
  136706. }
  136707. }
  136708. declare module BABYLON {
  136709. /**
  136710. * The Physically based simple base material of BJS.
  136711. *
  136712. * This enables better naming and convention enforcements on top of the pbrMaterial.
  136713. * It is used as the base class for both the specGloss and metalRough conventions.
  136714. */
  136715. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  136716. /**
  136717. * Number of Simultaneous lights allowed on the material.
  136718. */
  136719. maxSimultaneousLights: number;
  136720. /**
  136721. * If sets to true, disables all the lights affecting the material.
  136722. */
  136723. disableLighting: boolean;
  136724. /**
  136725. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  136726. */
  136727. environmentTexture: BaseTexture;
  136728. /**
  136729. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  136730. */
  136731. invertNormalMapX: boolean;
  136732. /**
  136733. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  136734. */
  136735. invertNormalMapY: boolean;
  136736. /**
  136737. * Normal map used in the model.
  136738. */
  136739. normalTexture: BaseTexture;
  136740. /**
  136741. * Emissivie color used to self-illuminate the model.
  136742. */
  136743. emissiveColor: Color3;
  136744. /**
  136745. * Emissivie texture used to self-illuminate the model.
  136746. */
  136747. emissiveTexture: BaseTexture;
  136748. /**
  136749. * Occlusion Channel Strenght.
  136750. */
  136751. occlusionStrength: number;
  136752. /**
  136753. * Occlusion Texture of the material (adding extra occlusion effects).
  136754. */
  136755. occlusionTexture: BaseTexture;
  136756. /**
  136757. * Defines the alpha limits in alpha test mode.
  136758. */
  136759. alphaCutOff: number;
  136760. /**
  136761. * Gets the current double sided mode.
  136762. */
  136763. get doubleSided(): boolean;
  136764. /**
  136765. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  136766. */
  136767. set doubleSided(value: boolean);
  136768. /**
  136769. * Stores the pre-calculated light information of a mesh in a texture.
  136770. */
  136771. lightmapTexture: BaseTexture;
  136772. /**
  136773. * If true, the light map contains occlusion information instead of lighting info.
  136774. */
  136775. useLightmapAsShadowmap: boolean;
  136776. /**
  136777. * Instantiates a new PBRMaterial instance.
  136778. *
  136779. * @param name The material name
  136780. * @param scene The scene the material will be use in.
  136781. */
  136782. constructor(name: string, scene: Scene);
  136783. getClassName(): string;
  136784. }
  136785. }
  136786. declare module BABYLON {
  136787. /**
  136788. * The PBR material of BJS following the metal roughness convention.
  136789. *
  136790. * This fits to the PBR convention in the GLTF definition:
  136791. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  136792. */
  136793. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  136794. /**
  136795. * The base color has two different interpretations depending on the value of metalness.
  136796. * When the material is a metal, the base color is the specific measured reflectance value
  136797. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  136798. * of the material.
  136799. */
  136800. baseColor: Color3;
  136801. /**
  136802. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  136803. * well as opacity information in the alpha channel.
  136804. */
  136805. baseTexture: BaseTexture;
  136806. /**
  136807. * Specifies the metallic scalar value of the material.
  136808. * Can also be used to scale the metalness values of the metallic texture.
  136809. */
  136810. metallic: number;
  136811. /**
  136812. * Specifies the roughness scalar value of the material.
  136813. * Can also be used to scale the roughness values of the metallic texture.
  136814. */
  136815. roughness: number;
  136816. /**
  136817. * Texture containing both the metallic value in the B channel and the
  136818. * roughness value in the G channel to keep better precision.
  136819. */
  136820. metallicRoughnessTexture: BaseTexture;
  136821. /**
  136822. * Instantiates a new PBRMetalRoughnessMaterial instance.
  136823. *
  136824. * @param name The material name
  136825. * @param scene The scene the material will be use in.
  136826. */
  136827. constructor(name: string, scene: Scene);
  136828. /**
  136829. * Return the currrent class name of the material.
  136830. */
  136831. getClassName(): string;
  136832. /**
  136833. * Makes a duplicate of the current material.
  136834. * @param name - name to use for the new material.
  136835. */
  136836. clone(name: string): PBRMetallicRoughnessMaterial;
  136837. /**
  136838. * Serialize the material to a parsable JSON object.
  136839. */
  136840. serialize(): any;
  136841. /**
  136842. * Parses a JSON object correponding to the serialize function.
  136843. */
  136844. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  136845. }
  136846. }
  136847. declare module BABYLON {
  136848. /**
  136849. * The PBR material of BJS following the specular glossiness convention.
  136850. *
  136851. * This fits to the PBR convention in the GLTF definition:
  136852. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  136853. */
  136854. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  136855. /**
  136856. * Specifies the diffuse color of the material.
  136857. */
  136858. diffuseColor: Color3;
  136859. /**
  136860. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  136861. * channel.
  136862. */
  136863. diffuseTexture: BaseTexture;
  136864. /**
  136865. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  136866. */
  136867. specularColor: Color3;
  136868. /**
  136869. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  136870. */
  136871. glossiness: number;
  136872. /**
  136873. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  136874. */
  136875. specularGlossinessTexture: BaseTexture;
  136876. /**
  136877. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  136878. *
  136879. * @param name The material name
  136880. * @param scene The scene the material will be use in.
  136881. */
  136882. constructor(name: string, scene: Scene);
  136883. /**
  136884. * Return the currrent class name of the material.
  136885. */
  136886. getClassName(): string;
  136887. /**
  136888. * Makes a duplicate of the current material.
  136889. * @param name - name to use for the new material.
  136890. */
  136891. clone(name: string): PBRSpecularGlossinessMaterial;
  136892. /**
  136893. * Serialize the material to a parsable JSON object.
  136894. */
  136895. serialize(): any;
  136896. /**
  136897. * Parses a JSON object correponding to the serialize function.
  136898. */
  136899. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  136900. }
  136901. }
  136902. declare module BABYLON {
  136903. /**
  136904. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  136905. * It can help converting any input color in a desired output one. This can then be used to create effects
  136906. * from sepia, black and white to sixties or futuristic rendering...
  136907. *
  136908. * The only supported format is currently 3dl.
  136909. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  136910. */
  136911. export class ColorGradingTexture extends BaseTexture {
  136912. /**
  136913. * The texture URL.
  136914. */
  136915. url: string;
  136916. /**
  136917. * Empty line regex stored for GC.
  136918. */
  136919. private static _noneEmptyLineRegex;
  136920. private _textureMatrix;
  136921. private _onLoad;
  136922. /**
  136923. * Instantiates a ColorGradingTexture from the following parameters.
  136924. *
  136925. * @param url The location of the color gradind data (currently only supporting 3dl)
  136926. * @param sceneOrEngine The scene or engine the texture will be used in
  136927. * @param onLoad defines a callback triggered when the texture has been loaded
  136928. */
  136929. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  136930. /**
  136931. * Fires the onload event from the constructor if requested.
  136932. */
  136933. private _triggerOnLoad;
  136934. /**
  136935. * Returns the texture matrix used in most of the material.
  136936. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  136937. */
  136938. getTextureMatrix(): Matrix;
  136939. /**
  136940. * Occurs when the file being loaded is a .3dl LUT file.
  136941. */
  136942. private load3dlTexture;
  136943. /**
  136944. * Starts the loading process of the texture.
  136945. */
  136946. private loadTexture;
  136947. /**
  136948. * Clones the color gradind texture.
  136949. */
  136950. clone(): ColorGradingTexture;
  136951. /**
  136952. * Called during delayed load for textures.
  136953. */
  136954. delayLoad(): void;
  136955. /**
  136956. * Parses a color grading texture serialized by Babylon.
  136957. * @param parsedTexture The texture information being parsedTexture
  136958. * @param scene The scene to load the texture in
  136959. * @param rootUrl The root url of the data assets to load
  136960. * @return A color gradind texture
  136961. */
  136962. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  136963. /**
  136964. * Serializes the LUT texture to json format.
  136965. */
  136966. serialize(): any;
  136967. }
  136968. }
  136969. declare module BABYLON {
  136970. /**
  136971. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  136972. */
  136973. export class EquiRectangularCubeTexture extends BaseTexture {
  136974. /** The six faces of the cube. */
  136975. private static _FacesMapping;
  136976. private _noMipmap;
  136977. private _onLoad;
  136978. private _onError;
  136979. /** The size of the cubemap. */
  136980. private _size;
  136981. /** The buffer of the image. */
  136982. private _buffer;
  136983. /** The width of the input image. */
  136984. private _width;
  136985. /** The height of the input image. */
  136986. private _height;
  136987. /** The URL to the image. */
  136988. url: string;
  136989. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  136990. coordinatesMode: number;
  136991. /**
  136992. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  136993. * @param url The location of the image
  136994. * @param scene The scene the texture will be used in
  136995. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  136996. * @param noMipmap Forces to not generate the mipmap if true
  136997. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  136998. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  136999. * @param onLoad — defines a callback called when texture is loaded
  137000. * @param onError — defines a callback called if there is an error
  137001. */
  137002. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  137003. /**
  137004. * Load the image data, by putting the image on a canvas and extracting its buffer.
  137005. */
  137006. private loadImage;
  137007. /**
  137008. * Convert the image buffer into a cubemap and create a CubeTexture.
  137009. */
  137010. private loadTexture;
  137011. /**
  137012. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  137013. * @param buffer The ArrayBuffer that should be converted.
  137014. * @returns The buffer as Float32Array.
  137015. */
  137016. private getFloat32ArrayFromArrayBuffer;
  137017. /**
  137018. * Get the current class name of the texture useful for serialization or dynamic coding.
  137019. * @returns "EquiRectangularCubeTexture"
  137020. */
  137021. getClassName(): string;
  137022. /**
  137023. * Create a clone of the current EquiRectangularCubeTexture and return it.
  137024. * @returns A clone of the current EquiRectangularCubeTexture.
  137025. */
  137026. clone(): EquiRectangularCubeTexture;
  137027. }
  137028. }
  137029. declare module BABYLON {
  137030. /**
  137031. * Defines the options related to the creation of an HtmlElementTexture
  137032. */
  137033. export interface IHtmlElementTextureOptions {
  137034. /**
  137035. * Defines wether mip maps should be created or not.
  137036. */
  137037. generateMipMaps?: boolean;
  137038. /**
  137039. * Defines the sampling mode of the texture.
  137040. */
  137041. samplingMode?: number;
  137042. /**
  137043. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  137044. */
  137045. engine: Nullable<ThinEngine>;
  137046. /**
  137047. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  137048. */
  137049. scene: Nullable<Scene>;
  137050. }
  137051. /**
  137052. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  137053. * To be as efficient as possible depending on your constraints nothing aside the first upload
  137054. * is automatically managed.
  137055. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  137056. * in your application.
  137057. *
  137058. * As the update is not automatic, you need to call them manually.
  137059. */
  137060. export class HtmlElementTexture extends BaseTexture {
  137061. /**
  137062. * The texture URL.
  137063. */
  137064. element: HTMLVideoElement | HTMLCanvasElement;
  137065. private static readonly DefaultOptions;
  137066. private _textureMatrix;
  137067. private _isVideo;
  137068. private _generateMipMaps;
  137069. private _samplingMode;
  137070. /**
  137071. * Instantiates a HtmlElementTexture from the following parameters.
  137072. *
  137073. * @param name Defines the name of the texture
  137074. * @param element Defines the video or canvas the texture is filled with
  137075. * @param options Defines the other none mandatory texture creation options
  137076. */
  137077. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  137078. private _createInternalTexture;
  137079. /**
  137080. * Returns the texture matrix used in most of the material.
  137081. */
  137082. getTextureMatrix(): Matrix;
  137083. /**
  137084. * Updates the content of the texture.
  137085. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  137086. */
  137087. update(invertY?: Nullable<boolean>): void;
  137088. }
  137089. }
  137090. declare module BABYLON {
  137091. /**
  137092. * Based on jsTGALoader - Javascript loader for TGA file
  137093. * By Vincent Thibault
  137094. * @see http://blog.robrowser.com/javascript-tga-loader.html
  137095. */
  137096. export class TGATools {
  137097. private static _TYPE_INDEXED;
  137098. private static _TYPE_RGB;
  137099. private static _TYPE_GREY;
  137100. private static _TYPE_RLE_INDEXED;
  137101. private static _TYPE_RLE_RGB;
  137102. private static _TYPE_RLE_GREY;
  137103. private static _ORIGIN_MASK;
  137104. private static _ORIGIN_SHIFT;
  137105. private static _ORIGIN_BL;
  137106. private static _ORIGIN_BR;
  137107. private static _ORIGIN_UL;
  137108. private static _ORIGIN_UR;
  137109. /**
  137110. * Gets the header of a TGA file
  137111. * @param data defines the TGA data
  137112. * @returns the header
  137113. */
  137114. static GetTGAHeader(data: Uint8Array): any;
  137115. /**
  137116. * Uploads TGA content to a Babylon Texture
  137117. * @hidden
  137118. */
  137119. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  137120. /** @hidden */
  137121. 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;
  137122. /** @hidden */
  137123. 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;
  137124. /** @hidden */
  137125. 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;
  137126. /** @hidden */
  137127. 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;
  137128. /** @hidden */
  137129. 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;
  137130. /** @hidden */
  137131. 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;
  137132. }
  137133. }
  137134. declare module BABYLON {
  137135. /**
  137136. * Implementation of the TGA Texture Loader.
  137137. * @hidden
  137138. */
  137139. export class _TGATextureLoader implements IInternalTextureLoader {
  137140. /**
  137141. * Defines wether the loader supports cascade loading the different faces.
  137142. */
  137143. readonly supportCascades: boolean;
  137144. /**
  137145. * This returns if the loader support the current file information.
  137146. * @param extension defines the file extension of the file being loaded
  137147. * @returns true if the loader can load the specified file
  137148. */
  137149. canLoad(extension: string): boolean;
  137150. /**
  137151. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  137152. * @param data contains the texture data
  137153. * @param texture defines the BabylonJS internal texture
  137154. * @param createPolynomials will be true if polynomials have been requested
  137155. * @param onLoad defines the callback to trigger once the texture is ready
  137156. * @param onError defines the callback to trigger in case of error
  137157. */
  137158. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  137159. /**
  137160. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  137161. * @param data contains the texture data
  137162. * @param texture defines the BabylonJS internal texture
  137163. * @param callback defines the method to call once ready to upload
  137164. */
  137165. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  137166. }
  137167. }
  137168. declare module BABYLON {
  137169. /**
  137170. * Info about the .basis files
  137171. */
  137172. class BasisFileInfo {
  137173. /**
  137174. * If the file has alpha
  137175. */
  137176. hasAlpha: boolean;
  137177. /**
  137178. * Info about each image of the basis file
  137179. */
  137180. images: Array<{
  137181. levels: Array<{
  137182. width: number;
  137183. height: number;
  137184. transcodedPixels: ArrayBufferView;
  137185. }>;
  137186. }>;
  137187. }
  137188. /**
  137189. * Result of transcoding a basis file
  137190. */
  137191. class TranscodeResult {
  137192. /**
  137193. * Info about the .basis file
  137194. */
  137195. fileInfo: BasisFileInfo;
  137196. /**
  137197. * Format to use when loading the file
  137198. */
  137199. format: number;
  137200. }
  137201. /**
  137202. * Configuration options for the Basis transcoder
  137203. */
  137204. export class BasisTranscodeConfiguration {
  137205. /**
  137206. * Supported compression formats used to determine the supported output format of the transcoder
  137207. */
  137208. supportedCompressionFormats?: {
  137209. /**
  137210. * etc1 compression format
  137211. */
  137212. etc1?: boolean;
  137213. /**
  137214. * s3tc compression format
  137215. */
  137216. s3tc?: boolean;
  137217. /**
  137218. * pvrtc compression format
  137219. */
  137220. pvrtc?: boolean;
  137221. /**
  137222. * etc2 compression format
  137223. */
  137224. etc2?: boolean;
  137225. };
  137226. /**
  137227. * If mipmap levels should be loaded for transcoded images (Default: true)
  137228. */
  137229. loadMipmapLevels?: boolean;
  137230. /**
  137231. * Index of a single image to load (Default: all images)
  137232. */
  137233. loadSingleImage?: number;
  137234. }
  137235. /**
  137236. * Used to load .Basis files
  137237. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  137238. */
  137239. export class BasisTools {
  137240. private static _IgnoreSupportedFormats;
  137241. /**
  137242. * URL to use when loading the basis transcoder
  137243. */
  137244. static JSModuleURL: string;
  137245. /**
  137246. * URL to use when loading the wasm module for the transcoder
  137247. */
  137248. static WasmModuleURL: string;
  137249. /**
  137250. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  137251. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  137252. * @returns internal format corresponding to the Basis format
  137253. */
  137254. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  137255. private static _WorkerPromise;
  137256. private static _Worker;
  137257. private static _actionId;
  137258. private static _CreateWorkerAsync;
  137259. /**
  137260. * Transcodes a loaded image file to compressed pixel data
  137261. * @param data image data to transcode
  137262. * @param config configuration options for the transcoding
  137263. * @returns a promise resulting in the transcoded image
  137264. */
  137265. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  137266. /**
  137267. * Loads a texture from the transcode result
  137268. * @param texture texture load to
  137269. * @param transcodeResult the result of transcoding the basis file to load from
  137270. */
  137271. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  137272. }
  137273. }
  137274. declare module BABYLON {
  137275. /**
  137276. * Loader for .basis file format
  137277. */
  137278. export class _BasisTextureLoader implements IInternalTextureLoader {
  137279. /**
  137280. * Defines whether the loader supports cascade loading the different faces.
  137281. */
  137282. readonly supportCascades: boolean;
  137283. /**
  137284. * This returns if the loader support the current file information.
  137285. * @param extension defines the file extension of the file being loaded
  137286. * @returns true if the loader can load the specified file
  137287. */
  137288. canLoad(extension: string): boolean;
  137289. /**
  137290. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  137291. * @param data contains the texture data
  137292. * @param texture defines the BabylonJS internal texture
  137293. * @param createPolynomials will be true if polynomials have been requested
  137294. * @param onLoad defines the callback to trigger once the texture is ready
  137295. * @param onError defines the callback to trigger in case of error
  137296. */
  137297. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  137298. /**
  137299. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  137300. * @param data contains the texture data
  137301. * @param texture defines the BabylonJS internal texture
  137302. * @param callback defines the method to call once ready to upload
  137303. */
  137304. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  137305. }
  137306. }
  137307. declare module BABYLON {
  137308. /**
  137309. * Defines the basic options interface of a TexturePacker Frame
  137310. */
  137311. export interface ITexturePackerFrame {
  137312. /**
  137313. * The frame ID
  137314. */
  137315. id: number;
  137316. /**
  137317. * The frames Scale
  137318. */
  137319. scale: Vector2;
  137320. /**
  137321. * The Frames offset
  137322. */
  137323. offset: Vector2;
  137324. }
  137325. /**
  137326. * This is a support class for frame Data on texture packer sets.
  137327. */
  137328. export class TexturePackerFrame implements ITexturePackerFrame {
  137329. /**
  137330. * The frame ID
  137331. */
  137332. id: number;
  137333. /**
  137334. * The frames Scale
  137335. */
  137336. scale: Vector2;
  137337. /**
  137338. * The Frames offset
  137339. */
  137340. offset: Vector2;
  137341. /**
  137342. * Initializes a texture package frame.
  137343. * @param id The numerical frame identifier
  137344. * @param scale Scalar Vector2 for UV frame
  137345. * @param offset Vector2 for the frame position in UV units.
  137346. * @returns TexturePackerFrame
  137347. */
  137348. constructor(id: number, scale: Vector2, offset: Vector2);
  137349. }
  137350. }
  137351. declare module BABYLON {
  137352. /**
  137353. * Defines the basic options interface of a TexturePacker
  137354. */
  137355. export interface ITexturePackerOptions {
  137356. /**
  137357. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  137358. */
  137359. map?: string[];
  137360. /**
  137361. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  137362. */
  137363. uvsIn?: string;
  137364. /**
  137365. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  137366. */
  137367. uvsOut?: string;
  137368. /**
  137369. * number representing the layout style. Defaults to LAYOUT_STRIP
  137370. */
  137371. layout?: number;
  137372. /**
  137373. * number of columns if using custom column count layout(2). This defaults to 4.
  137374. */
  137375. colnum?: number;
  137376. /**
  137377. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  137378. */
  137379. updateInputMeshes?: boolean;
  137380. /**
  137381. * boolean flag to dispose all the source textures. Defaults to true.
  137382. */
  137383. disposeSources?: boolean;
  137384. /**
  137385. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  137386. */
  137387. fillBlanks?: boolean;
  137388. /**
  137389. * string value representing the context fill style color. Defaults to 'black'.
  137390. */
  137391. customFillColor?: string;
  137392. /**
  137393. * Width and Height Value of each Frame in the TexturePacker Sets
  137394. */
  137395. frameSize?: number;
  137396. /**
  137397. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  137398. */
  137399. paddingRatio?: number;
  137400. /**
  137401. * Number that declares the fill method for the padding gutter.
  137402. */
  137403. paddingMode?: number;
  137404. /**
  137405. * If in SUBUV_COLOR padding mode what color to use.
  137406. */
  137407. paddingColor?: Color3 | Color4;
  137408. }
  137409. /**
  137410. * Defines the basic interface of a TexturePacker JSON File
  137411. */
  137412. export interface ITexturePackerJSON {
  137413. /**
  137414. * The frame ID
  137415. */
  137416. name: string;
  137417. /**
  137418. * The base64 channel data
  137419. */
  137420. sets: any;
  137421. /**
  137422. * The options of the Packer
  137423. */
  137424. options: ITexturePackerOptions;
  137425. /**
  137426. * The frame data of the Packer
  137427. */
  137428. frames: Array<number>;
  137429. }
  137430. /**
  137431. * This is a support class that generates a series of packed texture sets.
  137432. * @see https://doc.babylonjs.com/babylon101/materials
  137433. */
  137434. export class TexturePacker {
  137435. /** Packer Layout Constant 0 */
  137436. static readonly LAYOUT_STRIP: number;
  137437. /** Packer Layout Constant 1 */
  137438. static readonly LAYOUT_POWER2: number;
  137439. /** Packer Layout Constant 2 */
  137440. static readonly LAYOUT_COLNUM: number;
  137441. /** Packer Layout Constant 0 */
  137442. static readonly SUBUV_WRAP: number;
  137443. /** Packer Layout Constant 1 */
  137444. static readonly SUBUV_EXTEND: number;
  137445. /** Packer Layout Constant 2 */
  137446. static readonly SUBUV_COLOR: number;
  137447. /** The Name of the Texture Package */
  137448. name: string;
  137449. /** The scene scope of the TexturePacker */
  137450. scene: Scene;
  137451. /** The Meshes to target */
  137452. meshes: AbstractMesh[];
  137453. /** Arguments passed with the Constructor */
  137454. options: ITexturePackerOptions;
  137455. /** The promise that is started upon initialization */
  137456. promise: Nullable<Promise<TexturePacker | string>>;
  137457. /** The Container object for the channel sets that are generated */
  137458. sets: object;
  137459. /** The Container array for the frames that are generated */
  137460. frames: TexturePackerFrame[];
  137461. /** The expected number of textures the system is parsing. */
  137462. private _expecting;
  137463. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  137464. private _paddingValue;
  137465. /**
  137466. * Initializes a texture package series from an array of meshes or a single mesh.
  137467. * @param name The name of the package
  137468. * @param meshes The target meshes to compose the package from
  137469. * @param options The arguments that texture packer should follow while building.
  137470. * @param scene The scene which the textures are scoped to.
  137471. * @returns TexturePacker
  137472. */
  137473. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  137474. /**
  137475. * Starts the package process
  137476. * @param resolve The promises resolution function
  137477. * @returns TexturePacker
  137478. */
  137479. private _createFrames;
  137480. /**
  137481. * Calculates the Size of the Channel Sets
  137482. * @returns Vector2
  137483. */
  137484. private _calculateSize;
  137485. /**
  137486. * Calculates the UV data for the frames.
  137487. * @param baseSize the base frameSize
  137488. * @param padding the base frame padding
  137489. * @param dtSize size of the Dynamic Texture for that channel
  137490. * @param dtUnits is 1/dtSize
  137491. * @param update flag to update the input meshes
  137492. */
  137493. private _calculateMeshUVFrames;
  137494. /**
  137495. * Calculates the frames Offset.
  137496. * @param index of the frame
  137497. * @returns Vector2
  137498. */
  137499. private _getFrameOffset;
  137500. /**
  137501. * Updates a Mesh to the frame data
  137502. * @param mesh that is the target
  137503. * @param frameID or the frame index
  137504. */
  137505. private _updateMeshUV;
  137506. /**
  137507. * Updates a Meshes materials to use the texture packer channels
  137508. * @param m is the mesh to target
  137509. * @param force all channels on the packer to be set.
  137510. */
  137511. private _updateTextureReferences;
  137512. /**
  137513. * Public method to set a Mesh to a frame
  137514. * @param m that is the target
  137515. * @param frameID or the frame index
  137516. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  137517. */
  137518. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  137519. /**
  137520. * Starts the async promise to compile the texture packer.
  137521. * @returns Promise<void>
  137522. */
  137523. processAsync(): Promise<void>;
  137524. /**
  137525. * Disposes all textures associated with this packer
  137526. */
  137527. dispose(): void;
  137528. /**
  137529. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  137530. * @param imageType is the image type to use.
  137531. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  137532. */
  137533. download(imageType?: string, quality?: number): void;
  137534. /**
  137535. * Public method to load a texturePacker JSON file.
  137536. * @param data of the JSON file in string format.
  137537. */
  137538. updateFromJSON(data: string): void;
  137539. }
  137540. }
  137541. declare module BABYLON {
  137542. /**
  137543. * 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.
  137544. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  137545. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  137546. */
  137547. export class CustomProceduralTexture extends ProceduralTexture {
  137548. private _animate;
  137549. private _time;
  137550. private _config;
  137551. private _texturePath;
  137552. /**
  137553. * Instantiates a new Custom Procedural Texture.
  137554. * 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.
  137555. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  137556. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  137557. * @param name Define the name of the texture
  137558. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  137559. * @param size Define the size of the texture to create
  137560. * @param scene Define the scene the texture belongs to
  137561. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  137562. * @param generateMipMaps Define if the texture should creates mip maps or not
  137563. */
  137564. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  137565. private _loadJson;
  137566. /**
  137567. * Is the texture ready to be used ? (rendered at least once)
  137568. * @returns true if ready, otherwise, false.
  137569. */
  137570. isReady(): boolean;
  137571. /**
  137572. * Render the texture to its associated render target.
  137573. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  137574. */
  137575. render(useCameraPostProcess?: boolean): void;
  137576. /**
  137577. * Update the list of dependant textures samplers in the shader.
  137578. */
  137579. updateTextures(): void;
  137580. /**
  137581. * Update the uniform values of the procedural texture in the shader.
  137582. */
  137583. updateShaderUniforms(): void;
  137584. /**
  137585. * Define if the texture animates or not.
  137586. */
  137587. get animate(): boolean;
  137588. set animate(value: boolean);
  137589. }
  137590. }
  137591. declare module BABYLON {
  137592. /** @hidden */
  137593. export var noisePixelShader: {
  137594. name: string;
  137595. shader: string;
  137596. };
  137597. }
  137598. declare module BABYLON {
  137599. /**
  137600. * Class used to generate noise procedural textures
  137601. */
  137602. export class NoiseProceduralTexture extends ProceduralTexture {
  137603. private _time;
  137604. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  137605. brightness: number;
  137606. /** Defines the number of octaves to process */
  137607. octaves: number;
  137608. /** Defines the level of persistence (0.8 by default) */
  137609. persistence: number;
  137610. /** Gets or sets animation speed factor (default is 1) */
  137611. animationSpeedFactor: number;
  137612. /**
  137613. * Creates a new NoiseProceduralTexture
  137614. * @param name defines the name fo the texture
  137615. * @param size defines the size of the texture (default is 256)
  137616. * @param scene defines the hosting scene
  137617. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  137618. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  137619. */
  137620. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  137621. private _updateShaderUniforms;
  137622. protected _getDefines(): string;
  137623. /** Generate the current state of the procedural texture */
  137624. render(useCameraPostProcess?: boolean): void;
  137625. /**
  137626. * Serializes this noise procedural texture
  137627. * @returns a serialized noise procedural texture object
  137628. */
  137629. serialize(): any;
  137630. /**
  137631. * Clone the texture.
  137632. * @returns the cloned texture
  137633. */
  137634. clone(): NoiseProceduralTexture;
  137635. /**
  137636. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  137637. * @param parsedTexture defines parsed texture data
  137638. * @param scene defines the current scene
  137639. * @param rootUrl defines the root URL containing noise procedural texture information
  137640. * @returns a parsed NoiseProceduralTexture
  137641. */
  137642. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  137643. }
  137644. }
  137645. declare module BABYLON {
  137646. /**
  137647. * Raw cube texture where the raw buffers are passed in
  137648. */
  137649. export class RawCubeTexture extends CubeTexture {
  137650. /**
  137651. * Creates a cube texture where the raw buffers are passed in.
  137652. * @param scene defines the scene the texture is attached to
  137653. * @param data defines the array of data to use to create each face
  137654. * @param size defines the size of the textures
  137655. * @param format defines the format of the data
  137656. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  137657. * @param generateMipMaps defines if the engine should generate the mip levels
  137658. * @param invertY defines if data must be stored with Y axis inverted
  137659. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  137660. * @param compression defines the compression used (null by default)
  137661. */
  137662. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  137663. /**
  137664. * Updates the raw cube texture.
  137665. * @param data defines the data to store
  137666. * @param format defines the data format
  137667. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  137668. * @param invertY defines if data must be stored with Y axis inverted
  137669. * @param compression defines the compression used (null by default)
  137670. * @param level defines which level of the texture to update
  137671. */
  137672. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  137673. /**
  137674. * Updates a raw cube texture with RGBD encoded data.
  137675. * @param data defines the array of data [mipmap][face] to use to create each face
  137676. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  137677. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  137678. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  137679. * @returns a promsie that resolves when the operation is complete
  137680. */
  137681. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  137682. /**
  137683. * Clones the raw cube texture.
  137684. * @return a new cube texture
  137685. */
  137686. clone(): CubeTexture;
  137687. /** @hidden */
  137688. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  137689. }
  137690. }
  137691. declare module BABYLON {
  137692. /**
  137693. * Class used to store 2D array textures containing user data
  137694. */
  137695. export class RawTexture2DArray extends Texture {
  137696. /** Gets or sets the texture format to use */
  137697. format: number;
  137698. /**
  137699. * Create a new RawTexture2DArray
  137700. * @param data defines the data of the texture
  137701. * @param width defines the width of the texture
  137702. * @param height defines the height of the texture
  137703. * @param depth defines the number of layers of the texture
  137704. * @param format defines the texture format to use
  137705. * @param scene defines the hosting scene
  137706. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  137707. * @param invertY defines if texture must be stored with Y axis inverted
  137708. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  137709. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  137710. */
  137711. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  137712. /** Gets or sets the texture format to use */
  137713. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  137714. /**
  137715. * Update the texture with new data
  137716. * @param data defines the data to store in the texture
  137717. */
  137718. update(data: ArrayBufferView): void;
  137719. }
  137720. }
  137721. declare module BABYLON {
  137722. /**
  137723. * Class used to store 3D textures containing user data
  137724. */
  137725. export class RawTexture3D extends Texture {
  137726. /** Gets or sets the texture format to use */
  137727. format: number;
  137728. /**
  137729. * Create a new RawTexture3D
  137730. * @param data defines the data of the texture
  137731. * @param width defines the width of the texture
  137732. * @param height defines the height of the texture
  137733. * @param depth defines the depth of the texture
  137734. * @param format defines the texture format to use
  137735. * @param scene defines the hosting scene
  137736. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  137737. * @param invertY defines if texture must be stored with Y axis inverted
  137738. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  137739. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  137740. */
  137741. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  137742. /** Gets or sets the texture format to use */
  137743. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  137744. /**
  137745. * Update the texture with new data
  137746. * @param data defines the data to store in the texture
  137747. */
  137748. update(data: ArrayBufferView): void;
  137749. }
  137750. }
  137751. declare module BABYLON {
  137752. /**
  137753. * Creates a refraction texture used by refraction channel of the standard material.
  137754. * It is like a mirror but to see through a material.
  137755. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  137756. */
  137757. export class RefractionTexture extends RenderTargetTexture {
  137758. /**
  137759. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  137760. * 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.
  137761. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  137762. */
  137763. refractionPlane: Plane;
  137764. /**
  137765. * Define how deep under the surface we should see.
  137766. */
  137767. depth: number;
  137768. /**
  137769. * Creates a refraction texture used by refraction channel of the standard material.
  137770. * It is like a mirror but to see through a material.
  137771. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  137772. * @param name Define the texture name
  137773. * @param size Define the size of the underlying texture
  137774. * @param scene Define the scene the refraction belongs to
  137775. * @param generateMipMaps Define if we need to generate mips level for the refraction
  137776. */
  137777. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  137778. /**
  137779. * Clone the refraction texture.
  137780. * @returns the cloned texture
  137781. */
  137782. clone(): RefractionTexture;
  137783. /**
  137784. * Serialize the texture to a JSON representation you could use in Parse later on
  137785. * @returns the serialized JSON representation
  137786. */
  137787. serialize(): any;
  137788. }
  137789. }
  137790. declare module BABYLON {
  137791. /**
  137792. * Block used to add support for vertex skinning (bones)
  137793. */
  137794. export class BonesBlock extends NodeMaterialBlock {
  137795. /**
  137796. * Creates a new BonesBlock
  137797. * @param name defines the block name
  137798. */
  137799. constructor(name: string);
  137800. /**
  137801. * Initialize the block and prepare the context for build
  137802. * @param state defines the state that will be used for the build
  137803. */
  137804. initialize(state: NodeMaterialBuildState): void;
  137805. /**
  137806. * Gets the current class name
  137807. * @returns the class name
  137808. */
  137809. getClassName(): string;
  137810. /**
  137811. * Gets the matrix indices input component
  137812. */
  137813. get matricesIndices(): NodeMaterialConnectionPoint;
  137814. /**
  137815. * Gets the matrix weights input component
  137816. */
  137817. get matricesWeights(): NodeMaterialConnectionPoint;
  137818. /**
  137819. * Gets the extra matrix indices input component
  137820. */
  137821. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  137822. /**
  137823. * Gets the extra matrix weights input component
  137824. */
  137825. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  137826. /**
  137827. * Gets the world input component
  137828. */
  137829. get world(): NodeMaterialConnectionPoint;
  137830. /**
  137831. * Gets the output component
  137832. */
  137833. get output(): NodeMaterialConnectionPoint;
  137834. autoConfigure(material: NodeMaterial): void;
  137835. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  137836. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  137837. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  137838. protected _buildBlock(state: NodeMaterialBuildState): this;
  137839. }
  137840. }
  137841. declare module BABYLON {
  137842. /**
  137843. * Block used to add support for instances
  137844. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  137845. */
  137846. export class InstancesBlock extends NodeMaterialBlock {
  137847. /**
  137848. * Creates a new InstancesBlock
  137849. * @param name defines the block name
  137850. */
  137851. constructor(name: string);
  137852. /**
  137853. * Gets the current class name
  137854. * @returns the class name
  137855. */
  137856. getClassName(): string;
  137857. /**
  137858. * Gets the first world row input component
  137859. */
  137860. get world0(): NodeMaterialConnectionPoint;
  137861. /**
  137862. * Gets the second world row input component
  137863. */
  137864. get world1(): NodeMaterialConnectionPoint;
  137865. /**
  137866. * Gets the third world row input component
  137867. */
  137868. get world2(): NodeMaterialConnectionPoint;
  137869. /**
  137870. * Gets the forth world row input component
  137871. */
  137872. get world3(): NodeMaterialConnectionPoint;
  137873. /**
  137874. * Gets the world input component
  137875. */
  137876. get world(): NodeMaterialConnectionPoint;
  137877. /**
  137878. * Gets the output component
  137879. */
  137880. get output(): NodeMaterialConnectionPoint;
  137881. /**
  137882. * Gets the isntanceID component
  137883. */
  137884. get instanceID(): NodeMaterialConnectionPoint;
  137885. autoConfigure(material: NodeMaterial): void;
  137886. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  137887. protected _buildBlock(state: NodeMaterialBuildState): this;
  137888. }
  137889. }
  137890. declare module BABYLON {
  137891. /**
  137892. * Block used to add morph targets support to vertex shader
  137893. */
  137894. export class MorphTargetsBlock extends NodeMaterialBlock {
  137895. private _repeatableContentAnchor;
  137896. /**
  137897. * Create a new MorphTargetsBlock
  137898. * @param name defines the block name
  137899. */
  137900. constructor(name: string);
  137901. /**
  137902. * Gets the current class name
  137903. * @returns the class name
  137904. */
  137905. getClassName(): string;
  137906. /**
  137907. * Gets the position input component
  137908. */
  137909. get position(): NodeMaterialConnectionPoint;
  137910. /**
  137911. * Gets the normal input component
  137912. */
  137913. get normal(): NodeMaterialConnectionPoint;
  137914. /**
  137915. * Gets the tangent input component
  137916. */
  137917. get tangent(): NodeMaterialConnectionPoint;
  137918. /**
  137919. * Gets the tangent input component
  137920. */
  137921. get uv(): NodeMaterialConnectionPoint;
  137922. /**
  137923. * Gets the position output component
  137924. */
  137925. get positionOutput(): NodeMaterialConnectionPoint;
  137926. /**
  137927. * Gets the normal output component
  137928. */
  137929. get normalOutput(): NodeMaterialConnectionPoint;
  137930. /**
  137931. * Gets the tangent output component
  137932. */
  137933. get tangentOutput(): NodeMaterialConnectionPoint;
  137934. /**
  137935. * Gets the tangent output component
  137936. */
  137937. get uvOutput(): NodeMaterialConnectionPoint;
  137938. initialize(state: NodeMaterialBuildState): void;
  137939. autoConfigure(material: NodeMaterial): void;
  137940. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  137941. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  137942. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  137943. protected _buildBlock(state: NodeMaterialBuildState): this;
  137944. }
  137945. }
  137946. declare module BABYLON {
  137947. /**
  137948. * Block used to get data information from a light
  137949. */
  137950. export class LightInformationBlock extends NodeMaterialBlock {
  137951. private _lightDataUniformName;
  137952. private _lightColorUniformName;
  137953. private _lightTypeDefineName;
  137954. /**
  137955. * Gets or sets the light associated with this block
  137956. */
  137957. light: Nullable<Light>;
  137958. /**
  137959. * Creates a new LightInformationBlock
  137960. * @param name defines the block name
  137961. */
  137962. constructor(name: string);
  137963. /**
  137964. * Gets the current class name
  137965. * @returns the class name
  137966. */
  137967. getClassName(): string;
  137968. /**
  137969. * Gets the world position input component
  137970. */
  137971. get worldPosition(): NodeMaterialConnectionPoint;
  137972. /**
  137973. * Gets the direction output component
  137974. */
  137975. get direction(): NodeMaterialConnectionPoint;
  137976. /**
  137977. * Gets the direction output component
  137978. */
  137979. get color(): NodeMaterialConnectionPoint;
  137980. /**
  137981. * Gets the direction output component
  137982. */
  137983. get intensity(): NodeMaterialConnectionPoint;
  137984. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  137985. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  137986. protected _buildBlock(state: NodeMaterialBuildState): this;
  137987. serialize(): any;
  137988. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  137989. }
  137990. }
  137991. declare module BABYLON {
  137992. /**
  137993. * Block used to add image processing support to fragment shader
  137994. */
  137995. export class ImageProcessingBlock extends NodeMaterialBlock {
  137996. /**
  137997. * Create a new ImageProcessingBlock
  137998. * @param name defines the block name
  137999. */
  138000. constructor(name: string);
  138001. /**
  138002. * Gets the current class name
  138003. * @returns the class name
  138004. */
  138005. getClassName(): string;
  138006. /**
  138007. * Gets the color input component
  138008. */
  138009. get color(): NodeMaterialConnectionPoint;
  138010. /**
  138011. * Gets the output component
  138012. */
  138013. get output(): NodeMaterialConnectionPoint;
  138014. /**
  138015. * Initialize the block and prepare the context for build
  138016. * @param state defines the state that will be used for the build
  138017. */
  138018. initialize(state: NodeMaterialBuildState): void;
  138019. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  138020. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  138021. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  138022. protected _buildBlock(state: NodeMaterialBuildState): this;
  138023. }
  138024. }
  138025. declare module BABYLON {
  138026. /**
  138027. * Block used to pertub normals based on a normal map
  138028. */
  138029. export class PerturbNormalBlock extends NodeMaterialBlock {
  138030. private _tangentSpaceParameterName;
  138031. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  138032. invertX: boolean;
  138033. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  138034. invertY: boolean;
  138035. /**
  138036. * Create a new PerturbNormalBlock
  138037. * @param name defines the block name
  138038. */
  138039. constructor(name: string);
  138040. /**
  138041. * Gets the current class name
  138042. * @returns the class name
  138043. */
  138044. getClassName(): string;
  138045. /**
  138046. * Gets the world position input component
  138047. */
  138048. get worldPosition(): NodeMaterialConnectionPoint;
  138049. /**
  138050. * Gets the world normal input component
  138051. */
  138052. get worldNormal(): NodeMaterialConnectionPoint;
  138053. /**
  138054. * Gets the world tangent input component
  138055. */
  138056. get worldTangent(): NodeMaterialConnectionPoint;
  138057. /**
  138058. * Gets the uv input component
  138059. */
  138060. get uv(): NodeMaterialConnectionPoint;
  138061. /**
  138062. * Gets the normal map color input component
  138063. */
  138064. get normalMapColor(): NodeMaterialConnectionPoint;
  138065. /**
  138066. * Gets the strength input component
  138067. */
  138068. get strength(): NodeMaterialConnectionPoint;
  138069. /**
  138070. * Gets the output component
  138071. */
  138072. get output(): NodeMaterialConnectionPoint;
  138073. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  138074. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  138075. autoConfigure(material: NodeMaterial): void;
  138076. protected _buildBlock(state: NodeMaterialBuildState): this;
  138077. protected _dumpPropertiesCode(): string;
  138078. serialize(): any;
  138079. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  138080. }
  138081. }
  138082. declare module BABYLON {
  138083. /**
  138084. * Block used to discard a pixel if a value is smaller than a cutoff
  138085. */
  138086. export class DiscardBlock extends NodeMaterialBlock {
  138087. /**
  138088. * Create a new DiscardBlock
  138089. * @param name defines the block name
  138090. */
  138091. constructor(name: string);
  138092. /**
  138093. * Gets the current class name
  138094. * @returns the class name
  138095. */
  138096. getClassName(): string;
  138097. /**
  138098. * Gets the color input component
  138099. */
  138100. get value(): NodeMaterialConnectionPoint;
  138101. /**
  138102. * Gets the cutoff input component
  138103. */
  138104. get cutoff(): NodeMaterialConnectionPoint;
  138105. protected _buildBlock(state: NodeMaterialBuildState): this;
  138106. }
  138107. }
  138108. declare module BABYLON {
  138109. /**
  138110. * Block used to test if the fragment shader is front facing
  138111. */
  138112. export class FrontFacingBlock extends NodeMaterialBlock {
  138113. /**
  138114. * Creates a new FrontFacingBlock
  138115. * @param name defines the block name
  138116. */
  138117. constructor(name: string);
  138118. /**
  138119. * Gets the current class name
  138120. * @returns the class name
  138121. */
  138122. getClassName(): string;
  138123. /**
  138124. * Gets the output component
  138125. */
  138126. get output(): NodeMaterialConnectionPoint;
  138127. protected _buildBlock(state: NodeMaterialBuildState): this;
  138128. }
  138129. }
  138130. declare module BABYLON {
  138131. /**
  138132. * Block used to get the derivative value on x and y of a given input
  138133. */
  138134. export class DerivativeBlock extends NodeMaterialBlock {
  138135. /**
  138136. * Create a new DerivativeBlock
  138137. * @param name defines the block name
  138138. */
  138139. constructor(name: string);
  138140. /**
  138141. * Gets the current class name
  138142. * @returns the class name
  138143. */
  138144. getClassName(): string;
  138145. /**
  138146. * Gets the input component
  138147. */
  138148. get input(): NodeMaterialConnectionPoint;
  138149. /**
  138150. * Gets the derivative output on x
  138151. */
  138152. get dx(): NodeMaterialConnectionPoint;
  138153. /**
  138154. * Gets the derivative output on y
  138155. */
  138156. get dy(): NodeMaterialConnectionPoint;
  138157. protected _buildBlock(state: NodeMaterialBuildState): this;
  138158. }
  138159. }
  138160. declare module BABYLON {
  138161. /**
  138162. * Block used to add support for scene fog
  138163. */
  138164. export class FogBlock extends NodeMaterialBlock {
  138165. private _fogDistanceName;
  138166. private _fogParameters;
  138167. /**
  138168. * Create a new FogBlock
  138169. * @param name defines the block name
  138170. */
  138171. constructor(name: string);
  138172. /**
  138173. * Gets the current class name
  138174. * @returns the class name
  138175. */
  138176. getClassName(): string;
  138177. /**
  138178. * Gets the world position input component
  138179. */
  138180. get worldPosition(): NodeMaterialConnectionPoint;
  138181. /**
  138182. * Gets the view input component
  138183. */
  138184. get view(): NodeMaterialConnectionPoint;
  138185. /**
  138186. * Gets the color input component
  138187. */
  138188. get input(): NodeMaterialConnectionPoint;
  138189. /**
  138190. * Gets the fog color input component
  138191. */
  138192. get fogColor(): NodeMaterialConnectionPoint;
  138193. /**
  138194. * Gets the output component
  138195. */
  138196. get output(): NodeMaterialConnectionPoint;
  138197. autoConfigure(material: NodeMaterial): void;
  138198. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  138199. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  138200. protected _buildBlock(state: NodeMaterialBuildState): this;
  138201. }
  138202. }
  138203. declare module BABYLON {
  138204. /**
  138205. * Block used to add light in the fragment shader
  138206. */
  138207. export class LightBlock extends NodeMaterialBlock {
  138208. private _lightId;
  138209. /**
  138210. * Gets or sets the light associated with this block
  138211. */
  138212. light: Nullable<Light>;
  138213. /**
  138214. * Create a new LightBlock
  138215. * @param name defines the block name
  138216. */
  138217. constructor(name: string);
  138218. /**
  138219. * Gets the current class name
  138220. * @returns the class name
  138221. */
  138222. getClassName(): string;
  138223. /**
  138224. * Gets the world position input component
  138225. */
  138226. get worldPosition(): NodeMaterialConnectionPoint;
  138227. /**
  138228. * Gets the world normal input component
  138229. */
  138230. get worldNormal(): NodeMaterialConnectionPoint;
  138231. /**
  138232. * Gets the camera (or eye) position component
  138233. */
  138234. get cameraPosition(): NodeMaterialConnectionPoint;
  138235. /**
  138236. * Gets the glossiness component
  138237. */
  138238. get glossiness(): NodeMaterialConnectionPoint;
  138239. /**
  138240. * Gets the glossinness power component
  138241. */
  138242. get glossPower(): NodeMaterialConnectionPoint;
  138243. /**
  138244. * Gets the diffuse color component
  138245. */
  138246. get diffuseColor(): NodeMaterialConnectionPoint;
  138247. /**
  138248. * Gets the specular color component
  138249. */
  138250. get specularColor(): NodeMaterialConnectionPoint;
  138251. /**
  138252. * Gets the diffuse output component
  138253. */
  138254. get diffuseOutput(): NodeMaterialConnectionPoint;
  138255. /**
  138256. * Gets the specular output component
  138257. */
  138258. get specularOutput(): NodeMaterialConnectionPoint;
  138259. /**
  138260. * Gets the shadow output component
  138261. */
  138262. get shadow(): NodeMaterialConnectionPoint;
  138263. autoConfigure(material: NodeMaterial): void;
  138264. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  138265. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  138266. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  138267. private _injectVertexCode;
  138268. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  138269. serialize(): any;
  138270. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  138271. }
  138272. }
  138273. declare module BABYLON {
  138274. /**
  138275. * Block used to read a reflection texture from a sampler
  138276. */
  138277. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  138278. /**
  138279. * Create a new ReflectionTextureBlock
  138280. * @param name defines the block name
  138281. */
  138282. constructor(name: string);
  138283. /**
  138284. * Gets the current class name
  138285. * @returns the class name
  138286. */
  138287. getClassName(): string;
  138288. /**
  138289. * Gets the world position input component
  138290. */
  138291. get position(): NodeMaterialConnectionPoint;
  138292. /**
  138293. * Gets the world position input component
  138294. */
  138295. get worldPosition(): NodeMaterialConnectionPoint;
  138296. /**
  138297. * Gets the world normal input component
  138298. */
  138299. get worldNormal(): NodeMaterialConnectionPoint;
  138300. /**
  138301. * Gets the world input component
  138302. */
  138303. get world(): NodeMaterialConnectionPoint;
  138304. /**
  138305. * Gets the camera (or eye) position component
  138306. */
  138307. get cameraPosition(): NodeMaterialConnectionPoint;
  138308. /**
  138309. * Gets the view input component
  138310. */
  138311. get view(): NodeMaterialConnectionPoint;
  138312. /**
  138313. * Gets the rgb output component
  138314. */
  138315. get rgb(): NodeMaterialConnectionPoint;
  138316. /**
  138317. * Gets the r output component
  138318. */
  138319. get r(): NodeMaterialConnectionPoint;
  138320. /**
  138321. * Gets the g output component
  138322. */
  138323. get g(): NodeMaterialConnectionPoint;
  138324. /**
  138325. * Gets the b output component
  138326. */
  138327. get b(): NodeMaterialConnectionPoint;
  138328. autoConfigure(material: NodeMaterial): void;
  138329. protected _buildBlock(state: NodeMaterialBuildState): this;
  138330. }
  138331. }
  138332. declare module BABYLON {
  138333. /**
  138334. * Block used to add 2 vectors
  138335. */
  138336. export class AddBlock extends NodeMaterialBlock {
  138337. /**
  138338. * Creates a new AddBlock
  138339. * @param name defines the block name
  138340. */
  138341. constructor(name: string);
  138342. /**
  138343. * Gets the current class name
  138344. * @returns the class name
  138345. */
  138346. getClassName(): string;
  138347. /**
  138348. * Gets the left operand input component
  138349. */
  138350. get left(): NodeMaterialConnectionPoint;
  138351. /**
  138352. * Gets the right operand input component
  138353. */
  138354. get right(): NodeMaterialConnectionPoint;
  138355. /**
  138356. * Gets the output component
  138357. */
  138358. get output(): NodeMaterialConnectionPoint;
  138359. protected _buildBlock(state: NodeMaterialBuildState): this;
  138360. }
  138361. }
  138362. declare module BABYLON {
  138363. /**
  138364. * Block used to scale a vector by a float
  138365. */
  138366. export class ScaleBlock extends NodeMaterialBlock {
  138367. /**
  138368. * Creates a new ScaleBlock
  138369. * @param name defines the block name
  138370. */
  138371. constructor(name: string);
  138372. /**
  138373. * Gets the current class name
  138374. * @returns the class name
  138375. */
  138376. getClassName(): string;
  138377. /**
  138378. * Gets the input component
  138379. */
  138380. get input(): NodeMaterialConnectionPoint;
  138381. /**
  138382. * Gets the factor input component
  138383. */
  138384. get factor(): NodeMaterialConnectionPoint;
  138385. /**
  138386. * Gets the output component
  138387. */
  138388. get output(): NodeMaterialConnectionPoint;
  138389. protected _buildBlock(state: NodeMaterialBuildState): this;
  138390. }
  138391. }
  138392. declare module BABYLON {
  138393. /**
  138394. * Block used to clamp a float
  138395. */
  138396. export class ClampBlock extends NodeMaterialBlock {
  138397. /** Gets or sets the minimum range */
  138398. minimum: number;
  138399. /** Gets or sets the maximum range */
  138400. maximum: number;
  138401. /**
  138402. * Creates a new ClampBlock
  138403. * @param name defines the block name
  138404. */
  138405. constructor(name: string);
  138406. /**
  138407. * Gets the current class name
  138408. * @returns the class name
  138409. */
  138410. getClassName(): string;
  138411. /**
  138412. * Gets the value input component
  138413. */
  138414. get value(): NodeMaterialConnectionPoint;
  138415. /**
  138416. * Gets the output component
  138417. */
  138418. get output(): NodeMaterialConnectionPoint;
  138419. protected _buildBlock(state: NodeMaterialBuildState): this;
  138420. protected _dumpPropertiesCode(): string;
  138421. serialize(): any;
  138422. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  138423. }
  138424. }
  138425. declare module BABYLON {
  138426. /**
  138427. * Block used to apply a cross product between 2 vectors
  138428. */
  138429. export class CrossBlock extends NodeMaterialBlock {
  138430. /**
  138431. * Creates a new CrossBlock
  138432. * @param name defines the block name
  138433. */
  138434. constructor(name: string);
  138435. /**
  138436. * Gets the current class name
  138437. * @returns the class name
  138438. */
  138439. getClassName(): string;
  138440. /**
  138441. * Gets the left operand input component
  138442. */
  138443. get left(): NodeMaterialConnectionPoint;
  138444. /**
  138445. * Gets the right operand input component
  138446. */
  138447. get right(): NodeMaterialConnectionPoint;
  138448. /**
  138449. * Gets the output component
  138450. */
  138451. get output(): NodeMaterialConnectionPoint;
  138452. protected _buildBlock(state: NodeMaterialBuildState): this;
  138453. }
  138454. }
  138455. declare module BABYLON {
  138456. /**
  138457. * Block used to apply a dot product between 2 vectors
  138458. */
  138459. export class DotBlock extends NodeMaterialBlock {
  138460. /**
  138461. * Creates a new DotBlock
  138462. * @param name defines the block name
  138463. */
  138464. constructor(name: string);
  138465. /**
  138466. * Gets the current class name
  138467. * @returns the class name
  138468. */
  138469. getClassName(): string;
  138470. /**
  138471. * Gets the left operand input component
  138472. */
  138473. get left(): NodeMaterialConnectionPoint;
  138474. /**
  138475. * Gets the right operand input component
  138476. */
  138477. get right(): NodeMaterialConnectionPoint;
  138478. /**
  138479. * Gets the output component
  138480. */
  138481. get output(): NodeMaterialConnectionPoint;
  138482. protected _buildBlock(state: NodeMaterialBuildState): this;
  138483. }
  138484. }
  138485. declare module BABYLON {
  138486. /**
  138487. * Block used to normalize a vector
  138488. */
  138489. export class NormalizeBlock extends NodeMaterialBlock {
  138490. /**
  138491. * Creates a new NormalizeBlock
  138492. * @param name defines the block name
  138493. */
  138494. constructor(name: string);
  138495. /**
  138496. * Gets the current class name
  138497. * @returns the class name
  138498. */
  138499. getClassName(): string;
  138500. /**
  138501. * Gets the input component
  138502. */
  138503. get input(): NodeMaterialConnectionPoint;
  138504. /**
  138505. * Gets the output component
  138506. */
  138507. get output(): NodeMaterialConnectionPoint;
  138508. protected _buildBlock(state: NodeMaterialBuildState): this;
  138509. }
  138510. }
  138511. declare module BABYLON {
  138512. /**
  138513. * Operations supported by the Trigonometry block
  138514. */
  138515. export enum TrigonometryBlockOperations {
  138516. /** Cos */
  138517. Cos = 0,
  138518. /** Sin */
  138519. Sin = 1,
  138520. /** Abs */
  138521. Abs = 2,
  138522. /** Exp */
  138523. Exp = 3,
  138524. /** Exp2 */
  138525. Exp2 = 4,
  138526. /** Round */
  138527. Round = 5,
  138528. /** Floor */
  138529. Floor = 6,
  138530. /** Ceiling */
  138531. Ceiling = 7,
  138532. /** Square root */
  138533. Sqrt = 8,
  138534. /** Log */
  138535. Log = 9,
  138536. /** Tangent */
  138537. Tan = 10,
  138538. /** Arc tangent */
  138539. ArcTan = 11,
  138540. /** Arc cosinus */
  138541. ArcCos = 12,
  138542. /** Arc sinus */
  138543. ArcSin = 13,
  138544. /** Fraction */
  138545. Fract = 14,
  138546. /** Sign */
  138547. Sign = 15,
  138548. /** To radians (from degrees) */
  138549. Radians = 16,
  138550. /** To degrees (from radians) */
  138551. Degrees = 17
  138552. }
  138553. /**
  138554. * Block used to apply trigonometry operation to floats
  138555. */
  138556. export class TrigonometryBlock extends NodeMaterialBlock {
  138557. /**
  138558. * Gets or sets the operation applied by the block
  138559. */
  138560. operation: TrigonometryBlockOperations;
  138561. /**
  138562. * Creates a new TrigonometryBlock
  138563. * @param name defines the block name
  138564. */
  138565. constructor(name: string);
  138566. /**
  138567. * Gets the current class name
  138568. * @returns the class name
  138569. */
  138570. getClassName(): string;
  138571. /**
  138572. * Gets the input component
  138573. */
  138574. get input(): NodeMaterialConnectionPoint;
  138575. /**
  138576. * Gets the output component
  138577. */
  138578. get output(): NodeMaterialConnectionPoint;
  138579. protected _buildBlock(state: NodeMaterialBuildState): this;
  138580. serialize(): any;
  138581. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  138582. protected _dumpPropertiesCode(): string;
  138583. }
  138584. }
  138585. declare module BABYLON {
  138586. /**
  138587. * Block used to create a Color3/4 out of individual inputs (one for each component)
  138588. */
  138589. export class ColorMergerBlock extends NodeMaterialBlock {
  138590. /**
  138591. * Create a new ColorMergerBlock
  138592. * @param name defines the block name
  138593. */
  138594. constructor(name: string);
  138595. /**
  138596. * Gets the current class name
  138597. * @returns the class name
  138598. */
  138599. getClassName(): string;
  138600. /**
  138601. * Gets the rgb component (input)
  138602. */
  138603. get rgbIn(): NodeMaterialConnectionPoint;
  138604. /**
  138605. * Gets the r component (input)
  138606. */
  138607. get r(): NodeMaterialConnectionPoint;
  138608. /**
  138609. * Gets the g component (input)
  138610. */
  138611. get g(): NodeMaterialConnectionPoint;
  138612. /**
  138613. * Gets the b component (input)
  138614. */
  138615. get b(): NodeMaterialConnectionPoint;
  138616. /**
  138617. * Gets the a component (input)
  138618. */
  138619. get a(): NodeMaterialConnectionPoint;
  138620. /**
  138621. * Gets the rgba component (output)
  138622. */
  138623. get rgba(): NodeMaterialConnectionPoint;
  138624. /**
  138625. * Gets the rgb component (output)
  138626. */
  138627. get rgbOut(): NodeMaterialConnectionPoint;
  138628. /**
  138629. * Gets the rgb component (output)
  138630. * @deprecated Please use rgbOut instead.
  138631. */
  138632. get rgb(): NodeMaterialConnectionPoint;
  138633. protected _buildBlock(state: NodeMaterialBuildState): this;
  138634. }
  138635. }
  138636. declare module BABYLON {
  138637. /**
  138638. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  138639. */
  138640. export class VectorSplitterBlock extends NodeMaterialBlock {
  138641. /**
  138642. * Create a new VectorSplitterBlock
  138643. * @param name defines the block name
  138644. */
  138645. constructor(name: string);
  138646. /**
  138647. * Gets the current class name
  138648. * @returns the class name
  138649. */
  138650. getClassName(): string;
  138651. /**
  138652. * Gets the xyzw component (input)
  138653. */
  138654. get xyzw(): NodeMaterialConnectionPoint;
  138655. /**
  138656. * Gets the xyz component (input)
  138657. */
  138658. get xyzIn(): NodeMaterialConnectionPoint;
  138659. /**
  138660. * Gets the xy component (input)
  138661. */
  138662. get xyIn(): NodeMaterialConnectionPoint;
  138663. /**
  138664. * Gets the xyz component (output)
  138665. */
  138666. get xyzOut(): NodeMaterialConnectionPoint;
  138667. /**
  138668. * Gets the xy component (output)
  138669. */
  138670. get xyOut(): NodeMaterialConnectionPoint;
  138671. /**
  138672. * Gets the x component (output)
  138673. */
  138674. get x(): NodeMaterialConnectionPoint;
  138675. /**
  138676. * Gets the y component (output)
  138677. */
  138678. get y(): NodeMaterialConnectionPoint;
  138679. /**
  138680. * Gets the z component (output)
  138681. */
  138682. get z(): NodeMaterialConnectionPoint;
  138683. /**
  138684. * Gets the w component (output)
  138685. */
  138686. get w(): NodeMaterialConnectionPoint;
  138687. protected _inputRename(name: string): string;
  138688. protected _outputRename(name: string): string;
  138689. protected _buildBlock(state: NodeMaterialBuildState): this;
  138690. }
  138691. }
  138692. declare module BABYLON {
  138693. /**
  138694. * Block used to lerp between 2 values
  138695. */
  138696. export class LerpBlock extends NodeMaterialBlock {
  138697. /**
  138698. * Creates a new LerpBlock
  138699. * @param name defines the block name
  138700. */
  138701. constructor(name: string);
  138702. /**
  138703. * Gets the current class name
  138704. * @returns the class name
  138705. */
  138706. getClassName(): string;
  138707. /**
  138708. * Gets the left operand input component
  138709. */
  138710. get left(): NodeMaterialConnectionPoint;
  138711. /**
  138712. * Gets the right operand input component
  138713. */
  138714. get right(): NodeMaterialConnectionPoint;
  138715. /**
  138716. * Gets the gradient operand input component
  138717. */
  138718. get gradient(): NodeMaterialConnectionPoint;
  138719. /**
  138720. * Gets the output component
  138721. */
  138722. get output(): NodeMaterialConnectionPoint;
  138723. protected _buildBlock(state: NodeMaterialBuildState): this;
  138724. }
  138725. }
  138726. declare module BABYLON {
  138727. /**
  138728. * Block used to divide 2 vectors
  138729. */
  138730. export class DivideBlock extends NodeMaterialBlock {
  138731. /**
  138732. * Creates a new DivideBlock
  138733. * @param name defines the block name
  138734. */
  138735. constructor(name: string);
  138736. /**
  138737. * Gets the current class name
  138738. * @returns the class name
  138739. */
  138740. getClassName(): string;
  138741. /**
  138742. * Gets the left operand input component
  138743. */
  138744. get left(): NodeMaterialConnectionPoint;
  138745. /**
  138746. * Gets the right operand input component
  138747. */
  138748. get right(): NodeMaterialConnectionPoint;
  138749. /**
  138750. * Gets the output component
  138751. */
  138752. get output(): NodeMaterialConnectionPoint;
  138753. protected _buildBlock(state: NodeMaterialBuildState): this;
  138754. }
  138755. }
  138756. declare module BABYLON {
  138757. /**
  138758. * Block used to subtract 2 vectors
  138759. */
  138760. export class SubtractBlock extends NodeMaterialBlock {
  138761. /**
  138762. * Creates a new SubtractBlock
  138763. * @param name defines the block name
  138764. */
  138765. constructor(name: string);
  138766. /**
  138767. * Gets the current class name
  138768. * @returns the class name
  138769. */
  138770. getClassName(): string;
  138771. /**
  138772. * Gets the left operand input component
  138773. */
  138774. get left(): NodeMaterialConnectionPoint;
  138775. /**
  138776. * Gets the right operand input component
  138777. */
  138778. get right(): NodeMaterialConnectionPoint;
  138779. /**
  138780. * Gets the output component
  138781. */
  138782. get output(): NodeMaterialConnectionPoint;
  138783. protected _buildBlock(state: NodeMaterialBuildState): this;
  138784. }
  138785. }
  138786. declare module BABYLON {
  138787. /**
  138788. * Block used to step a value
  138789. */
  138790. export class StepBlock extends NodeMaterialBlock {
  138791. /**
  138792. * Creates a new StepBlock
  138793. * @param name defines the block name
  138794. */
  138795. constructor(name: string);
  138796. /**
  138797. * Gets the current class name
  138798. * @returns the class name
  138799. */
  138800. getClassName(): string;
  138801. /**
  138802. * Gets the value operand input component
  138803. */
  138804. get value(): NodeMaterialConnectionPoint;
  138805. /**
  138806. * Gets the edge operand input component
  138807. */
  138808. get edge(): NodeMaterialConnectionPoint;
  138809. /**
  138810. * Gets the output component
  138811. */
  138812. get output(): NodeMaterialConnectionPoint;
  138813. protected _buildBlock(state: NodeMaterialBuildState): this;
  138814. }
  138815. }
  138816. declare module BABYLON {
  138817. /**
  138818. * Block used to get the opposite (1 - x) of a value
  138819. */
  138820. export class OneMinusBlock extends NodeMaterialBlock {
  138821. /**
  138822. * Creates a new OneMinusBlock
  138823. * @param name defines the block name
  138824. */
  138825. constructor(name: string);
  138826. /**
  138827. * Gets the current class name
  138828. * @returns the class name
  138829. */
  138830. getClassName(): string;
  138831. /**
  138832. * Gets the input component
  138833. */
  138834. get input(): NodeMaterialConnectionPoint;
  138835. /**
  138836. * Gets the output component
  138837. */
  138838. get output(): NodeMaterialConnectionPoint;
  138839. protected _buildBlock(state: NodeMaterialBuildState): this;
  138840. }
  138841. }
  138842. declare module BABYLON {
  138843. /**
  138844. * Block used to get the view direction
  138845. */
  138846. export class ViewDirectionBlock extends NodeMaterialBlock {
  138847. /**
  138848. * Creates a new ViewDirectionBlock
  138849. * @param name defines the block name
  138850. */
  138851. constructor(name: string);
  138852. /**
  138853. * Gets the current class name
  138854. * @returns the class name
  138855. */
  138856. getClassName(): string;
  138857. /**
  138858. * Gets the world position component
  138859. */
  138860. get worldPosition(): NodeMaterialConnectionPoint;
  138861. /**
  138862. * Gets the camera position component
  138863. */
  138864. get cameraPosition(): NodeMaterialConnectionPoint;
  138865. /**
  138866. * Gets the output component
  138867. */
  138868. get output(): NodeMaterialConnectionPoint;
  138869. autoConfigure(material: NodeMaterial): void;
  138870. protected _buildBlock(state: NodeMaterialBuildState): this;
  138871. }
  138872. }
  138873. declare module BABYLON {
  138874. /**
  138875. * Block used to compute fresnel value
  138876. */
  138877. export class FresnelBlock extends NodeMaterialBlock {
  138878. /**
  138879. * Create a new FresnelBlock
  138880. * @param name defines the block name
  138881. */
  138882. constructor(name: string);
  138883. /**
  138884. * Gets the current class name
  138885. * @returns the class name
  138886. */
  138887. getClassName(): string;
  138888. /**
  138889. * Gets the world normal input component
  138890. */
  138891. get worldNormal(): NodeMaterialConnectionPoint;
  138892. /**
  138893. * Gets the view direction input component
  138894. */
  138895. get viewDirection(): NodeMaterialConnectionPoint;
  138896. /**
  138897. * Gets the bias input component
  138898. */
  138899. get bias(): NodeMaterialConnectionPoint;
  138900. /**
  138901. * Gets the camera (or eye) position component
  138902. */
  138903. get power(): NodeMaterialConnectionPoint;
  138904. /**
  138905. * Gets the fresnel output component
  138906. */
  138907. get fresnel(): NodeMaterialConnectionPoint;
  138908. autoConfigure(material: NodeMaterial): void;
  138909. protected _buildBlock(state: NodeMaterialBuildState): this;
  138910. }
  138911. }
  138912. declare module BABYLON {
  138913. /**
  138914. * Block used to get the max of 2 values
  138915. */
  138916. export class MaxBlock extends NodeMaterialBlock {
  138917. /**
  138918. * Creates a new MaxBlock
  138919. * @param name defines the block name
  138920. */
  138921. constructor(name: string);
  138922. /**
  138923. * Gets the current class name
  138924. * @returns the class name
  138925. */
  138926. getClassName(): string;
  138927. /**
  138928. * Gets the left operand input component
  138929. */
  138930. get left(): NodeMaterialConnectionPoint;
  138931. /**
  138932. * Gets the right operand input component
  138933. */
  138934. get right(): NodeMaterialConnectionPoint;
  138935. /**
  138936. * Gets the output component
  138937. */
  138938. get output(): NodeMaterialConnectionPoint;
  138939. protected _buildBlock(state: NodeMaterialBuildState): this;
  138940. }
  138941. }
  138942. declare module BABYLON {
  138943. /**
  138944. * Block used to get the min of 2 values
  138945. */
  138946. export class MinBlock extends NodeMaterialBlock {
  138947. /**
  138948. * Creates a new MinBlock
  138949. * @param name defines the block name
  138950. */
  138951. constructor(name: string);
  138952. /**
  138953. * Gets the current class name
  138954. * @returns the class name
  138955. */
  138956. getClassName(): string;
  138957. /**
  138958. * Gets the left operand input component
  138959. */
  138960. get left(): NodeMaterialConnectionPoint;
  138961. /**
  138962. * Gets the right operand input component
  138963. */
  138964. get right(): NodeMaterialConnectionPoint;
  138965. /**
  138966. * Gets the output component
  138967. */
  138968. get output(): NodeMaterialConnectionPoint;
  138969. protected _buildBlock(state: NodeMaterialBuildState): this;
  138970. }
  138971. }
  138972. declare module BABYLON {
  138973. /**
  138974. * Block used to get the distance between 2 values
  138975. */
  138976. export class DistanceBlock extends NodeMaterialBlock {
  138977. /**
  138978. * Creates a new DistanceBlock
  138979. * @param name defines the block name
  138980. */
  138981. constructor(name: string);
  138982. /**
  138983. * Gets the current class name
  138984. * @returns the class name
  138985. */
  138986. getClassName(): string;
  138987. /**
  138988. * Gets the left operand input component
  138989. */
  138990. get left(): NodeMaterialConnectionPoint;
  138991. /**
  138992. * Gets the right operand input component
  138993. */
  138994. get right(): NodeMaterialConnectionPoint;
  138995. /**
  138996. * Gets the output component
  138997. */
  138998. get output(): NodeMaterialConnectionPoint;
  138999. protected _buildBlock(state: NodeMaterialBuildState): this;
  139000. }
  139001. }
  139002. declare module BABYLON {
  139003. /**
  139004. * Block used to get the length of a vector
  139005. */
  139006. export class LengthBlock extends NodeMaterialBlock {
  139007. /**
  139008. * Creates a new LengthBlock
  139009. * @param name defines the block name
  139010. */
  139011. constructor(name: string);
  139012. /**
  139013. * Gets the current class name
  139014. * @returns the class name
  139015. */
  139016. getClassName(): string;
  139017. /**
  139018. * Gets the value input component
  139019. */
  139020. get value(): NodeMaterialConnectionPoint;
  139021. /**
  139022. * Gets the output component
  139023. */
  139024. get output(): NodeMaterialConnectionPoint;
  139025. protected _buildBlock(state: NodeMaterialBuildState): this;
  139026. }
  139027. }
  139028. declare module BABYLON {
  139029. /**
  139030. * Block used to get negative version of a value (i.e. x * -1)
  139031. */
  139032. export class NegateBlock extends NodeMaterialBlock {
  139033. /**
  139034. * Creates a new NegateBlock
  139035. * @param name defines the block name
  139036. */
  139037. constructor(name: string);
  139038. /**
  139039. * Gets the current class name
  139040. * @returns the class name
  139041. */
  139042. getClassName(): string;
  139043. /**
  139044. * Gets the value input component
  139045. */
  139046. get value(): NodeMaterialConnectionPoint;
  139047. /**
  139048. * Gets the output component
  139049. */
  139050. get output(): NodeMaterialConnectionPoint;
  139051. protected _buildBlock(state: NodeMaterialBuildState): this;
  139052. }
  139053. }
  139054. declare module BABYLON {
  139055. /**
  139056. * Block used to get the value of the first parameter raised to the power of the second
  139057. */
  139058. export class PowBlock extends NodeMaterialBlock {
  139059. /**
  139060. * Creates a new PowBlock
  139061. * @param name defines the block name
  139062. */
  139063. constructor(name: string);
  139064. /**
  139065. * Gets the current class name
  139066. * @returns the class name
  139067. */
  139068. getClassName(): string;
  139069. /**
  139070. * Gets the value operand input component
  139071. */
  139072. get value(): NodeMaterialConnectionPoint;
  139073. /**
  139074. * Gets the power operand input component
  139075. */
  139076. get power(): NodeMaterialConnectionPoint;
  139077. /**
  139078. * Gets the output component
  139079. */
  139080. get output(): NodeMaterialConnectionPoint;
  139081. protected _buildBlock(state: NodeMaterialBuildState): this;
  139082. }
  139083. }
  139084. declare module BABYLON {
  139085. /**
  139086. * Block used to get a random number
  139087. */
  139088. export class RandomNumberBlock extends NodeMaterialBlock {
  139089. /**
  139090. * Creates a new RandomNumberBlock
  139091. * @param name defines the block name
  139092. */
  139093. constructor(name: string);
  139094. /**
  139095. * Gets the current class name
  139096. * @returns the class name
  139097. */
  139098. getClassName(): string;
  139099. /**
  139100. * Gets the seed input component
  139101. */
  139102. get seed(): NodeMaterialConnectionPoint;
  139103. /**
  139104. * Gets the output component
  139105. */
  139106. get output(): NodeMaterialConnectionPoint;
  139107. protected _buildBlock(state: NodeMaterialBuildState): this;
  139108. }
  139109. }
  139110. declare module BABYLON {
  139111. /**
  139112. * Block used to compute arc tangent of 2 values
  139113. */
  139114. export class ArcTan2Block extends NodeMaterialBlock {
  139115. /**
  139116. * Creates a new ArcTan2Block
  139117. * @param name defines the block name
  139118. */
  139119. constructor(name: string);
  139120. /**
  139121. * Gets the current class name
  139122. * @returns the class name
  139123. */
  139124. getClassName(): string;
  139125. /**
  139126. * Gets the x operand input component
  139127. */
  139128. get x(): NodeMaterialConnectionPoint;
  139129. /**
  139130. * Gets the y operand input component
  139131. */
  139132. get y(): NodeMaterialConnectionPoint;
  139133. /**
  139134. * Gets the output component
  139135. */
  139136. get output(): NodeMaterialConnectionPoint;
  139137. protected _buildBlock(state: NodeMaterialBuildState): this;
  139138. }
  139139. }
  139140. declare module BABYLON {
  139141. /**
  139142. * Block used to smooth step a value
  139143. */
  139144. export class SmoothStepBlock extends NodeMaterialBlock {
  139145. /**
  139146. * Creates a new SmoothStepBlock
  139147. * @param name defines the block name
  139148. */
  139149. constructor(name: string);
  139150. /**
  139151. * Gets the current class name
  139152. * @returns the class name
  139153. */
  139154. getClassName(): string;
  139155. /**
  139156. * Gets the value operand input component
  139157. */
  139158. get value(): NodeMaterialConnectionPoint;
  139159. /**
  139160. * Gets the first edge operand input component
  139161. */
  139162. get edge0(): NodeMaterialConnectionPoint;
  139163. /**
  139164. * Gets the second edge operand input component
  139165. */
  139166. get edge1(): NodeMaterialConnectionPoint;
  139167. /**
  139168. * Gets the output component
  139169. */
  139170. get output(): NodeMaterialConnectionPoint;
  139171. protected _buildBlock(state: NodeMaterialBuildState): this;
  139172. }
  139173. }
  139174. declare module BABYLON {
  139175. /**
  139176. * Block used to get the reciprocal (1 / x) of a value
  139177. */
  139178. export class ReciprocalBlock extends NodeMaterialBlock {
  139179. /**
  139180. * Creates a new ReciprocalBlock
  139181. * @param name defines the block name
  139182. */
  139183. constructor(name: string);
  139184. /**
  139185. * Gets the current class name
  139186. * @returns the class name
  139187. */
  139188. getClassName(): string;
  139189. /**
  139190. * Gets the input component
  139191. */
  139192. get input(): NodeMaterialConnectionPoint;
  139193. /**
  139194. * Gets the output component
  139195. */
  139196. get output(): NodeMaterialConnectionPoint;
  139197. protected _buildBlock(state: NodeMaterialBuildState): this;
  139198. }
  139199. }
  139200. declare module BABYLON {
  139201. /**
  139202. * Block used to replace a color by another one
  139203. */
  139204. export class ReplaceColorBlock extends NodeMaterialBlock {
  139205. /**
  139206. * Creates a new ReplaceColorBlock
  139207. * @param name defines the block name
  139208. */
  139209. constructor(name: string);
  139210. /**
  139211. * Gets the current class name
  139212. * @returns the class name
  139213. */
  139214. getClassName(): string;
  139215. /**
  139216. * Gets the value input component
  139217. */
  139218. get value(): NodeMaterialConnectionPoint;
  139219. /**
  139220. * Gets the reference input component
  139221. */
  139222. get reference(): NodeMaterialConnectionPoint;
  139223. /**
  139224. * Gets the distance input component
  139225. */
  139226. get distance(): NodeMaterialConnectionPoint;
  139227. /**
  139228. * Gets the replacement input component
  139229. */
  139230. get replacement(): NodeMaterialConnectionPoint;
  139231. /**
  139232. * Gets the output component
  139233. */
  139234. get output(): NodeMaterialConnectionPoint;
  139235. protected _buildBlock(state: NodeMaterialBuildState): this;
  139236. }
  139237. }
  139238. declare module BABYLON {
  139239. /**
  139240. * Block used to posterize a value
  139241. * @see https://en.wikipedia.org/wiki/Posterization
  139242. */
  139243. export class PosterizeBlock extends NodeMaterialBlock {
  139244. /**
  139245. * Creates a new PosterizeBlock
  139246. * @param name defines the block name
  139247. */
  139248. constructor(name: string);
  139249. /**
  139250. * Gets the current class name
  139251. * @returns the class name
  139252. */
  139253. getClassName(): string;
  139254. /**
  139255. * Gets the value input component
  139256. */
  139257. get value(): NodeMaterialConnectionPoint;
  139258. /**
  139259. * Gets the steps input component
  139260. */
  139261. get steps(): NodeMaterialConnectionPoint;
  139262. /**
  139263. * Gets the output component
  139264. */
  139265. get output(): NodeMaterialConnectionPoint;
  139266. protected _buildBlock(state: NodeMaterialBuildState): this;
  139267. }
  139268. }
  139269. declare module BABYLON {
  139270. /**
  139271. * Operations supported by the Wave block
  139272. */
  139273. export enum WaveBlockKind {
  139274. /** SawTooth */
  139275. SawTooth = 0,
  139276. /** Square */
  139277. Square = 1,
  139278. /** Triangle */
  139279. Triangle = 2
  139280. }
  139281. /**
  139282. * Block used to apply wave operation to floats
  139283. */
  139284. export class WaveBlock extends NodeMaterialBlock {
  139285. /**
  139286. * Gets or sets the kibnd of wave to be applied by the block
  139287. */
  139288. kind: WaveBlockKind;
  139289. /**
  139290. * Creates a new WaveBlock
  139291. * @param name defines the block name
  139292. */
  139293. constructor(name: string);
  139294. /**
  139295. * Gets the current class name
  139296. * @returns the class name
  139297. */
  139298. getClassName(): string;
  139299. /**
  139300. * Gets the input component
  139301. */
  139302. get input(): NodeMaterialConnectionPoint;
  139303. /**
  139304. * Gets the output component
  139305. */
  139306. get output(): NodeMaterialConnectionPoint;
  139307. protected _buildBlock(state: NodeMaterialBuildState): this;
  139308. serialize(): any;
  139309. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  139310. }
  139311. }
  139312. declare module BABYLON {
  139313. /**
  139314. * Class used to store a color step for the GradientBlock
  139315. */
  139316. export class GradientBlockColorStep {
  139317. /**
  139318. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  139319. */
  139320. step: number;
  139321. /**
  139322. * Gets or sets the color associated with this step
  139323. */
  139324. color: Color3;
  139325. /**
  139326. * Creates a new GradientBlockColorStep
  139327. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  139328. * @param color defines the color associated with this step
  139329. */
  139330. constructor(
  139331. /**
  139332. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  139333. */
  139334. step: number,
  139335. /**
  139336. * Gets or sets the color associated with this step
  139337. */
  139338. color: Color3);
  139339. }
  139340. /**
  139341. * Block used to return a color from a gradient based on an input value between 0 and 1
  139342. */
  139343. export class GradientBlock extends NodeMaterialBlock {
  139344. /**
  139345. * Gets or sets the list of color steps
  139346. */
  139347. colorSteps: GradientBlockColorStep[];
  139348. /**
  139349. * Creates a new GradientBlock
  139350. * @param name defines the block name
  139351. */
  139352. constructor(name: string);
  139353. /**
  139354. * Gets the current class name
  139355. * @returns the class name
  139356. */
  139357. getClassName(): string;
  139358. /**
  139359. * Gets the gradient input component
  139360. */
  139361. get gradient(): NodeMaterialConnectionPoint;
  139362. /**
  139363. * Gets the output component
  139364. */
  139365. get output(): NodeMaterialConnectionPoint;
  139366. private _writeColorConstant;
  139367. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  139368. serialize(): any;
  139369. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  139370. protected _dumpPropertiesCode(): string;
  139371. }
  139372. }
  139373. declare module BABYLON {
  139374. /**
  139375. * Block used to normalize lerp between 2 values
  139376. */
  139377. export class NLerpBlock extends NodeMaterialBlock {
  139378. /**
  139379. * Creates a new NLerpBlock
  139380. * @param name defines the block name
  139381. */
  139382. constructor(name: string);
  139383. /**
  139384. * Gets the current class name
  139385. * @returns the class name
  139386. */
  139387. getClassName(): string;
  139388. /**
  139389. * Gets the left operand input component
  139390. */
  139391. get left(): NodeMaterialConnectionPoint;
  139392. /**
  139393. * Gets the right operand input component
  139394. */
  139395. get right(): NodeMaterialConnectionPoint;
  139396. /**
  139397. * Gets the gradient operand input component
  139398. */
  139399. get gradient(): NodeMaterialConnectionPoint;
  139400. /**
  139401. * Gets the output component
  139402. */
  139403. get output(): NodeMaterialConnectionPoint;
  139404. protected _buildBlock(state: NodeMaterialBuildState): this;
  139405. }
  139406. }
  139407. declare module BABYLON {
  139408. /**
  139409. * block used to Generate a Worley Noise 3D Noise Pattern
  139410. */
  139411. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  139412. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  139413. manhattanDistance: boolean;
  139414. /**
  139415. * Creates a new WorleyNoise3DBlock
  139416. * @param name defines the block name
  139417. */
  139418. constructor(name: string);
  139419. /**
  139420. * Gets the current class name
  139421. * @returns the class name
  139422. */
  139423. getClassName(): string;
  139424. /**
  139425. * Gets the seed input component
  139426. */
  139427. get seed(): NodeMaterialConnectionPoint;
  139428. /**
  139429. * Gets the jitter input component
  139430. */
  139431. get jitter(): NodeMaterialConnectionPoint;
  139432. /**
  139433. * Gets the output component
  139434. */
  139435. get output(): NodeMaterialConnectionPoint;
  139436. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  139437. /**
  139438. * Exposes the properties to the UI?
  139439. */
  139440. protected _dumpPropertiesCode(): string;
  139441. /**
  139442. * Exposes the properties to the Seralize?
  139443. */
  139444. serialize(): any;
  139445. /**
  139446. * Exposes the properties to the deseralize?
  139447. */
  139448. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  139449. }
  139450. }
  139451. declare module BABYLON {
  139452. /**
  139453. * block used to Generate a Simplex Perlin 3d Noise Pattern
  139454. */
  139455. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  139456. /**
  139457. * Creates a new SimplexPerlin3DBlock
  139458. * @param name defines the block name
  139459. */
  139460. constructor(name: string);
  139461. /**
  139462. * Gets the current class name
  139463. * @returns the class name
  139464. */
  139465. getClassName(): string;
  139466. /**
  139467. * Gets the seed operand input component
  139468. */
  139469. get seed(): NodeMaterialConnectionPoint;
  139470. /**
  139471. * Gets the output component
  139472. */
  139473. get output(): NodeMaterialConnectionPoint;
  139474. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  139475. }
  139476. }
  139477. declare module BABYLON {
  139478. /**
  139479. * Block used to blend normals
  139480. */
  139481. export class NormalBlendBlock extends NodeMaterialBlock {
  139482. /**
  139483. * Creates a new NormalBlendBlock
  139484. * @param name defines the block name
  139485. */
  139486. constructor(name: string);
  139487. /**
  139488. * Gets the current class name
  139489. * @returns the class name
  139490. */
  139491. getClassName(): string;
  139492. /**
  139493. * Gets the first input component
  139494. */
  139495. get normalMap0(): NodeMaterialConnectionPoint;
  139496. /**
  139497. * Gets the second input component
  139498. */
  139499. get normalMap1(): NodeMaterialConnectionPoint;
  139500. /**
  139501. * Gets the output component
  139502. */
  139503. get output(): NodeMaterialConnectionPoint;
  139504. protected _buildBlock(state: NodeMaterialBuildState): this;
  139505. }
  139506. }
  139507. declare module BABYLON {
  139508. /**
  139509. * Block used to rotate a 2d vector by a given angle
  139510. */
  139511. export class Rotate2dBlock extends NodeMaterialBlock {
  139512. /**
  139513. * Creates a new Rotate2dBlock
  139514. * @param name defines the block name
  139515. */
  139516. constructor(name: string);
  139517. /**
  139518. * Gets the current class name
  139519. * @returns the class name
  139520. */
  139521. getClassName(): string;
  139522. /**
  139523. * Gets the input vector
  139524. */
  139525. get input(): NodeMaterialConnectionPoint;
  139526. /**
  139527. * Gets the input angle
  139528. */
  139529. get angle(): NodeMaterialConnectionPoint;
  139530. /**
  139531. * Gets the output component
  139532. */
  139533. get output(): NodeMaterialConnectionPoint;
  139534. autoConfigure(material: NodeMaterial): void;
  139535. protected _buildBlock(state: NodeMaterialBuildState): this;
  139536. }
  139537. }
  139538. declare module BABYLON {
  139539. /**
  139540. * Block used to get the reflected vector from a direction and a normal
  139541. */
  139542. export class ReflectBlock extends NodeMaterialBlock {
  139543. /**
  139544. * Creates a new ReflectBlock
  139545. * @param name defines the block name
  139546. */
  139547. constructor(name: string);
  139548. /**
  139549. * Gets the current class name
  139550. * @returns the class name
  139551. */
  139552. getClassName(): string;
  139553. /**
  139554. * Gets the incident component
  139555. */
  139556. get incident(): NodeMaterialConnectionPoint;
  139557. /**
  139558. * Gets the normal component
  139559. */
  139560. get normal(): NodeMaterialConnectionPoint;
  139561. /**
  139562. * Gets the output component
  139563. */
  139564. get output(): NodeMaterialConnectionPoint;
  139565. protected _buildBlock(state: NodeMaterialBuildState): this;
  139566. }
  139567. }
  139568. declare module BABYLON {
  139569. /**
  139570. * Block used to get the refracted vector from a direction and a normal
  139571. */
  139572. export class RefractBlock extends NodeMaterialBlock {
  139573. /**
  139574. * Creates a new RefractBlock
  139575. * @param name defines the block name
  139576. */
  139577. constructor(name: string);
  139578. /**
  139579. * Gets the current class name
  139580. * @returns the class name
  139581. */
  139582. getClassName(): string;
  139583. /**
  139584. * Gets the incident component
  139585. */
  139586. get incident(): NodeMaterialConnectionPoint;
  139587. /**
  139588. * Gets the normal component
  139589. */
  139590. get normal(): NodeMaterialConnectionPoint;
  139591. /**
  139592. * Gets the index of refraction component
  139593. */
  139594. get ior(): NodeMaterialConnectionPoint;
  139595. /**
  139596. * Gets the output component
  139597. */
  139598. get output(): NodeMaterialConnectionPoint;
  139599. protected _buildBlock(state: NodeMaterialBuildState): this;
  139600. }
  139601. }
  139602. declare module BABYLON {
  139603. /**
  139604. * Block used to desaturate a color
  139605. */
  139606. export class DesaturateBlock extends NodeMaterialBlock {
  139607. /**
  139608. * Creates a new DesaturateBlock
  139609. * @param name defines the block name
  139610. */
  139611. constructor(name: string);
  139612. /**
  139613. * Gets the current class name
  139614. * @returns the class name
  139615. */
  139616. getClassName(): string;
  139617. /**
  139618. * Gets the color operand input component
  139619. */
  139620. get color(): NodeMaterialConnectionPoint;
  139621. /**
  139622. * Gets the level operand input component
  139623. */
  139624. get level(): NodeMaterialConnectionPoint;
  139625. /**
  139626. * Gets the output component
  139627. */
  139628. get output(): NodeMaterialConnectionPoint;
  139629. protected _buildBlock(state: NodeMaterialBuildState): this;
  139630. }
  139631. }
  139632. declare module BABYLON {
  139633. /**
  139634. * Block used to implement the ambient occlusion module of the PBR material
  139635. */
  139636. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  139637. /**
  139638. * Create a new AmbientOcclusionBlock
  139639. * @param name defines the block name
  139640. */
  139641. constructor(name: string);
  139642. /**
  139643. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  139644. */
  139645. useAmbientInGrayScale: boolean;
  139646. /**
  139647. * Initialize the block and prepare the context for build
  139648. * @param state defines the state that will be used for the build
  139649. */
  139650. initialize(state: NodeMaterialBuildState): void;
  139651. /**
  139652. * Gets the current class name
  139653. * @returns the class name
  139654. */
  139655. getClassName(): string;
  139656. /**
  139657. * Gets the texture input component
  139658. */
  139659. get texture(): NodeMaterialConnectionPoint;
  139660. /**
  139661. * Gets the texture intensity component
  139662. */
  139663. get intensity(): NodeMaterialConnectionPoint;
  139664. /**
  139665. * Gets the direct light intensity input component
  139666. */
  139667. get directLightIntensity(): NodeMaterialConnectionPoint;
  139668. /**
  139669. * Gets the ambient occlusion object output component
  139670. */
  139671. get ambientOcclusion(): NodeMaterialConnectionPoint;
  139672. /**
  139673. * Gets the main code of the block (fragment side)
  139674. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  139675. * @returns the shader code
  139676. */
  139677. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  139678. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  139679. protected _buildBlock(state: NodeMaterialBuildState): this;
  139680. protected _dumpPropertiesCode(): string;
  139681. serialize(): any;
  139682. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  139683. }
  139684. }
  139685. declare module BABYLON {
  139686. /**
  139687. * Block used to implement the reflection module of the PBR material
  139688. */
  139689. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  139690. /** @hidden */
  139691. _defineLODReflectionAlpha: string;
  139692. /** @hidden */
  139693. _defineLinearSpecularReflection: string;
  139694. private _vEnvironmentIrradianceName;
  139695. /** @hidden */
  139696. _vReflectionMicrosurfaceInfosName: string;
  139697. /** @hidden */
  139698. _vReflectionInfosName: string;
  139699. private _scene;
  139700. /**
  139701. * The three properties below are set by the main PBR block prior to calling methods of this class.
  139702. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  139703. * It's less burden on the user side in the editor part.
  139704. */
  139705. /** @hidden */
  139706. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  139707. /** @hidden */
  139708. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  139709. /** @hidden */
  139710. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  139711. /**
  139712. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  139713. * diffuse part of the IBL.
  139714. */
  139715. useSphericalHarmonics: boolean;
  139716. /**
  139717. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  139718. */
  139719. forceIrradianceInFragment: boolean;
  139720. /**
  139721. * Create a new ReflectionBlock
  139722. * @param name defines the block name
  139723. */
  139724. constructor(name: string);
  139725. /**
  139726. * Gets the current class name
  139727. * @returns the class name
  139728. */
  139729. getClassName(): string;
  139730. /**
  139731. * Gets the position input component
  139732. */
  139733. get position(): NodeMaterialConnectionPoint;
  139734. /**
  139735. * Gets the world position input component
  139736. */
  139737. get worldPosition(): NodeMaterialConnectionPoint;
  139738. /**
  139739. * Gets the world normal input component
  139740. */
  139741. get worldNormal(): NodeMaterialConnectionPoint;
  139742. /**
  139743. * Gets the world input component
  139744. */
  139745. get world(): NodeMaterialConnectionPoint;
  139746. /**
  139747. * Gets the camera (or eye) position component
  139748. */
  139749. get cameraPosition(): NodeMaterialConnectionPoint;
  139750. /**
  139751. * Gets the view input component
  139752. */
  139753. get view(): NodeMaterialConnectionPoint;
  139754. /**
  139755. * Gets the color input component
  139756. */
  139757. get color(): NodeMaterialConnectionPoint;
  139758. /**
  139759. * Gets the reflection object output component
  139760. */
  139761. get reflection(): NodeMaterialConnectionPoint;
  139762. /**
  139763. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  139764. */
  139765. get hasTexture(): boolean;
  139766. /**
  139767. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  139768. */
  139769. get reflectionColor(): string;
  139770. protected _getTexture(): Nullable<BaseTexture>;
  139771. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  139772. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  139773. /**
  139774. * Gets the code to inject in the vertex shader
  139775. * @param state current state of the node material building
  139776. * @returns the shader code
  139777. */
  139778. handleVertexSide(state: NodeMaterialBuildState): string;
  139779. /**
  139780. * Gets the main code of the block (fragment side)
  139781. * @param state current state of the node material building
  139782. * @param normalVarName name of the existing variable corresponding to the normal
  139783. * @returns the shader code
  139784. */
  139785. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  139786. protected _buildBlock(state: NodeMaterialBuildState): this;
  139787. protected _dumpPropertiesCode(): string;
  139788. serialize(): any;
  139789. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  139790. }
  139791. }
  139792. declare module BABYLON {
  139793. /**
  139794. * Block used to implement the sheen module of the PBR material
  139795. */
  139796. export class SheenBlock extends NodeMaterialBlock {
  139797. /**
  139798. * Create a new SheenBlock
  139799. * @param name defines the block name
  139800. */
  139801. constructor(name: string);
  139802. /**
  139803. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  139804. * It allows the strength of the sheen effect to not depend on the base color of the material,
  139805. * making it easier to setup and tweak the effect
  139806. */
  139807. albedoScaling: boolean;
  139808. /**
  139809. * Defines if the sheen is linked to the sheen color.
  139810. */
  139811. linkSheenWithAlbedo: boolean;
  139812. /**
  139813. * Initialize the block and prepare the context for build
  139814. * @param state defines the state that will be used for the build
  139815. */
  139816. initialize(state: NodeMaterialBuildState): void;
  139817. /**
  139818. * Gets the current class name
  139819. * @returns the class name
  139820. */
  139821. getClassName(): string;
  139822. /**
  139823. * Gets the intensity input component
  139824. */
  139825. get intensity(): NodeMaterialConnectionPoint;
  139826. /**
  139827. * Gets the color input component
  139828. */
  139829. get color(): NodeMaterialConnectionPoint;
  139830. /**
  139831. * Gets the roughness input component
  139832. */
  139833. get roughness(): NodeMaterialConnectionPoint;
  139834. /**
  139835. * Gets the texture input component
  139836. */
  139837. get texture(): NodeMaterialConnectionPoint;
  139838. /**
  139839. * Gets the sheen object output component
  139840. */
  139841. get sheen(): NodeMaterialConnectionPoint;
  139842. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  139843. /**
  139844. * Gets the main code of the block (fragment side)
  139845. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  139846. * @returns the shader code
  139847. */
  139848. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  139849. protected _buildBlock(state: NodeMaterialBuildState): this;
  139850. protected _dumpPropertiesCode(): string;
  139851. serialize(): any;
  139852. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  139853. }
  139854. }
  139855. declare module BABYLON {
  139856. /**
  139857. * Block used to implement the reflectivity module of the PBR material
  139858. */
  139859. export class ReflectivityBlock extends NodeMaterialBlock {
  139860. /**
  139861. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  139862. */
  139863. useAmbientOcclusionFromMetallicTextureRed: boolean;
  139864. /**
  139865. * Specifies if the metallic texture contains the metallness information in its blue channel.
  139866. */
  139867. useMetallnessFromMetallicTextureBlue: boolean;
  139868. /**
  139869. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  139870. */
  139871. useRoughnessFromMetallicTextureAlpha: boolean;
  139872. /**
  139873. * Specifies if the metallic texture contains the roughness information in its green channel.
  139874. */
  139875. useRoughnessFromMetallicTextureGreen: boolean;
  139876. /**
  139877. * Create a new ReflectivityBlock
  139878. * @param name defines the block name
  139879. */
  139880. constructor(name: string);
  139881. /**
  139882. * Initialize the block and prepare the context for build
  139883. * @param state defines the state that will be used for the build
  139884. */
  139885. initialize(state: NodeMaterialBuildState): void;
  139886. /**
  139887. * Gets the current class name
  139888. * @returns the class name
  139889. */
  139890. getClassName(): string;
  139891. /**
  139892. * Gets the metallic input component
  139893. */
  139894. get metallic(): NodeMaterialConnectionPoint;
  139895. /**
  139896. * Gets the roughness input component
  139897. */
  139898. get roughness(): NodeMaterialConnectionPoint;
  139899. /**
  139900. * Gets the texture input component
  139901. */
  139902. get texture(): NodeMaterialConnectionPoint;
  139903. /**
  139904. * Gets the reflectivity object output component
  139905. */
  139906. get reflectivity(): NodeMaterialConnectionPoint;
  139907. /**
  139908. * Gets the main code of the block (fragment side)
  139909. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  139910. * @returns the shader code
  139911. */
  139912. getCode(aoIntensityVarName: string): string;
  139913. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  139914. protected _buildBlock(state: NodeMaterialBuildState): this;
  139915. protected _dumpPropertiesCode(): string;
  139916. serialize(): any;
  139917. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  139918. }
  139919. }
  139920. declare module BABYLON {
  139921. /**
  139922. * Block used to implement the anisotropy module of the PBR material
  139923. */
  139924. export class AnisotropyBlock extends NodeMaterialBlock {
  139925. /**
  139926. * The two properties below are set by the main PBR block prior to calling methods of this class.
  139927. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  139928. * It's less burden on the user side in the editor part.
  139929. */
  139930. /** @hidden */
  139931. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  139932. /** @hidden */
  139933. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  139934. /**
  139935. * Create a new AnisotropyBlock
  139936. * @param name defines the block name
  139937. */
  139938. constructor(name: string);
  139939. /**
  139940. * Initialize the block and prepare the context for build
  139941. * @param state defines the state that will be used for the build
  139942. */
  139943. initialize(state: NodeMaterialBuildState): void;
  139944. /**
  139945. * Gets the current class name
  139946. * @returns the class name
  139947. */
  139948. getClassName(): string;
  139949. /**
  139950. * Gets the intensity input component
  139951. */
  139952. get intensity(): NodeMaterialConnectionPoint;
  139953. /**
  139954. * Gets the direction input component
  139955. */
  139956. get direction(): NodeMaterialConnectionPoint;
  139957. /**
  139958. * Gets the texture input component
  139959. */
  139960. get texture(): NodeMaterialConnectionPoint;
  139961. /**
  139962. * Gets the uv input component
  139963. */
  139964. get uv(): NodeMaterialConnectionPoint;
  139965. /**
  139966. * Gets the worldTangent input component
  139967. */
  139968. get worldTangent(): NodeMaterialConnectionPoint;
  139969. /**
  139970. * Gets the anisotropy object output component
  139971. */
  139972. get anisotropy(): NodeMaterialConnectionPoint;
  139973. private _generateTBNSpace;
  139974. /**
  139975. * Gets the main code of the block (fragment side)
  139976. * @param state current state of the node material building
  139977. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  139978. * @returns the shader code
  139979. */
  139980. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  139981. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  139982. protected _buildBlock(state: NodeMaterialBuildState): this;
  139983. }
  139984. }
  139985. declare module BABYLON {
  139986. /**
  139987. * Block used to implement the clear coat module of the PBR material
  139988. */
  139989. export class ClearCoatBlock extends NodeMaterialBlock {
  139990. private _scene;
  139991. /**
  139992. * Create a new ClearCoatBlock
  139993. * @param name defines the block name
  139994. */
  139995. constructor(name: string);
  139996. /**
  139997. * Initialize the block and prepare the context for build
  139998. * @param state defines the state that will be used for the build
  139999. */
  140000. initialize(state: NodeMaterialBuildState): void;
  140001. /**
  140002. * Gets the current class name
  140003. * @returns the class name
  140004. */
  140005. getClassName(): string;
  140006. /**
  140007. * Gets the intensity input component
  140008. */
  140009. get intensity(): NodeMaterialConnectionPoint;
  140010. /**
  140011. * Gets the roughness input component
  140012. */
  140013. get roughness(): NodeMaterialConnectionPoint;
  140014. /**
  140015. * Gets the ior input component
  140016. */
  140017. get ior(): NodeMaterialConnectionPoint;
  140018. /**
  140019. * Gets the texture input component
  140020. */
  140021. get texture(): NodeMaterialConnectionPoint;
  140022. /**
  140023. * Gets the bump texture input component
  140024. */
  140025. get bumpTexture(): NodeMaterialConnectionPoint;
  140026. /**
  140027. * Gets the uv input component
  140028. */
  140029. get uv(): NodeMaterialConnectionPoint;
  140030. /**
  140031. * Gets the tint color input component
  140032. */
  140033. get tintColor(): NodeMaterialConnectionPoint;
  140034. /**
  140035. * Gets the tint "at distance" input component
  140036. */
  140037. get tintAtDistance(): NodeMaterialConnectionPoint;
  140038. /**
  140039. * Gets the tint thickness input component
  140040. */
  140041. get tintThickness(): NodeMaterialConnectionPoint;
  140042. /**
  140043. * Gets the tint texture input component
  140044. */
  140045. get tintTexture(): NodeMaterialConnectionPoint;
  140046. /**
  140047. * Gets the world tangent input component
  140048. */
  140049. get worldTangent(): NodeMaterialConnectionPoint;
  140050. /**
  140051. * Gets the clear coat object output component
  140052. */
  140053. get clearcoat(): NodeMaterialConnectionPoint;
  140054. autoConfigure(material: NodeMaterial): void;
  140055. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  140056. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  140057. private _generateTBNSpace;
  140058. /**
  140059. * Gets the main code of the block (fragment side)
  140060. * @param state current state of the node material building
  140061. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  140062. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  140063. * @param worldPosVarName name of the variable holding the world position
  140064. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  140065. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  140066. * @param worldNormalVarName name of the variable holding the world normal
  140067. * @returns the shader code
  140068. */
  140069. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  140070. protected _buildBlock(state: NodeMaterialBuildState): this;
  140071. }
  140072. }
  140073. declare module BABYLON {
  140074. /**
  140075. * Block used to implement the sub surface module of the PBR material
  140076. */
  140077. export class SubSurfaceBlock extends NodeMaterialBlock {
  140078. /**
  140079. * Create a new SubSurfaceBlock
  140080. * @param name defines the block name
  140081. */
  140082. constructor(name: string);
  140083. /**
  140084. * Stores the intensity of the different subsurface effects in the thickness texture.
  140085. * * the green channel is the translucency intensity.
  140086. * * the blue channel is the scattering intensity.
  140087. * * the alpha channel is the refraction intensity.
  140088. */
  140089. useMaskFromThicknessTexture: boolean;
  140090. /**
  140091. * Initialize the block and prepare the context for build
  140092. * @param state defines the state that will be used for the build
  140093. */
  140094. initialize(state: NodeMaterialBuildState): void;
  140095. /**
  140096. * Gets the current class name
  140097. * @returns the class name
  140098. */
  140099. getClassName(): string;
  140100. /**
  140101. * Gets the min thickness input component
  140102. */
  140103. get minThickness(): NodeMaterialConnectionPoint;
  140104. /**
  140105. * Gets the max thickness input component
  140106. */
  140107. get maxThickness(): NodeMaterialConnectionPoint;
  140108. /**
  140109. * Gets the thickness texture component
  140110. */
  140111. get thicknessTexture(): NodeMaterialConnectionPoint;
  140112. /**
  140113. * Gets the tint color input component
  140114. */
  140115. get tintColor(): NodeMaterialConnectionPoint;
  140116. /**
  140117. * Gets the translucency intensity input component
  140118. */
  140119. get translucencyIntensity(): NodeMaterialConnectionPoint;
  140120. /**
  140121. * Gets the translucency diffusion distance input component
  140122. */
  140123. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  140124. /**
  140125. * Gets the refraction object parameters
  140126. */
  140127. get refraction(): NodeMaterialConnectionPoint;
  140128. /**
  140129. * Gets the sub surface object output component
  140130. */
  140131. get subsurface(): NodeMaterialConnectionPoint;
  140132. autoConfigure(material: NodeMaterial): void;
  140133. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  140134. /**
  140135. * Gets the main code of the block (fragment side)
  140136. * @param state current state of the node material building
  140137. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  140138. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  140139. * @param worldPosVarName name of the variable holding the world position
  140140. * @returns the shader code
  140141. */
  140142. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  140143. protected _buildBlock(state: NodeMaterialBuildState): this;
  140144. }
  140145. }
  140146. declare module BABYLON {
  140147. /**
  140148. * Block used to implement the PBR metallic/roughness model
  140149. */
  140150. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  140151. /**
  140152. * Gets or sets the light associated with this block
  140153. */
  140154. light: Nullable<Light>;
  140155. private _lightId;
  140156. private _scene;
  140157. private _environmentBRDFTexture;
  140158. private _environmentBrdfSamplerName;
  140159. private _vNormalWName;
  140160. private _invertNormalName;
  140161. /**
  140162. * Create a new ReflectionBlock
  140163. * @param name defines the block name
  140164. */
  140165. constructor(name: string);
  140166. /**
  140167. * Intensity of the direct lights e.g. the four lights available in your scene.
  140168. * This impacts both the direct diffuse and specular highlights.
  140169. */
  140170. directIntensity: number;
  140171. /**
  140172. * Intensity of the environment e.g. how much the environment will light the object
  140173. * either through harmonics for rough material or through the refelction for shiny ones.
  140174. */
  140175. environmentIntensity: number;
  140176. /**
  140177. * This is a special control allowing the reduction of the specular highlights coming from the
  140178. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  140179. */
  140180. specularIntensity: number;
  140181. /**
  140182. * Defines the falloff type used in this material.
  140183. * It by default is Physical.
  140184. */
  140185. lightFalloff: number;
  140186. /**
  140187. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  140188. */
  140189. useAlphaFromAlbedoTexture: boolean;
  140190. /**
  140191. * Specifies that alpha test should be used
  140192. */
  140193. useAlphaTest: boolean;
  140194. /**
  140195. * Defines the alpha limits in alpha test mode.
  140196. */
  140197. alphaTestCutoff: number;
  140198. /**
  140199. * Specifies that alpha blending should be used
  140200. */
  140201. useAlphaBlending: boolean;
  140202. /**
  140203. * Defines if the alpha value should be determined via the rgb values.
  140204. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  140205. */
  140206. opacityRGB: boolean;
  140207. /**
  140208. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  140209. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  140210. */
  140211. useRadianceOverAlpha: boolean;
  140212. /**
  140213. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  140214. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  140215. */
  140216. useSpecularOverAlpha: boolean;
  140217. /**
  140218. * Enables specular anti aliasing in the PBR shader.
  140219. * It will both interacts on the Geometry for analytical and IBL lighting.
  140220. * It also prefilter the roughness map based on the bump values.
  140221. */
  140222. enableSpecularAntiAliasing: boolean;
  140223. /**
  140224. * Defines if the material uses energy conservation.
  140225. */
  140226. useEnergyConservation: boolean;
  140227. /**
  140228. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  140229. * too much the area relying on ambient texture to define their ambient occlusion.
  140230. */
  140231. useRadianceOcclusion: boolean;
  140232. /**
  140233. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  140234. * makes the reflect vector face the model (under horizon).
  140235. */
  140236. useHorizonOcclusion: boolean;
  140237. /**
  140238. * If set to true, no lighting calculations will be applied.
  140239. */
  140240. unlit: boolean;
  140241. /**
  140242. * Force normal to face away from face.
  140243. */
  140244. forceNormalForward: boolean;
  140245. /**
  140246. * Defines the material debug mode.
  140247. * It helps seeing only some components of the material while troubleshooting.
  140248. */
  140249. debugMode: number;
  140250. /**
  140251. * Specify from where on screen the debug mode should start.
  140252. * The value goes from -1 (full screen) to 1 (not visible)
  140253. * It helps with side by side comparison against the final render
  140254. * This defaults to 0
  140255. */
  140256. debugLimit: number;
  140257. /**
  140258. * As the default viewing range might not be enough (if the ambient is really small for instance)
  140259. * You can use the factor to better multiply the final value.
  140260. */
  140261. debugFactor: number;
  140262. /**
  140263. * Initialize the block and prepare the context for build
  140264. * @param state defines the state that will be used for the build
  140265. */
  140266. initialize(state: NodeMaterialBuildState): void;
  140267. /**
  140268. * Gets the current class name
  140269. * @returns the class name
  140270. */
  140271. getClassName(): string;
  140272. /**
  140273. * Gets the world position input component
  140274. */
  140275. get worldPosition(): NodeMaterialConnectionPoint;
  140276. /**
  140277. * Gets the world normal input component
  140278. */
  140279. get worldNormal(): NodeMaterialConnectionPoint;
  140280. /**
  140281. * Gets the perturbed normal input component
  140282. */
  140283. get perturbedNormal(): NodeMaterialConnectionPoint;
  140284. /**
  140285. * Gets the camera position input component
  140286. */
  140287. get cameraPosition(): NodeMaterialConnectionPoint;
  140288. /**
  140289. * Gets the base color input component
  140290. */
  140291. get baseColor(): NodeMaterialConnectionPoint;
  140292. /**
  140293. * Gets the base texture input component
  140294. */
  140295. get baseTexture(): NodeMaterialConnectionPoint;
  140296. /**
  140297. * Gets the opacity texture input component
  140298. */
  140299. get opacityTexture(): NodeMaterialConnectionPoint;
  140300. /**
  140301. * Gets the ambient color input component
  140302. */
  140303. get ambientColor(): NodeMaterialConnectionPoint;
  140304. /**
  140305. * Gets the reflectivity object parameters
  140306. */
  140307. get reflectivity(): NodeMaterialConnectionPoint;
  140308. /**
  140309. * Gets the ambient occlusion object parameters
  140310. */
  140311. get ambientOcclusion(): NodeMaterialConnectionPoint;
  140312. /**
  140313. * Gets the reflection object parameters
  140314. */
  140315. get reflection(): NodeMaterialConnectionPoint;
  140316. /**
  140317. * Gets the sheen object parameters
  140318. */
  140319. get sheen(): NodeMaterialConnectionPoint;
  140320. /**
  140321. * Gets the clear coat object parameters
  140322. */
  140323. get clearcoat(): NodeMaterialConnectionPoint;
  140324. /**
  140325. * Gets the sub surface object parameters
  140326. */
  140327. get subsurface(): NodeMaterialConnectionPoint;
  140328. /**
  140329. * Gets the anisotropy object parameters
  140330. */
  140331. get anisotropy(): NodeMaterialConnectionPoint;
  140332. /**
  140333. * Gets the ambient output component
  140334. */
  140335. get ambient(): NodeMaterialConnectionPoint;
  140336. /**
  140337. * Gets the diffuse output component
  140338. */
  140339. get diffuse(): NodeMaterialConnectionPoint;
  140340. /**
  140341. * Gets the specular output component
  140342. */
  140343. get specular(): NodeMaterialConnectionPoint;
  140344. /**
  140345. * Gets the sheen output component
  140346. */
  140347. get sheenDir(): NodeMaterialConnectionPoint;
  140348. /**
  140349. * Gets the clear coat output component
  140350. */
  140351. get clearcoatDir(): NodeMaterialConnectionPoint;
  140352. /**
  140353. * Gets the indirect diffuse output component
  140354. */
  140355. get diffuseIndirect(): NodeMaterialConnectionPoint;
  140356. /**
  140357. * Gets the indirect specular output component
  140358. */
  140359. get specularIndirect(): NodeMaterialConnectionPoint;
  140360. /**
  140361. * Gets the indirect sheen output component
  140362. */
  140363. get sheenIndirect(): NodeMaterialConnectionPoint;
  140364. /**
  140365. * Gets the indirect clear coat output component
  140366. */
  140367. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  140368. /**
  140369. * Gets the refraction output component
  140370. */
  140371. get refraction(): NodeMaterialConnectionPoint;
  140372. /**
  140373. * Gets the global lighting output component
  140374. */
  140375. get lighting(): NodeMaterialConnectionPoint;
  140376. /**
  140377. * Gets the shadow output component
  140378. */
  140379. get shadow(): NodeMaterialConnectionPoint;
  140380. /**
  140381. * Gets the alpha output component
  140382. */
  140383. get alpha(): NodeMaterialConnectionPoint;
  140384. autoConfigure(material: NodeMaterial): void;
  140385. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  140386. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  140387. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  140388. private _injectVertexCode;
  140389. /**
  140390. * Gets the code corresponding to the albedo/opacity module
  140391. * @returns the shader code
  140392. */
  140393. getAlbedoOpacityCode(): string;
  140394. protected _buildBlock(state: NodeMaterialBuildState): this;
  140395. protected _dumpPropertiesCode(): string;
  140396. serialize(): any;
  140397. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  140398. }
  140399. }
  140400. declare module BABYLON {
  140401. /**
  140402. * Block used to compute value of one parameter modulo another
  140403. */
  140404. export class ModBlock extends NodeMaterialBlock {
  140405. /**
  140406. * Creates a new ModBlock
  140407. * @param name defines the block name
  140408. */
  140409. constructor(name: string);
  140410. /**
  140411. * Gets the current class name
  140412. * @returns the class name
  140413. */
  140414. getClassName(): string;
  140415. /**
  140416. * Gets the left operand input component
  140417. */
  140418. get left(): NodeMaterialConnectionPoint;
  140419. /**
  140420. * Gets the right operand input component
  140421. */
  140422. get right(): NodeMaterialConnectionPoint;
  140423. /**
  140424. * Gets the output component
  140425. */
  140426. get output(): NodeMaterialConnectionPoint;
  140427. protected _buildBlock(state: NodeMaterialBuildState): this;
  140428. }
  140429. }
  140430. declare module BABYLON {
  140431. /**
  140432. * Helper class to push actions to a pool of workers.
  140433. */
  140434. export class WorkerPool implements IDisposable {
  140435. private _workerInfos;
  140436. private _pendingActions;
  140437. /**
  140438. * Constructor
  140439. * @param workers Array of workers to use for actions
  140440. */
  140441. constructor(workers: Array<Worker>);
  140442. /**
  140443. * Terminates all workers and clears any pending actions.
  140444. */
  140445. dispose(): void;
  140446. /**
  140447. * Pushes an action to the worker pool. If all the workers are active, the action will be
  140448. * pended until a worker has completed its action.
  140449. * @param action The action to perform. Call onComplete when the action is complete.
  140450. */
  140451. push(action: (worker: Worker, onComplete: () => void) => void): void;
  140452. private _execute;
  140453. }
  140454. }
  140455. declare module BABYLON {
  140456. /**
  140457. * Configuration for Draco compression
  140458. */
  140459. export interface IDracoCompressionConfiguration {
  140460. /**
  140461. * Configuration for the decoder.
  140462. */
  140463. decoder: {
  140464. /**
  140465. * The url to the WebAssembly module.
  140466. */
  140467. wasmUrl?: string;
  140468. /**
  140469. * The url to the WebAssembly binary.
  140470. */
  140471. wasmBinaryUrl?: string;
  140472. /**
  140473. * The url to the fallback JavaScript module.
  140474. */
  140475. fallbackUrl?: string;
  140476. };
  140477. }
  140478. /**
  140479. * Draco compression (https://google.github.io/draco/)
  140480. *
  140481. * This class wraps the Draco module.
  140482. *
  140483. * **Encoder**
  140484. *
  140485. * The encoder is not currently implemented.
  140486. *
  140487. * **Decoder**
  140488. *
  140489. * 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.
  140490. *
  140491. * To update the configuration, use the following code:
  140492. * ```javascript
  140493. * DracoCompression.Configuration = {
  140494. * decoder: {
  140495. * wasmUrl: "<url to the WebAssembly library>",
  140496. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  140497. * fallbackUrl: "<url to the fallback JavaScript library>",
  140498. * }
  140499. * };
  140500. * ```
  140501. *
  140502. * 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.
  140503. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  140504. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  140505. *
  140506. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  140507. * ```javascript
  140508. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  140509. * ```
  140510. *
  140511. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  140512. */
  140513. export class DracoCompression implements IDisposable {
  140514. private _workerPoolPromise?;
  140515. private _decoderModulePromise?;
  140516. /**
  140517. * The configuration. Defaults to the following urls:
  140518. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  140519. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  140520. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  140521. */
  140522. static Configuration: IDracoCompressionConfiguration;
  140523. /**
  140524. * Returns true if the decoder configuration is available.
  140525. */
  140526. static get DecoderAvailable(): boolean;
  140527. /**
  140528. * Default number of workers to create when creating the draco compression object.
  140529. */
  140530. static DefaultNumWorkers: number;
  140531. private static GetDefaultNumWorkers;
  140532. private static _Default;
  140533. /**
  140534. * Default instance for the draco compression object.
  140535. */
  140536. static get Default(): DracoCompression;
  140537. /**
  140538. * Constructor
  140539. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  140540. */
  140541. constructor(numWorkers?: number);
  140542. /**
  140543. * Stop all async operations and release resources.
  140544. */
  140545. dispose(): void;
  140546. /**
  140547. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  140548. * @returns a promise that resolves when ready
  140549. */
  140550. whenReadyAsync(): Promise<void>;
  140551. /**
  140552. * Decode Draco compressed mesh data to vertex data.
  140553. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  140554. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  140555. * @returns A promise that resolves with the decoded vertex data
  140556. */
  140557. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  140558. [kind: string]: number;
  140559. }): Promise<VertexData>;
  140560. }
  140561. }
  140562. declare module BABYLON {
  140563. /**
  140564. * Class for building Constructive Solid Geometry
  140565. */
  140566. export class CSG {
  140567. private polygons;
  140568. /**
  140569. * The world matrix
  140570. */
  140571. matrix: Matrix;
  140572. /**
  140573. * Stores the position
  140574. */
  140575. position: Vector3;
  140576. /**
  140577. * Stores the rotation
  140578. */
  140579. rotation: Vector3;
  140580. /**
  140581. * Stores the rotation quaternion
  140582. */
  140583. rotationQuaternion: Nullable<Quaternion>;
  140584. /**
  140585. * Stores the scaling vector
  140586. */
  140587. scaling: Vector3;
  140588. /**
  140589. * Convert the Mesh to CSG
  140590. * @param mesh The Mesh to convert to CSG
  140591. * @returns A new CSG from the Mesh
  140592. */
  140593. static FromMesh(mesh: Mesh): CSG;
  140594. /**
  140595. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  140596. * @param polygons Polygons used to construct a CSG solid
  140597. */
  140598. private static FromPolygons;
  140599. /**
  140600. * Clones, or makes a deep copy, of the CSG
  140601. * @returns A new CSG
  140602. */
  140603. clone(): CSG;
  140604. /**
  140605. * Unions this CSG with another CSG
  140606. * @param csg The CSG to union against this CSG
  140607. * @returns The unioned CSG
  140608. */
  140609. union(csg: CSG): CSG;
  140610. /**
  140611. * Unions this CSG with another CSG in place
  140612. * @param csg The CSG to union against this CSG
  140613. */
  140614. unionInPlace(csg: CSG): void;
  140615. /**
  140616. * Subtracts this CSG with another CSG
  140617. * @param csg The CSG to subtract against this CSG
  140618. * @returns A new CSG
  140619. */
  140620. subtract(csg: CSG): CSG;
  140621. /**
  140622. * Subtracts this CSG with another CSG in place
  140623. * @param csg The CSG to subtact against this CSG
  140624. */
  140625. subtractInPlace(csg: CSG): void;
  140626. /**
  140627. * Intersect this CSG with another CSG
  140628. * @param csg The CSG to intersect against this CSG
  140629. * @returns A new CSG
  140630. */
  140631. intersect(csg: CSG): CSG;
  140632. /**
  140633. * Intersects this CSG with another CSG in place
  140634. * @param csg The CSG to intersect against this CSG
  140635. */
  140636. intersectInPlace(csg: CSG): void;
  140637. /**
  140638. * Return a new CSG solid with solid and empty space switched. This solid is
  140639. * not modified.
  140640. * @returns A new CSG solid with solid and empty space switched
  140641. */
  140642. inverse(): CSG;
  140643. /**
  140644. * Inverses the CSG in place
  140645. */
  140646. inverseInPlace(): void;
  140647. /**
  140648. * This is used to keep meshes transformations so they can be restored
  140649. * when we build back a Babylon Mesh
  140650. * NB : All CSG operations are performed in world coordinates
  140651. * @param csg The CSG to copy the transform attributes from
  140652. * @returns This CSG
  140653. */
  140654. copyTransformAttributes(csg: CSG): CSG;
  140655. /**
  140656. * Build Raw mesh from CSG
  140657. * Coordinates here are in world space
  140658. * @param name The name of the mesh geometry
  140659. * @param scene The Scene
  140660. * @param keepSubMeshes Specifies if the submeshes should be kept
  140661. * @returns A new Mesh
  140662. */
  140663. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  140664. /**
  140665. * Build Mesh from CSG taking material and transforms into account
  140666. * @param name The name of the Mesh
  140667. * @param material The material of the Mesh
  140668. * @param scene The Scene
  140669. * @param keepSubMeshes Specifies if submeshes should be kept
  140670. * @returns The new Mesh
  140671. */
  140672. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  140673. }
  140674. }
  140675. declare module BABYLON {
  140676. /**
  140677. * Class used to create a trail following a mesh
  140678. */
  140679. export class TrailMesh extends Mesh {
  140680. private _generator;
  140681. private _autoStart;
  140682. private _running;
  140683. private _diameter;
  140684. private _length;
  140685. private _sectionPolygonPointsCount;
  140686. private _sectionVectors;
  140687. private _sectionNormalVectors;
  140688. private _beforeRenderObserver;
  140689. /**
  140690. * @constructor
  140691. * @param name The value used by scene.getMeshByName() to do a lookup.
  140692. * @param generator The mesh or transform node to generate a trail.
  140693. * @param scene The scene to add this mesh to.
  140694. * @param diameter Diameter of trailing mesh. Default is 1.
  140695. * @param length Length of trailing mesh. Default is 60.
  140696. * @param autoStart Automatically start trailing mesh. Default true.
  140697. */
  140698. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  140699. /**
  140700. * "TrailMesh"
  140701. * @returns "TrailMesh"
  140702. */
  140703. getClassName(): string;
  140704. private _createMesh;
  140705. /**
  140706. * Start trailing mesh.
  140707. */
  140708. start(): void;
  140709. /**
  140710. * Stop trailing mesh.
  140711. */
  140712. stop(): void;
  140713. /**
  140714. * Update trailing mesh geometry.
  140715. */
  140716. update(): void;
  140717. /**
  140718. * Returns a new TrailMesh object.
  140719. * @param name is a string, the name given to the new mesh
  140720. * @param newGenerator use new generator object for cloned trail mesh
  140721. * @returns a new mesh
  140722. */
  140723. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  140724. /**
  140725. * Serializes this trail mesh
  140726. * @param serializationObject object to write serialization to
  140727. */
  140728. serialize(serializationObject: any): void;
  140729. /**
  140730. * Parses a serialized trail mesh
  140731. * @param parsedMesh the serialized mesh
  140732. * @param scene the scene to create the trail mesh in
  140733. * @returns the created trail mesh
  140734. */
  140735. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  140736. }
  140737. }
  140738. declare module BABYLON {
  140739. /**
  140740. * Class containing static functions to help procedurally build meshes
  140741. */
  140742. export class TiledBoxBuilder {
  140743. /**
  140744. * Creates a box mesh
  140745. * 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)
  140746. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  140747. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  140748. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  140749. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  140750. * @param name defines the name of the mesh
  140751. * @param options defines the options used to create the mesh
  140752. * @param scene defines the hosting scene
  140753. * @returns the box mesh
  140754. */
  140755. static CreateTiledBox(name: string, options: {
  140756. pattern?: number;
  140757. width?: number;
  140758. height?: number;
  140759. depth?: number;
  140760. tileSize?: number;
  140761. tileWidth?: number;
  140762. tileHeight?: number;
  140763. alignHorizontal?: number;
  140764. alignVertical?: number;
  140765. faceUV?: Vector4[];
  140766. faceColors?: Color4[];
  140767. sideOrientation?: number;
  140768. updatable?: boolean;
  140769. }, scene?: Nullable<Scene>): Mesh;
  140770. }
  140771. }
  140772. declare module BABYLON {
  140773. /**
  140774. * Class containing static functions to help procedurally build meshes
  140775. */
  140776. export class TorusKnotBuilder {
  140777. /**
  140778. * Creates a torus knot mesh
  140779. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  140780. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  140781. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  140782. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  140783. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  140784. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  140785. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  140786. * @param name defines the name of the mesh
  140787. * @param options defines the options used to create the mesh
  140788. * @param scene defines the hosting scene
  140789. * @returns the torus knot mesh
  140790. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  140791. */
  140792. static CreateTorusKnot(name: string, options: {
  140793. radius?: number;
  140794. tube?: number;
  140795. radialSegments?: number;
  140796. tubularSegments?: number;
  140797. p?: number;
  140798. q?: number;
  140799. updatable?: boolean;
  140800. sideOrientation?: number;
  140801. frontUVs?: Vector4;
  140802. backUVs?: Vector4;
  140803. }, scene: any): Mesh;
  140804. }
  140805. }
  140806. declare module BABYLON {
  140807. /**
  140808. * Polygon
  140809. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  140810. */
  140811. export class Polygon {
  140812. /**
  140813. * Creates a rectangle
  140814. * @param xmin bottom X coord
  140815. * @param ymin bottom Y coord
  140816. * @param xmax top X coord
  140817. * @param ymax top Y coord
  140818. * @returns points that make the resulting rectation
  140819. */
  140820. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  140821. /**
  140822. * Creates a circle
  140823. * @param radius radius of circle
  140824. * @param cx scale in x
  140825. * @param cy scale in y
  140826. * @param numberOfSides number of sides that make up the circle
  140827. * @returns points that make the resulting circle
  140828. */
  140829. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  140830. /**
  140831. * Creates a polygon from input string
  140832. * @param input Input polygon data
  140833. * @returns the parsed points
  140834. */
  140835. static Parse(input: string): Vector2[];
  140836. /**
  140837. * Starts building a polygon from x and y coordinates
  140838. * @param x x coordinate
  140839. * @param y y coordinate
  140840. * @returns the started path2
  140841. */
  140842. static StartingAt(x: number, y: number): Path2;
  140843. }
  140844. /**
  140845. * Builds a polygon
  140846. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  140847. */
  140848. export class PolygonMeshBuilder {
  140849. private _points;
  140850. private _outlinepoints;
  140851. private _holes;
  140852. private _name;
  140853. private _scene;
  140854. private _epoints;
  140855. private _eholes;
  140856. private _addToepoint;
  140857. /**
  140858. * Babylon reference to the earcut plugin.
  140859. */
  140860. bjsEarcut: any;
  140861. /**
  140862. * Creates a PolygonMeshBuilder
  140863. * @param name name of the builder
  140864. * @param contours Path of the polygon
  140865. * @param scene scene to add to when creating the mesh
  140866. * @param earcutInjection can be used to inject your own earcut reference
  140867. */
  140868. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  140869. /**
  140870. * Adds a whole within the polygon
  140871. * @param hole Array of points defining the hole
  140872. * @returns this
  140873. */
  140874. addHole(hole: Vector2[]): PolygonMeshBuilder;
  140875. /**
  140876. * Creates the polygon
  140877. * @param updatable If the mesh should be updatable
  140878. * @param depth The depth of the mesh created
  140879. * @returns the created mesh
  140880. */
  140881. build(updatable?: boolean, depth?: number): Mesh;
  140882. /**
  140883. * Creates the polygon
  140884. * @param depth The depth of the mesh created
  140885. * @returns the created VertexData
  140886. */
  140887. buildVertexData(depth?: number): VertexData;
  140888. /**
  140889. * Adds a side to the polygon
  140890. * @param positions points that make the polygon
  140891. * @param normals normals of the polygon
  140892. * @param uvs uvs of the polygon
  140893. * @param indices indices of the polygon
  140894. * @param bounds bounds of the polygon
  140895. * @param points points of the polygon
  140896. * @param depth depth of the polygon
  140897. * @param flip flip of the polygon
  140898. */
  140899. private addSide;
  140900. }
  140901. }
  140902. declare module BABYLON {
  140903. /**
  140904. * Class containing static functions to help procedurally build meshes
  140905. */
  140906. export class PolygonBuilder {
  140907. /**
  140908. * Creates a polygon mesh
  140909. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  140910. * * 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
  140911. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  140912. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  140913. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  140914. * * Remember you can only change the shape positions, not their number when updating a polygon
  140915. * @param name defines the name of the mesh
  140916. * @param options defines the options used to create the mesh
  140917. * @param scene defines the hosting scene
  140918. * @param earcutInjection can be used to inject your own earcut reference
  140919. * @returns the polygon mesh
  140920. */
  140921. static CreatePolygon(name: string, options: {
  140922. shape: Vector3[];
  140923. holes?: Vector3[][];
  140924. depth?: number;
  140925. faceUV?: Vector4[];
  140926. faceColors?: Color4[];
  140927. updatable?: boolean;
  140928. sideOrientation?: number;
  140929. frontUVs?: Vector4;
  140930. backUVs?: Vector4;
  140931. wrap?: boolean;
  140932. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  140933. /**
  140934. * Creates an extruded polygon mesh, with depth in the Y direction.
  140935. * * 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)
  140936. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  140937. * @param name defines the name of the mesh
  140938. * @param options defines the options used to create the mesh
  140939. * @param scene defines the hosting scene
  140940. * @param earcutInjection can be used to inject your own earcut reference
  140941. * @returns the polygon mesh
  140942. */
  140943. static ExtrudePolygon(name: string, options: {
  140944. shape: Vector3[];
  140945. holes?: Vector3[][];
  140946. depth?: number;
  140947. faceUV?: Vector4[];
  140948. faceColors?: Color4[];
  140949. updatable?: boolean;
  140950. sideOrientation?: number;
  140951. frontUVs?: Vector4;
  140952. backUVs?: Vector4;
  140953. wrap?: boolean;
  140954. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  140955. }
  140956. }
  140957. declare module BABYLON {
  140958. /**
  140959. * Class containing static functions to help procedurally build meshes
  140960. */
  140961. export class LatheBuilder {
  140962. /**
  140963. * Creates lathe mesh.
  140964. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  140965. * * 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
  140966. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  140967. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  140968. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  140969. * * 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
  140970. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  140971. * * 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
  140972. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  140973. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  140974. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  140975. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  140976. * @param name defines the name of the mesh
  140977. * @param options defines the options used to create the mesh
  140978. * @param scene defines the hosting scene
  140979. * @returns the lathe mesh
  140980. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  140981. */
  140982. static CreateLathe(name: string, options: {
  140983. shape: Vector3[];
  140984. radius?: number;
  140985. tessellation?: number;
  140986. clip?: number;
  140987. arc?: number;
  140988. closed?: boolean;
  140989. updatable?: boolean;
  140990. sideOrientation?: number;
  140991. frontUVs?: Vector4;
  140992. backUVs?: Vector4;
  140993. cap?: number;
  140994. invertUV?: boolean;
  140995. }, scene?: Nullable<Scene>): Mesh;
  140996. }
  140997. }
  140998. declare module BABYLON {
  140999. /**
  141000. * Class containing static functions to help procedurally build meshes
  141001. */
  141002. export class TiledPlaneBuilder {
  141003. /**
  141004. * Creates a tiled plane mesh
  141005. * * The parameter `pattern` will, depending on value, do nothing or
  141006. * * * flip (reflect about central vertical) alternate tiles across and up
  141007. * * * flip every tile on alternate rows
  141008. * * * rotate (180 degs) alternate tiles across and up
  141009. * * * rotate every tile on alternate rows
  141010. * * * flip and rotate alternate tiles across and up
  141011. * * * flip and rotate every tile on alternate rows
  141012. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  141013. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  141014. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141015. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  141016. * * 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)
  141017. * * 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)
  141018. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  141019. * @param name defines the name of the mesh
  141020. * @param options defines the options used to create the mesh
  141021. * @param scene defines the hosting scene
  141022. * @returns the box mesh
  141023. */
  141024. static CreateTiledPlane(name: string, options: {
  141025. pattern?: number;
  141026. tileSize?: number;
  141027. tileWidth?: number;
  141028. tileHeight?: number;
  141029. size?: number;
  141030. width?: number;
  141031. height?: number;
  141032. alignHorizontal?: number;
  141033. alignVertical?: number;
  141034. sideOrientation?: number;
  141035. frontUVs?: Vector4;
  141036. backUVs?: Vector4;
  141037. updatable?: boolean;
  141038. }, scene?: Nullable<Scene>): Mesh;
  141039. }
  141040. }
  141041. declare module BABYLON {
  141042. /**
  141043. * Class containing static functions to help procedurally build meshes
  141044. */
  141045. export class TubeBuilder {
  141046. /**
  141047. * Creates a tube mesh.
  141048. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  141049. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  141050. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  141051. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  141052. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  141053. * * 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)
  141054. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  141055. * * 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
  141056. * * 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
  141057. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141058. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141059. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  141060. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141061. * @param name defines the name of the mesh
  141062. * @param options defines the options used to create the mesh
  141063. * @param scene defines the hosting scene
  141064. * @returns the tube mesh
  141065. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  141066. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  141067. */
  141068. static CreateTube(name: string, options: {
  141069. path: Vector3[];
  141070. radius?: number;
  141071. tessellation?: number;
  141072. radiusFunction?: {
  141073. (i: number, distance: number): number;
  141074. };
  141075. cap?: number;
  141076. arc?: number;
  141077. updatable?: boolean;
  141078. sideOrientation?: number;
  141079. frontUVs?: Vector4;
  141080. backUVs?: Vector4;
  141081. instance?: Mesh;
  141082. invertUV?: boolean;
  141083. }, scene?: Nullable<Scene>): Mesh;
  141084. }
  141085. }
  141086. declare module BABYLON {
  141087. /**
  141088. * Class containing static functions to help procedurally build meshes
  141089. */
  141090. export class IcoSphereBuilder {
  141091. /**
  141092. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  141093. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  141094. * * 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`)
  141095. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  141096. * * 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
  141097. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141098. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141099. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141100. * @param name defines the name of the mesh
  141101. * @param options defines the options used to create the mesh
  141102. * @param scene defines the hosting scene
  141103. * @returns the icosahedron mesh
  141104. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  141105. */
  141106. static CreateIcoSphere(name: string, options: {
  141107. radius?: number;
  141108. radiusX?: number;
  141109. radiusY?: number;
  141110. radiusZ?: number;
  141111. flat?: boolean;
  141112. subdivisions?: number;
  141113. sideOrientation?: number;
  141114. frontUVs?: Vector4;
  141115. backUVs?: Vector4;
  141116. updatable?: boolean;
  141117. }, scene?: Nullable<Scene>): Mesh;
  141118. }
  141119. }
  141120. declare module BABYLON {
  141121. /**
  141122. * Class containing static functions to help procedurally build meshes
  141123. */
  141124. export class DecalBuilder {
  141125. /**
  141126. * Creates a decal mesh.
  141127. * 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
  141128. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  141129. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  141130. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  141131. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  141132. * @param name defines the name of the mesh
  141133. * @param sourceMesh defines the mesh where the decal must be applied
  141134. * @param options defines the options used to create the mesh
  141135. * @param scene defines the hosting scene
  141136. * @returns the decal mesh
  141137. * @see https://doc.babylonjs.com/how_to/decals
  141138. */
  141139. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  141140. position?: Vector3;
  141141. normal?: Vector3;
  141142. size?: Vector3;
  141143. angle?: number;
  141144. }): Mesh;
  141145. }
  141146. }
  141147. declare module BABYLON {
  141148. /**
  141149. * Class containing static functions to help procedurally build meshes
  141150. */
  141151. export class MeshBuilder {
  141152. /**
  141153. * Creates a box mesh
  141154. * * The parameter `size` sets the size (float) of each box side (default 1)
  141155. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  141156. * * 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)
  141157. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  141158. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141159. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141160. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141161. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  141162. * @param name defines the name of the mesh
  141163. * @param options defines the options used to create the mesh
  141164. * @param scene defines the hosting scene
  141165. * @returns the box mesh
  141166. */
  141167. static CreateBox(name: string, options: {
  141168. size?: number;
  141169. width?: number;
  141170. height?: number;
  141171. depth?: number;
  141172. faceUV?: Vector4[];
  141173. faceColors?: Color4[];
  141174. sideOrientation?: number;
  141175. frontUVs?: Vector4;
  141176. backUVs?: Vector4;
  141177. wrap?: boolean;
  141178. topBaseAt?: number;
  141179. bottomBaseAt?: number;
  141180. updatable?: boolean;
  141181. }, scene?: Nullable<Scene>): Mesh;
  141182. /**
  141183. * Creates a tiled box mesh
  141184. * * faceTiles sets the pattern, tile size and number of tiles for a face
  141185. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141186. * @param name defines the name of the mesh
  141187. * @param options defines the options used to create the mesh
  141188. * @param scene defines the hosting scene
  141189. * @returns the tiled box mesh
  141190. */
  141191. static CreateTiledBox(name: string, options: {
  141192. pattern?: number;
  141193. size?: number;
  141194. width?: number;
  141195. height?: number;
  141196. depth: number;
  141197. tileSize?: number;
  141198. tileWidth?: number;
  141199. tileHeight?: number;
  141200. faceUV?: Vector4[];
  141201. faceColors?: Color4[];
  141202. alignHorizontal?: number;
  141203. alignVertical?: number;
  141204. sideOrientation?: number;
  141205. updatable?: boolean;
  141206. }, scene?: Nullable<Scene>): Mesh;
  141207. /**
  141208. * Creates a sphere mesh
  141209. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  141210. * * 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`)
  141211. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  141212. * * 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
  141213. * * 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)
  141214. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141215. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141216. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141217. * @param name defines the name of the mesh
  141218. * @param options defines the options used to create the mesh
  141219. * @param scene defines the hosting scene
  141220. * @returns the sphere mesh
  141221. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  141222. */
  141223. static CreateSphere(name: string, options: {
  141224. segments?: number;
  141225. diameter?: number;
  141226. diameterX?: number;
  141227. diameterY?: number;
  141228. diameterZ?: number;
  141229. arc?: number;
  141230. slice?: number;
  141231. sideOrientation?: number;
  141232. frontUVs?: Vector4;
  141233. backUVs?: Vector4;
  141234. updatable?: boolean;
  141235. }, scene?: Nullable<Scene>): Mesh;
  141236. /**
  141237. * Creates a plane polygonal mesh. By default, this is a disc
  141238. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  141239. * * 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
  141240. * * 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
  141241. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141242. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141243. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141244. * @param name defines the name of the mesh
  141245. * @param options defines the options used to create the mesh
  141246. * @param scene defines the hosting scene
  141247. * @returns the plane polygonal mesh
  141248. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  141249. */
  141250. static CreateDisc(name: string, options: {
  141251. radius?: number;
  141252. tessellation?: number;
  141253. arc?: number;
  141254. updatable?: boolean;
  141255. sideOrientation?: number;
  141256. frontUVs?: Vector4;
  141257. backUVs?: Vector4;
  141258. }, scene?: Nullable<Scene>): Mesh;
  141259. /**
  141260. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  141261. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  141262. * * 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`)
  141263. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  141264. * * 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
  141265. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141266. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141267. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141268. * @param name defines the name of the mesh
  141269. * @param options defines the options used to create the mesh
  141270. * @param scene defines the hosting scene
  141271. * @returns the icosahedron mesh
  141272. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  141273. */
  141274. static CreateIcoSphere(name: string, options: {
  141275. radius?: number;
  141276. radiusX?: number;
  141277. radiusY?: number;
  141278. radiusZ?: number;
  141279. flat?: boolean;
  141280. subdivisions?: number;
  141281. sideOrientation?: number;
  141282. frontUVs?: Vector4;
  141283. backUVs?: Vector4;
  141284. updatable?: boolean;
  141285. }, scene?: Nullable<Scene>): Mesh;
  141286. /**
  141287. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  141288. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  141289. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  141290. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  141291. * * 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
  141292. * * 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
  141293. * * 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
  141294. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141295. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141296. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  141297. * * 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
  141298. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  141299. * * 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
  141300. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  141301. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141302. * @param name defines the name of the mesh
  141303. * @param options defines the options used to create the mesh
  141304. * @param scene defines the hosting scene
  141305. * @returns the ribbon mesh
  141306. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  141307. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  141308. */
  141309. static CreateRibbon(name: string, options: {
  141310. pathArray: Vector3[][];
  141311. closeArray?: boolean;
  141312. closePath?: boolean;
  141313. offset?: number;
  141314. updatable?: boolean;
  141315. sideOrientation?: number;
  141316. frontUVs?: Vector4;
  141317. backUVs?: Vector4;
  141318. instance?: Mesh;
  141319. invertUV?: boolean;
  141320. uvs?: Vector2[];
  141321. colors?: Color4[];
  141322. }, scene?: Nullable<Scene>): Mesh;
  141323. /**
  141324. * Creates a cylinder or a cone mesh
  141325. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  141326. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  141327. * * 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.
  141328. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  141329. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  141330. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  141331. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  141332. * * 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).
  141333. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  141334. * * 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).
  141335. * * 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
  141336. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  141337. * * 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
  141338. * * 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.
  141339. * * If `enclose` is false, a ring surface is one element.
  141340. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  141341. * * 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
  141342. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141343. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141344. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  141345. * @param name defines the name of the mesh
  141346. * @param options defines the options used to create the mesh
  141347. * @param scene defines the hosting scene
  141348. * @returns the cylinder mesh
  141349. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  141350. */
  141351. static CreateCylinder(name: string, options: {
  141352. height?: number;
  141353. diameterTop?: number;
  141354. diameterBottom?: number;
  141355. diameter?: number;
  141356. tessellation?: number;
  141357. subdivisions?: number;
  141358. arc?: number;
  141359. faceColors?: Color4[];
  141360. faceUV?: Vector4[];
  141361. updatable?: boolean;
  141362. hasRings?: boolean;
  141363. enclose?: boolean;
  141364. cap?: number;
  141365. sideOrientation?: number;
  141366. frontUVs?: Vector4;
  141367. backUVs?: Vector4;
  141368. }, scene?: Nullable<Scene>): Mesh;
  141369. /**
  141370. * Creates a torus mesh
  141371. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  141372. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  141373. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  141374. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141375. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141376. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  141377. * @param name defines the name of the mesh
  141378. * @param options defines the options used to create the mesh
  141379. * @param scene defines the hosting scene
  141380. * @returns the torus mesh
  141381. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  141382. */
  141383. static CreateTorus(name: string, options: {
  141384. diameter?: number;
  141385. thickness?: number;
  141386. tessellation?: number;
  141387. updatable?: boolean;
  141388. sideOrientation?: number;
  141389. frontUVs?: Vector4;
  141390. backUVs?: Vector4;
  141391. }, scene?: Nullable<Scene>): Mesh;
  141392. /**
  141393. * Creates a torus knot mesh
  141394. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  141395. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  141396. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  141397. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  141398. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141399. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141400. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  141401. * @param name defines the name of the mesh
  141402. * @param options defines the options used to create the mesh
  141403. * @param scene defines the hosting scene
  141404. * @returns the torus knot mesh
  141405. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  141406. */
  141407. static CreateTorusKnot(name: string, options: {
  141408. radius?: number;
  141409. tube?: number;
  141410. radialSegments?: number;
  141411. tubularSegments?: number;
  141412. p?: number;
  141413. q?: number;
  141414. updatable?: boolean;
  141415. sideOrientation?: number;
  141416. frontUVs?: Vector4;
  141417. backUVs?: Vector4;
  141418. }, scene?: Nullable<Scene>): Mesh;
  141419. /**
  141420. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  141421. * * 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
  141422. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  141423. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  141424. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  141425. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  141426. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  141427. * * 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
  141428. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  141429. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141430. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  141431. * @param name defines the name of the new line system
  141432. * @param options defines the options used to create the line system
  141433. * @param scene defines the hosting scene
  141434. * @returns a new line system mesh
  141435. */
  141436. static CreateLineSystem(name: string, options: {
  141437. lines: Vector3[][];
  141438. updatable?: boolean;
  141439. instance?: Nullable<LinesMesh>;
  141440. colors?: Nullable<Color4[][]>;
  141441. useVertexAlpha?: boolean;
  141442. }, scene: Nullable<Scene>): LinesMesh;
  141443. /**
  141444. * Creates a line mesh
  141445. * 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
  141446. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  141447. * * The parameter `points` is an array successive Vector3
  141448. * * 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
  141449. * * The optional parameter `colors` is an array of successive Color4, one per line point
  141450. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  141451. * * When updating an instance, remember that only point positions can change, not the number of points
  141452. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141453. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  141454. * @param name defines the name of the new line system
  141455. * @param options defines the options used to create the line system
  141456. * @param scene defines the hosting scene
  141457. * @returns a new line mesh
  141458. */
  141459. static CreateLines(name: string, options: {
  141460. points: Vector3[];
  141461. updatable?: boolean;
  141462. instance?: Nullable<LinesMesh>;
  141463. colors?: Color4[];
  141464. useVertexAlpha?: boolean;
  141465. }, scene?: Nullable<Scene>): LinesMesh;
  141466. /**
  141467. * Creates a dashed line mesh
  141468. * * 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
  141469. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  141470. * * The parameter `points` is an array successive Vector3
  141471. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  141472. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  141473. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  141474. * * 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
  141475. * * When updating an instance, remember that only point positions can change, not the number of points
  141476. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141477. * @param name defines the name of the mesh
  141478. * @param options defines the options used to create the mesh
  141479. * @param scene defines the hosting scene
  141480. * @returns the dashed line mesh
  141481. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  141482. */
  141483. static CreateDashedLines(name: string, options: {
  141484. points: Vector3[];
  141485. dashSize?: number;
  141486. gapSize?: number;
  141487. dashNb?: number;
  141488. updatable?: boolean;
  141489. instance?: LinesMesh;
  141490. }, scene?: Nullable<Scene>): LinesMesh;
  141491. /**
  141492. * 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.
  141493. * * 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.
  141494. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  141495. * * 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.
  141496. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  141497. * * 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
  141498. * * 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
  141499. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  141500. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141501. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141502. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  141503. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  141504. * @param name defines the name of the mesh
  141505. * @param options defines the options used to create the mesh
  141506. * @param scene defines the hosting scene
  141507. * @returns the extruded shape mesh
  141508. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  141509. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  141510. */
  141511. static ExtrudeShape(name: string, options: {
  141512. shape: Vector3[];
  141513. path: Vector3[];
  141514. scale?: number;
  141515. rotation?: number;
  141516. cap?: number;
  141517. updatable?: boolean;
  141518. sideOrientation?: number;
  141519. frontUVs?: Vector4;
  141520. backUVs?: Vector4;
  141521. instance?: Mesh;
  141522. invertUV?: boolean;
  141523. }, scene?: Nullable<Scene>): Mesh;
  141524. /**
  141525. * Creates an custom extruded shape mesh.
  141526. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  141527. * * 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.
  141528. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  141529. * * 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
  141530. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  141531. * * 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
  141532. * * It must returns a float value that will be the scale value applied to the shape on each path point
  141533. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  141534. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  141535. * * 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
  141536. * * 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
  141537. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  141538. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141539. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141540. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  141541. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141542. * @param name defines the name of the mesh
  141543. * @param options defines the options used to create the mesh
  141544. * @param scene defines the hosting scene
  141545. * @returns the custom extruded shape mesh
  141546. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  141547. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  141548. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  141549. */
  141550. static ExtrudeShapeCustom(name: string, options: {
  141551. shape: Vector3[];
  141552. path: Vector3[];
  141553. scaleFunction?: any;
  141554. rotationFunction?: any;
  141555. ribbonCloseArray?: boolean;
  141556. ribbonClosePath?: boolean;
  141557. cap?: number;
  141558. updatable?: boolean;
  141559. sideOrientation?: number;
  141560. frontUVs?: Vector4;
  141561. backUVs?: Vector4;
  141562. instance?: Mesh;
  141563. invertUV?: boolean;
  141564. }, scene?: Nullable<Scene>): Mesh;
  141565. /**
  141566. * Creates lathe mesh.
  141567. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  141568. * * 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
  141569. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  141570. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  141571. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  141572. * * 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
  141573. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  141574. * * 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
  141575. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141576. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141577. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  141578. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141579. * @param name defines the name of the mesh
  141580. * @param options defines the options used to create the mesh
  141581. * @param scene defines the hosting scene
  141582. * @returns the lathe mesh
  141583. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  141584. */
  141585. static CreateLathe(name: string, options: {
  141586. shape: Vector3[];
  141587. radius?: number;
  141588. tessellation?: number;
  141589. clip?: number;
  141590. arc?: number;
  141591. closed?: boolean;
  141592. updatable?: boolean;
  141593. sideOrientation?: number;
  141594. frontUVs?: Vector4;
  141595. backUVs?: Vector4;
  141596. cap?: number;
  141597. invertUV?: boolean;
  141598. }, scene?: Nullable<Scene>): Mesh;
  141599. /**
  141600. * Creates a tiled plane mesh
  141601. * * You can set a limited pattern arrangement with the tiles
  141602. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141603. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141604. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141605. * @param name defines the name of the mesh
  141606. * @param options defines the options used to create the mesh
  141607. * @param scene defines the hosting scene
  141608. * @returns the plane mesh
  141609. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  141610. */
  141611. static CreateTiledPlane(name: string, options: {
  141612. pattern?: number;
  141613. tileSize?: number;
  141614. tileWidth?: number;
  141615. tileHeight?: number;
  141616. size?: number;
  141617. width?: number;
  141618. height?: number;
  141619. alignHorizontal?: number;
  141620. alignVertical?: number;
  141621. sideOrientation?: number;
  141622. frontUVs?: Vector4;
  141623. backUVs?: Vector4;
  141624. updatable?: boolean;
  141625. }, scene?: Nullable<Scene>): Mesh;
  141626. /**
  141627. * Creates a plane mesh
  141628. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  141629. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  141630. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  141631. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141632. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141633. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141634. * @param name defines the name of the mesh
  141635. * @param options defines the options used to create the mesh
  141636. * @param scene defines the hosting scene
  141637. * @returns the plane mesh
  141638. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  141639. */
  141640. static CreatePlane(name: string, options: {
  141641. size?: number;
  141642. width?: number;
  141643. height?: number;
  141644. sideOrientation?: number;
  141645. frontUVs?: Vector4;
  141646. backUVs?: Vector4;
  141647. updatable?: boolean;
  141648. sourcePlane?: Plane;
  141649. }, scene?: Nullable<Scene>): Mesh;
  141650. /**
  141651. * Creates a ground mesh
  141652. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  141653. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  141654. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141655. * @param name defines the name of the mesh
  141656. * @param options defines the options used to create the mesh
  141657. * @param scene defines the hosting scene
  141658. * @returns the ground mesh
  141659. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  141660. */
  141661. static CreateGround(name: string, options: {
  141662. width?: number;
  141663. height?: number;
  141664. subdivisions?: number;
  141665. subdivisionsX?: number;
  141666. subdivisionsY?: number;
  141667. updatable?: boolean;
  141668. }, scene?: Nullable<Scene>): Mesh;
  141669. /**
  141670. * Creates a tiled ground mesh
  141671. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  141672. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  141673. * * 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
  141674. * * 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
  141675. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  141676. * @param name defines the name of the mesh
  141677. * @param options defines the options used to create the mesh
  141678. * @param scene defines the hosting scene
  141679. * @returns the tiled ground mesh
  141680. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  141681. */
  141682. static CreateTiledGround(name: string, options: {
  141683. xmin: number;
  141684. zmin: number;
  141685. xmax: number;
  141686. zmax: number;
  141687. subdivisions?: {
  141688. w: number;
  141689. h: number;
  141690. };
  141691. precision?: {
  141692. w: number;
  141693. h: number;
  141694. };
  141695. updatable?: boolean;
  141696. }, scene?: Nullable<Scene>): Mesh;
  141697. /**
  141698. * Creates a ground mesh from a height map
  141699. * * The parameter `url` sets the URL of the height map image resource.
  141700. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  141701. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  141702. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  141703. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  141704. * * 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.
  141705. * * 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).
  141706. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  141707. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  141708. * @param name defines the name of the mesh
  141709. * @param url defines the url to the height map
  141710. * @param options defines the options used to create the mesh
  141711. * @param scene defines the hosting scene
  141712. * @returns the ground mesh
  141713. * @see https://doc.babylonjs.com/babylon101/height_map
  141714. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  141715. */
  141716. static CreateGroundFromHeightMap(name: string, url: string, options: {
  141717. width?: number;
  141718. height?: number;
  141719. subdivisions?: number;
  141720. minHeight?: number;
  141721. maxHeight?: number;
  141722. colorFilter?: Color3;
  141723. alphaFilter?: number;
  141724. updatable?: boolean;
  141725. onReady?: (mesh: GroundMesh) => void;
  141726. }, scene?: Nullable<Scene>): GroundMesh;
  141727. /**
  141728. * Creates a polygon mesh
  141729. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  141730. * * 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
  141731. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  141732. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141733. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  141734. * * Remember you can only change the shape positions, not their number when updating a polygon
  141735. * @param name defines the name of the mesh
  141736. * @param options defines the options used to create the mesh
  141737. * @param scene defines the hosting scene
  141738. * @param earcutInjection can be used to inject your own earcut reference
  141739. * @returns the polygon mesh
  141740. */
  141741. static CreatePolygon(name: string, options: {
  141742. shape: Vector3[];
  141743. holes?: Vector3[][];
  141744. depth?: number;
  141745. faceUV?: Vector4[];
  141746. faceColors?: Color4[];
  141747. updatable?: boolean;
  141748. sideOrientation?: number;
  141749. frontUVs?: Vector4;
  141750. backUVs?: Vector4;
  141751. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  141752. /**
  141753. * Creates an extruded polygon mesh, with depth in the Y direction.
  141754. * * 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)
  141755. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  141756. * @param name defines the name of the mesh
  141757. * @param options defines the options used to create the mesh
  141758. * @param scene defines the hosting scene
  141759. * @param earcutInjection can be used to inject your own earcut reference
  141760. * @returns the polygon mesh
  141761. */
  141762. static ExtrudePolygon(name: string, options: {
  141763. shape: Vector3[];
  141764. holes?: Vector3[][];
  141765. depth?: number;
  141766. faceUV?: Vector4[];
  141767. faceColors?: Color4[];
  141768. updatable?: boolean;
  141769. sideOrientation?: number;
  141770. frontUVs?: Vector4;
  141771. backUVs?: Vector4;
  141772. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  141773. /**
  141774. * Creates a tube mesh.
  141775. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  141776. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  141777. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  141778. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  141779. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  141780. * * 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)
  141781. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  141782. * * 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
  141783. * * 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
  141784. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141785. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141786. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  141787. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141788. * @param name defines the name of the mesh
  141789. * @param options defines the options used to create the mesh
  141790. * @param scene defines the hosting scene
  141791. * @returns the tube mesh
  141792. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  141793. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  141794. */
  141795. static CreateTube(name: string, options: {
  141796. path: Vector3[];
  141797. radius?: number;
  141798. tessellation?: number;
  141799. radiusFunction?: {
  141800. (i: number, distance: number): number;
  141801. };
  141802. cap?: number;
  141803. arc?: number;
  141804. updatable?: boolean;
  141805. sideOrientation?: number;
  141806. frontUVs?: Vector4;
  141807. backUVs?: Vector4;
  141808. instance?: Mesh;
  141809. invertUV?: boolean;
  141810. }, scene?: Nullable<Scene>): Mesh;
  141811. /**
  141812. * Creates a polyhedron mesh
  141813. * * 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
  141814. * * The parameter `size` (positive float, default 1) sets the polygon size
  141815. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  141816. * * 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`
  141817. * * 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
  141818. * * 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)`)
  141819. * * 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
  141820. * * 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
  141821. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141822. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141823. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141824. * @param name defines the name of the mesh
  141825. * @param options defines the options used to create the mesh
  141826. * @param scene defines the hosting scene
  141827. * @returns the polyhedron mesh
  141828. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  141829. */
  141830. static CreatePolyhedron(name: string, options: {
  141831. type?: number;
  141832. size?: number;
  141833. sizeX?: number;
  141834. sizeY?: number;
  141835. sizeZ?: number;
  141836. custom?: any;
  141837. faceUV?: Vector4[];
  141838. faceColors?: Color4[];
  141839. flat?: boolean;
  141840. updatable?: boolean;
  141841. sideOrientation?: number;
  141842. frontUVs?: Vector4;
  141843. backUVs?: Vector4;
  141844. }, scene?: Nullable<Scene>): Mesh;
  141845. /**
  141846. * Creates a decal mesh.
  141847. * 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
  141848. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  141849. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  141850. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  141851. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  141852. * @param name defines the name of the mesh
  141853. * @param sourceMesh defines the mesh where the decal must be applied
  141854. * @param options defines the options used to create the mesh
  141855. * @param scene defines the hosting scene
  141856. * @returns the decal mesh
  141857. * @see https://doc.babylonjs.com/how_to/decals
  141858. */
  141859. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  141860. position?: Vector3;
  141861. normal?: Vector3;
  141862. size?: Vector3;
  141863. angle?: number;
  141864. }): Mesh;
  141865. }
  141866. }
  141867. declare module BABYLON {
  141868. /**
  141869. * A simplifier interface for future simplification implementations
  141870. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  141871. */
  141872. export interface ISimplifier {
  141873. /**
  141874. * Simplification of a given mesh according to the given settings.
  141875. * Since this requires computation, it is assumed that the function runs async.
  141876. * @param settings The settings of the simplification, including quality and distance
  141877. * @param successCallback A callback that will be called after the mesh was simplified.
  141878. * @param errorCallback in case of an error, this callback will be called. optional.
  141879. */
  141880. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  141881. }
  141882. /**
  141883. * Expected simplification settings.
  141884. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  141885. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  141886. */
  141887. export interface ISimplificationSettings {
  141888. /**
  141889. * Gets or sets the expected quality
  141890. */
  141891. quality: number;
  141892. /**
  141893. * Gets or sets the distance when this optimized version should be used
  141894. */
  141895. distance: number;
  141896. /**
  141897. * Gets an already optimized mesh
  141898. */
  141899. optimizeMesh?: boolean;
  141900. }
  141901. /**
  141902. * Class used to specify simplification options
  141903. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  141904. */
  141905. export class SimplificationSettings implements ISimplificationSettings {
  141906. /** expected quality */
  141907. quality: number;
  141908. /** distance when this optimized version should be used */
  141909. distance: number;
  141910. /** already optimized mesh */
  141911. optimizeMesh?: boolean | undefined;
  141912. /**
  141913. * Creates a SimplificationSettings
  141914. * @param quality expected quality
  141915. * @param distance distance when this optimized version should be used
  141916. * @param optimizeMesh already optimized mesh
  141917. */
  141918. constructor(
  141919. /** expected quality */
  141920. quality: number,
  141921. /** distance when this optimized version should be used */
  141922. distance: number,
  141923. /** already optimized mesh */
  141924. optimizeMesh?: boolean | undefined);
  141925. }
  141926. /**
  141927. * Interface used to define a simplification task
  141928. */
  141929. export interface ISimplificationTask {
  141930. /**
  141931. * Array of settings
  141932. */
  141933. settings: Array<ISimplificationSettings>;
  141934. /**
  141935. * Simplification type
  141936. */
  141937. simplificationType: SimplificationType;
  141938. /**
  141939. * Mesh to simplify
  141940. */
  141941. mesh: Mesh;
  141942. /**
  141943. * Callback called on success
  141944. */
  141945. successCallback?: () => void;
  141946. /**
  141947. * Defines if parallel processing can be used
  141948. */
  141949. parallelProcessing: boolean;
  141950. }
  141951. /**
  141952. * Queue used to order the simplification tasks
  141953. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  141954. */
  141955. export class SimplificationQueue {
  141956. private _simplificationArray;
  141957. /**
  141958. * Gets a boolean indicating that the process is still running
  141959. */
  141960. running: boolean;
  141961. /**
  141962. * Creates a new queue
  141963. */
  141964. constructor();
  141965. /**
  141966. * Adds a new simplification task
  141967. * @param task defines a task to add
  141968. */
  141969. addTask(task: ISimplificationTask): void;
  141970. /**
  141971. * Execute next task
  141972. */
  141973. executeNext(): void;
  141974. /**
  141975. * Execute a simplification task
  141976. * @param task defines the task to run
  141977. */
  141978. runSimplification(task: ISimplificationTask): void;
  141979. private getSimplifier;
  141980. }
  141981. /**
  141982. * The implemented types of simplification
  141983. * At the moment only Quadratic Error Decimation is implemented
  141984. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  141985. */
  141986. export enum SimplificationType {
  141987. /** Quadratic error decimation */
  141988. QUADRATIC = 0
  141989. }
  141990. /**
  141991. * An implementation of the Quadratic Error simplification algorithm.
  141992. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  141993. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  141994. * @author RaananW
  141995. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  141996. */
  141997. export class QuadraticErrorSimplification implements ISimplifier {
  141998. private _mesh;
  141999. private triangles;
  142000. private vertices;
  142001. private references;
  142002. private _reconstructedMesh;
  142003. /** Gets or sets the number pf sync interations */
  142004. syncIterations: number;
  142005. /** Gets or sets the aggressiveness of the simplifier */
  142006. aggressiveness: number;
  142007. /** Gets or sets the number of allowed iterations for decimation */
  142008. decimationIterations: number;
  142009. /** Gets or sets the espilon to use for bounding box computation */
  142010. boundingBoxEpsilon: number;
  142011. /**
  142012. * Creates a new QuadraticErrorSimplification
  142013. * @param _mesh defines the target mesh
  142014. */
  142015. constructor(_mesh: Mesh);
  142016. /**
  142017. * Simplification of a given mesh according to the given settings.
  142018. * Since this requires computation, it is assumed that the function runs async.
  142019. * @param settings The settings of the simplification, including quality and distance
  142020. * @param successCallback A callback that will be called after the mesh was simplified.
  142021. */
  142022. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  142023. private runDecimation;
  142024. private initWithMesh;
  142025. private init;
  142026. private reconstructMesh;
  142027. private initDecimatedMesh;
  142028. private isFlipped;
  142029. private updateTriangles;
  142030. private identifyBorder;
  142031. private updateMesh;
  142032. private vertexError;
  142033. private calculateError;
  142034. }
  142035. }
  142036. declare module BABYLON {
  142037. interface Scene {
  142038. /** @hidden (Backing field) */
  142039. _simplificationQueue: SimplificationQueue;
  142040. /**
  142041. * Gets or sets the simplification queue attached to the scene
  142042. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  142043. */
  142044. simplificationQueue: SimplificationQueue;
  142045. }
  142046. interface Mesh {
  142047. /**
  142048. * Simplify the mesh according to the given array of settings.
  142049. * Function will return immediately and will simplify async
  142050. * @param settings a collection of simplification settings
  142051. * @param parallelProcessing should all levels calculate parallel or one after the other
  142052. * @param simplificationType the type of simplification to run
  142053. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  142054. * @returns the current mesh
  142055. */
  142056. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  142057. }
  142058. /**
  142059. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  142060. * created in a scene
  142061. */
  142062. export class SimplicationQueueSceneComponent implements ISceneComponent {
  142063. /**
  142064. * The component name helpfull to identify the component in the list of scene components.
  142065. */
  142066. readonly name: string;
  142067. /**
  142068. * The scene the component belongs to.
  142069. */
  142070. scene: Scene;
  142071. /**
  142072. * Creates a new instance of the component for the given scene
  142073. * @param scene Defines the scene to register the component in
  142074. */
  142075. constructor(scene: Scene);
  142076. /**
  142077. * Registers the component in a given scene
  142078. */
  142079. register(): void;
  142080. /**
  142081. * Rebuilds the elements related to this component in case of
  142082. * context lost for instance.
  142083. */
  142084. rebuild(): void;
  142085. /**
  142086. * Disposes the component and the associated ressources
  142087. */
  142088. dispose(): void;
  142089. private _beforeCameraUpdate;
  142090. }
  142091. }
  142092. declare module BABYLON {
  142093. interface Mesh {
  142094. /**
  142095. * Creates a new thin instance
  142096. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  142097. * @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
  142098. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  142099. */
  142100. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  142101. /**
  142102. * Adds the transformation (matrix) of the current mesh as a thin instance
  142103. * @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
  142104. * @returns the thin instance index number
  142105. */
  142106. thinInstanceAddSelf(refresh: boolean): number;
  142107. /**
  142108. * Registers a custom attribute to be used with thin instances
  142109. * @param kind name of the attribute
  142110. * @param stride size in floats of the attribute
  142111. */
  142112. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  142113. /**
  142114. * Sets the matrix of a thin instance
  142115. * @param index index of the thin instance
  142116. * @param matrix matrix to set
  142117. * @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
  142118. */
  142119. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  142120. /**
  142121. * Sets the value of a custom attribute for a thin instance
  142122. * @param kind name of the attribute
  142123. * @param index index of the thin instance
  142124. * @param value value to set
  142125. * @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
  142126. */
  142127. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  142128. /**
  142129. * 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.
  142130. */
  142131. thinInstanceCount: number;
  142132. /**
  142133. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  142134. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  142135. * @param buffer buffer to set
  142136. * @param stride size in floats of each value of the buffer
  142137. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  142138. */
  142139. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  142140. /**
  142141. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  142142. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  142143. */
  142144. thinInstanceBufferUpdated(kind: string): void;
  142145. /**
  142146. * Refreshes the bounding info, taking into account all the thin instances defined
  142147. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  142148. */
  142149. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  142150. /** @hidden */
  142151. _thinInstanceInitializeUserStorage(): void;
  142152. /** @hidden */
  142153. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  142154. /** @hidden */
  142155. _userThinInstanceBuffersStorage: {
  142156. data: {
  142157. [key: string]: Float32Array;
  142158. };
  142159. sizes: {
  142160. [key: string]: number;
  142161. };
  142162. vertexBuffers: {
  142163. [key: string]: Nullable<VertexBuffer>;
  142164. };
  142165. strides: {
  142166. [key: string]: number;
  142167. };
  142168. };
  142169. }
  142170. }
  142171. declare module BABYLON {
  142172. /**
  142173. * Navigation plugin interface to add navigation constrained by a navigation mesh
  142174. */
  142175. export interface INavigationEnginePlugin {
  142176. /**
  142177. * plugin name
  142178. */
  142179. name: string;
  142180. /**
  142181. * Creates a navigation mesh
  142182. * @param meshes array of all the geometry used to compute the navigatio mesh
  142183. * @param parameters bunch of parameters used to filter geometry
  142184. */
  142185. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  142186. /**
  142187. * Create a navigation mesh debug mesh
  142188. * @param scene is where the mesh will be added
  142189. * @returns debug display mesh
  142190. */
  142191. createDebugNavMesh(scene: Scene): Mesh;
  142192. /**
  142193. * Get a navigation mesh constrained position, closest to the parameter position
  142194. * @param position world position
  142195. * @returns the closest point to position constrained by the navigation mesh
  142196. */
  142197. getClosestPoint(position: Vector3): Vector3;
  142198. /**
  142199. * Get a navigation mesh constrained position, closest to the parameter position
  142200. * @param position world position
  142201. * @param result output the closest point to position constrained by the navigation mesh
  142202. */
  142203. getClosestPointToRef(position: Vector3, result: Vector3): void;
  142204. /**
  142205. * Get a navigation mesh constrained position, within a particular radius
  142206. * @param position world position
  142207. * @param maxRadius the maximum distance to the constrained world position
  142208. * @returns the closest point to position constrained by the navigation mesh
  142209. */
  142210. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  142211. /**
  142212. * Get a navigation mesh constrained position, within a particular radius
  142213. * @param position world position
  142214. * @param maxRadius the maximum distance to the constrained world position
  142215. * @param result output the closest point to position constrained by the navigation mesh
  142216. */
  142217. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  142218. /**
  142219. * Compute the final position from a segment made of destination-position
  142220. * @param position world position
  142221. * @param destination world position
  142222. * @returns the resulting point along the navmesh
  142223. */
  142224. moveAlong(position: Vector3, destination: Vector3): Vector3;
  142225. /**
  142226. * Compute the final position from a segment made of destination-position
  142227. * @param position world position
  142228. * @param destination world position
  142229. * @param result output the resulting point along the navmesh
  142230. */
  142231. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  142232. /**
  142233. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  142234. * @param start world position
  142235. * @param end world position
  142236. * @returns array containing world position composing the path
  142237. */
  142238. computePath(start: Vector3, end: Vector3): Vector3[];
  142239. /**
  142240. * If this plugin is supported
  142241. * @returns true if plugin is supported
  142242. */
  142243. isSupported(): boolean;
  142244. /**
  142245. * Create a new Crowd so you can add agents
  142246. * @param maxAgents the maximum agent count in the crowd
  142247. * @param maxAgentRadius the maximum radius an agent can have
  142248. * @param scene to attach the crowd to
  142249. * @returns the crowd you can add agents to
  142250. */
  142251. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  142252. /**
  142253. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  142254. * The queries will try to find a solution within those bounds
  142255. * default is (1,1,1)
  142256. * @param extent x,y,z value that define the extent around the queries point of reference
  142257. */
  142258. setDefaultQueryExtent(extent: Vector3): void;
  142259. /**
  142260. * Get the Bounding box extent specified by setDefaultQueryExtent
  142261. * @returns the box extent values
  142262. */
  142263. getDefaultQueryExtent(): Vector3;
  142264. /**
  142265. * build the navmesh from a previously saved state using getNavmeshData
  142266. * @param data the Uint8Array returned by getNavmeshData
  142267. */
  142268. buildFromNavmeshData(data: Uint8Array): void;
  142269. /**
  142270. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  142271. * @returns data the Uint8Array that can be saved and reused
  142272. */
  142273. getNavmeshData(): Uint8Array;
  142274. /**
  142275. * Get the Bounding box extent result specified by setDefaultQueryExtent
  142276. * @param result output the box extent values
  142277. */
  142278. getDefaultQueryExtentToRef(result: Vector3): void;
  142279. /**
  142280. * Release all resources
  142281. */
  142282. dispose(): void;
  142283. }
  142284. /**
  142285. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  142286. */
  142287. export interface ICrowd {
  142288. /**
  142289. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  142290. * You can attach anything to that node. The node position is updated in the scene update tick.
  142291. * @param pos world position that will be constrained by the navigation mesh
  142292. * @param parameters agent parameters
  142293. * @param transform hooked to the agent that will be update by the scene
  142294. * @returns agent index
  142295. */
  142296. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  142297. /**
  142298. * Returns the agent position in world space
  142299. * @param index agent index returned by addAgent
  142300. * @returns world space position
  142301. */
  142302. getAgentPosition(index: number): Vector3;
  142303. /**
  142304. * Gets the agent position result in world space
  142305. * @param index agent index returned by addAgent
  142306. * @param result output world space position
  142307. */
  142308. getAgentPositionToRef(index: number, result: Vector3): void;
  142309. /**
  142310. * Gets the agent velocity in world space
  142311. * @param index agent index returned by addAgent
  142312. * @returns world space velocity
  142313. */
  142314. getAgentVelocity(index: number): Vector3;
  142315. /**
  142316. * Gets the agent velocity result in world space
  142317. * @param index agent index returned by addAgent
  142318. * @param result output world space velocity
  142319. */
  142320. getAgentVelocityToRef(index: number, result: Vector3): void;
  142321. /**
  142322. * remove a particular agent previously created
  142323. * @param index agent index returned by addAgent
  142324. */
  142325. removeAgent(index: number): void;
  142326. /**
  142327. * get the list of all agents attached to this crowd
  142328. * @returns list of agent indices
  142329. */
  142330. getAgents(): number[];
  142331. /**
  142332. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  142333. * @param deltaTime in seconds
  142334. */
  142335. update(deltaTime: number): void;
  142336. /**
  142337. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  142338. * @param index agent index returned by addAgent
  142339. * @param destination targeted world position
  142340. */
  142341. agentGoto(index: number, destination: Vector3): void;
  142342. /**
  142343. * Teleport the agent to a new position
  142344. * @param index agent index returned by addAgent
  142345. * @param destination targeted world position
  142346. */
  142347. agentTeleport(index: number, destination: Vector3): void;
  142348. /**
  142349. * Update agent parameters
  142350. * @param index agent index returned by addAgent
  142351. * @param parameters agent parameters
  142352. */
  142353. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  142354. /**
  142355. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  142356. * The queries will try to find a solution within those bounds
  142357. * default is (1,1,1)
  142358. * @param extent x,y,z value that define the extent around the queries point of reference
  142359. */
  142360. setDefaultQueryExtent(extent: Vector3): void;
  142361. /**
  142362. * Get the Bounding box extent specified by setDefaultQueryExtent
  142363. * @returns the box extent values
  142364. */
  142365. getDefaultQueryExtent(): Vector3;
  142366. /**
  142367. * Get the Bounding box extent result specified by setDefaultQueryExtent
  142368. * @param result output the box extent values
  142369. */
  142370. getDefaultQueryExtentToRef(result: Vector3): void;
  142371. /**
  142372. * Release all resources
  142373. */
  142374. dispose(): void;
  142375. }
  142376. /**
  142377. * Configures an agent
  142378. */
  142379. export interface IAgentParameters {
  142380. /**
  142381. * Agent radius. [Limit: >= 0]
  142382. */
  142383. radius: number;
  142384. /**
  142385. * Agent height. [Limit: > 0]
  142386. */
  142387. height: number;
  142388. /**
  142389. * Maximum allowed acceleration. [Limit: >= 0]
  142390. */
  142391. maxAcceleration: number;
  142392. /**
  142393. * Maximum allowed speed. [Limit: >= 0]
  142394. */
  142395. maxSpeed: number;
  142396. /**
  142397. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  142398. */
  142399. collisionQueryRange: number;
  142400. /**
  142401. * The path visibility optimization range. [Limit: > 0]
  142402. */
  142403. pathOptimizationRange: number;
  142404. /**
  142405. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  142406. */
  142407. separationWeight: number;
  142408. }
  142409. /**
  142410. * Configures the navigation mesh creation
  142411. */
  142412. export interface INavMeshParameters {
  142413. /**
  142414. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  142415. */
  142416. cs: number;
  142417. /**
  142418. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  142419. */
  142420. ch: number;
  142421. /**
  142422. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  142423. */
  142424. walkableSlopeAngle: number;
  142425. /**
  142426. * Minimum floor to 'ceiling' height that will still allow the floor area to
  142427. * be considered walkable. [Limit: >= 3] [Units: vx]
  142428. */
  142429. walkableHeight: number;
  142430. /**
  142431. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  142432. */
  142433. walkableClimb: number;
  142434. /**
  142435. * The distance to erode/shrink the walkable area of the heightfield away from
  142436. * obstructions. [Limit: >=0] [Units: vx]
  142437. */
  142438. walkableRadius: number;
  142439. /**
  142440. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  142441. */
  142442. maxEdgeLen: number;
  142443. /**
  142444. * The maximum distance a simplfied contour's border edges should deviate
  142445. * the original raw contour. [Limit: >=0] [Units: vx]
  142446. */
  142447. maxSimplificationError: number;
  142448. /**
  142449. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  142450. */
  142451. minRegionArea: number;
  142452. /**
  142453. * Any regions with a span count smaller than this value will, if possible,
  142454. * be merged with larger regions. [Limit: >=0] [Units: vx]
  142455. */
  142456. mergeRegionArea: number;
  142457. /**
  142458. * The maximum number of vertices allowed for polygons generated during the
  142459. * contour to polygon conversion process. [Limit: >= 3]
  142460. */
  142461. maxVertsPerPoly: number;
  142462. /**
  142463. * Sets the sampling distance to use when generating the detail mesh.
  142464. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  142465. */
  142466. detailSampleDist: number;
  142467. /**
  142468. * The maximum distance the detail mesh surface should deviate from heightfield
  142469. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  142470. */
  142471. detailSampleMaxError: number;
  142472. }
  142473. }
  142474. declare module BABYLON {
  142475. /**
  142476. * RecastJS navigation plugin
  142477. */
  142478. export class RecastJSPlugin implements INavigationEnginePlugin {
  142479. /**
  142480. * Reference to the Recast library
  142481. */
  142482. bjsRECAST: any;
  142483. /**
  142484. * plugin name
  142485. */
  142486. name: string;
  142487. /**
  142488. * the first navmesh created. We might extend this to support multiple navmeshes
  142489. */
  142490. navMesh: any;
  142491. /**
  142492. * Initializes the recastJS plugin
  142493. * @param recastInjection can be used to inject your own recast reference
  142494. */
  142495. constructor(recastInjection?: any);
  142496. /**
  142497. * Creates a navigation mesh
  142498. * @param meshes array of all the geometry used to compute the navigatio mesh
  142499. * @param parameters bunch of parameters used to filter geometry
  142500. */
  142501. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  142502. /**
  142503. * Create a navigation mesh debug mesh
  142504. * @param scene is where the mesh will be added
  142505. * @returns debug display mesh
  142506. */
  142507. createDebugNavMesh(scene: Scene): Mesh;
  142508. /**
  142509. * Get a navigation mesh constrained position, closest to the parameter position
  142510. * @param position world position
  142511. * @returns the closest point to position constrained by the navigation mesh
  142512. */
  142513. getClosestPoint(position: Vector3): Vector3;
  142514. /**
  142515. * Get a navigation mesh constrained position, closest to the parameter position
  142516. * @param position world position
  142517. * @param result output the closest point to position constrained by the navigation mesh
  142518. */
  142519. getClosestPointToRef(position: Vector3, result: Vector3): void;
  142520. /**
  142521. * Get a navigation mesh constrained position, within a particular radius
  142522. * @param position world position
  142523. * @param maxRadius the maximum distance to the constrained world position
  142524. * @returns the closest point to position constrained by the navigation mesh
  142525. */
  142526. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  142527. /**
  142528. * Get a navigation mesh constrained position, within a particular radius
  142529. * @param position world position
  142530. * @param maxRadius the maximum distance to the constrained world position
  142531. * @param result output the closest point to position constrained by the navigation mesh
  142532. */
  142533. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  142534. /**
  142535. * Compute the final position from a segment made of destination-position
  142536. * @param position world position
  142537. * @param destination world position
  142538. * @returns the resulting point along the navmesh
  142539. */
  142540. moveAlong(position: Vector3, destination: Vector3): Vector3;
  142541. /**
  142542. * Compute the final position from a segment made of destination-position
  142543. * @param position world position
  142544. * @param destination world position
  142545. * @param result output the resulting point along the navmesh
  142546. */
  142547. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  142548. /**
  142549. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  142550. * @param start world position
  142551. * @param end world position
  142552. * @returns array containing world position composing the path
  142553. */
  142554. computePath(start: Vector3, end: Vector3): Vector3[];
  142555. /**
  142556. * Create a new Crowd so you can add agents
  142557. * @param maxAgents the maximum agent count in the crowd
  142558. * @param maxAgentRadius the maximum radius an agent can have
  142559. * @param scene to attach the crowd to
  142560. * @returns the crowd you can add agents to
  142561. */
  142562. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  142563. /**
  142564. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  142565. * The queries will try to find a solution within those bounds
  142566. * default is (1,1,1)
  142567. * @param extent x,y,z value that define the extent around the queries point of reference
  142568. */
  142569. setDefaultQueryExtent(extent: Vector3): void;
  142570. /**
  142571. * Get the Bounding box extent specified by setDefaultQueryExtent
  142572. * @returns the box extent values
  142573. */
  142574. getDefaultQueryExtent(): Vector3;
  142575. /**
  142576. * build the navmesh from a previously saved state using getNavmeshData
  142577. * @param data the Uint8Array returned by getNavmeshData
  142578. */
  142579. buildFromNavmeshData(data: Uint8Array): void;
  142580. /**
  142581. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  142582. * @returns data the Uint8Array that can be saved and reused
  142583. */
  142584. getNavmeshData(): Uint8Array;
  142585. /**
  142586. * Get the Bounding box extent result specified by setDefaultQueryExtent
  142587. * @param result output the box extent values
  142588. */
  142589. getDefaultQueryExtentToRef(result: Vector3): void;
  142590. /**
  142591. * Disposes
  142592. */
  142593. dispose(): void;
  142594. /**
  142595. * If this plugin is supported
  142596. * @returns true if plugin is supported
  142597. */
  142598. isSupported(): boolean;
  142599. }
  142600. /**
  142601. * Recast detour crowd implementation
  142602. */
  142603. export class RecastJSCrowd implements ICrowd {
  142604. /**
  142605. * Recast/detour plugin
  142606. */
  142607. bjsRECASTPlugin: RecastJSPlugin;
  142608. /**
  142609. * Link to the detour crowd
  142610. */
  142611. recastCrowd: any;
  142612. /**
  142613. * One transform per agent
  142614. */
  142615. transforms: TransformNode[];
  142616. /**
  142617. * All agents created
  142618. */
  142619. agents: number[];
  142620. /**
  142621. * Link to the scene is kept to unregister the crowd from the scene
  142622. */
  142623. private _scene;
  142624. /**
  142625. * Observer for crowd updates
  142626. */
  142627. private _onBeforeAnimationsObserver;
  142628. /**
  142629. * Constructor
  142630. * @param plugin recastJS plugin
  142631. * @param maxAgents the maximum agent count in the crowd
  142632. * @param maxAgentRadius the maximum radius an agent can have
  142633. * @param scene to attach the crowd to
  142634. * @returns the crowd you can add agents to
  142635. */
  142636. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  142637. /**
  142638. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  142639. * You can attach anything to that node. The node position is updated in the scene update tick.
  142640. * @param pos world position that will be constrained by the navigation mesh
  142641. * @param parameters agent parameters
  142642. * @param transform hooked to the agent that will be update by the scene
  142643. * @returns agent index
  142644. */
  142645. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  142646. /**
  142647. * Returns the agent position in world space
  142648. * @param index agent index returned by addAgent
  142649. * @returns world space position
  142650. */
  142651. getAgentPosition(index: number): Vector3;
  142652. /**
  142653. * Returns the agent position result in world space
  142654. * @param index agent index returned by addAgent
  142655. * @param result output world space position
  142656. */
  142657. getAgentPositionToRef(index: number, result: Vector3): void;
  142658. /**
  142659. * Returns the agent velocity in world space
  142660. * @param index agent index returned by addAgent
  142661. * @returns world space velocity
  142662. */
  142663. getAgentVelocity(index: number): Vector3;
  142664. /**
  142665. * Returns the agent velocity result in world space
  142666. * @param index agent index returned by addAgent
  142667. * @param result output world space velocity
  142668. */
  142669. getAgentVelocityToRef(index: number, result: Vector3): void;
  142670. /**
  142671. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  142672. * @param index agent index returned by addAgent
  142673. * @param destination targeted world position
  142674. */
  142675. agentGoto(index: number, destination: Vector3): void;
  142676. /**
  142677. * Teleport the agent to a new position
  142678. * @param index agent index returned by addAgent
  142679. * @param destination targeted world position
  142680. */
  142681. agentTeleport(index: number, destination: Vector3): void;
  142682. /**
  142683. * Update agent parameters
  142684. * @param index agent index returned by addAgent
  142685. * @param parameters agent parameters
  142686. */
  142687. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  142688. /**
  142689. * remove a particular agent previously created
  142690. * @param index agent index returned by addAgent
  142691. */
  142692. removeAgent(index: number): void;
  142693. /**
  142694. * get the list of all agents attached to this crowd
  142695. * @returns list of agent indices
  142696. */
  142697. getAgents(): number[];
  142698. /**
  142699. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  142700. * @param deltaTime in seconds
  142701. */
  142702. update(deltaTime: number): void;
  142703. /**
  142704. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  142705. * The queries will try to find a solution within those bounds
  142706. * default is (1,1,1)
  142707. * @param extent x,y,z value that define the extent around the queries point of reference
  142708. */
  142709. setDefaultQueryExtent(extent: Vector3): void;
  142710. /**
  142711. * Get the Bounding box extent specified by setDefaultQueryExtent
  142712. * @returns the box extent values
  142713. */
  142714. getDefaultQueryExtent(): Vector3;
  142715. /**
  142716. * Get the Bounding box extent result specified by setDefaultQueryExtent
  142717. * @param result output the box extent values
  142718. */
  142719. getDefaultQueryExtentToRef(result: Vector3): void;
  142720. /**
  142721. * Release all resources
  142722. */
  142723. dispose(): void;
  142724. }
  142725. }
  142726. declare module BABYLON {
  142727. /**
  142728. * Class used to enable access to IndexedDB
  142729. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  142730. */
  142731. export class Database implements IOfflineProvider {
  142732. private _callbackManifestChecked;
  142733. private _currentSceneUrl;
  142734. private _db;
  142735. private _enableSceneOffline;
  142736. private _enableTexturesOffline;
  142737. private _manifestVersionFound;
  142738. private _mustUpdateRessources;
  142739. private _hasReachedQuota;
  142740. private _isSupported;
  142741. private _idbFactory;
  142742. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  142743. private static IsUASupportingBlobStorage;
  142744. /**
  142745. * Gets a boolean indicating if Database storate is enabled (off by default)
  142746. */
  142747. static IDBStorageEnabled: boolean;
  142748. /**
  142749. * Gets a boolean indicating if scene must be saved in the database
  142750. */
  142751. get enableSceneOffline(): boolean;
  142752. /**
  142753. * Gets a boolean indicating if textures must be saved in the database
  142754. */
  142755. get enableTexturesOffline(): boolean;
  142756. /**
  142757. * Creates a new Database
  142758. * @param urlToScene defines the url to load the scene
  142759. * @param callbackManifestChecked defines the callback to use when manifest is checked
  142760. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  142761. */
  142762. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  142763. private static _ParseURL;
  142764. private static _ReturnFullUrlLocation;
  142765. private _checkManifestFile;
  142766. /**
  142767. * Open the database and make it available
  142768. * @param successCallback defines the callback to call on success
  142769. * @param errorCallback defines the callback to call on error
  142770. */
  142771. open(successCallback: () => void, errorCallback: () => void): void;
  142772. /**
  142773. * Loads an image from the database
  142774. * @param url defines the url to load from
  142775. * @param image defines the target DOM image
  142776. */
  142777. loadImage(url: string, image: HTMLImageElement): void;
  142778. private _loadImageFromDBAsync;
  142779. private _saveImageIntoDBAsync;
  142780. private _checkVersionFromDB;
  142781. private _loadVersionFromDBAsync;
  142782. private _saveVersionIntoDBAsync;
  142783. /**
  142784. * Loads a file from database
  142785. * @param url defines the URL to load from
  142786. * @param sceneLoaded defines a callback to call on success
  142787. * @param progressCallBack defines a callback to call when progress changed
  142788. * @param errorCallback defines a callback to call on error
  142789. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  142790. */
  142791. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  142792. private _loadFileAsync;
  142793. private _saveFileAsync;
  142794. /**
  142795. * Validates if xhr data is correct
  142796. * @param xhr defines the request to validate
  142797. * @param dataType defines the expected data type
  142798. * @returns true if data is correct
  142799. */
  142800. private static _ValidateXHRData;
  142801. }
  142802. }
  142803. declare module BABYLON {
  142804. /** @hidden */
  142805. export var gpuUpdateParticlesPixelShader: {
  142806. name: string;
  142807. shader: string;
  142808. };
  142809. }
  142810. declare module BABYLON {
  142811. /** @hidden */
  142812. export var gpuUpdateParticlesVertexShader: {
  142813. name: string;
  142814. shader: string;
  142815. };
  142816. }
  142817. declare module BABYLON {
  142818. /** @hidden */
  142819. export var clipPlaneFragmentDeclaration2: {
  142820. name: string;
  142821. shader: string;
  142822. };
  142823. }
  142824. declare module BABYLON {
  142825. /** @hidden */
  142826. export var gpuRenderParticlesPixelShader: {
  142827. name: string;
  142828. shader: string;
  142829. };
  142830. }
  142831. declare module BABYLON {
  142832. /** @hidden */
  142833. export var clipPlaneVertexDeclaration2: {
  142834. name: string;
  142835. shader: string;
  142836. };
  142837. }
  142838. declare module BABYLON {
  142839. /** @hidden */
  142840. export var gpuRenderParticlesVertexShader: {
  142841. name: string;
  142842. shader: string;
  142843. };
  142844. }
  142845. declare module BABYLON {
  142846. /**
  142847. * This represents a GPU particle system in Babylon
  142848. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  142849. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  142850. */
  142851. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  142852. /**
  142853. * The layer mask we are rendering the particles through.
  142854. */
  142855. layerMask: number;
  142856. private _capacity;
  142857. private _activeCount;
  142858. private _currentActiveCount;
  142859. private _accumulatedCount;
  142860. private _renderEffect;
  142861. private _updateEffect;
  142862. private _buffer0;
  142863. private _buffer1;
  142864. private _spriteBuffer;
  142865. private _updateVAO;
  142866. private _renderVAO;
  142867. private _targetIndex;
  142868. private _sourceBuffer;
  142869. private _targetBuffer;
  142870. private _engine;
  142871. private _currentRenderId;
  142872. private _started;
  142873. private _stopped;
  142874. private _timeDelta;
  142875. private _randomTexture;
  142876. private _randomTexture2;
  142877. private _attributesStrideSize;
  142878. private _updateEffectOptions;
  142879. private _randomTextureSize;
  142880. private _actualFrame;
  142881. private _customEffect;
  142882. private readonly _rawTextureWidth;
  142883. /**
  142884. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  142885. */
  142886. static get IsSupported(): boolean;
  142887. /**
  142888. * An event triggered when the system is disposed.
  142889. */
  142890. onDisposeObservable: Observable<IParticleSystem>;
  142891. /**
  142892. * Gets the maximum number of particles active at the same time.
  142893. * @returns The max number of active particles.
  142894. */
  142895. getCapacity(): number;
  142896. /**
  142897. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  142898. * to override the particles.
  142899. */
  142900. forceDepthWrite: boolean;
  142901. /**
  142902. * Gets or set the number of active particles
  142903. */
  142904. get activeParticleCount(): number;
  142905. set activeParticleCount(value: number);
  142906. private _preWarmDone;
  142907. /**
  142908. * Specifies if the particles are updated in emitter local space or world space.
  142909. */
  142910. isLocal: boolean;
  142911. /**
  142912. * Is this system ready to be used/rendered
  142913. * @return true if the system is ready
  142914. */
  142915. isReady(): boolean;
  142916. /**
  142917. * Gets if the system has been started. (Note: this will still be true after stop is called)
  142918. * @returns True if it has been started, otherwise false.
  142919. */
  142920. isStarted(): boolean;
  142921. /**
  142922. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  142923. * @returns True if it has been stopped, otherwise false.
  142924. */
  142925. isStopped(): boolean;
  142926. /**
  142927. * Gets a boolean indicating that the system is stopping
  142928. * @returns true if the system is currently stopping
  142929. */
  142930. isStopping(): boolean;
  142931. /**
  142932. * Gets the number of particles active at the same time.
  142933. * @returns The number of active particles.
  142934. */
  142935. getActiveCount(): number;
  142936. /**
  142937. * Starts the particle system and begins to emit
  142938. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  142939. */
  142940. start(delay?: number): void;
  142941. /**
  142942. * Stops the particle system.
  142943. */
  142944. stop(): void;
  142945. /**
  142946. * Remove all active particles
  142947. */
  142948. reset(): void;
  142949. /**
  142950. * Returns the string "GPUParticleSystem"
  142951. * @returns a string containing the class name
  142952. */
  142953. getClassName(): string;
  142954. /**
  142955. * Gets the custom effect used to render the particles
  142956. * @param blendMode Blend mode for which the effect should be retrieved
  142957. * @returns The effect
  142958. */
  142959. getCustomEffect(blendMode?: number): Nullable<Effect>;
  142960. /**
  142961. * Sets the custom effect used to render the particles
  142962. * @param effect The effect to set
  142963. * @param blendMode Blend mode for which the effect should be set
  142964. */
  142965. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  142966. /** @hidden */
  142967. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  142968. /**
  142969. * Observable that will be called just before the particles are drawn
  142970. */
  142971. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  142972. /**
  142973. * Gets the name of the particle vertex shader
  142974. */
  142975. get vertexShaderName(): string;
  142976. private _colorGradientsTexture;
  142977. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  142978. /**
  142979. * Adds a new color gradient
  142980. * @param gradient defines the gradient to use (between 0 and 1)
  142981. * @param color1 defines the color to affect to the specified gradient
  142982. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  142983. * @returns the current particle system
  142984. */
  142985. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  142986. private _refreshColorGradient;
  142987. /** Force the system to rebuild all gradients that need to be resync */
  142988. forceRefreshGradients(): void;
  142989. /**
  142990. * Remove a specific color gradient
  142991. * @param gradient defines the gradient to remove
  142992. * @returns the current particle system
  142993. */
  142994. removeColorGradient(gradient: number): GPUParticleSystem;
  142995. private _angularSpeedGradientsTexture;
  142996. private _sizeGradientsTexture;
  142997. private _velocityGradientsTexture;
  142998. private _limitVelocityGradientsTexture;
  142999. private _dragGradientsTexture;
  143000. private _addFactorGradient;
  143001. /**
  143002. * Adds a new size gradient
  143003. * @param gradient defines the gradient to use (between 0 and 1)
  143004. * @param factor defines the size factor to affect to the specified gradient
  143005. * @returns the current particle system
  143006. */
  143007. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  143008. /**
  143009. * Remove a specific size gradient
  143010. * @param gradient defines the gradient to remove
  143011. * @returns the current particle system
  143012. */
  143013. removeSizeGradient(gradient: number): GPUParticleSystem;
  143014. private _refreshFactorGradient;
  143015. /**
  143016. * Adds a new angular speed gradient
  143017. * @param gradient defines the gradient to use (between 0 and 1)
  143018. * @param factor defines the angular speed to affect to the specified gradient
  143019. * @returns the current particle system
  143020. */
  143021. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  143022. /**
  143023. * Remove a specific angular speed gradient
  143024. * @param gradient defines the gradient to remove
  143025. * @returns the current particle system
  143026. */
  143027. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  143028. /**
  143029. * Adds a new velocity gradient
  143030. * @param gradient defines the gradient to use (between 0 and 1)
  143031. * @param factor defines the velocity to affect to the specified gradient
  143032. * @returns the current particle system
  143033. */
  143034. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  143035. /**
  143036. * Remove a specific velocity gradient
  143037. * @param gradient defines the gradient to remove
  143038. * @returns the current particle system
  143039. */
  143040. removeVelocityGradient(gradient: number): GPUParticleSystem;
  143041. /**
  143042. * Adds a new limit velocity gradient
  143043. * @param gradient defines the gradient to use (between 0 and 1)
  143044. * @param factor defines the limit velocity value to affect to the specified gradient
  143045. * @returns the current particle system
  143046. */
  143047. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  143048. /**
  143049. * Remove a specific limit velocity gradient
  143050. * @param gradient defines the gradient to remove
  143051. * @returns the current particle system
  143052. */
  143053. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  143054. /**
  143055. * Adds a new drag gradient
  143056. * @param gradient defines the gradient to use (between 0 and 1)
  143057. * @param factor defines the drag value to affect to the specified gradient
  143058. * @returns the current particle system
  143059. */
  143060. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  143061. /**
  143062. * Remove a specific drag gradient
  143063. * @param gradient defines the gradient to remove
  143064. * @returns the current particle system
  143065. */
  143066. removeDragGradient(gradient: number): GPUParticleSystem;
  143067. /**
  143068. * Not supported by GPUParticleSystem
  143069. * @param gradient defines the gradient to use (between 0 and 1)
  143070. * @param factor defines the emit rate value to affect to the specified gradient
  143071. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  143072. * @returns the current particle system
  143073. */
  143074. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  143075. /**
  143076. * Not supported by GPUParticleSystem
  143077. * @param gradient defines the gradient to remove
  143078. * @returns the current particle system
  143079. */
  143080. removeEmitRateGradient(gradient: number): IParticleSystem;
  143081. /**
  143082. * Not supported by GPUParticleSystem
  143083. * @param gradient defines the gradient to use (between 0 and 1)
  143084. * @param factor defines the start size value to affect to the specified gradient
  143085. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  143086. * @returns the current particle system
  143087. */
  143088. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  143089. /**
  143090. * Not supported by GPUParticleSystem
  143091. * @param gradient defines the gradient to remove
  143092. * @returns the current particle system
  143093. */
  143094. removeStartSizeGradient(gradient: number): IParticleSystem;
  143095. /**
  143096. * Not supported by GPUParticleSystem
  143097. * @param gradient defines the gradient to use (between 0 and 1)
  143098. * @param min defines the color remap minimal range
  143099. * @param max defines the color remap maximal range
  143100. * @returns the current particle system
  143101. */
  143102. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  143103. /**
  143104. * Not supported by GPUParticleSystem
  143105. * @param gradient defines the gradient to remove
  143106. * @returns the current particle system
  143107. */
  143108. removeColorRemapGradient(): IParticleSystem;
  143109. /**
  143110. * Not supported by GPUParticleSystem
  143111. * @param gradient defines the gradient to use (between 0 and 1)
  143112. * @param min defines the alpha remap minimal range
  143113. * @param max defines the alpha remap maximal range
  143114. * @returns the current particle system
  143115. */
  143116. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  143117. /**
  143118. * Not supported by GPUParticleSystem
  143119. * @param gradient defines the gradient to remove
  143120. * @returns the current particle system
  143121. */
  143122. removeAlphaRemapGradient(): IParticleSystem;
  143123. /**
  143124. * Not supported by GPUParticleSystem
  143125. * @param gradient defines the gradient to use (between 0 and 1)
  143126. * @param color defines the color to affect to the specified gradient
  143127. * @returns the current particle system
  143128. */
  143129. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  143130. /**
  143131. * Not supported by GPUParticleSystem
  143132. * @param gradient defines the gradient to remove
  143133. * @returns the current particle system
  143134. */
  143135. removeRampGradient(): IParticleSystem;
  143136. /**
  143137. * Not supported by GPUParticleSystem
  143138. * @returns the list of ramp gradients
  143139. */
  143140. getRampGradients(): Nullable<Array<Color3Gradient>>;
  143141. /**
  143142. * Not supported by GPUParticleSystem
  143143. * Gets or sets a boolean indicating that ramp gradients must be used
  143144. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  143145. */
  143146. get useRampGradients(): boolean;
  143147. set useRampGradients(value: boolean);
  143148. /**
  143149. * Not supported by GPUParticleSystem
  143150. * @param gradient defines the gradient to use (between 0 and 1)
  143151. * @param factor defines the life time factor to affect to the specified gradient
  143152. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  143153. * @returns the current particle system
  143154. */
  143155. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  143156. /**
  143157. * Not supported by GPUParticleSystem
  143158. * @param gradient defines the gradient to remove
  143159. * @returns the current particle system
  143160. */
  143161. removeLifeTimeGradient(gradient: number): IParticleSystem;
  143162. /**
  143163. * Instantiates a GPU particle system.
  143164. * 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.
  143165. * @param name The name of the particle system
  143166. * @param options The options used to create the system
  143167. * @param scene The scene the particle system belongs to
  143168. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  143169. * @param customEffect a custom effect used to change the way particles are rendered by default
  143170. */
  143171. constructor(name: string, options: Partial<{
  143172. capacity: number;
  143173. randomTextureSize: number;
  143174. }>, scene: Scene, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  143175. protected _reset(): void;
  143176. private _createUpdateVAO;
  143177. private _createRenderVAO;
  143178. private _initialize;
  143179. /** @hidden */
  143180. _recreateUpdateEffect(): void;
  143181. private _getEffect;
  143182. /**
  143183. * Fill the defines array according to the current settings of the particle system
  143184. * @param defines Array to be updated
  143185. * @param blendMode blend mode to take into account when updating the array
  143186. */
  143187. fillDefines(defines: Array<string>, blendMode?: number): void;
  143188. /**
  143189. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  143190. * @param uniforms Uniforms array to fill
  143191. * @param attributes Attributes array to fill
  143192. * @param samplers Samplers array to fill
  143193. */
  143194. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  143195. /** @hidden */
  143196. _recreateRenderEffect(): Effect;
  143197. /**
  143198. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  143199. * @param preWarm defines if we are in the pre-warmimg phase
  143200. */
  143201. animate(preWarm?: boolean): void;
  143202. private _createFactorGradientTexture;
  143203. private _createSizeGradientTexture;
  143204. private _createAngularSpeedGradientTexture;
  143205. private _createVelocityGradientTexture;
  143206. private _createLimitVelocityGradientTexture;
  143207. private _createDragGradientTexture;
  143208. private _createColorGradientTexture;
  143209. /**
  143210. * Renders the particle system in its current state
  143211. * @param preWarm defines if the system should only update the particles but not render them
  143212. * @returns the current number of particles
  143213. */
  143214. render(preWarm?: boolean): number;
  143215. /**
  143216. * Rebuilds the particle system
  143217. */
  143218. rebuild(): void;
  143219. private _releaseBuffers;
  143220. private _releaseVAOs;
  143221. /**
  143222. * Disposes the particle system and free the associated resources
  143223. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  143224. */
  143225. dispose(disposeTexture?: boolean): void;
  143226. /**
  143227. * Clones the particle system.
  143228. * @param name The name of the cloned object
  143229. * @param newEmitter The new emitter to use
  143230. * @returns the cloned particle system
  143231. */
  143232. clone(name: string, newEmitter: any): GPUParticleSystem;
  143233. /**
  143234. * Serializes the particle system to a JSON object
  143235. * @param serializeTexture defines if the texture must be serialized as well
  143236. * @returns the JSON object
  143237. */
  143238. serialize(serializeTexture?: boolean): any;
  143239. /**
  143240. * Parses a JSON object to create a GPU particle system.
  143241. * @param parsedParticleSystem The JSON object to parse
  143242. * @param scene The scene to create the particle system in
  143243. * @param rootUrl The root url to use to load external dependencies like texture
  143244. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  143245. * @returns the parsed GPU particle system
  143246. */
  143247. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  143248. }
  143249. }
  143250. declare module BABYLON {
  143251. /**
  143252. * Represents a set of particle systems working together to create a specific effect
  143253. */
  143254. export class ParticleSystemSet implements IDisposable {
  143255. /**
  143256. * Gets or sets base Assets URL
  143257. */
  143258. static BaseAssetsUrl: string;
  143259. private _emitterCreationOptions;
  143260. private _emitterNode;
  143261. /**
  143262. * Gets the particle system list
  143263. */
  143264. systems: IParticleSystem[];
  143265. /**
  143266. * Gets the emitter node used with this set
  143267. */
  143268. get emitterNode(): Nullable<TransformNode>;
  143269. /**
  143270. * Creates a new emitter mesh as a sphere
  143271. * @param options defines the options used to create the sphere
  143272. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  143273. * @param scene defines the hosting scene
  143274. */
  143275. setEmitterAsSphere(options: {
  143276. diameter: number;
  143277. segments: number;
  143278. color: Color3;
  143279. }, renderingGroupId: number, scene: Scene): void;
  143280. /**
  143281. * Starts all particle systems of the set
  143282. * @param emitter defines an optional mesh to use as emitter for the particle systems
  143283. */
  143284. start(emitter?: AbstractMesh): void;
  143285. /**
  143286. * Release all associated resources
  143287. */
  143288. dispose(): void;
  143289. /**
  143290. * Serialize the set into a JSON compatible object
  143291. * @param serializeTexture defines if the texture must be serialized as well
  143292. * @returns a JSON compatible representation of the set
  143293. */
  143294. serialize(serializeTexture?: boolean): any;
  143295. /**
  143296. * Parse a new ParticleSystemSet from a serialized source
  143297. * @param data defines a JSON compatible representation of the set
  143298. * @param scene defines the hosting scene
  143299. * @param gpu defines if we want GPU particles or CPU particles
  143300. * @returns a new ParticleSystemSet
  143301. */
  143302. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  143303. }
  143304. }
  143305. declare module BABYLON {
  143306. /**
  143307. * This class is made for on one-liner static method to help creating particle system set.
  143308. */
  143309. export class ParticleHelper {
  143310. /**
  143311. * Gets or sets base Assets URL
  143312. */
  143313. static BaseAssetsUrl: string;
  143314. /** Define the Url to load snippets */
  143315. static SnippetUrl: string;
  143316. /**
  143317. * Create a default particle system that you can tweak
  143318. * @param emitter defines the emitter to use
  143319. * @param capacity defines the system capacity (default is 500 particles)
  143320. * @param scene defines the hosting scene
  143321. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  143322. * @returns the new Particle system
  143323. */
  143324. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  143325. /**
  143326. * This is the main static method (one-liner) of this helper to create different particle systems
  143327. * @param type This string represents the type to the particle system to create
  143328. * @param scene The scene where the particle system should live
  143329. * @param gpu If the system will use gpu
  143330. * @returns the ParticleSystemSet created
  143331. */
  143332. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  143333. /**
  143334. * Static function used to export a particle system to a ParticleSystemSet variable.
  143335. * Please note that the emitter shape is not exported
  143336. * @param systems defines the particle systems to export
  143337. * @returns the created particle system set
  143338. */
  143339. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  143340. /**
  143341. * Creates a particle system from a snippet saved in a remote file
  143342. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  143343. * @param url defines the url to load from
  143344. * @param scene defines the hosting scene
  143345. * @param gpu If the system will use gpu
  143346. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  143347. * @returns a promise that will resolve to the new particle system
  143348. */
  143349. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  143350. /**
  143351. * Creates a particle system from a snippet saved by the particle system editor
  143352. * @param snippetId defines the snippet to load
  143353. * @param scene defines the hosting scene
  143354. * @param gpu If the system will use gpu
  143355. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  143356. * @returns a promise that will resolve to the new particle system
  143357. */
  143358. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  143359. }
  143360. }
  143361. declare module BABYLON {
  143362. interface Engine {
  143363. /**
  143364. * Create an effect to use with particle systems.
  143365. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  143366. * the particle system for which you want to create a custom effect in the last parameter
  143367. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  143368. * @param uniformsNames defines a list of attribute names
  143369. * @param samplers defines an array of string used to represent textures
  143370. * @param defines defines the string containing the defines to use to compile the shaders
  143371. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  143372. * @param onCompiled defines a function to call when the effect creation is successful
  143373. * @param onError defines a function to call when the effect creation has failed
  143374. * @param particleSystem the particle system you want to create the effect for
  143375. * @returns the new Effect
  143376. */
  143377. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  143378. }
  143379. interface Mesh {
  143380. /**
  143381. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  143382. * @returns an array of IParticleSystem
  143383. */
  143384. getEmittedParticleSystems(): IParticleSystem[];
  143385. /**
  143386. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  143387. * @returns an array of IParticleSystem
  143388. */
  143389. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  143390. }
  143391. }
  143392. declare module BABYLON {
  143393. /** Defines the 4 color options */
  143394. export enum PointColor {
  143395. /** color value */
  143396. Color = 2,
  143397. /** uv value */
  143398. UV = 1,
  143399. /** random value */
  143400. Random = 0,
  143401. /** stated value */
  143402. Stated = 3
  143403. }
  143404. /**
  143405. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  143406. * 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.
  143407. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  143408. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  143409. *
  143410. * Full documentation here : TO BE ENTERED
  143411. */
  143412. export class PointsCloudSystem implements IDisposable {
  143413. /**
  143414. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  143415. * Example : var p = SPS.particles[i];
  143416. */
  143417. particles: CloudPoint[];
  143418. /**
  143419. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  143420. */
  143421. nbParticles: number;
  143422. /**
  143423. * This a counter for your own usage. It's not set by any SPS functions.
  143424. */
  143425. counter: number;
  143426. /**
  143427. * The PCS name. This name is also given to the underlying mesh.
  143428. */
  143429. name: string;
  143430. /**
  143431. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  143432. */
  143433. mesh: Mesh;
  143434. /**
  143435. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  143436. * Please read :
  143437. */
  143438. vars: any;
  143439. /**
  143440. * @hidden
  143441. */
  143442. _size: number;
  143443. private _scene;
  143444. private _promises;
  143445. private _positions;
  143446. private _indices;
  143447. private _normals;
  143448. private _colors;
  143449. private _uvs;
  143450. private _indices32;
  143451. private _positions32;
  143452. private _colors32;
  143453. private _uvs32;
  143454. private _updatable;
  143455. private _isVisibilityBoxLocked;
  143456. private _alwaysVisible;
  143457. private _groups;
  143458. private _groupCounter;
  143459. private _computeParticleColor;
  143460. private _computeParticleTexture;
  143461. private _computeParticleRotation;
  143462. private _computeBoundingBox;
  143463. private _isReady;
  143464. /**
  143465. * Creates a PCS (Points Cloud System) object
  143466. * @param name (String) is the PCS name, this will be the underlying mesh name
  143467. * @param pointSize (number) is the size for each point
  143468. * @param scene (Scene) is the scene in which the PCS is added
  143469. * @param options defines the options of the PCS e.g.
  143470. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  143471. */
  143472. constructor(name: string, pointSize: number, scene: Scene, options?: {
  143473. updatable?: boolean;
  143474. });
  143475. /**
  143476. * Builds the PCS underlying mesh. Returns a standard Mesh.
  143477. * If no points were added to the PCS, the returned mesh is just a single point.
  143478. * @returns a promise for the created mesh
  143479. */
  143480. buildMeshAsync(): Promise<Mesh>;
  143481. /**
  143482. * @hidden
  143483. */
  143484. private _buildMesh;
  143485. private _addParticle;
  143486. private _randomUnitVector;
  143487. private _getColorIndicesForCoord;
  143488. private _setPointsColorOrUV;
  143489. private _colorFromTexture;
  143490. private _calculateDensity;
  143491. /**
  143492. * Adds points to the PCS in random positions within a unit sphere
  143493. * @param nb (positive integer) the number of particles to be created from this model
  143494. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  143495. * @returns the number of groups in the system
  143496. */
  143497. addPoints(nb: number, pointFunction?: any): number;
  143498. /**
  143499. * Adds points to the PCS from the surface of the model shape
  143500. * @param mesh is any Mesh object that will be used as a surface model for the points
  143501. * @param nb (positive integer) the number of particles to be created from this model
  143502. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  143503. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  143504. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  143505. * @returns the number of groups in the system
  143506. */
  143507. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  143508. /**
  143509. * Adds points to the PCS inside the model shape
  143510. * @param mesh is any Mesh object that will be used as a surface model for the points
  143511. * @param nb (positive integer) the number of particles to be created from this model
  143512. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  143513. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  143514. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  143515. * @returns the number of groups in the system
  143516. */
  143517. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  143518. /**
  143519. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  143520. * This method calls `updateParticle()` for each particle of the SPS.
  143521. * For an animated SPS, it is usually called within the render loop.
  143522. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  143523. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  143524. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  143525. * @returns the PCS.
  143526. */
  143527. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  143528. /**
  143529. * Disposes the PCS.
  143530. */
  143531. dispose(): void;
  143532. /**
  143533. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  143534. * doc :
  143535. * @returns the PCS.
  143536. */
  143537. refreshVisibleSize(): PointsCloudSystem;
  143538. /**
  143539. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  143540. * @param size the size (float) of the visibility box
  143541. * note : this doesn't lock the PCS mesh bounding box.
  143542. * doc :
  143543. */
  143544. setVisibilityBox(size: number): void;
  143545. /**
  143546. * Gets whether the PCS is always visible or not
  143547. * doc :
  143548. */
  143549. get isAlwaysVisible(): boolean;
  143550. /**
  143551. * Sets the PCS as always visible or not
  143552. * doc :
  143553. */
  143554. set isAlwaysVisible(val: boolean);
  143555. /**
  143556. * Tells to `setParticles()` to compute the particle rotations or not
  143557. * Default value : false. The PCS is faster when it's set to false
  143558. * Note : particle rotations are only applied to parent particles
  143559. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  143560. */
  143561. set computeParticleRotation(val: boolean);
  143562. /**
  143563. * Tells to `setParticles()` to compute the particle colors or not.
  143564. * Default value : true. The PCS is faster when it's set to false.
  143565. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  143566. */
  143567. set computeParticleColor(val: boolean);
  143568. set computeParticleTexture(val: boolean);
  143569. /**
  143570. * Gets if `setParticles()` computes the particle colors or not.
  143571. * Default value : false. The PCS is faster when it's set to false.
  143572. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  143573. */
  143574. get computeParticleColor(): boolean;
  143575. /**
  143576. * Gets if `setParticles()` computes the particle textures or not.
  143577. * Default value : false. The PCS is faster when it's set to false.
  143578. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  143579. */
  143580. get computeParticleTexture(): boolean;
  143581. /**
  143582. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  143583. */
  143584. set computeBoundingBox(val: boolean);
  143585. /**
  143586. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  143587. */
  143588. get computeBoundingBox(): boolean;
  143589. /**
  143590. * This function does nothing. It may be overwritten to set all the particle first values.
  143591. * The PCS doesn't call this function, you may have to call it by your own.
  143592. * doc :
  143593. */
  143594. initParticles(): void;
  143595. /**
  143596. * This function does nothing. It may be overwritten to recycle a particle
  143597. * The PCS doesn't call this function, you can to call it
  143598. * doc :
  143599. * @param particle The particle to recycle
  143600. * @returns the recycled particle
  143601. */
  143602. recycleParticle(particle: CloudPoint): CloudPoint;
  143603. /**
  143604. * Updates a particle : this function should be overwritten by the user.
  143605. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  143606. * doc :
  143607. * @example : just set a particle position or velocity and recycle conditions
  143608. * @param particle The particle to update
  143609. * @returns the updated particle
  143610. */
  143611. updateParticle(particle: CloudPoint): CloudPoint;
  143612. /**
  143613. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  143614. * This does nothing and may be overwritten by the user.
  143615. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  143616. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  143617. * @param update the boolean update value actually passed to setParticles()
  143618. */
  143619. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  143620. /**
  143621. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  143622. * This will be passed three parameters.
  143623. * This does nothing and may be overwritten by the user.
  143624. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  143625. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  143626. * @param update the boolean update value actually passed to setParticles()
  143627. */
  143628. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  143629. }
  143630. }
  143631. declare module BABYLON {
  143632. /**
  143633. * Represents one particle of a points cloud system.
  143634. */
  143635. export class CloudPoint {
  143636. /**
  143637. * particle global index
  143638. */
  143639. idx: number;
  143640. /**
  143641. * The color of the particle
  143642. */
  143643. color: Nullable<Color4>;
  143644. /**
  143645. * The world space position of the particle.
  143646. */
  143647. position: Vector3;
  143648. /**
  143649. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  143650. */
  143651. rotation: Vector3;
  143652. /**
  143653. * The world space rotation quaternion of the particle.
  143654. */
  143655. rotationQuaternion: Nullable<Quaternion>;
  143656. /**
  143657. * The uv of the particle.
  143658. */
  143659. uv: Nullable<Vector2>;
  143660. /**
  143661. * The current speed of the particle.
  143662. */
  143663. velocity: Vector3;
  143664. /**
  143665. * The pivot point in the particle local space.
  143666. */
  143667. pivot: Vector3;
  143668. /**
  143669. * Must the particle be translated from its pivot point in its local space ?
  143670. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  143671. * Default : false
  143672. */
  143673. translateFromPivot: boolean;
  143674. /**
  143675. * Index of this particle in the global "positions" array (Internal use)
  143676. * @hidden
  143677. */
  143678. _pos: number;
  143679. /**
  143680. * @hidden Index of this particle in the global "indices" array (Internal use)
  143681. */
  143682. _ind: number;
  143683. /**
  143684. * Group this particle belongs to
  143685. */
  143686. _group: PointsGroup;
  143687. /**
  143688. * Group id of this particle
  143689. */
  143690. groupId: number;
  143691. /**
  143692. * Index of the particle in its group id (Internal use)
  143693. */
  143694. idxInGroup: number;
  143695. /**
  143696. * @hidden Particle BoundingInfo object (Internal use)
  143697. */
  143698. _boundingInfo: BoundingInfo;
  143699. /**
  143700. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  143701. */
  143702. _pcs: PointsCloudSystem;
  143703. /**
  143704. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  143705. */
  143706. _stillInvisible: boolean;
  143707. /**
  143708. * @hidden Last computed particle rotation matrix
  143709. */
  143710. _rotationMatrix: number[];
  143711. /**
  143712. * Parent particle Id, if any.
  143713. * Default null.
  143714. */
  143715. parentId: Nullable<number>;
  143716. /**
  143717. * @hidden Internal global position in the PCS.
  143718. */
  143719. _globalPosition: Vector3;
  143720. /**
  143721. * Creates a Point Cloud object.
  143722. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  143723. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  143724. * @param group (PointsGroup) is the group the particle belongs to
  143725. * @param groupId (integer) is the group identifier in the PCS.
  143726. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  143727. * @param pcs defines the PCS it is associated to
  143728. */
  143729. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  143730. /**
  143731. * get point size
  143732. */
  143733. get size(): Vector3;
  143734. /**
  143735. * Set point size
  143736. */
  143737. set size(scale: Vector3);
  143738. /**
  143739. * Legacy support, changed quaternion to rotationQuaternion
  143740. */
  143741. get quaternion(): Nullable<Quaternion>;
  143742. /**
  143743. * Legacy support, changed quaternion to rotationQuaternion
  143744. */
  143745. set quaternion(q: Nullable<Quaternion>);
  143746. /**
  143747. * Returns a boolean. True if the particle intersects a mesh, else false
  143748. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  143749. * @param target is the object (point or mesh) what the intersection is computed against
  143750. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  143751. * @returns true if it intersects
  143752. */
  143753. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  143754. /**
  143755. * get the rotation matrix of the particle
  143756. * @hidden
  143757. */
  143758. getRotationMatrix(m: Matrix): void;
  143759. }
  143760. /**
  143761. * Represents a group of points in a points cloud system
  143762. * * PCS internal tool, don't use it manually.
  143763. */
  143764. export class PointsGroup {
  143765. /**
  143766. * The group id
  143767. * @hidden
  143768. */
  143769. groupID: number;
  143770. /**
  143771. * image data for group (internal use)
  143772. * @hidden
  143773. */
  143774. _groupImageData: Nullable<ArrayBufferView>;
  143775. /**
  143776. * Image Width (internal use)
  143777. * @hidden
  143778. */
  143779. _groupImgWidth: number;
  143780. /**
  143781. * Image Height (internal use)
  143782. * @hidden
  143783. */
  143784. _groupImgHeight: number;
  143785. /**
  143786. * Custom position function (internal use)
  143787. * @hidden
  143788. */
  143789. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  143790. /**
  143791. * density per facet for surface points
  143792. * @hidden
  143793. */
  143794. _groupDensity: number[];
  143795. /**
  143796. * Only when points are colored by texture carries pointer to texture list array
  143797. * @hidden
  143798. */
  143799. _textureNb: number;
  143800. /**
  143801. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  143802. * PCS internal tool, don't use it manually.
  143803. * @hidden
  143804. */
  143805. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  143806. }
  143807. }
  143808. declare module BABYLON {
  143809. interface Scene {
  143810. /** @hidden (Backing field) */
  143811. _physicsEngine: Nullable<IPhysicsEngine>;
  143812. /** @hidden */
  143813. _physicsTimeAccumulator: number;
  143814. /**
  143815. * Gets the current physics engine
  143816. * @returns a IPhysicsEngine or null if none attached
  143817. */
  143818. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  143819. /**
  143820. * Enables physics to the current scene
  143821. * @param gravity defines the scene's gravity for the physics engine
  143822. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  143823. * @return a boolean indicating if the physics engine was initialized
  143824. */
  143825. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  143826. /**
  143827. * Disables and disposes the physics engine associated with the scene
  143828. */
  143829. disablePhysicsEngine(): void;
  143830. /**
  143831. * Gets a boolean indicating if there is an active physics engine
  143832. * @returns a boolean indicating if there is an active physics engine
  143833. */
  143834. isPhysicsEnabled(): boolean;
  143835. /**
  143836. * Deletes a physics compound impostor
  143837. * @param compound defines the compound to delete
  143838. */
  143839. deleteCompoundImpostor(compound: any): void;
  143840. /**
  143841. * An event triggered when physic simulation is about to be run
  143842. */
  143843. onBeforePhysicsObservable: Observable<Scene>;
  143844. /**
  143845. * An event triggered when physic simulation has been done
  143846. */
  143847. onAfterPhysicsObservable: Observable<Scene>;
  143848. }
  143849. interface AbstractMesh {
  143850. /** @hidden */
  143851. _physicsImpostor: Nullable<PhysicsImpostor>;
  143852. /**
  143853. * Gets or sets impostor used for physic simulation
  143854. * @see http://doc.babylonjs.com/features/physics_engine
  143855. */
  143856. physicsImpostor: Nullable<PhysicsImpostor>;
  143857. /**
  143858. * Gets the current physics impostor
  143859. * @see http://doc.babylonjs.com/features/physics_engine
  143860. * @returns a physics impostor or null
  143861. */
  143862. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  143863. /** Apply a physic impulse to the mesh
  143864. * @param force defines the force to apply
  143865. * @param contactPoint defines where to apply the force
  143866. * @returns the current mesh
  143867. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  143868. */
  143869. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  143870. /**
  143871. * Creates a physic joint between two meshes
  143872. * @param otherMesh defines the other mesh to use
  143873. * @param pivot1 defines the pivot to use on this mesh
  143874. * @param pivot2 defines the pivot to use on the other mesh
  143875. * @param options defines additional options (can be plugin dependent)
  143876. * @returns the current mesh
  143877. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  143878. */
  143879. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  143880. /** @hidden */
  143881. _disposePhysicsObserver: Nullable<Observer<Node>>;
  143882. }
  143883. /**
  143884. * Defines the physics engine scene component responsible to manage a physics engine
  143885. */
  143886. export class PhysicsEngineSceneComponent implements ISceneComponent {
  143887. /**
  143888. * The component name helpful to identify the component in the list of scene components.
  143889. */
  143890. readonly name: string;
  143891. /**
  143892. * The scene the component belongs to.
  143893. */
  143894. scene: Scene;
  143895. /**
  143896. * Creates a new instance of the component for the given scene
  143897. * @param scene Defines the scene to register the component in
  143898. */
  143899. constructor(scene: Scene);
  143900. /**
  143901. * Registers the component in a given scene
  143902. */
  143903. register(): void;
  143904. /**
  143905. * Rebuilds the elements related to this component in case of
  143906. * context lost for instance.
  143907. */
  143908. rebuild(): void;
  143909. /**
  143910. * Disposes the component and the associated ressources
  143911. */
  143912. dispose(): void;
  143913. }
  143914. }
  143915. declare module BABYLON {
  143916. /**
  143917. * A helper for physics simulations
  143918. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  143919. */
  143920. export class PhysicsHelper {
  143921. private _scene;
  143922. private _physicsEngine;
  143923. /**
  143924. * Initializes the Physics helper
  143925. * @param scene Babylon.js scene
  143926. */
  143927. constructor(scene: Scene);
  143928. /**
  143929. * Applies a radial explosion impulse
  143930. * @param origin the origin of the explosion
  143931. * @param radiusOrEventOptions the radius or the options of radial explosion
  143932. * @param strength the explosion strength
  143933. * @param falloff possible options: Constant & Linear. Defaults to Constant
  143934. * @returns A physics radial explosion event, or null
  143935. */
  143936. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  143937. /**
  143938. * Applies a radial explosion force
  143939. * @param origin the origin of the explosion
  143940. * @param radiusOrEventOptions the radius or the options of radial explosion
  143941. * @param strength the explosion strength
  143942. * @param falloff possible options: Constant & Linear. Defaults to Constant
  143943. * @returns A physics radial explosion event, or null
  143944. */
  143945. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  143946. /**
  143947. * Creates a gravitational field
  143948. * @param origin the origin of the explosion
  143949. * @param radiusOrEventOptions the radius or the options of radial explosion
  143950. * @param strength the explosion strength
  143951. * @param falloff possible options: Constant & Linear. Defaults to Constant
  143952. * @returns A physics gravitational field event, or null
  143953. */
  143954. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  143955. /**
  143956. * Creates a physics updraft event
  143957. * @param origin the origin of the updraft
  143958. * @param radiusOrEventOptions the radius or the options of the updraft
  143959. * @param strength the strength of the updraft
  143960. * @param height the height of the updraft
  143961. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  143962. * @returns A physics updraft event, or null
  143963. */
  143964. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  143965. /**
  143966. * Creates a physics vortex event
  143967. * @param origin the of the vortex
  143968. * @param radiusOrEventOptions the radius or the options of the vortex
  143969. * @param strength the strength of the vortex
  143970. * @param height the height of the vortex
  143971. * @returns a Physics vortex event, or null
  143972. * A physics vortex event or null
  143973. */
  143974. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  143975. }
  143976. /**
  143977. * Represents a physics radial explosion event
  143978. */
  143979. class PhysicsRadialExplosionEvent {
  143980. private _scene;
  143981. private _options;
  143982. private _sphere;
  143983. private _dataFetched;
  143984. /**
  143985. * Initializes a radial explosioin event
  143986. * @param _scene BabylonJS scene
  143987. * @param _options The options for the vortex event
  143988. */
  143989. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  143990. /**
  143991. * Returns the data related to the radial explosion event (sphere).
  143992. * @returns The radial explosion event data
  143993. */
  143994. getData(): PhysicsRadialExplosionEventData;
  143995. /**
  143996. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  143997. * @param impostor A physics imposter
  143998. * @param origin the origin of the explosion
  143999. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  144000. */
  144001. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  144002. /**
  144003. * Triggers affecterd impostors callbacks
  144004. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  144005. */
  144006. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  144007. /**
  144008. * Disposes the sphere.
  144009. * @param force Specifies if the sphere should be disposed by force
  144010. */
  144011. dispose(force?: boolean): void;
  144012. /*** Helpers ***/
  144013. private _prepareSphere;
  144014. private _intersectsWithSphere;
  144015. }
  144016. /**
  144017. * Represents a gravitational field event
  144018. */
  144019. class PhysicsGravitationalFieldEvent {
  144020. private _physicsHelper;
  144021. private _scene;
  144022. private _origin;
  144023. private _options;
  144024. private _tickCallback;
  144025. private _sphere;
  144026. private _dataFetched;
  144027. /**
  144028. * Initializes the physics gravitational field event
  144029. * @param _physicsHelper A physics helper
  144030. * @param _scene BabylonJS scene
  144031. * @param _origin The origin position of the gravitational field event
  144032. * @param _options The options for the vortex event
  144033. */
  144034. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  144035. /**
  144036. * Returns the data related to the gravitational field event (sphere).
  144037. * @returns A gravitational field event
  144038. */
  144039. getData(): PhysicsGravitationalFieldEventData;
  144040. /**
  144041. * Enables the gravitational field.
  144042. */
  144043. enable(): void;
  144044. /**
  144045. * Disables the gravitational field.
  144046. */
  144047. disable(): void;
  144048. /**
  144049. * Disposes the sphere.
  144050. * @param force The force to dispose from the gravitational field event
  144051. */
  144052. dispose(force?: boolean): void;
  144053. private _tick;
  144054. }
  144055. /**
  144056. * Represents a physics updraft event
  144057. */
  144058. class PhysicsUpdraftEvent {
  144059. private _scene;
  144060. private _origin;
  144061. private _options;
  144062. private _physicsEngine;
  144063. private _originTop;
  144064. private _originDirection;
  144065. private _tickCallback;
  144066. private _cylinder;
  144067. private _cylinderPosition;
  144068. private _dataFetched;
  144069. /**
  144070. * Initializes the physics updraft event
  144071. * @param _scene BabylonJS scene
  144072. * @param _origin The origin position of the updraft
  144073. * @param _options The options for the updraft event
  144074. */
  144075. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  144076. /**
  144077. * Returns the data related to the updraft event (cylinder).
  144078. * @returns A physics updraft event
  144079. */
  144080. getData(): PhysicsUpdraftEventData;
  144081. /**
  144082. * Enables the updraft.
  144083. */
  144084. enable(): void;
  144085. /**
  144086. * Disables the updraft.
  144087. */
  144088. disable(): void;
  144089. /**
  144090. * Disposes the cylinder.
  144091. * @param force Specifies if the updraft should be disposed by force
  144092. */
  144093. dispose(force?: boolean): void;
  144094. private getImpostorHitData;
  144095. private _tick;
  144096. /*** Helpers ***/
  144097. private _prepareCylinder;
  144098. private _intersectsWithCylinder;
  144099. }
  144100. /**
  144101. * Represents a physics vortex event
  144102. */
  144103. class PhysicsVortexEvent {
  144104. private _scene;
  144105. private _origin;
  144106. private _options;
  144107. private _physicsEngine;
  144108. private _originTop;
  144109. private _tickCallback;
  144110. private _cylinder;
  144111. private _cylinderPosition;
  144112. private _dataFetched;
  144113. /**
  144114. * Initializes the physics vortex event
  144115. * @param _scene The BabylonJS scene
  144116. * @param _origin The origin position of the vortex
  144117. * @param _options The options for the vortex event
  144118. */
  144119. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  144120. /**
  144121. * Returns the data related to the vortex event (cylinder).
  144122. * @returns The physics vortex event data
  144123. */
  144124. getData(): PhysicsVortexEventData;
  144125. /**
  144126. * Enables the vortex.
  144127. */
  144128. enable(): void;
  144129. /**
  144130. * Disables the cortex.
  144131. */
  144132. disable(): void;
  144133. /**
  144134. * Disposes the sphere.
  144135. * @param force
  144136. */
  144137. dispose(force?: boolean): void;
  144138. private getImpostorHitData;
  144139. private _tick;
  144140. /*** Helpers ***/
  144141. private _prepareCylinder;
  144142. private _intersectsWithCylinder;
  144143. }
  144144. /**
  144145. * Options fot the radial explosion event
  144146. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  144147. */
  144148. export class PhysicsRadialExplosionEventOptions {
  144149. /**
  144150. * The radius of the sphere for the radial explosion.
  144151. */
  144152. radius: number;
  144153. /**
  144154. * The strenth of the explosion.
  144155. */
  144156. strength: number;
  144157. /**
  144158. * The strenght of the force in correspondence to the distance of the affected object
  144159. */
  144160. falloff: PhysicsRadialImpulseFalloff;
  144161. /**
  144162. * Sphere options for the radial explosion.
  144163. */
  144164. sphere: {
  144165. segments: number;
  144166. diameter: number;
  144167. };
  144168. /**
  144169. * Sphere options for the radial explosion.
  144170. */
  144171. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  144172. }
  144173. /**
  144174. * Options fot the updraft event
  144175. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  144176. */
  144177. export class PhysicsUpdraftEventOptions {
  144178. /**
  144179. * The radius of the cylinder for the vortex
  144180. */
  144181. radius: number;
  144182. /**
  144183. * The strenth of the updraft.
  144184. */
  144185. strength: number;
  144186. /**
  144187. * The height of the cylinder for the updraft.
  144188. */
  144189. height: number;
  144190. /**
  144191. * The mode for the the updraft.
  144192. */
  144193. updraftMode: PhysicsUpdraftMode;
  144194. }
  144195. /**
  144196. * Options fot the vortex event
  144197. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  144198. */
  144199. export class PhysicsVortexEventOptions {
  144200. /**
  144201. * The radius of the cylinder for the vortex
  144202. */
  144203. radius: number;
  144204. /**
  144205. * The strenth of the vortex.
  144206. */
  144207. strength: number;
  144208. /**
  144209. * The height of the cylinder for the vortex.
  144210. */
  144211. height: number;
  144212. /**
  144213. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  144214. */
  144215. centripetalForceThreshold: number;
  144216. /**
  144217. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  144218. */
  144219. centripetalForceMultiplier: number;
  144220. /**
  144221. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  144222. */
  144223. centrifugalForceMultiplier: number;
  144224. /**
  144225. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  144226. */
  144227. updraftForceMultiplier: number;
  144228. }
  144229. /**
  144230. * The strenght of the force in correspondence to the distance of the affected object
  144231. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  144232. */
  144233. export enum PhysicsRadialImpulseFalloff {
  144234. /** Defines that impulse is constant in strength across it's whole radius */
  144235. Constant = 0,
  144236. /** Defines that impulse gets weaker if it's further from the origin */
  144237. Linear = 1
  144238. }
  144239. /**
  144240. * The strength of the force in correspondence to the distance of the affected object
  144241. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  144242. */
  144243. export enum PhysicsUpdraftMode {
  144244. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  144245. Center = 0,
  144246. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  144247. Perpendicular = 1
  144248. }
  144249. /**
  144250. * Interface for a physics hit data
  144251. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  144252. */
  144253. export interface PhysicsHitData {
  144254. /**
  144255. * The force applied at the contact point
  144256. */
  144257. force: Vector3;
  144258. /**
  144259. * The contact point
  144260. */
  144261. contactPoint: Vector3;
  144262. /**
  144263. * The distance from the origin to the contact point
  144264. */
  144265. distanceFromOrigin: number;
  144266. }
  144267. /**
  144268. * Interface for radial explosion event data
  144269. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  144270. */
  144271. export interface PhysicsRadialExplosionEventData {
  144272. /**
  144273. * A sphere used for the radial explosion event
  144274. */
  144275. sphere: Mesh;
  144276. }
  144277. /**
  144278. * Interface for gravitational field event data
  144279. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  144280. */
  144281. export interface PhysicsGravitationalFieldEventData {
  144282. /**
  144283. * A sphere mesh used for the gravitational field event
  144284. */
  144285. sphere: Mesh;
  144286. }
  144287. /**
  144288. * Interface for updraft event data
  144289. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  144290. */
  144291. export interface PhysicsUpdraftEventData {
  144292. /**
  144293. * A cylinder used for the updraft event
  144294. */
  144295. cylinder: Mesh;
  144296. }
  144297. /**
  144298. * Interface for vortex event data
  144299. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  144300. */
  144301. export interface PhysicsVortexEventData {
  144302. /**
  144303. * A cylinder used for the vortex event
  144304. */
  144305. cylinder: Mesh;
  144306. }
  144307. /**
  144308. * Interface for an affected physics impostor
  144309. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  144310. */
  144311. export interface PhysicsAffectedImpostorWithData {
  144312. /**
  144313. * The impostor affected by the effect
  144314. */
  144315. impostor: PhysicsImpostor;
  144316. /**
  144317. * The data about the hit/horce from the explosion
  144318. */
  144319. hitData: PhysicsHitData;
  144320. }
  144321. }
  144322. declare module BABYLON {
  144323. /** @hidden */
  144324. export var blackAndWhitePixelShader: {
  144325. name: string;
  144326. shader: string;
  144327. };
  144328. }
  144329. declare module BABYLON {
  144330. /**
  144331. * Post process used to render in black and white
  144332. */
  144333. export class BlackAndWhitePostProcess extends PostProcess {
  144334. /**
  144335. * Linear about to convert he result to black and white (default: 1)
  144336. */
  144337. degree: number;
  144338. /**
  144339. * Creates a black and white post process
  144340. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  144341. * @param name The name of the effect.
  144342. * @param options The required width/height ratio to downsize to before computing the render pass.
  144343. * @param camera The camera to apply the render pass to.
  144344. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  144345. * @param engine The engine which the post process will be applied. (default: current engine)
  144346. * @param reusable If the post process can be reused on the same frame. (default: false)
  144347. */
  144348. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  144349. }
  144350. }
  144351. declare module BABYLON {
  144352. /**
  144353. * This represents a set of one or more post processes in Babylon.
  144354. * A post process can be used to apply a shader to a texture after it is rendered.
  144355. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  144356. */
  144357. export class PostProcessRenderEffect {
  144358. private _postProcesses;
  144359. private _getPostProcesses;
  144360. private _singleInstance;
  144361. private _cameras;
  144362. private _indicesForCamera;
  144363. /**
  144364. * Name of the effect
  144365. * @hidden
  144366. */
  144367. _name: string;
  144368. /**
  144369. * Instantiates a post process render effect.
  144370. * A post process can be used to apply a shader to a texture after it is rendered.
  144371. * @param engine The engine the effect is tied to
  144372. * @param name The name of the effect
  144373. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  144374. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  144375. */
  144376. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  144377. /**
  144378. * Checks if all the post processes in the effect are supported.
  144379. */
  144380. get isSupported(): boolean;
  144381. /**
  144382. * Updates the current state of the effect
  144383. * @hidden
  144384. */
  144385. _update(): void;
  144386. /**
  144387. * Attaches the effect on cameras
  144388. * @param cameras The camera to attach to.
  144389. * @hidden
  144390. */
  144391. _attachCameras(cameras: Camera): void;
  144392. /**
  144393. * Attaches the effect on cameras
  144394. * @param cameras The camera to attach to.
  144395. * @hidden
  144396. */
  144397. _attachCameras(cameras: Camera[]): void;
  144398. /**
  144399. * Detaches the effect on cameras
  144400. * @param cameras The camera to detatch from.
  144401. * @hidden
  144402. */
  144403. _detachCameras(cameras: Camera): void;
  144404. /**
  144405. * Detatches the effect on cameras
  144406. * @param cameras The camera to detatch from.
  144407. * @hidden
  144408. */
  144409. _detachCameras(cameras: Camera[]): void;
  144410. /**
  144411. * Enables the effect on given cameras
  144412. * @param cameras The camera to enable.
  144413. * @hidden
  144414. */
  144415. _enable(cameras: Camera): void;
  144416. /**
  144417. * Enables the effect on given cameras
  144418. * @param cameras The camera to enable.
  144419. * @hidden
  144420. */
  144421. _enable(cameras: Nullable<Camera[]>): void;
  144422. /**
  144423. * Disables the effect on the given cameras
  144424. * @param cameras The camera to disable.
  144425. * @hidden
  144426. */
  144427. _disable(cameras: Camera): void;
  144428. /**
  144429. * Disables the effect on the given cameras
  144430. * @param cameras The camera to disable.
  144431. * @hidden
  144432. */
  144433. _disable(cameras: Nullable<Camera[]>): void;
  144434. /**
  144435. * Gets a list of the post processes contained in the effect.
  144436. * @param camera The camera to get the post processes on.
  144437. * @returns The list of the post processes in the effect.
  144438. */
  144439. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  144440. }
  144441. }
  144442. declare module BABYLON {
  144443. /** @hidden */
  144444. export var extractHighlightsPixelShader: {
  144445. name: string;
  144446. shader: string;
  144447. };
  144448. }
  144449. declare module BABYLON {
  144450. /**
  144451. * 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.
  144452. */
  144453. export class ExtractHighlightsPostProcess extends PostProcess {
  144454. /**
  144455. * The luminance threshold, pixels below this value will be set to black.
  144456. */
  144457. threshold: number;
  144458. /** @hidden */
  144459. _exposure: number;
  144460. /**
  144461. * Post process which has the input texture to be used when performing highlight extraction
  144462. * @hidden
  144463. */
  144464. _inputPostProcess: Nullable<PostProcess>;
  144465. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  144466. }
  144467. }
  144468. declare module BABYLON {
  144469. /** @hidden */
  144470. export var bloomMergePixelShader: {
  144471. name: string;
  144472. shader: string;
  144473. };
  144474. }
  144475. declare module BABYLON {
  144476. /**
  144477. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  144478. */
  144479. export class BloomMergePostProcess extends PostProcess {
  144480. /** Weight of the bloom to be added to the original input. */
  144481. weight: number;
  144482. /**
  144483. * Creates a new instance of @see BloomMergePostProcess
  144484. * @param name The name of the effect.
  144485. * @param originalFromInput Post process which's input will be used for the merge.
  144486. * @param blurred Blurred highlights post process which's output will be used.
  144487. * @param weight Weight of the bloom to be added to the original input.
  144488. * @param options The required width/height ratio to downsize to before computing the render pass.
  144489. * @param camera The camera to apply the render pass to.
  144490. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  144491. * @param engine The engine which the post process will be applied. (default: current engine)
  144492. * @param reusable If the post process can be reused on the same frame. (default: false)
  144493. * @param textureType Type of textures used when performing the post process. (default: 0)
  144494. * @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)
  144495. */
  144496. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  144497. /** Weight of the bloom to be added to the original input. */
  144498. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  144499. }
  144500. }
  144501. declare module BABYLON {
  144502. /**
  144503. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  144504. */
  144505. export class BloomEffect extends PostProcessRenderEffect {
  144506. private bloomScale;
  144507. /**
  144508. * @hidden Internal
  144509. */
  144510. _effects: Array<PostProcess>;
  144511. /**
  144512. * @hidden Internal
  144513. */
  144514. _downscale: ExtractHighlightsPostProcess;
  144515. private _blurX;
  144516. private _blurY;
  144517. private _merge;
  144518. /**
  144519. * The luminance threshold to find bright areas of the image to bloom.
  144520. */
  144521. get threshold(): number;
  144522. set threshold(value: number);
  144523. /**
  144524. * The strength of the bloom.
  144525. */
  144526. get weight(): number;
  144527. set weight(value: number);
  144528. /**
  144529. * Specifies the size of the bloom blur kernel, relative to the final output size
  144530. */
  144531. get kernel(): number;
  144532. set kernel(value: number);
  144533. /**
  144534. * Creates a new instance of @see BloomEffect
  144535. * @param scene The scene the effect belongs to.
  144536. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  144537. * @param bloomKernel The size of the kernel to be used when applying the blur.
  144538. * @param bloomWeight The the strength of bloom.
  144539. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  144540. * @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)
  144541. */
  144542. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  144543. /**
  144544. * Disposes each of the internal effects for a given camera.
  144545. * @param camera The camera to dispose the effect on.
  144546. */
  144547. disposeEffects(camera: Camera): void;
  144548. /**
  144549. * @hidden Internal
  144550. */
  144551. _updateEffects(): void;
  144552. /**
  144553. * Internal
  144554. * @returns if all the contained post processes are ready.
  144555. * @hidden
  144556. */
  144557. _isReady(): boolean;
  144558. }
  144559. }
  144560. declare module BABYLON {
  144561. /** @hidden */
  144562. export var chromaticAberrationPixelShader: {
  144563. name: string;
  144564. shader: string;
  144565. };
  144566. }
  144567. declare module BABYLON {
  144568. /**
  144569. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  144570. */
  144571. export class ChromaticAberrationPostProcess extends PostProcess {
  144572. /**
  144573. * The amount of seperation of rgb channels (default: 30)
  144574. */
  144575. aberrationAmount: number;
  144576. /**
  144577. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  144578. */
  144579. radialIntensity: number;
  144580. /**
  144581. * 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))
  144582. */
  144583. direction: Vector2;
  144584. /**
  144585. * 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))
  144586. */
  144587. centerPosition: Vector2;
  144588. /**
  144589. * Creates a new instance ChromaticAberrationPostProcess
  144590. * @param name The name of the effect.
  144591. * @param screenWidth The width of the screen to apply the effect on.
  144592. * @param screenHeight The height of the screen to apply the effect on.
  144593. * @param options The required width/height ratio to downsize to before computing the render pass.
  144594. * @param camera The camera to apply the render pass to.
  144595. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  144596. * @param engine The engine which the post process will be applied. (default: current engine)
  144597. * @param reusable If the post process can be reused on the same frame. (default: false)
  144598. * @param textureType Type of textures used when performing the post process. (default: 0)
  144599. * @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)
  144600. */
  144601. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  144602. }
  144603. }
  144604. declare module BABYLON {
  144605. /** @hidden */
  144606. export var circleOfConfusionPixelShader: {
  144607. name: string;
  144608. shader: string;
  144609. };
  144610. }
  144611. declare module BABYLON {
  144612. /**
  144613. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  144614. */
  144615. export class CircleOfConfusionPostProcess extends PostProcess {
  144616. /**
  144617. * 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.
  144618. */
  144619. lensSize: number;
  144620. /**
  144621. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  144622. */
  144623. fStop: number;
  144624. /**
  144625. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  144626. */
  144627. focusDistance: number;
  144628. /**
  144629. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  144630. */
  144631. focalLength: number;
  144632. private _depthTexture;
  144633. /**
  144634. * Creates a new instance CircleOfConfusionPostProcess
  144635. * @param name The name of the effect.
  144636. * @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.
  144637. * @param options The required width/height ratio to downsize to before computing the render pass.
  144638. * @param camera The camera to apply the render pass to.
  144639. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  144640. * @param engine The engine which the post process will be applied. (default: current engine)
  144641. * @param reusable If the post process can be reused on the same frame. (default: false)
  144642. * @param textureType Type of textures used when performing the post process. (default: 0)
  144643. * @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)
  144644. */
  144645. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  144646. /**
  144647. * 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.
  144648. */
  144649. set depthTexture(value: RenderTargetTexture);
  144650. }
  144651. }
  144652. declare module BABYLON {
  144653. /** @hidden */
  144654. export var colorCorrectionPixelShader: {
  144655. name: string;
  144656. shader: string;
  144657. };
  144658. }
  144659. declare module BABYLON {
  144660. /**
  144661. *
  144662. * This post-process allows the modification of rendered colors by using
  144663. * a 'look-up table' (LUT). This effect is also called Color Grading.
  144664. *
  144665. * The object needs to be provided an url to a texture containing the color
  144666. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  144667. * Use an image editing software to tweak the LUT to match your needs.
  144668. *
  144669. * For an example of a color LUT, see here:
  144670. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  144671. * For explanations on color grading, see here:
  144672. * @see http://udn.epicgames.com/Three/ColorGrading.html
  144673. *
  144674. */
  144675. export class ColorCorrectionPostProcess extends PostProcess {
  144676. private _colorTableTexture;
  144677. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  144678. }
  144679. }
  144680. declare module BABYLON {
  144681. /** @hidden */
  144682. export var convolutionPixelShader: {
  144683. name: string;
  144684. shader: string;
  144685. };
  144686. }
  144687. declare module BABYLON {
  144688. /**
  144689. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  144690. * input texture to perform effects such as edge detection or sharpening
  144691. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  144692. */
  144693. export class ConvolutionPostProcess extends PostProcess {
  144694. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  144695. kernel: number[];
  144696. /**
  144697. * Creates a new instance ConvolutionPostProcess
  144698. * @param name The name of the effect.
  144699. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  144700. * @param options The required width/height ratio to downsize to before computing the render pass.
  144701. * @param camera The camera to apply the render pass to.
  144702. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  144703. * @param engine The engine which the post process will be applied. (default: current engine)
  144704. * @param reusable If the post process can be reused on the same frame. (default: false)
  144705. * @param textureType Type of textures used when performing the post process. (default: 0)
  144706. */
  144707. constructor(name: string,
  144708. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  144709. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  144710. /**
  144711. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  144712. */
  144713. static EdgeDetect0Kernel: number[];
  144714. /**
  144715. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  144716. */
  144717. static EdgeDetect1Kernel: number[];
  144718. /**
  144719. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  144720. */
  144721. static EdgeDetect2Kernel: number[];
  144722. /**
  144723. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  144724. */
  144725. static SharpenKernel: number[];
  144726. /**
  144727. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  144728. */
  144729. static EmbossKernel: number[];
  144730. /**
  144731. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  144732. */
  144733. static GaussianKernel: number[];
  144734. }
  144735. }
  144736. declare module BABYLON {
  144737. /**
  144738. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  144739. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  144740. * based on samples that have a large difference in distance than the center pixel.
  144741. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  144742. */
  144743. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  144744. direction: Vector2;
  144745. /**
  144746. * Creates a new instance CircleOfConfusionPostProcess
  144747. * @param name The name of the effect.
  144748. * @param scene The scene the effect belongs to.
  144749. * @param direction The direction the blur should be applied.
  144750. * @param kernel The size of the kernel used to blur.
  144751. * @param options The required width/height ratio to downsize to before computing the render pass.
  144752. * @param camera The camera to apply the render pass to.
  144753. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  144754. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  144755. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  144756. * @param engine The engine which the post process will be applied. (default: current engine)
  144757. * @param reusable If the post process can be reused on the same frame. (default: false)
  144758. * @param textureType Type of textures used when performing the post process. (default: 0)
  144759. * @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)
  144760. */
  144761. 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);
  144762. }
  144763. }
  144764. declare module BABYLON {
  144765. /** @hidden */
  144766. export var depthOfFieldMergePixelShader: {
  144767. name: string;
  144768. shader: string;
  144769. };
  144770. }
  144771. declare module BABYLON {
  144772. /**
  144773. * Options to be set when merging outputs from the default pipeline.
  144774. */
  144775. export class DepthOfFieldMergePostProcessOptions {
  144776. /**
  144777. * The original image to merge on top of
  144778. */
  144779. originalFromInput: PostProcess;
  144780. /**
  144781. * Parameters to perform the merge of the depth of field effect
  144782. */
  144783. depthOfField?: {
  144784. circleOfConfusion: PostProcess;
  144785. blurSteps: Array<PostProcess>;
  144786. };
  144787. /**
  144788. * Parameters to perform the merge of bloom effect
  144789. */
  144790. bloom?: {
  144791. blurred: PostProcess;
  144792. weight: number;
  144793. };
  144794. }
  144795. /**
  144796. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  144797. */
  144798. export class DepthOfFieldMergePostProcess extends PostProcess {
  144799. private blurSteps;
  144800. /**
  144801. * Creates a new instance of DepthOfFieldMergePostProcess
  144802. * @param name The name of the effect.
  144803. * @param originalFromInput Post process which's input will be used for the merge.
  144804. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  144805. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  144806. * @param options The required width/height ratio to downsize to before computing the render pass.
  144807. * @param camera The camera to apply the render pass to.
  144808. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  144809. * @param engine The engine which the post process will be applied. (default: current engine)
  144810. * @param reusable If the post process can be reused on the same frame. (default: false)
  144811. * @param textureType Type of textures used when performing the post process. (default: 0)
  144812. * @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)
  144813. */
  144814. 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);
  144815. /**
  144816. * Updates the effect with the current post process compile time values and recompiles the shader.
  144817. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  144818. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  144819. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  144820. * @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
  144821. * @param onCompiled Called when the shader has been compiled.
  144822. * @param onError Called if there is an error when compiling a shader.
  144823. */
  144824. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  144825. }
  144826. }
  144827. declare module BABYLON {
  144828. /**
  144829. * Specifies the level of max blur that should be applied when using the depth of field effect
  144830. */
  144831. export enum DepthOfFieldEffectBlurLevel {
  144832. /**
  144833. * Subtle blur
  144834. */
  144835. Low = 0,
  144836. /**
  144837. * Medium blur
  144838. */
  144839. Medium = 1,
  144840. /**
  144841. * Large blur
  144842. */
  144843. High = 2
  144844. }
  144845. /**
  144846. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  144847. */
  144848. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  144849. private _circleOfConfusion;
  144850. /**
  144851. * @hidden Internal, blurs from high to low
  144852. */
  144853. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  144854. private _depthOfFieldBlurY;
  144855. private _dofMerge;
  144856. /**
  144857. * @hidden Internal post processes in depth of field effect
  144858. */
  144859. _effects: Array<PostProcess>;
  144860. /**
  144861. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  144862. */
  144863. set focalLength(value: number);
  144864. get focalLength(): number;
  144865. /**
  144866. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  144867. */
  144868. set fStop(value: number);
  144869. get fStop(): number;
  144870. /**
  144871. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  144872. */
  144873. set focusDistance(value: number);
  144874. get focusDistance(): number;
  144875. /**
  144876. * 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.
  144877. */
  144878. set lensSize(value: number);
  144879. get lensSize(): number;
  144880. /**
  144881. * Creates a new instance DepthOfFieldEffect
  144882. * @param scene The scene the effect belongs to.
  144883. * @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.
  144884. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  144885. * @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)
  144886. */
  144887. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  144888. /**
  144889. * Get the current class name of the current effet
  144890. * @returns "DepthOfFieldEffect"
  144891. */
  144892. getClassName(): string;
  144893. /**
  144894. * 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.
  144895. */
  144896. set depthTexture(value: RenderTargetTexture);
  144897. /**
  144898. * Disposes each of the internal effects for a given camera.
  144899. * @param camera The camera to dispose the effect on.
  144900. */
  144901. disposeEffects(camera: Camera): void;
  144902. /**
  144903. * @hidden Internal
  144904. */
  144905. _updateEffects(): void;
  144906. /**
  144907. * Internal
  144908. * @returns if all the contained post processes are ready.
  144909. * @hidden
  144910. */
  144911. _isReady(): boolean;
  144912. }
  144913. }
  144914. declare module BABYLON {
  144915. /** @hidden */
  144916. export var displayPassPixelShader: {
  144917. name: string;
  144918. shader: string;
  144919. };
  144920. }
  144921. declare module BABYLON {
  144922. /**
  144923. * DisplayPassPostProcess which produces an output the same as it's input
  144924. */
  144925. export class DisplayPassPostProcess extends PostProcess {
  144926. /**
  144927. * Creates the DisplayPassPostProcess
  144928. * @param name The name of the effect.
  144929. * @param options The required width/height ratio to downsize to before computing the render pass.
  144930. * @param camera The camera to apply the render pass to.
  144931. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  144932. * @param engine The engine which the post process will be applied. (default: current engine)
  144933. * @param reusable If the post process can be reused on the same frame. (default: false)
  144934. */
  144935. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  144936. }
  144937. }
  144938. declare module BABYLON {
  144939. /** @hidden */
  144940. export var filterPixelShader: {
  144941. name: string;
  144942. shader: string;
  144943. };
  144944. }
  144945. declare module BABYLON {
  144946. /**
  144947. * Applies a kernel filter to the image
  144948. */
  144949. export class FilterPostProcess extends PostProcess {
  144950. /** The matrix to be applied to the image */
  144951. kernelMatrix: Matrix;
  144952. /**
  144953. *
  144954. * @param name The name of the effect.
  144955. * @param kernelMatrix The matrix to be applied to the image
  144956. * @param options The required width/height ratio to downsize to before computing the render pass.
  144957. * @param camera The camera to apply the render pass to.
  144958. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  144959. * @param engine The engine which the post process will be applied. (default: current engine)
  144960. * @param reusable If the post process can be reused on the same frame. (default: false)
  144961. */
  144962. constructor(name: string,
  144963. /** The matrix to be applied to the image */
  144964. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  144965. }
  144966. }
  144967. declare module BABYLON {
  144968. /** @hidden */
  144969. export var fxaaPixelShader: {
  144970. name: string;
  144971. shader: string;
  144972. };
  144973. }
  144974. declare module BABYLON {
  144975. /** @hidden */
  144976. export var fxaaVertexShader: {
  144977. name: string;
  144978. shader: string;
  144979. };
  144980. }
  144981. declare module BABYLON {
  144982. /**
  144983. * Fxaa post process
  144984. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  144985. */
  144986. export class FxaaPostProcess extends PostProcess {
  144987. /** @hidden */
  144988. texelWidth: number;
  144989. /** @hidden */
  144990. texelHeight: number;
  144991. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  144992. private _getDefines;
  144993. }
  144994. }
  144995. declare module BABYLON {
  144996. /** @hidden */
  144997. export var grainPixelShader: {
  144998. name: string;
  144999. shader: string;
  145000. };
  145001. }
  145002. declare module BABYLON {
  145003. /**
  145004. * The GrainPostProcess adds noise to the image at mid luminance levels
  145005. */
  145006. export class GrainPostProcess extends PostProcess {
  145007. /**
  145008. * The intensity of the grain added (default: 30)
  145009. */
  145010. intensity: number;
  145011. /**
  145012. * If the grain should be randomized on every frame
  145013. */
  145014. animated: boolean;
  145015. /**
  145016. * Creates a new instance of @see GrainPostProcess
  145017. * @param name The name of the effect.
  145018. * @param options The required width/height ratio to downsize to before computing the render pass.
  145019. * @param camera The camera to apply the render pass to.
  145020. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  145021. * @param engine The engine which the post process will be applied. (default: current engine)
  145022. * @param reusable If the post process can be reused on the same frame. (default: false)
  145023. * @param textureType Type of textures used when performing the post process. (default: 0)
  145024. * @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)
  145025. */
  145026. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  145027. }
  145028. }
  145029. declare module BABYLON {
  145030. /** @hidden */
  145031. export var highlightsPixelShader: {
  145032. name: string;
  145033. shader: string;
  145034. };
  145035. }
  145036. declare module BABYLON {
  145037. /**
  145038. * Extracts highlights from the image
  145039. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  145040. */
  145041. export class HighlightsPostProcess extends PostProcess {
  145042. /**
  145043. * Extracts highlights from the image
  145044. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  145045. * @param name The name of the effect.
  145046. * @param options The required width/height ratio to downsize to before computing the render pass.
  145047. * @param camera The camera to apply the render pass to.
  145048. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  145049. * @param engine The engine which the post process will be applied. (default: current engine)
  145050. * @param reusable If the post process can be reused on the same frame. (default: false)
  145051. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  145052. */
  145053. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  145054. }
  145055. }
  145056. declare module BABYLON {
  145057. /** @hidden */
  145058. export var mrtFragmentDeclaration: {
  145059. name: string;
  145060. shader: string;
  145061. };
  145062. }
  145063. declare module BABYLON {
  145064. /** @hidden */
  145065. export var geometryPixelShader: {
  145066. name: string;
  145067. shader: string;
  145068. };
  145069. }
  145070. declare module BABYLON {
  145071. /** @hidden */
  145072. export var geometryVertexShader: {
  145073. name: string;
  145074. shader: string;
  145075. };
  145076. }
  145077. declare module BABYLON {
  145078. /** @hidden */
  145079. interface ISavedTransformationMatrix {
  145080. world: Matrix;
  145081. viewProjection: Matrix;
  145082. }
  145083. /**
  145084. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  145085. */
  145086. export class GeometryBufferRenderer {
  145087. /**
  145088. * Constant used to retrieve the position texture index in the G-Buffer textures array
  145089. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  145090. */
  145091. static readonly POSITION_TEXTURE_TYPE: number;
  145092. /**
  145093. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  145094. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  145095. */
  145096. static readonly VELOCITY_TEXTURE_TYPE: number;
  145097. /**
  145098. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  145099. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  145100. */
  145101. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  145102. /**
  145103. * Dictionary used to store the previous transformation matrices of each rendered mesh
  145104. * in order to compute objects velocities when enableVelocity is set to "true"
  145105. * @hidden
  145106. */
  145107. _previousTransformationMatrices: {
  145108. [index: number]: ISavedTransformationMatrix;
  145109. };
  145110. /**
  145111. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  145112. * in order to compute objects velocities when enableVelocity is set to "true"
  145113. * @hidden
  145114. */
  145115. _previousBonesTransformationMatrices: {
  145116. [index: number]: Float32Array;
  145117. };
  145118. /**
  145119. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  145120. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  145121. */
  145122. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  145123. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  145124. renderTransparentMeshes: boolean;
  145125. private _scene;
  145126. private _multiRenderTarget;
  145127. private _ratio;
  145128. private _enablePosition;
  145129. private _enableVelocity;
  145130. private _enableReflectivity;
  145131. private _positionIndex;
  145132. private _velocityIndex;
  145133. private _reflectivityIndex;
  145134. protected _effect: Effect;
  145135. protected _cachedDefines: string;
  145136. /**
  145137. * Set the render list (meshes to be rendered) used in the G buffer.
  145138. */
  145139. set renderList(meshes: Mesh[]);
  145140. /**
  145141. * Gets wether or not G buffer are supported by the running hardware.
  145142. * This requires draw buffer supports
  145143. */
  145144. get isSupported(): boolean;
  145145. /**
  145146. * Returns the index of the given texture type in the G-Buffer textures array
  145147. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  145148. * @returns the index of the given texture type in the G-Buffer textures array
  145149. */
  145150. getTextureIndex(textureType: number): number;
  145151. /**
  145152. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  145153. */
  145154. get enablePosition(): boolean;
  145155. /**
  145156. * Sets whether or not objects positions are enabled for the G buffer.
  145157. */
  145158. set enablePosition(enable: boolean);
  145159. /**
  145160. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  145161. */
  145162. get enableVelocity(): boolean;
  145163. /**
  145164. * Sets wether or not objects velocities are enabled for the G buffer.
  145165. */
  145166. set enableVelocity(enable: boolean);
  145167. /**
  145168. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  145169. */
  145170. get enableReflectivity(): boolean;
  145171. /**
  145172. * Sets wether or not objects roughness are enabled for the G buffer.
  145173. */
  145174. set enableReflectivity(enable: boolean);
  145175. /**
  145176. * Gets the scene associated with the buffer.
  145177. */
  145178. get scene(): Scene;
  145179. /**
  145180. * Gets the ratio used by the buffer during its creation.
  145181. * How big is the buffer related to the main canvas.
  145182. */
  145183. get ratio(): number;
  145184. /** @hidden */
  145185. static _SceneComponentInitialization: (scene: Scene) => void;
  145186. /**
  145187. * Creates a new G Buffer for the scene
  145188. * @param scene The scene the buffer belongs to
  145189. * @param ratio How big is the buffer related to the main canvas.
  145190. */
  145191. constructor(scene: Scene, ratio?: number);
  145192. /**
  145193. * Checks wether everything is ready to render a submesh to the G buffer.
  145194. * @param subMesh the submesh to check readiness for
  145195. * @param useInstances is the mesh drawn using instance or not
  145196. * @returns true if ready otherwise false
  145197. */
  145198. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  145199. /**
  145200. * Gets the current underlying G Buffer.
  145201. * @returns the buffer
  145202. */
  145203. getGBuffer(): MultiRenderTarget;
  145204. /**
  145205. * Gets the number of samples used to render the buffer (anti aliasing).
  145206. */
  145207. get samples(): number;
  145208. /**
  145209. * Sets the number of samples used to render the buffer (anti aliasing).
  145210. */
  145211. set samples(value: number);
  145212. /**
  145213. * Disposes the renderer and frees up associated resources.
  145214. */
  145215. dispose(): void;
  145216. protected _createRenderTargets(): void;
  145217. private _copyBonesTransformationMatrices;
  145218. }
  145219. }
  145220. declare module BABYLON {
  145221. interface Scene {
  145222. /** @hidden (Backing field) */
  145223. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  145224. /**
  145225. * Gets or Sets the current geometry buffer associated to the scene.
  145226. */
  145227. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  145228. /**
  145229. * Enables a GeometryBufferRender and associates it with the scene
  145230. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  145231. * @returns the GeometryBufferRenderer
  145232. */
  145233. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  145234. /**
  145235. * Disables the GeometryBufferRender associated with the scene
  145236. */
  145237. disableGeometryBufferRenderer(): void;
  145238. }
  145239. /**
  145240. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  145241. * in several rendering techniques.
  145242. */
  145243. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  145244. /**
  145245. * The component name helpful to identify the component in the list of scene components.
  145246. */
  145247. readonly name: string;
  145248. /**
  145249. * The scene the component belongs to.
  145250. */
  145251. scene: Scene;
  145252. /**
  145253. * Creates a new instance of the component for the given scene
  145254. * @param scene Defines the scene to register the component in
  145255. */
  145256. constructor(scene: Scene);
  145257. /**
  145258. * Registers the component in a given scene
  145259. */
  145260. register(): void;
  145261. /**
  145262. * Rebuilds the elements related to this component in case of
  145263. * context lost for instance.
  145264. */
  145265. rebuild(): void;
  145266. /**
  145267. * Disposes the component and the associated ressources
  145268. */
  145269. dispose(): void;
  145270. private _gatherRenderTargets;
  145271. }
  145272. }
  145273. declare module BABYLON {
  145274. /** @hidden */
  145275. export var motionBlurPixelShader: {
  145276. name: string;
  145277. shader: string;
  145278. };
  145279. }
  145280. declare module BABYLON {
  145281. /**
  145282. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  145283. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  145284. * As an example, all you have to do is to create the post-process:
  145285. * var mb = new BABYLON.MotionBlurPostProcess(
  145286. * 'mb', // The name of the effect.
  145287. * scene, // The scene containing the objects to blur according to their velocity.
  145288. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  145289. * camera // The camera to apply the render pass to.
  145290. * );
  145291. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  145292. */
  145293. export class MotionBlurPostProcess extends PostProcess {
  145294. /**
  145295. * Defines how much the image is blurred by the movement. Default value is equal to 1
  145296. */
  145297. motionStrength: number;
  145298. /**
  145299. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  145300. */
  145301. get motionBlurSamples(): number;
  145302. /**
  145303. * Sets the number of iterations to be used for motion blur quality
  145304. */
  145305. set motionBlurSamples(samples: number);
  145306. private _motionBlurSamples;
  145307. private _geometryBufferRenderer;
  145308. /**
  145309. * Creates a new instance MotionBlurPostProcess
  145310. * @param name The name of the effect.
  145311. * @param scene The scene containing the objects to blur according to their velocity.
  145312. * @param options The required width/height ratio to downsize to before computing the render pass.
  145313. * @param camera The camera to apply the render pass to.
  145314. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  145315. * @param engine The engine which the post process will be applied. (default: current engine)
  145316. * @param reusable If the post process can be reused on the same frame. (default: false)
  145317. * @param textureType Type of textures used when performing the post process. (default: 0)
  145318. * @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)
  145319. */
  145320. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  145321. /**
  145322. * Excludes the given skinned mesh from computing bones velocities.
  145323. * 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.
  145324. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  145325. */
  145326. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  145327. /**
  145328. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  145329. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  145330. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  145331. */
  145332. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  145333. /**
  145334. * Disposes the post process.
  145335. * @param camera The camera to dispose the post process on.
  145336. */
  145337. dispose(camera?: Camera): void;
  145338. }
  145339. }
  145340. declare module BABYLON {
  145341. /** @hidden */
  145342. export var refractionPixelShader: {
  145343. name: string;
  145344. shader: string;
  145345. };
  145346. }
  145347. declare module BABYLON {
  145348. /**
  145349. * Post process which applies a refractin texture
  145350. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  145351. */
  145352. export class RefractionPostProcess extends PostProcess {
  145353. /** the base color of the refraction (used to taint the rendering) */
  145354. color: Color3;
  145355. /** simulated refraction depth */
  145356. depth: number;
  145357. /** the coefficient of the base color (0 to remove base color tainting) */
  145358. colorLevel: number;
  145359. private _refTexture;
  145360. private _ownRefractionTexture;
  145361. /**
  145362. * Gets or sets the refraction texture
  145363. * Please note that you are responsible for disposing the texture if you set it manually
  145364. */
  145365. get refractionTexture(): Texture;
  145366. set refractionTexture(value: Texture);
  145367. /**
  145368. * Initializes the RefractionPostProcess
  145369. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  145370. * @param name The name of the effect.
  145371. * @param refractionTextureUrl Url of the refraction texture to use
  145372. * @param color the base color of the refraction (used to taint the rendering)
  145373. * @param depth simulated refraction depth
  145374. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  145375. * @param camera The camera to apply the render pass to.
  145376. * @param options The required width/height ratio to downsize to before computing the render pass.
  145377. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  145378. * @param engine The engine which the post process will be applied. (default: current engine)
  145379. * @param reusable If the post process can be reused on the same frame. (default: false)
  145380. */
  145381. constructor(name: string, refractionTextureUrl: string,
  145382. /** the base color of the refraction (used to taint the rendering) */
  145383. color: Color3,
  145384. /** simulated refraction depth */
  145385. depth: number,
  145386. /** the coefficient of the base color (0 to remove base color tainting) */
  145387. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  145388. /**
  145389. * Disposes of the post process
  145390. * @param camera Camera to dispose post process on
  145391. */
  145392. dispose(camera: Camera): void;
  145393. }
  145394. }
  145395. declare module BABYLON {
  145396. /** @hidden */
  145397. export var sharpenPixelShader: {
  145398. name: string;
  145399. shader: string;
  145400. };
  145401. }
  145402. declare module BABYLON {
  145403. /**
  145404. * The SharpenPostProcess applies a sharpen kernel to every pixel
  145405. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  145406. */
  145407. export class SharpenPostProcess extends PostProcess {
  145408. /**
  145409. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  145410. */
  145411. colorAmount: number;
  145412. /**
  145413. * How much sharpness should be applied (default: 0.3)
  145414. */
  145415. edgeAmount: number;
  145416. /**
  145417. * Creates a new instance ConvolutionPostProcess
  145418. * @param name The name of the effect.
  145419. * @param options The required width/height ratio to downsize to before computing the render pass.
  145420. * @param camera The camera to apply the render pass to.
  145421. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  145422. * @param engine The engine which the post process will be applied. (default: current engine)
  145423. * @param reusable If the post process can be reused on the same frame. (default: false)
  145424. * @param textureType Type of textures used when performing the post process. (default: 0)
  145425. * @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)
  145426. */
  145427. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  145428. }
  145429. }
  145430. declare module BABYLON {
  145431. /**
  145432. * PostProcessRenderPipeline
  145433. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  145434. */
  145435. export class PostProcessRenderPipeline {
  145436. private engine;
  145437. private _renderEffects;
  145438. private _renderEffectsForIsolatedPass;
  145439. /**
  145440. * List of inspectable custom properties (used by the Inspector)
  145441. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  145442. */
  145443. inspectableCustomProperties: IInspectable[];
  145444. /**
  145445. * @hidden
  145446. */
  145447. protected _cameras: Camera[];
  145448. /** @hidden */
  145449. _name: string;
  145450. /**
  145451. * Gets pipeline name
  145452. */
  145453. get name(): string;
  145454. /** Gets the list of attached cameras */
  145455. get cameras(): Camera[];
  145456. /**
  145457. * Initializes a PostProcessRenderPipeline
  145458. * @param engine engine to add the pipeline to
  145459. * @param name name of the pipeline
  145460. */
  145461. constructor(engine: Engine, name: string);
  145462. /**
  145463. * Gets the class name
  145464. * @returns "PostProcessRenderPipeline"
  145465. */
  145466. getClassName(): string;
  145467. /**
  145468. * If all the render effects in the pipeline are supported
  145469. */
  145470. get isSupported(): boolean;
  145471. /**
  145472. * Adds an effect to the pipeline
  145473. * @param renderEffect the effect to add
  145474. */
  145475. addEffect(renderEffect: PostProcessRenderEffect): void;
  145476. /** @hidden */
  145477. _rebuild(): void;
  145478. /** @hidden */
  145479. _enableEffect(renderEffectName: string, cameras: Camera): void;
  145480. /** @hidden */
  145481. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  145482. /** @hidden */
  145483. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  145484. /** @hidden */
  145485. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  145486. /** @hidden */
  145487. _attachCameras(cameras: Camera, unique: boolean): void;
  145488. /** @hidden */
  145489. _attachCameras(cameras: Camera[], unique: boolean): void;
  145490. /** @hidden */
  145491. _detachCameras(cameras: Camera): void;
  145492. /** @hidden */
  145493. _detachCameras(cameras: Nullable<Camera[]>): void;
  145494. /** @hidden */
  145495. _update(): void;
  145496. /** @hidden */
  145497. _reset(): void;
  145498. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  145499. /**
  145500. * Disposes of the pipeline
  145501. */
  145502. dispose(): void;
  145503. }
  145504. }
  145505. declare module BABYLON {
  145506. /**
  145507. * PostProcessRenderPipelineManager class
  145508. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  145509. */
  145510. export class PostProcessRenderPipelineManager {
  145511. private _renderPipelines;
  145512. /**
  145513. * Initializes a PostProcessRenderPipelineManager
  145514. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  145515. */
  145516. constructor();
  145517. /**
  145518. * Gets the list of supported render pipelines
  145519. */
  145520. get supportedPipelines(): PostProcessRenderPipeline[];
  145521. /**
  145522. * Adds a pipeline to the manager
  145523. * @param renderPipeline The pipeline to add
  145524. */
  145525. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  145526. /**
  145527. * Attaches a camera to the pipeline
  145528. * @param renderPipelineName The name of the pipeline to attach to
  145529. * @param cameras the camera to attach
  145530. * @param unique if the camera can be attached multiple times to the pipeline
  145531. */
  145532. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  145533. /**
  145534. * Detaches a camera from the pipeline
  145535. * @param renderPipelineName The name of the pipeline to detach from
  145536. * @param cameras the camera to detach
  145537. */
  145538. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  145539. /**
  145540. * Enables an effect by name on a pipeline
  145541. * @param renderPipelineName the name of the pipeline to enable the effect in
  145542. * @param renderEffectName the name of the effect to enable
  145543. * @param cameras the cameras that the effect should be enabled on
  145544. */
  145545. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  145546. /**
  145547. * Disables an effect by name on a pipeline
  145548. * @param renderPipelineName the name of the pipeline to disable the effect in
  145549. * @param renderEffectName the name of the effect to disable
  145550. * @param cameras the cameras that the effect should be disabled on
  145551. */
  145552. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  145553. /**
  145554. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  145555. */
  145556. update(): void;
  145557. /** @hidden */
  145558. _rebuild(): void;
  145559. /**
  145560. * Disposes of the manager and pipelines
  145561. */
  145562. dispose(): void;
  145563. }
  145564. }
  145565. declare module BABYLON {
  145566. interface Scene {
  145567. /** @hidden (Backing field) */
  145568. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  145569. /**
  145570. * Gets the postprocess render pipeline manager
  145571. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  145572. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  145573. */
  145574. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  145575. }
  145576. /**
  145577. * Defines the Render Pipeline scene component responsible to rendering pipelines
  145578. */
  145579. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  145580. /**
  145581. * The component name helpfull to identify the component in the list of scene components.
  145582. */
  145583. readonly name: string;
  145584. /**
  145585. * The scene the component belongs to.
  145586. */
  145587. scene: Scene;
  145588. /**
  145589. * Creates a new instance of the component for the given scene
  145590. * @param scene Defines the scene to register the component in
  145591. */
  145592. constructor(scene: Scene);
  145593. /**
  145594. * Registers the component in a given scene
  145595. */
  145596. register(): void;
  145597. /**
  145598. * Rebuilds the elements related to this component in case of
  145599. * context lost for instance.
  145600. */
  145601. rebuild(): void;
  145602. /**
  145603. * Disposes the component and the associated ressources
  145604. */
  145605. dispose(): void;
  145606. private _gatherRenderTargets;
  145607. }
  145608. }
  145609. declare module BABYLON {
  145610. /**
  145611. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  145612. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  145613. */
  145614. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  145615. private _scene;
  145616. private _camerasToBeAttached;
  145617. /**
  145618. * ID of the sharpen post process,
  145619. */
  145620. private readonly SharpenPostProcessId;
  145621. /**
  145622. * @ignore
  145623. * ID of the image processing post process;
  145624. */
  145625. readonly ImageProcessingPostProcessId: string;
  145626. /**
  145627. * @ignore
  145628. * ID of the Fast Approximate Anti-Aliasing post process;
  145629. */
  145630. readonly FxaaPostProcessId: string;
  145631. /**
  145632. * ID of the chromatic aberration post process,
  145633. */
  145634. private readonly ChromaticAberrationPostProcessId;
  145635. /**
  145636. * ID of the grain post process
  145637. */
  145638. private readonly GrainPostProcessId;
  145639. /**
  145640. * Sharpen post process which will apply a sharpen convolution to enhance edges
  145641. */
  145642. sharpen: SharpenPostProcess;
  145643. private _sharpenEffect;
  145644. private bloom;
  145645. /**
  145646. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  145647. */
  145648. depthOfField: DepthOfFieldEffect;
  145649. /**
  145650. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  145651. */
  145652. fxaa: FxaaPostProcess;
  145653. /**
  145654. * Image post processing pass used to perform operations such as tone mapping or color grading.
  145655. */
  145656. imageProcessing: ImageProcessingPostProcess;
  145657. /**
  145658. * Chromatic aberration post process which will shift rgb colors in the image
  145659. */
  145660. chromaticAberration: ChromaticAberrationPostProcess;
  145661. private _chromaticAberrationEffect;
  145662. /**
  145663. * Grain post process which add noise to the image
  145664. */
  145665. grain: GrainPostProcess;
  145666. private _grainEffect;
  145667. /**
  145668. * Glow post process which adds a glow to emissive areas of the image
  145669. */
  145670. private _glowLayer;
  145671. /**
  145672. * Animations which can be used to tweak settings over a period of time
  145673. */
  145674. animations: Animation[];
  145675. private _imageProcessingConfigurationObserver;
  145676. private _sharpenEnabled;
  145677. private _bloomEnabled;
  145678. private _depthOfFieldEnabled;
  145679. private _depthOfFieldBlurLevel;
  145680. private _fxaaEnabled;
  145681. private _imageProcessingEnabled;
  145682. private _defaultPipelineTextureType;
  145683. private _bloomScale;
  145684. private _chromaticAberrationEnabled;
  145685. private _grainEnabled;
  145686. private _buildAllowed;
  145687. /**
  145688. * Gets active scene
  145689. */
  145690. get scene(): Scene;
  145691. /**
  145692. * Enable or disable the sharpen process from the pipeline
  145693. */
  145694. set sharpenEnabled(enabled: boolean);
  145695. get sharpenEnabled(): boolean;
  145696. private _resizeObserver;
  145697. private _hardwareScaleLevel;
  145698. private _bloomKernel;
  145699. /**
  145700. * Specifies the size of the bloom blur kernel, relative to the final output size
  145701. */
  145702. get bloomKernel(): number;
  145703. set bloomKernel(value: number);
  145704. /**
  145705. * Specifies the weight of the bloom in the final rendering
  145706. */
  145707. private _bloomWeight;
  145708. /**
  145709. * Specifies the luma threshold for the area that will be blurred by the bloom
  145710. */
  145711. private _bloomThreshold;
  145712. private _hdr;
  145713. /**
  145714. * The strength of the bloom.
  145715. */
  145716. set bloomWeight(value: number);
  145717. get bloomWeight(): number;
  145718. /**
  145719. * The strength of the bloom.
  145720. */
  145721. set bloomThreshold(value: number);
  145722. get bloomThreshold(): number;
  145723. /**
  145724. * The scale of the bloom, lower value will provide better performance.
  145725. */
  145726. set bloomScale(value: number);
  145727. get bloomScale(): number;
  145728. /**
  145729. * Enable or disable the bloom from the pipeline
  145730. */
  145731. set bloomEnabled(enabled: boolean);
  145732. get bloomEnabled(): boolean;
  145733. private _rebuildBloom;
  145734. /**
  145735. * If the depth of field is enabled.
  145736. */
  145737. get depthOfFieldEnabled(): boolean;
  145738. set depthOfFieldEnabled(enabled: boolean);
  145739. /**
  145740. * Blur level of the depth of field effect. (Higher blur will effect performance)
  145741. */
  145742. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  145743. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  145744. /**
  145745. * If the anti aliasing is enabled.
  145746. */
  145747. set fxaaEnabled(enabled: boolean);
  145748. get fxaaEnabled(): boolean;
  145749. private _samples;
  145750. /**
  145751. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  145752. */
  145753. set samples(sampleCount: number);
  145754. get samples(): number;
  145755. /**
  145756. * If image processing is enabled.
  145757. */
  145758. set imageProcessingEnabled(enabled: boolean);
  145759. get imageProcessingEnabled(): boolean;
  145760. /**
  145761. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  145762. */
  145763. set glowLayerEnabled(enabled: boolean);
  145764. get glowLayerEnabled(): boolean;
  145765. /**
  145766. * Gets the glow layer (or null if not defined)
  145767. */
  145768. get glowLayer(): Nullable<GlowLayer>;
  145769. /**
  145770. * Enable or disable the chromaticAberration process from the pipeline
  145771. */
  145772. set chromaticAberrationEnabled(enabled: boolean);
  145773. get chromaticAberrationEnabled(): boolean;
  145774. /**
  145775. * Enable or disable the grain process from the pipeline
  145776. */
  145777. set grainEnabled(enabled: boolean);
  145778. get grainEnabled(): boolean;
  145779. /**
  145780. * @constructor
  145781. * @param name - The rendering pipeline name (default: "")
  145782. * @param hdr - If high dynamic range textures should be used (default: true)
  145783. * @param scene - The scene linked to this pipeline (default: the last created scene)
  145784. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  145785. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  145786. */
  145787. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  145788. /**
  145789. * Get the class name
  145790. * @returns "DefaultRenderingPipeline"
  145791. */
  145792. getClassName(): string;
  145793. /**
  145794. * Force the compilation of the entire pipeline.
  145795. */
  145796. prepare(): void;
  145797. private _hasCleared;
  145798. private _prevPostProcess;
  145799. private _prevPrevPostProcess;
  145800. private _setAutoClearAndTextureSharing;
  145801. private _depthOfFieldSceneObserver;
  145802. private _buildPipeline;
  145803. private _disposePostProcesses;
  145804. /**
  145805. * Adds a camera to the pipeline
  145806. * @param camera the camera to be added
  145807. */
  145808. addCamera(camera: Camera): void;
  145809. /**
  145810. * Removes a camera from the pipeline
  145811. * @param camera the camera to remove
  145812. */
  145813. removeCamera(camera: Camera): void;
  145814. /**
  145815. * Dispose of the pipeline and stop all post processes
  145816. */
  145817. dispose(): void;
  145818. /**
  145819. * Serialize the rendering pipeline (Used when exporting)
  145820. * @returns the serialized object
  145821. */
  145822. serialize(): any;
  145823. /**
  145824. * Parse the serialized pipeline
  145825. * @param source Source pipeline.
  145826. * @param scene The scene to load the pipeline to.
  145827. * @param rootUrl The URL of the serialized pipeline.
  145828. * @returns An instantiated pipeline from the serialized object.
  145829. */
  145830. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  145831. }
  145832. }
  145833. declare module BABYLON {
  145834. /** @hidden */
  145835. export var lensHighlightsPixelShader: {
  145836. name: string;
  145837. shader: string;
  145838. };
  145839. }
  145840. declare module BABYLON {
  145841. /** @hidden */
  145842. export var depthOfFieldPixelShader: {
  145843. name: string;
  145844. shader: string;
  145845. };
  145846. }
  145847. declare module BABYLON {
  145848. /**
  145849. * BABYLON.JS Chromatic Aberration GLSL Shader
  145850. * Author: Olivier Guyot
  145851. * Separates very slightly R, G and B colors on the edges of the screen
  145852. * Inspired by Francois Tarlier & Martins Upitis
  145853. */
  145854. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  145855. /**
  145856. * @ignore
  145857. * The chromatic aberration PostProcess id in the pipeline
  145858. */
  145859. LensChromaticAberrationEffect: string;
  145860. /**
  145861. * @ignore
  145862. * The highlights enhancing PostProcess id in the pipeline
  145863. */
  145864. HighlightsEnhancingEffect: string;
  145865. /**
  145866. * @ignore
  145867. * The depth-of-field PostProcess id in the pipeline
  145868. */
  145869. LensDepthOfFieldEffect: string;
  145870. private _scene;
  145871. private _depthTexture;
  145872. private _grainTexture;
  145873. private _chromaticAberrationPostProcess;
  145874. private _highlightsPostProcess;
  145875. private _depthOfFieldPostProcess;
  145876. private _edgeBlur;
  145877. private _grainAmount;
  145878. private _chromaticAberration;
  145879. private _distortion;
  145880. private _highlightsGain;
  145881. private _highlightsThreshold;
  145882. private _dofDistance;
  145883. private _dofAperture;
  145884. private _dofDarken;
  145885. private _dofPentagon;
  145886. private _blurNoise;
  145887. /**
  145888. * @constructor
  145889. *
  145890. * Effect parameters are as follow:
  145891. * {
  145892. * chromatic_aberration: number; // from 0 to x (1 for realism)
  145893. * edge_blur: number; // from 0 to x (1 for realism)
  145894. * distortion: number; // from 0 to x (1 for realism)
  145895. * grain_amount: number; // from 0 to 1
  145896. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  145897. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  145898. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  145899. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  145900. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  145901. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  145902. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  145903. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  145904. * }
  145905. * Note: if an effect parameter is unset, effect is disabled
  145906. *
  145907. * @param name The rendering pipeline name
  145908. * @param parameters - An object containing all parameters (see above)
  145909. * @param scene The scene linked to this pipeline
  145910. * @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)
  145911. * @param cameras The array of cameras that the rendering pipeline will be attached to
  145912. */
  145913. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  145914. /**
  145915. * Get the class name
  145916. * @returns "LensRenderingPipeline"
  145917. */
  145918. getClassName(): string;
  145919. /**
  145920. * Gets associated scene
  145921. */
  145922. get scene(): Scene;
  145923. /**
  145924. * Gets or sets the edge blur
  145925. */
  145926. get edgeBlur(): number;
  145927. set edgeBlur(value: number);
  145928. /**
  145929. * Gets or sets the grain amount
  145930. */
  145931. get grainAmount(): number;
  145932. set grainAmount(value: number);
  145933. /**
  145934. * Gets or sets the chromatic aberration amount
  145935. */
  145936. get chromaticAberration(): number;
  145937. set chromaticAberration(value: number);
  145938. /**
  145939. * Gets or sets the depth of field aperture
  145940. */
  145941. get dofAperture(): number;
  145942. set dofAperture(value: number);
  145943. /**
  145944. * Gets or sets the edge distortion
  145945. */
  145946. get edgeDistortion(): number;
  145947. set edgeDistortion(value: number);
  145948. /**
  145949. * Gets or sets the depth of field distortion
  145950. */
  145951. get dofDistortion(): number;
  145952. set dofDistortion(value: number);
  145953. /**
  145954. * Gets or sets the darken out of focus amount
  145955. */
  145956. get darkenOutOfFocus(): number;
  145957. set darkenOutOfFocus(value: number);
  145958. /**
  145959. * Gets or sets a boolean indicating if blur noise is enabled
  145960. */
  145961. get blurNoise(): boolean;
  145962. set blurNoise(value: boolean);
  145963. /**
  145964. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  145965. */
  145966. get pentagonBokeh(): boolean;
  145967. set pentagonBokeh(value: boolean);
  145968. /**
  145969. * Gets or sets the highlight grain amount
  145970. */
  145971. get highlightsGain(): number;
  145972. set highlightsGain(value: number);
  145973. /**
  145974. * Gets or sets the highlight threshold
  145975. */
  145976. get highlightsThreshold(): number;
  145977. set highlightsThreshold(value: number);
  145978. /**
  145979. * Sets the amount of blur at the edges
  145980. * @param amount blur amount
  145981. */
  145982. setEdgeBlur(amount: number): void;
  145983. /**
  145984. * Sets edge blur to 0
  145985. */
  145986. disableEdgeBlur(): void;
  145987. /**
  145988. * Sets the amout of grain
  145989. * @param amount Amount of grain
  145990. */
  145991. setGrainAmount(amount: number): void;
  145992. /**
  145993. * Set grain amount to 0
  145994. */
  145995. disableGrain(): void;
  145996. /**
  145997. * Sets the chromatic aberration amount
  145998. * @param amount amount of chromatic aberration
  145999. */
  146000. setChromaticAberration(amount: number): void;
  146001. /**
  146002. * Sets chromatic aberration amount to 0
  146003. */
  146004. disableChromaticAberration(): void;
  146005. /**
  146006. * Sets the EdgeDistortion amount
  146007. * @param amount amount of EdgeDistortion
  146008. */
  146009. setEdgeDistortion(amount: number): void;
  146010. /**
  146011. * Sets edge distortion to 0
  146012. */
  146013. disableEdgeDistortion(): void;
  146014. /**
  146015. * Sets the FocusDistance amount
  146016. * @param amount amount of FocusDistance
  146017. */
  146018. setFocusDistance(amount: number): void;
  146019. /**
  146020. * Disables depth of field
  146021. */
  146022. disableDepthOfField(): void;
  146023. /**
  146024. * Sets the Aperture amount
  146025. * @param amount amount of Aperture
  146026. */
  146027. setAperture(amount: number): void;
  146028. /**
  146029. * Sets the DarkenOutOfFocus amount
  146030. * @param amount amount of DarkenOutOfFocus
  146031. */
  146032. setDarkenOutOfFocus(amount: number): void;
  146033. private _pentagonBokehIsEnabled;
  146034. /**
  146035. * Creates a pentagon bokeh effect
  146036. */
  146037. enablePentagonBokeh(): void;
  146038. /**
  146039. * Disables the pentagon bokeh effect
  146040. */
  146041. disablePentagonBokeh(): void;
  146042. /**
  146043. * Enables noise blur
  146044. */
  146045. enableNoiseBlur(): void;
  146046. /**
  146047. * Disables noise blur
  146048. */
  146049. disableNoiseBlur(): void;
  146050. /**
  146051. * Sets the HighlightsGain amount
  146052. * @param amount amount of HighlightsGain
  146053. */
  146054. setHighlightsGain(amount: number): void;
  146055. /**
  146056. * Sets the HighlightsThreshold amount
  146057. * @param amount amount of HighlightsThreshold
  146058. */
  146059. setHighlightsThreshold(amount: number): void;
  146060. /**
  146061. * Disables highlights
  146062. */
  146063. disableHighlights(): void;
  146064. /**
  146065. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  146066. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  146067. */
  146068. dispose(disableDepthRender?: boolean): void;
  146069. private _createChromaticAberrationPostProcess;
  146070. private _createHighlightsPostProcess;
  146071. private _createDepthOfFieldPostProcess;
  146072. private _createGrainTexture;
  146073. }
  146074. }
  146075. declare module BABYLON {
  146076. /** @hidden */
  146077. export var ssao2PixelShader: {
  146078. name: string;
  146079. shader: string;
  146080. };
  146081. }
  146082. declare module BABYLON {
  146083. /** @hidden */
  146084. export var ssaoCombinePixelShader: {
  146085. name: string;
  146086. shader: string;
  146087. };
  146088. }
  146089. declare module BABYLON {
  146090. /**
  146091. * Render pipeline to produce ssao effect
  146092. */
  146093. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  146094. /**
  146095. * @ignore
  146096. * The PassPostProcess id in the pipeline that contains the original scene color
  146097. */
  146098. SSAOOriginalSceneColorEffect: string;
  146099. /**
  146100. * @ignore
  146101. * The SSAO PostProcess id in the pipeline
  146102. */
  146103. SSAORenderEffect: string;
  146104. /**
  146105. * @ignore
  146106. * The horizontal blur PostProcess id in the pipeline
  146107. */
  146108. SSAOBlurHRenderEffect: string;
  146109. /**
  146110. * @ignore
  146111. * The vertical blur PostProcess id in the pipeline
  146112. */
  146113. SSAOBlurVRenderEffect: string;
  146114. /**
  146115. * @ignore
  146116. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  146117. */
  146118. SSAOCombineRenderEffect: string;
  146119. /**
  146120. * The output strength of the SSAO post-process. Default value is 1.0.
  146121. */
  146122. totalStrength: number;
  146123. /**
  146124. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  146125. */
  146126. maxZ: number;
  146127. /**
  146128. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  146129. */
  146130. minZAspect: number;
  146131. private _samples;
  146132. /**
  146133. * Number of samples used for the SSAO calculations. Default value is 8
  146134. */
  146135. set samples(n: number);
  146136. get samples(): number;
  146137. private _textureSamples;
  146138. /**
  146139. * Number of samples to use for antialiasing
  146140. */
  146141. set textureSamples(n: number);
  146142. get textureSamples(): number;
  146143. /**
  146144. * Ratio object used for SSAO ratio and blur ratio
  146145. */
  146146. private _ratio;
  146147. /**
  146148. * Dynamically generated sphere sampler.
  146149. */
  146150. private _sampleSphere;
  146151. /**
  146152. * Blur filter offsets
  146153. */
  146154. private _samplerOffsets;
  146155. private _expensiveBlur;
  146156. /**
  146157. * If bilateral blur should be used
  146158. */
  146159. set expensiveBlur(b: boolean);
  146160. get expensiveBlur(): boolean;
  146161. /**
  146162. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  146163. */
  146164. radius: number;
  146165. /**
  146166. * The base color of the SSAO post-process
  146167. * The final result is "base + ssao" between [0, 1]
  146168. */
  146169. base: number;
  146170. /**
  146171. * Support test.
  146172. */
  146173. static get IsSupported(): boolean;
  146174. private _scene;
  146175. private _depthTexture;
  146176. private _normalTexture;
  146177. private _randomTexture;
  146178. private _originalColorPostProcess;
  146179. private _ssaoPostProcess;
  146180. private _blurHPostProcess;
  146181. private _blurVPostProcess;
  146182. private _ssaoCombinePostProcess;
  146183. /**
  146184. * Gets active scene
  146185. */
  146186. get scene(): Scene;
  146187. /**
  146188. * @constructor
  146189. * @param name The rendering pipeline name
  146190. * @param scene The scene linked to this pipeline
  146191. * @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 }
  146192. * @param cameras The array of cameras that the rendering pipeline will be attached to
  146193. */
  146194. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  146195. /**
  146196. * Get the class name
  146197. * @returns "SSAO2RenderingPipeline"
  146198. */
  146199. getClassName(): string;
  146200. /**
  146201. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  146202. */
  146203. dispose(disableGeometryBufferRenderer?: boolean): void;
  146204. private _createBlurPostProcess;
  146205. /** @hidden */
  146206. _rebuild(): void;
  146207. private _bits;
  146208. private _radicalInverse_VdC;
  146209. private _hammersley;
  146210. private _hemisphereSample_uniform;
  146211. private _generateHemisphere;
  146212. private _createSSAOPostProcess;
  146213. private _createSSAOCombinePostProcess;
  146214. private _createRandomTexture;
  146215. /**
  146216. * Serialize the rendering pipeline (Used when exporting)
  146217. * @returns the serialized object
  146218. */
  146219. serialize(): any;
  146220. /**
  146221. * Parse the serialized pipeline
  146222. * @param source Source pipeline.
  146223. * @param scene The scene to load the pipeline to.
  146224. * @param rootUrl The URL of the serialized pipeline.
  146225. * @returns An instantiated pipeline from the serialized object.
  146226. */
  146227. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  146228. }
  146229. }
  146230. declare module BABYLON {
  146231. /** @hidden */
  146232. export var ssaoPixelShader: {
  146233. name: string;
  146234. shader: string;
  146235. };
  146236. }
  146237. declare module BABYLON {
  146238. /**
  146239. * Render pipeline to produce ssao effect
  146240. */
  146241. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  146242. /**
  146243. * @ignore
  146244. * The PassPostProcess id in the pipeline that contains the original scene color
  146245. */
  146246. SSAOOriginalSceneColorEffect: string;
  146247. /**
  146248. * @ignore
  146249. * The SSAO PostProcess id in the pipeline
  146250. */
  146251. SSAORenderEffect: string;
  146252. /**
  146253. * @ignore
  146254. * The horizontal blur PostProcess id in the pipeline
  146255. */
  146256. SSAOBlurHRenderEffect: string;
  146257. /**
  146258. * @ignore
  146259. * The vertical blur PostProcess id in the pipeline
  146260. */
  146261. SSAOBlurVRenderEffect: string;
  146262. /**
  146263. * @ignore
  146264. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  146265. */
  146266. SSAOCombineRenderEffect: string;
  146267. /**
  146268. * The output strength of the SSAO post-process. Default value is 1.0.
  146269. */
  146270. totalStrength: number;
  146271. /**
  146272. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  146273. */
  146274. radius: number;
  146275. /**
  146276. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  146277. * Must not be equal to fallOff and superior to fallOff.
  146278. * Default value is 0.0075
  146279. */
  146280. area: number;
  146281. /**
  146282. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  146283. * Must not be equal to area and inferior to area.
  146284. * Default value is 0.000001
  146285. */
  146286. fallOff: number;
  146287. /**
  146288. * The base color of the SSAO post-process
  146289. * The final result is "base + ssao" between [0, 1]
  146290. */
  146291. base: number;
  146292. private _scene;
  146293. private _depthTexture;
  146294. private _randomTexture;
  146295. private _originalColorPostProcess;
  146296. private _ssaoPostProcess;
  146297. private _blurHPostProcess;
  146298. private _blurVPostProcess;
  146299. private _ssaoCombinePostProcess;
  146300. private _firstUpdate;
  146301. /**
  146302. * Gets active scene
  146303. */
  146304. get scene(): Scene;
  146305. /**
  146306. * @constructor
  146307. * @param name - The rendering pipeline name
  146308. * @param scene - The scene linked to this pipeline
  146309. * @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 }
  146310. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  146311. */
  146312. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  146313. /**
  146314. * Get the class name
  146315. * @returns "SSAORenderingPipeline"
  146316. */
  146317. getClassName(): string;
  146318. /**
  146319. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  146320. */
  146321. dispose(disableDepthRender?: boolean): void;
  146322. private _createBlurPostProcess;
  146323. /** @hidden */
  146324. _rebuild(): void;
  146325. private _createSSAOPostProcess;
  146326. private _createSSAOCombinePostProcess;
  146327. private _createRandomTexture;
  146328. }
  146329. }
  146330. declare module BABYLON {
  146331. /** @hidden */
  146332. export var screenSpaceReflectionPixelShader: {
  146333. name: string;
  146334. shader: string;
  146335. };
  146336. }
  146337. declare module BABYLON {
  146338. /**
  146339. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  146340. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  146341. */
  146342. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  146343. /**
  146344. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  146345. */
  146346. threshold: number;
  146347. /**
  146348. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  146349. */
  146350. strength: number;
  146351. /**
  146352. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  146353. */
  146354. reflectionSpecularFalloffExponent: number;
  146355. /**
  146356. * 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]
  146357. */
  146358. step: number;
  146359. /**
  146360. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  146361. */
  146362. roughnessFactor: number;
  146363. private _geometryBufferRenderer;
  146364. private _enableSmoothReflections;
  146365. private _reflectionSamples;
  146366. private _smoothSteps;
  146367. /**
  146368. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  146369. * @param name The name of the effect.
  146370. * @param scene The scene containing the objects to calculate reflections.
  146371. * @param options The required width/height ratio to downsize to before computing the render pass.
  146372. * @param camera The camera to apply the render pass to.
  146373. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146374. * @param engine The engine which the post process will be applied. (default: current engine)
  146375. * @param reusable If the post process can be reused on the same frame. (default: false)
  146376. * @param textureType Type of textures used when performing the post process. (default: 0)
  146377. * @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)
  146378. */
  146379. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  146380. /**
  146381. * Gets wether or not smoothing reflections is enabled.
  146382. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  146383. */
  146384. get enableSmoothReflections(): boolean;
  146385. /**
  146386. * Sets wether or not smoothing reflections is enabled.
  146387. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  146388. */
  146389. set enableSmoothReflections(enabled: boolean);
  146390. /**
  146391. * Gets the number of samples taken while computing reflections. More samples count is high,
  146392. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  146393. */
  146394. get reflectionSamples(): number;
  146395. /**
  146396. * Sets the number of samples taken while computing reflections. More samples count is high,
  146397. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  146398. */
  146399. set reflectionSamples(samples: number);
  146400. /**
  146401. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  146402. * more the post-process will require GPU power and can generate a drop in FPS.
  146403. * Default value (5.0) work pretty well in all cases but can be adjusted.
  146404. */
  146405. get smoothSteps(): number;
  146406. set smoothSteps(steps: number);
  146407. private _updateEffectDefines;
  146408. }
  146409. }
  146410. declare module BABYLON {
  146411. /** @hidden */
  146412. export var standardPixelShader: {
  146413. name: string;
  146414. shader: string;
  146415. };
  146416. }
  146417. declare module BABYLON {
  146418. /**
  146419. * Standard rendering pipeline
  146420. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  146421. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  146422. */
  146423. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  146424. /**
  146425. * Public members
  146426. */
  146427. /**
  146428. * Post-process which contains the original scene color before the pipeline applies all the effects
  146429. */
  146430. originalPostProcess: Nullable<PostProcess>;
  146431. /**
  146432. * Post-process used to down scale an image x4
  146433. */
  146434. downSampleX4PostProcess: Nullable<PostProcess>;
  146435. /**
  146436. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  146437. */
  146438. brightPassPostProcess: Nullable<PostProcess>;
  146439. /**
  146440. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  146441. */
  146442. blurHPostProcesses: PostProcess[];
  146443. /**
  146444. * Post-process array storing all the vertical blur post-processes used by the pipeline
  146445. */
  146446. blurVPostProcesses: PostProcess[];
  146447. /**
  146448. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  146449. */
  146450. textureAdderPostProcess: Nullable<PostProcess>;
  146451. /**
  146452. * Post-process used to create volumetric lighting effect
  146453. */
  146454. volumetricLightPostProcess: Nullable<PostProcess>;
  146455. /**
  146456. * Post-process used to smooth the previous volumetric light post-process on the X axis
  146457. */
  146458. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  146459. /**
  146460. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  146461. */
  146462. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  146463. /**
  146464. * Post-process used to merge the volumetric light effect and the real scene color
  146465. */
  146466. volumetricLightMergePostProces: Nullable<PostProcess>;
  146467. /**
  146468. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  146469. */
  146470. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  146471. /**
  146472. * Base post-process used to calculate the average luminance of the final image for HDR
  146473. */
  146474. luminancePostProcess: Nullable<PostProcess>;
  146475. /**
  146476. * Post-processes used to create down sample post-processes in order to get
  146477. * the average luminance of the final image for HDR
  146478. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  146479. */
  146480. luminanceDownSamplePostProcesses: PostProcess[];
  146481. /**
  146482. * Post-process used to create a HDR effect (light adaptation)
  146483. */
  146484. hdrPostProcess: Nullable<PostProcess>;
  146485. /**
  146486. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  146487. */
  146488. textureAdderFinalPostProcess: Nullable<PostProcess>;
  146489. /**
  146490. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  146491. */
  146492. lensFlareFinalPostProcess: Nullable<PostProcess>;
  146493. /**
  146494. * Post-process used to merge the final HDR post-process and the real scene color
  146495. */
  146496. hdrFinalPostProcess: Nullable<PostProcess>;
  146497. /**
  146498. * Post-process used to create a lens flare effect
  146499. */
  146500. lensFlarePostProcess: Nullable<PostProcess>;
  146501. /**
  146502. * Post-process that merges the result of the lens flare post-process and the real scene color
  146503. */
  146504. lensFlareComposePostProcess: Nullable<PostProcess>;
  146505. /**
  146506. * Post-process used to create a motion blur effect
  146507. */
  146508. motionBlurPostProcess: Nullable<PostProcess>;
  146509. /**
  146510. * Post-process used to create a depth of field effect
  146511. */
  146512. depthOfFieldPostProcess: Nullable<PostProcess>;
  146513. /**
  146514. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  146515. */
  146516. fxaaPostProcess: Nullable<FxaaPostProcess>;
  146517. /**
  146518. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  146519. */
  146520. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  146521. /**
  146522. * Represents the brightness threshold in order to configure the illuminated surfaces
  146523. */
  146524. brightThreshold: number;
  146525. /**
  146526. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  146527. */
  146528. blurWidth: number;
  146529. /**
  146530. * Sets if the blur for highlighted surfaces must be only horizontal
  146531. */
  146532. horizontalBlur: boolean;
  146533. /**
  146534. * Gets the overall exposure used by the pipeline
  146535. */
  146536. get exposure(): number;
  146537. /**
  146538. * Sets the overall exposure used by the pipeline
  146539. */
  146540. set exposure(value: number);
  146541. /**
  146542. * Texture used typically to simulate "dirty" on camera lens
  146543. */
  146544. lensTexture: Nullable<Texture>;
  146545. /**
  146546. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  146547. */
  146548. volumetricLightCoefficient: number;
  146549. /**
  146550. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  146551. */
  146552. volumetricLightPower: number;
  146553. /**
  146554. * Used the set the blur intensity to smooth the volumetric lights
  146555. */
  146556. volumetricLightBlurScale: number;
  146557. /**
  146558. * Light (spot or directional) used to generate the volumetric lights rays
  146559. * The source light must have a shadow generate so the pipeline can get its
  146560. * depth map
  146561. */
  146562. sourceLight: Nullable<SpotLight | DirectionalLight>;
  146563. /**
  146564. * For eye adaptation, represents the minimum luminance the eye can see
  146565. */
  146566. hdrMinimumLuminance: number;
  146567. /**
  146568. * For eye adaptation, represents the decrease luminance speed
  146569. */
  146570. hdrDecreaseRate: number;
  146571. /**
  146572. * For eye adaptation, represents the increase luminance speed
  146573. */
  146574. hdrIncreaseRate: number;
  146575. /**
  146576. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  146577. */
  146578. get hdrAutoExposure(): boolean;
  146579. /**
  146580. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  146581. */
  146582. set hdrAutoExposure(value: boolean);
  146583. /**
  146584. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  146585. */
  146586. lensColorTexture: Nullable<Texture>;
  146587. /**
  146588. * The overall strengh for the lens flare effect
  146589. */
  146590. lensFlareStrength: number;
  146591. /**
  146592. * Dispersion coefficient for lens flare ghosts
  146593. */
  146594. lensFlareGhostDispersal: number;
  146595. /**
  146596. * Main lens flare halo width
  146597. */
  146598. lensFlareHaloWidth: number;
  146599. /**
  146600. * Based on the lens distortion effect, defines how much the lens flare result
  146601. * is distorted
  146602. */
  146603. lensFlareDistortionStrength: number;
  146604. /**
  146605. * Configures the blur intensity used for for lens flare (halo)
  146606. */
  146607. lensFlareBlurWidth: number;
  146608. /**
  146609. * Lens star texture must be used to simulate rays on the flares and is available
  146610. * in the documentation
  146611. */
  146612. lensStarTexture: Nullable<Texture>;
  146613. /**
  146614. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  146615. * flare effect by taking account of the dirt texture
  146616. */
  146617. lensFlareDirtTexture: Nullable<Texture>;
  146618. /**
  146619. * Represents the focal length for the depth of field effect
  146620. */
  146621. depthOfFieldDistance: number;
  146622. /**
  146623. * Represents the blur intensity for the blurred part of the depth of field effect
  146624. */
  146625. depthOfFieldBlurWidth: number;
  146626. /**
  146627. * Gets how much the image is blurred by the movement while using the motion blur post-process
  146628. */
  146629. get motionStrength(): number;
  146630. /**
  146631. * Sets how much the image is blurred by the movement while using the motion blur post-process
  146632. */
  146633. set motionStrength(strength: number);
  146634. /**
  146635. * Gets wether or not the motion blur post-process is object based or screen based.
  146636. */
  146637. get objectBasedMotionBlur(): boolean;
  146638. /**
  146639. * Sets wether or not the motion blur post-process should be object based or screen based
  146640. */
  146641. set objectBasedMotionBlur(value: boolean);
  146642. /**
  146643. * List of animations for the pipeline (IAnimatable implementation)
  146644. */
  146645. animations: Animation[];
  146646. /**
  146647. * Private members
  146648. */
  146649. private _scene;
  146650. private _currentDepthOfFieldSource;
  146651. private _basePostProcess;
  146652. private _fixedExposure;
  146653. private _currentExposure;
  146654. private _hdrAutoExposure;
  146655. private _hdrCurrentLuminance;
  146656. private _motionStrength;
  146657. private _isObjectBasedMotionBlur;
  146658. private _floatTextureType;
  146659. private _camerasToBeAttached;
  146660. private _ratio;
  146661. private _bloomEnabled;
  146662. private _depthOfFieldEnabled;
  146663. private _vlsEnabled;
  146664. private _lensFlareEnabled;
  146665. private _hdrEnabled;
  146666. private _motionBlurEnabled;
  146667. private _fxaaEnabled;
  146668. private _screenSpaceReflectionsEnabled;
  146669. private _motionBlurSamples;
  146670. private _volumetricLightStepsCount;
  146671. private _samples;
  146672. /**
  146673. * @ignore
  146674. * Specifies if the bloom pipeline is enabled
  146675. */
  146676. get BloomEnabled(): boolean;
  146677. set BloomEnabled(enabled: boolean);
  146678. /**
  146679. * @ignore
  146680. * Specifies if the depth of field pipeline is enabed
  146681. */
  146682. get DepthOfFieldEnabled(): boolean;
  146683. set DepthOfFieldEnabled(enabled: boolean);
  146684. /**
  146685. * @ignore
  146686. * Specifies if the lens flare pipeline is enabed
  146687. */
  146688. get LensFlareEnabled(): boolean;
  146689. set LensFlareEnabled(enabled: boolean);
  146690. /**
  146691. * @ignore
  146692. * Specifies if the HDR pipeline is enabled
  146693. */
  146694. get HDREnabled(): boolean;
  146695. set HDREnabled(enabled: boolean);
  146696. /**
  146697. * @ignore
  146698. * Specifies if the volumetric lights scattering effect is enabled
  146699. */
  146700. get VLSEnabled(): boolean;
  146701. set VLSEnabled(enabled: boolean);
  146702. /**
  146703. * @ignore
  146704. * Specifies if the motion blur effect is enabled
  146705. */
  146706. get MotionBlurEnabled(): boolean;
  146707. set MotionBlurEnabled(enabled: boolean);
  146708. /**
  146709. * Specifies if anti-aliasing is enabled
  146710. */
  146711. get fxaaEnabled(): boolean;
  146712. set fxaaEnabled(enabled: boolean);
  146713. /**
  146714. * Specifies if screen space reflections are enabled.
  146715. */
  146716. get screenSpaceReflectionsEnabled(): boolean;
  146717. set screenSpaceReflectionsEnabled(enabled: boolean);
  146718. /**
  146719. * Specifies the number of steps used to calculate the volumetric lights
  146720. * Typically in interval [50, 200]
  146721. */
  146722. get volumetricLightStepsCount(): number;
  146723. set volumetricLightStepsCount(count: number);
  146724. /**
  146725. * Specifies the number of samples used for the motion blur effect
  146726. * Typically in interval [16, 64]
  146727. */
  146728. get motionBlurSamples(): number;
  146729. set motionBlurSamples(samples: number);
  146730. /**
  146731. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  146732. */
  146733. get samples(): number;
  146734. set samples(sampleCount: number);
  146735. /**
  146736. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  146737. * @constructor
  146738. * @param name The rendering pipeline name
  146739. * @param scene The scene linked to this pipeline
  146740. * @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)
  146741. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  146742. * @param cameras The array of cameras that the rendering pipeline will be attached to
  146743. */
  146744. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  146745. private _buildPipeline;
  146746. private _createDownSampleX4PostProcess;
  146747. private _createBrightPassPostProcess;
  146748. private _createBlurPostProcesses;
  146749. private _createTextureAdderPostProcess;
  146750. private _createVolumetricLightPostProcess;
  146751. private _createLuminancePostProcesses;
  146752. private _createHdrPostProcess;
  146753. private _createLensFlarePostProcess;
  146754. private _createDepthOfFieldPostProcess;
  146755. private _createMotionBlurPostProcess;
  146756. private _getDepthTexture;
  146757. private _disposePostProcesses;
  146758. /**
  146759. * Dispose of the pipeline and stop all post processes
  146760. */
  146761. dispose(): void;
  146762. /**
  146763. * Serialize the rendering pipeline (Used when exporting)
  146764. * @returns the serialized object
  146765. */
  146766. serialize(): any;
  146767. /**
  146768. * Parse the serialized pipeline
  146769. * @param source Source pipeline.
  146770. * @param scene The scene to load the pipeline to.
  146771. * @param rootUrl The URL of the serialized pipeline.
  146772. * @returns An instantiated pipeline from the serialized object.
  146773. */
  146774. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  146775. /**
  146776. * Luminance steps
  146777. */
  146778. static LuminanceSteps: number;
  146779. }
  146780. }
  146781. declare module BABYLON {
  146782. /** @hidden */
  146783. export var stereoscopicInterlacePixelShader: {
  146784. name: string;
  146785. shader: string;
  146786. };
  146787. }
  146788. declare module BABYLON {
  146789. /**
  146790. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  146791. */
  146792. export class StereoscopicInterlacePostProcessI extends PostProcess {
  146793. private _stepSize;
  146794. private _passedProcess;
  146795. /**
  146796. * Initializes a StereoscopicInterlacePostProcessI
  146797. * @param name The name of the effect.
  146798. * @param rigCameras The rig cameras to be appled to the post process
  146799. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  146800. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  146801. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146802. * @param engine The engine which the post process will be applied. (default: current engine)
  146803. * @param reusable If the post process can be reused on the same frame. (default: false)
  146804. */
  146805. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  146806. }
  146807. /**
  146808. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  146809. */
  146810. export class StereoscopicInterlacePostProcess extends PostProcess {
  146811. private _stepSize;
  146812. private _passedProcess;
  146813. /**
  146814. * Initializes a StereoscopicInterlacePostProcess
  146815. * @param name The name of the effect.
  146816. * @param rigCameras The rig cameras to be appled to the post process
  146817. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  146818. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146819. * @param engine The engine which the post process will be applied. (default: current engine)
  146820. * @param reusable If the post process can be reused on the same frame. (default: false)
  146821. */
  146822. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  146823. }
  146824. }
  146825. declare module BABYLON {
  146826. /** @hidden */
  146827. export var tonemapPixelShader: {
  146828. name: string;
  146829. shader: string;
  146830. };
  146831. }
  146832. declare module BABYLON {
  146833. /** Defines operator used for tonemapping */
  146834. export enum TonemappingOperator {
  146835. /** Hable */
  146836. Hable = 0,
  146837. /** Reinhard */
  146838. Reinhard = 1,
  146839. /** HejiDawson */
  146840. HejiDawson = 2,
  146841. /** Photographic */
  146842. Photographic = 3
  146843. }
  146844. /**
  146845. * Defines a post process to apply tone mapping
  146846. */
  146847. export class TonemapPostProcess extends PostProcess {
  146848. private _operator;
  146849. /** Defines the required exposure adjustement */
  146850. exposureAdjustment: number;
  146851. /**
  146852. * Creates a new TonemapPostProcess
  146853. * @param name defines the name of the postprocess
  146854. * @param _operator defines the operator to use
  146855. * @param exposureAdjustment defines the required exposure adjustement
  146856. * @param camera defines the camera to use (can be null)
  146857. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  146858. * @param engine defines the hosting engine (can be ignore if camera is set)
  146859. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  146860. */
  146861. constructor(name: string, _operator: TonemappingOperator,
  146862. /** Defines the required exposure adjustement */
  146863. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  146864. }
  146865. }
  146866. declare module BABYLON {
  146867. /** @hidden */
  146868. export var volumetricLightScatteringPixelShader: {
  146869. name: string;
  146870. shader: string;
  146871. };
  146872. }
  146873. declare module BABYLON {
  146874. /** @hidden */
  146875. export var volumetricLightScatteringPassVertexShader: {
  146876. name: string;
  146877. shader: string;
  146878. };
  146879. }
  146880. declare module BABYLON {
  146881. /** @hidden */
  146882. export var volumetricLightScatteringPassPixelShader: {
  146883. name: string;
  146884. shader: string;
  146885. };
  146886. }
  146887. declare module BABYLON {
  146888. /**
  146889. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  146890. */
  146891. export class VolumetricLightScatteringPostProcess extends PostProcess {
  146892. private _volumetricLightScatteringPass;
  146893. private _volumetricLightScatteringRTT;
  146894. private _viewPort;
  146895. private _screenCoordinates;
  146896. private _cachedDefines;
  146897. /**
  146898. * If not undefined, the mesh position is computed from the attached node position
  146899. */
  146900. attachedNode: {
  146901. position: Vector3;
  146902. };
  146903. /**
  146904. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  146905. */
  146906. customMeshPosition: Vector3;
  146907. /**
  146908. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  146909. */
  146910. useCustomMeshPosition: boolean;
  146911. /**
  146912. * If the post-process should inverse the light scattering direction
  146913. */
  146914. invert: boolean;
  146915. /**
  146916. * The internal mesh used by the post-process
  146917. */
  146918. mesh: Mesh;
  146919. /**
  146920. * @hidden
  146921. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  146922. */
  146923. get useDiffuseColor(): boolean;
  146924. set useDiffuseColor(useDiffuseColor: boolean);
  146925. /**
  146926. * Array containing the excluded meshes not rendered in the internal pass
  146927. */
  146928. excludedMeshes: AbstractMesh[];
  146929. /**
  146930. * Controls the overall intensity of the post-process
  146931. */
  146932. exposure: number;
  146933. /**
  146934. * Dissipates each sample's contribution in range [0, 1]
  146935. */
  146936. decay: number;
  146937. /**
  146938. * Controls the overall intensity of each sample
  146939. */
  146940. weight: number;
  146941. /**
  146942. * Controls the density of each sample
  146943. */
  146944. density: number;
  146945. /**
  146946. * @constructor
  146947. * @param name The post-process name
  146948. * @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)
  146949. * @param camera The camera that the post-process will be attached to
  146950. * @param mesh The mesh used to create the light scattering
  146951. * @param samples The post-process quality, default 100
  146952. * @param samplingModeThe post-process filtering mode
  146953. * @param engine The babylon engine
  146954. * @param reusable If the post-process is reusable
  146955. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  146956. */
  146957. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  146958. /**
  146959. * Returns the string "VolumetricLightScatteringPostProcess"
  146960. * @returns "VolumetricLightScatteringPostProcess"
  146961. */
  146962. getClassName(): string;
  146963. private _isReady;
  146964. /**
  146965. * Sets the new light position for light scattering effect
  146966. * @param position The new custom light position
  146967. */
  146968. setCustomMeshPosition(position: Vector3): void;
  146969. /**
  146970. * Returns the light position for light scattering effect
  146971. * @return Vector3 The custom light position
  146972. */
  146973. getCustomMeshPosition(): Vector3;
  146974. /**
  146975. * Disposes the internal assets and detaches the post-process from the camera
  146976. */
  146977. dispose(camera: Camera): void;
  146978. /**
  146979. * Returns the render target texture used by the post-process
  146980. * @return the render target texture used by the post-process
  146981. */
  146982. getPass(): RenderTargetTexture;
  146983. private _meshExcluded;
  146984. private _createPass;
  146985. private _updateMeshScreenCoordinates;
  146986. /**
  146987. * Creates a default mesh for the Volumeric Light Scattering post-process
  146988. * @param name The mesh name
  146989. * @param scene The scene where to create the mesh
  146990. * @return the default mesh
  146991. */
  146992. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  146993. }
  146994. }
  146995. declare module BABYLON {
  146996. interface Scene {
  146997. /** @hidden (Backing field) */
  146998. _boundingBoxRenderer: BoundingBoxRenderer;
  146999. /** @hidden (Backing field) */
  147000. _forceShowBoundingBoxes: boolean;
  147001. /**
  147002. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  147003. */
  147004. forceShowBoundingBoxes: boolean;
  147005. /**
  147006. * Gets the bounding box renderer associated with the scene
  147007. * @returns a BoundingBoxRenderer
  147008. */
  147009. getBoundingBoxRenderer(): BoundingBoxRenderer;
  147010. }
  147011. interface AbstractMesh {
  147012. /** @hidden (Backing field) */
  147013. _showBoundingBox: boolean;
  147014. /**
  147015. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  147016. */
  147017. showBoundingBox: boolean;
  147018. }
  147019. /**
  147020. * Component responsible of rendering the bounding box of the meshes in a scene.
  147021. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  147022. */
  147023. export class BoundingBoxRenderer implements ISceneComponent {
  147024. /**
  147025. * The component name helpfull to identify the component in the list of scene components.
  147026. */
  147027. readonly name: string;
  147028. /**
  147029. * The scene the component belongs to.
  147030. */
  147031. scene: Scene;
  147032. /**
  147033. * Color of the bounding box lines placed in front of an object
  147034. */
  147035. frontColor: Color3;
  147036. /**
  147037. * Color of the bounding box lines placed behind an object
  147038. */
  147039. backColor: Color3;
  147040. /**
  147041. * Defines if the renderer should show the back lines or not
  147042. */
  147043. showBackLines: boolean;
  147044. /**
  147045. * Observable raised before rendering a bounding box
  147046. */
  147047. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  147048. /**
  147049. * Observable raised after rendering a bounding box
  147050. */
  147051. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  147052. /**
  147053. * @hidden
  147054. */
  147055. renderList: SmartArray<BoundingBox>;
  147056. private _colorShader;
  147057. private _vertexBuffers;
  147058. private _indexBuffer;
  147059. private _fillIndexBuffer;
  147060. private _fillIndexData;
  147061. /**
  147062. * Instantiates a new bounding box renderer in a scene.
  147063. * @param scene the scene the renderer renders in
  147064. */
  147065. constructor(scene: Scene);
  147066. /**
  147067. * Registers the component in a given scene
  147068. */
  147069. register(): void;
  147070. private _evaluateSubMesh;
  147071. private _activeMesh;
  147072. private _prepareRessources;
  147073. private _createIndexBuffer;
  147074. /**
  147075. * Rebuilds the elements related to this component in case of
  147076. * context lost for instance.
  147077. */
  147078. rebuild(): void;
  147079. /**
  147080. * @hidden
  147081. */
  147082. reset(): void;
  147083. /**
  147084. * Render the bounding boxes of a specific rendering group
  147085. * @param renderingGroupId defines the rendering group to render
  147086. */
  147087. render(renderingGroupId: number): void;
  147088. /**
  147089. * In case of occlusion queries, we can render the occlusion bounding box through this method
  147090. * @param mesh Define the mesh to render the occlusion bounding box for
  147091. */
  147092. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  147093. /**
  147094. * Dispose and release the resources attached to this renderer.
  147095. */
  147096. dispose(): void;
  147097. }
  147098. }
  147099. declare module BABYLON {
  147100. interface Scene {
  147101. /** @hidden (Backing field) */
  147102. _depthRenderer: {
  147103. [id: string]: DepthRenderer;
  147104. };
  147105. /**
  147106. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  147107. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  147108. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  147109. * @returns the created depth renderer
  147110. */
  147111. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  147112. /**
  147113. * Disables a depth renderer for a given camera
  147114. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  147115. */
  147116. disableDepthRenderer(camera?: Nullable<Camera>): void;
  147117. }
  147118. /**
  147119. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  147120. * in several rendering techniques.
  147121. */
  147122. export class DepthRendererSceneComponent implements ISceneComponent {
  147123. /**
  147124. * The component name helpfull to identify the component in the list of scene components.
  147125. */
  147126. readonly name: string;
  147127. /**
  147128. * The scene the component belongs to.
  147129. */
  147130. scene: Scene;
  147131. /**
  147132. * Creates a new instance of the component for the given scene
  147133. * @param scene Defines the scene to register the component in
  147134. */
  147135. constructor(scene: Scene);
  147136. /**
  147137. * Registers the component in a given scene
  147138. */
  147139. register(): void;
  147140. /**
  147141. * Rebuilds the elements related to this component in case of
  147142. * context lost for instance.
  147143. */
  147144. rebuild(): void;
  147145. /**
  147146. * Disposes the component and the associated ressources
  147147. */
  147148. dispose(): void;
  147149. private _gatherRenderTargets;
  147150. private _gatherActiveCameraRenderTargets;
  147151. }
  147152. }
  147153. declare module BABYLON {
  147154. /** @hidden */
  147155. export var outlinePixelShader: {
  147156. name: string;
  147157. shader: string;
  147158. };
  147159. }
  147160. declare module BABYLON {
  147161. /** @hidden */
  147162. export var outlineVertexShader: {
  147163. name: string;
  147164. shader: string;
  147165. };
  147166. }
  147167. declare module BABYLON {
  147168. interface Scene {
  147169. /** @hidden */
  147170. _outlineRenderer: OutlineRenderer;
  147171. /**
  147172. * Gets the outline renderer associated with the scene
  147173. * @returns a OutlineRenderer
  147174. */
  147175. getOutlineRenderer(): OutlineRenderer;
  147176. }
  147177. interface AbstractMesh {
  147178. /** @hidden (Backing field) */
  147179. _renderOutline: boolean;
  147180. /**
  147181. * Gets or sets a boolean indicating if the outline must be rendered as well
  147182. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  147183. */
  147184. renderOutline: boolean;
  147185. /** @hidden (Backing field) */
  147186. _renderOverlay: boolean;
  147187. /**
  147188. * Gets or sets a boolean indicating if the overlay must be rendered as well
  147189. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  147190. */
  147191. renderOverlay: boolean;
  147192. }
  147193. /**
  147194. * This class is responsible to draw bothe outline/overlay of meshes.
  147195. * It should not be used directly but through the available method on mesh.
  147196. */
  147197. export class OutlineRenderer implements ISceneComponent {
  147198. /**
  147199. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  147200. */
  147201. private static _StencilReference;
  147202. /**
  147203. * The name of the component. Each component must have a unique name.
  147204. */
  147205. name: string;
  147206. /**
  147207. * The scene the component belongs to.
  147208. */
  147209. scene: Scene;
  147210. /**
  147211. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  147212. */
  147213. zOffset: number;
  147214. private _engine;
  147215. private _effect;
  147216. private _cachedDefines;
  147217. private _savedDepthWrite;
  147218. /**
  147219. * Instantiates a new outline renderer. (There could be only one per scene).
  147220. * @param scene Defines the scene it belongs to
  147221. */
  147222. constructor(scene: Scene);
  147223. /**
  147224. * Register the component to one instance of a scene.
  147225. */
  147226. register(): void;
  147227. /**
  147228. * Rebuilds the elements related to this component in case of
  147229. * context lost for instance.
  147230. */
  147231. rebuild(): void;
  147232. /**
  147233. * Disposes the component and the associated ressources.
  147234. */
  147235. dispose(): void;
  147236. /**
  147237. * Renders the outline in the canvas.
  147238. * @param subMesh Defines the sumesh to render
  147239. * @param batch Defines the batch of meshes in case of instances
  147240. * @param useOverlay Defines if the rendering is for the overlay or the outline
  147241. */
  147242. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  147243. /**
  147244. * Returns whether or not the outline renderer is ready for a given submesh.
  147245. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  147246. * @param subMesh Defines the submesh to check readyness for
  147247. * @param useInstances Defines wheter wee are trying to render instances or not
  147248. * @returns true if ready otherwise false
  147249. */
  147250. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  147251. private _beforeRenderingMesh;
  147252. private _afterRenderingMesh;
  147253. }
  147254. }
  147255. declare module BABYLON {
  147256. /**
  147257. * Defines the basic options interface of a Sprite Frame Source Size.
  147258. */
  147259. export interface ISpriteJSONSpriteSourceSize {
  147260. /**
  147261. * number of the original width of the Frame
  147262. */
  147263. w: number;
  147264. /**
  147265. * number of the original height of the Frame
  147266. */
  147267. h: number;
  147268. }
  147269. /**
  147270. * Defines the basic options interface of a Sprite Frame Data.
  147271. */
  147272. export interface ISpriteJSONSpriteFrameData {
  147273. /**
  147274. * number of the x offset of the Frame
  147275. */
  147276. x: number;
  147277. /**
  147278. * number of the y offset of the Frame
  147279. */
  147280. y: number;
  147281. /**
  147282. * number of the width of the Frame
  147283. */
  147284. w: number;
  147285. /**
  147286. * number of the height of the Frame
  147287. */
  147288. h: number;
  147289. }
  147290. /**
  147291. * Defines the basic options interface of a JSON Sprite.
  147292. */
  147293. export interface ISpriteJSONSprite {
  147294. /**
  147295. * string name of the Frame
  147296. */
  147297. filename: string;
  147298. /**
  147299. * ISpriteJSONSpriteFrame basic object of the frame data
  147300. */
  147301. frame: ISpriteJSONSpriteFrameData;
  147302. /**
  147303. * boolean to flag is the frame was rotated.
  147304. */
  147305. rotated: boolean;
  147306. /**
  147307. * boolean to flag is the frame was trimmed.
  147308. */
  147309. trimmed: boolean;
  147310. /**
  147311. * ISpriteJSONSpriteFrame basic object of the source data
  147312. */
  147313. spriteSourceSize: ISpriteJSONSpriteFrameData;
  147314. /**
  147315. * ISpriteJSONSpriteFrame basic object of the source data
  147316. */
  147317. sourceSize: ISpriteJSONSpriteSourceSize;
  147318. }
  147319. /**
  147320. * Defines the basic options interface of a JSON atlas.
  147321. */
  147322. export interface ISpriteJSONAtlas {
  147323. /**
  147324. * Array of objects that contain the frame data.
  147325. */
  147326. frames: Array<ISpriteJSONSprite>;
  147327. /**
  147328. * object basic object containing the sprite meta data.
  147329. */
  147330. meta?: object;
  147331. }
  147332. }
  147333. declare module BABYLON {
  147334. /** @hidden */
  147335. export var spriteMapPixelShader: {
  147336. name: string;
  147337. shader: string;
  147338. };
  147339. }
  147340. declare module BABYLON {
  147341. /** @hidden */
  147342. export var spriteMapVertexShader: {
  147343. name: string;
  147344. shader: string;
  147345. };
  147346. }
  147347. declare module BABYLON {
  147348. /**
  147349. * Defines the basic options interface of a SpriteMap
  147350. */
  147351. export interface ISpriteMapOptions {
  147352. /**
  147353. * Vector2 of the number of cells in the grid.
  147354. */
  147355. stageSize?: Vector2;
  147356. /**
  147357. * Vector2 of the size of the output plane in World Units.
  147358. */
  147359. outputSize?: Vector2;
  147360. /**
  147361. * Vector3 of the position of the output plane in World Units.
  147362. */
  147363. outputPosition?: Vector3;
  147364. /**
  147365. * Vector3 of the rotation of the output plane.
  147366. */
  147367. outputRotation?: Vector3;
  147368. /**
  147369. * number of layers that the system will reserve in resources.
  147370. */
  147371. layerCount?: number;
  147372. /**
  147373. * number of max animation frames a single cell will reserve in resources.
  147374. */
  147375. maxAnimationFrames?: number;
  147376. /**
  147377. * number cell index of the base tile when the system compiles.
  147378. */
  147379. baseTile?: number;
  147380. /**
  147381. * boolean flip the sprite after its been repositioned by the framing data.
  147382. */
  147383. flipU?: boolean;
  147384. /**
  147385. * Vector3 scalar of the global RGB values of the SpriteMap.
  147386. */
  147387. colorMultiply?: Vector3;
  147388. }
  147389. /**
  147390. * Defines the IDisposable interface in order to be cleanable from resources.
  147391. */
  147392. export interface ISpriteMap extends IDisposable {
  147393. /**
  147394. * String name of the SpriteMap.
  147395. */
  147396. name: string;
  147397. /**
  147398. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  147399. */
  147400. atlasJSON: ISpriteJSONAtlas;
  147401. /**
  147402. * Texture of the SpriteMap.
  147403. */
  147404. spriteSheet: Texture;
  147405. /**
  147406. * The parameters to initialize the SpriteMap with.
  147407. */
  147408. options: ISpriteMapOptions;
  147409. }
  147410. /**
  147411. * Class used to manage a grid restricted sprite deployment on an Output plane.
  147412. */
  147413. export class SpriteMap implements ISpriteMap {
  147414. /** The Name of the spriteMap */
  147415. name: string;
  147416. /** The JSON file with the frame and meta data */
  147417. atlasJSON: ISpriteJSONAtlas;
  147418. /** The systems Sprite Sheet Texture */
  147419. spriteSheet: Texture;
  147420. /** Arguments passed with the Constructor */
  147421. options: ISpriteMapOptions;
  147422. /** Public Sprite Storage array, parsed from atlasJSON */
  147423. sprites: Array<ISpriteJSONSprite>;
  147424. /** Returns the Number of Sprites in the System */
  147425. get spriteCount(): number;
  147426. /** Returns the Position of Output Plane*/
  147427. get position(): Vector3;
  147428. /** Returns the Position of Output Plane*/
  147429. set position(v: Vector3);
  147430. /** Returns the Rotation of Output Plane*/
  147431. get rotation(): Vector3;
  147432. /** Returns the Rotation of Output Plane*/
  147433. set rotation(v: Vector3);
  147434. /** Sets the AnimationMap*/
  147435. get animationMap(): RawTexture;
  147436. /** Sets the AnimationMap*/
  147437. set animationMap(v: RawTexture);
  147438. /** Scene that the SpriteMap was created in */
  147439. private _scene;
  147440. /** Texture Buffer of Float32 that holds tile frame data*/
  147441. private _frameMap;
  147442. /** Texture Buffers of Float32 that holds tileMap data*/
  147443. private _tileMaps;
  147444. /** Texture Buffer of Float32 that holds Animation Data*/
  147445. private _animationMap;
  147446. /** Custom ShaderMaterial Central to the System*/
  147447. private _material;
  147448. /** Custom ShaderMaterial Central to the System*/
  147449. private _output;
  147450. /** Systems Time Ticker*/
  147451. private _time;
  147452. /**
  147453. * Creates a new SpriteMap
  147454. * @param name defines the SpriteMaps Name
  147455. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  147456. * @param spriteSheet is the Texture that the Sprites are on.
  147457. * @param options a basic deployment configuration
  147458. * @param scene The Scene that the map is deployed on
  147459. */
  147460. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  147461. /**
  147462. * Returns tileID location
  147463. * @returns Vector2 the cell position ID
  147464. */
  147465. getTileID(): Vector2;
  147466. /**
  147467. * Gets the UV location of the mouse over the SpriteMap.
  147468. * @returns Vector2 the UV position of the mouse interaction
  147469. */
  147470. getMousePosition(): Vector2;
  147471. /**
  147472. * Creates the "frame" texture Buffer
  147473. * -------------------------------------
  147474. * Structure of frames
  147475. * "filename": "Falling-Water-2.png",
  147476. * "frame": {"x":69,"y":103,"w":24,"h":32},
  147477. * "rotated": true,
  147478. * "trimmed": true,
  147479. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  147480. * "sourceSize": {"w":32,"h":32}
  147481. * @returns RawTexture of the frameMap
  147482. */
  147483. private _createFrameBuffer;
  147484. /**
  147485. * Creates the tileMap texture Buffer
  147486. * @param buffer normally and array of numbers, or a false to generate from scratch
  147487. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  147488. * @returns RawTexture of the tileMap
  147489. */
  147490. private _createTileBuffer;
  147491. /**
  147492. * Modifies the data of the tileMaps
  147493. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  147494. * @param pos is the iVector2 Coordinates of the Tile
  147495. * @param tile The SpriteIndex of the new Tile
  147496. */
  147497. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  147498. /**
  147499. * Creates the animationMap texture Buffer
  147500. * @param buffer normally and array of numbers, or a false to generate from scratch
  147501. * @returns RawTexture of the animationMap
  147502. */
  147503. private _createTileAnimationBuffer;
  147504. /**
  147505. * Modifies the data of the animationMap
  147506. * @param cellID is the Index of the Sprite
  147507. * @param _frame is the target Animation frame
  147508. * @param toCell is the Target Index of the next frame of the animation
  147509. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  147510. * @param speed is a global scalar of the time variable on the map.
  147511. */
  147512. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  147513. /**
  147514. * Exports the .tilemaps file
  147515. */
  147516. saveTileMaps(): void;
  147517. /**
  147518. * Imports the .tilemaps file
  147519. * @param url of the .tilemaps file
  147520. */
  147521. loadTileMaps(url: string): void;
  147522. /**
  147523. * Release associated resources
  147524. */
  147525. dispose(): void;
  147526. }
  147527. }
  147528. declare module BABYLON {
  147529. /**
  147530. * Class used to manage multiple sprites of different sizes on the same spritesheet
  147531. * @see http://doc.babylonjs.com/babylon101/sprites
  147532. */
  147533. export class SpritePackedManager extends SpriteManager {
  147534. /** defines the packed manager's name */
  147535. name: string;
  147536. /**
  147537. * Creates a new sprite manager from a packed sprite sheet
  147538. * @param name defines the manager's name
  147539. * @param imgUrl defines the sprite sheet url
  147540. * @param capacity defines the maximum allowed number of sprites
  147541. * @param scene defines the hosting scene
  147542. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  147543. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  147544. * @param samplingMode defines the smapling mode to use with spritesheet
  147545. * @param fromPacked set to true; do not alter
  147546. */
  147547. constructor(
  147548. /** defines the packed manager's name */
  147549. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  147550. }
  147551. }
  147552. declare module BABYLON {
  147553. /**
  147554. * Defines the list of states available for a task inside a AssetsManager
  147555. */
  147556. export enum AssetTaskState {
  147557. /**
  147558. * Initialization
  147559. */
  147560. INIT = 0,
  147561. /**
  147562. * Running
  147563. */
  147564. RUNNING = 1,
  147565. /**
  147566. * Done
  147567. */
  147568. DONE = 2,
  147569. /**
  147570. * Error
  147571. */
  147572. ERROR = 3
  147573. }
  147574. /**
  147575. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  147576. */
  147577. export abstract class AbstractAssetTask {
  147578. /**
  147579. * Task name
  147580. */ name: string;
  147581. /**
  147582. * Callback called when the task is successful
  147583. */
  147584. onSuccess: (task: any) => void;
  147585. /**
  147586. * Callback called when the task is not successful
  147587. */
  147588. onError: (task: any, message?: string, exception?: any) => void;
  147589. /**
  147590. * Creates a new AssetsManager
  147591. * @param name defines the name of the task
  147592. */
  147593. constructor(
  147594. /**
  147595. * Task name
  147596. */ name: string);
  147597. private _isCompleted;
  147598. private _taskState;
  147599. private _errorObject;
  147600. /**
  147601. * Get if the task is completed
  147602. */
  147603. get isCompleted(): boolean;
  147604. /**
  147605. * Gets the current state of the task
  147606. */
  147607. get taskState(): AssetTaskState;
  147608. /**
  147609. * Gets the current error object (if task is in error)
  147610. */
  147611. get errorObject(): {
  147612. message?: string;
  147613. exception?: any;
  147614. };
  147615. /**
  147616. * Internal only
  147617. * @hidden
  147618. */
  147619. _setErrorObject(message?: string, exception?: any): void;
  147620. /**
  147621. * Execute the current task
  147622. * @param scene defines the scene where you want your assets to be loaded
  147623. * @param onSuccess is a callback called when the task is successfully executed
  147624. * @param onError is a callback called if an error occurs
  147625. */
  147626. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  147627. /**
  147628. * Execute the current task
  147629. * @param scene defines the scene where you want your assets to be loaded
  147630. * @param onSuccess is a callback called when the task is successfully executed
  147631. * @param onError is a callback called if an error occurs
  147632. */
  147633. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  147634. /**
  147635. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  147636. * This can be used with failed tasks that have the reason for failure fixed.
  147637. */
  147638. reset(): void;
  147639. private onErrorCallback;
  147640. private onDoneCallback;
  147641. }
  147642. /**
  147643. * Define the interface used by progress events raised during assets loading
  147644. */
  147645. export interface IAssetsProgressEvent {
  147646. /**
  147647. * Defines the number of remaining tasks to process
  147648. */
  147649. remainingCount: number;
  147650. /**
  147651. * Defines the total number of tasks
  147652. */
  147653. totalCount: number;
  147654. /**
  147655. * Defines the task that was just processed
  147656. */
  147657. task: AbstractAssetTask;
  147658. }
  147659. /**
  147660. * Class used to share progress information about assets loading
  147661. */
  147662. export class AssetsProgressEvent implements IAssetsProgressEvent {
  147663. /**
  147664. * Defines the number of remaining tasks to process
  147665. */
  147666. remainingCount: number;
  147667. /**
  147668. * Defines the total number of tasks
  147669. */
  147670. totalCount: number;
  147671. /**
  147672. * Defines the task that was just processed
  147673. */
  147674. task: AbstractAssetTask;
  147675. /**
  147676. * Creates a AssetsProgressEvent
  147677. * @param remainingCount defines the number of remaining tasks to process
  147678. * @param totalCount defines the total number of tasks
  147679. * @param task defines the task that was just processed
  147680. */
  147681. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  147682. }
  147683. /**
  147684. * Define a task used by AssetsManager to load meshes
  147685. */
  147686. export class MeshAssetTask extends AbstractAssetTask {
  147687. /**
  147688. * Defines the name of the task
  147689. */
  147690. name: string;
  147691. /**
  147692. * Defines the list of mesh's names you want to load
  147693. */
  147694. meshesNames: any;
  147695. /**
  147696. * Defines the root url to use as a base to load your meshes and associated resources
  147697. */
  147698. rootUrl: string;
  147699. /**
  147700. * Defines the filename or File of the scene to load from
  147701. */
  147702. sceneFilename: string | File;
  147703. /**
  147704. * Gets the list of loaded meshes
  147705. */
  147706. loadedMeshes: Array<AbstractMesh>;
  147707. /**
  147708. * Gets the list of loaded particle systems
  147709. */
  147710. loadedParticleSystems: Array<IParticleSystem>;
  147711. /**
  147712. * Gets the list of loaded skeletons
  147713. */
  147714. loadedSkeletons: Array<Skeleton>;
  147715. /**
  147716. * Gets the list of loaded animation groups
  147717. */
  147718. loadedAnimationGroups: Array<AnimationGroup>;
  147719. /**
  147720. * Callback called when the task is successful
  147721. */
  147722. onSuccess: (task: MeshAssetTask) => void;
  147723. /**
  147724. * Callback called when the task is successful
  147725. */
  147726. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  147727. /**
  147728. * Creates a new MeshAssetTask
  147729. * @param name defines the name of the task
  147730. * @param meshesNames defines the list of mesh's names you want to load
  147731. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  147732. * @param sceneFilename defines the filename or File of the scene to load from
  147733. */
  147734. constructor(
  147735. /**
  147736. * Defines the name of the task
  147737. */
  147738. name: string,
  147739. /**
  147740. * Defines the list of mesh's names you want to load
  147741. */
  147742. meshesNames: any,
  147743. /**
  147744. * Defines the root url to use as a base to load your meshes and associated resources
  147745. */
  147746. rootUrl: string,
  147747. /**
  147748. * Defines the filename or File of the scene to load from
  147749. */
  147750. sceneFilename: string | File);
  147751. /**
  147752. * Execute the current task
  147753. * @param scene defines the scene where you want your assets to be loaded
  147754. * @param onSuccess is a callback called when the task is successfully executed
  147755. * @param onError is a callback called if an error occurs
  147756. */
  147757. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  147758. }
  147759. /**
  147760. * Define a task used by AssetsManager to load text content
  147761. */
  147762. export class TextFileAssetTask extends AbstractAssetTask {
  147763. /**
  147764. * Defines the name of the task
  147765. */
  147766. name: string;
  147767. /**
  147768. * Defines the location of the file to load
  147769. */
  147770. url: string;
  147771. /**
  147772. * Gets the loaded text string
  147773. */
  147774. text: string;
  147775. /**
  147776. * Callback called when the task is successful
  147777. */
  147778. onSuccess: (task: TextFileAssetTask) => void;
  147779. /**
  147780. * Callback called when the task is successful
  147781. */
  147782. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  147783. /**
  147784. * Creates a new TextFileAssetTask object
  147785. * @param name defines the name of the task
  147786. * @param url defines the location of the file to load
  147787. */
  147788. constructor(
  147789. /**
  147790. * Defines the name of the task
  147791. */
  147792. name: string,
  147793. /**
  147794. * Defines the location of the file to load
  147795. */
  147796. url: string);
  147797. /**
  147798. * Execute the current task
  147799. * @param scene defines the scene where you want your assets to be loaded
  147800. * @param onSuccess is a callback called when the task is successfully executed
  147801. * @param onError is a callback called if an error occurs
  147802. */
  147803. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  147804. }
  147805. /**
  147806. * Define a task used by AssetsManager to load binary data
  147807. */
  147808. export class BinaryFileAssetTask extends AbstractAssetTask {
  147809. /**
  147810. * Defines the name of the task
  147811. */
  147812. name: string;
  147813. /**
  147814. * Defines the location of the file to load
  147815. */
  147816. url: string;
  147817. /**
  147818. * Gets the lodaded data (as an array buffer)
  147819. */
  147820. data: ArrayBuffer;
  147821. /**
  147822. * Callback called when the task is successful
  147823. */
  147824. onSuccess: (task: BinaryFileAssetTask) => void;
  147825. /**
  147826. * Callback called when the task is successful
  147827. */
  147828. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  147829. /**
  147830. * Creates a new BinaryFileAssetTask object
  147831. * @param name defines the name of the new task
  147832. * @param url defines the location of the file to load
  147833. */
  147834. constructor(
  147835. /**
  147836. * Defines the name of the task
  147837. */
  147838. name: string,
  147839. /**
  147840. * Defines the location of the file to load
  147841. */
  147842. url: string);
  147843. /**
  147844. * Execute the current task
  147845. * @param scene defines the scene where you want your assets to be loaded
  147846. * @param onSuccess is a callback called when the task is successfully executed
  147847. * @param onError is a callback called if an error occurs
  147848. */
  147849. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  147850. }
  147851. /**
  147852. * Define a task used by AssetsManager to load images
  147853. */
  147854. export class ImageAssetTask extends AbstractAssetTask {
  147855. /**
  147856. * Defines the name of the task
  147857. */
  147858. name: string;
  147859. /**
  147860. * Defines the location of the image to load
  147861. */
  147862. url: string;
  147863. /**
  147864. * Gets the loaded images
  147865. */
  147866. image: HTMLImageElement;
  147867. /**
  147868. * Callback called when the task is successful
  147869. */
  147870. onSuccess: (task: ImageAssetTask) => void;
  147871. /**
  147872. * Callback called when the task is successful
  147873. */
  147874. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  147875. /**
  147876. * Creates a new ImageAssetTask
  147877. * @param name defines the name of the task
  147878. * @param url defines the location of the image to load
  147879. */
  147880. constructor(
  147881. /**
  147882. * Defines the name of the task
  147883. */
  147884. name: string,
  147885. /**
  147886. * Defines the location of the image to load
  147887. */
  147888. url: string);
  147889. /**
  147890. * Execute the current task
  147891. * @param scene defines the scene where you want your assets to be loaded
  147892. * @param onSuccess is a callback called when the task is successfully executed
  147893. * @param onError is a callback called if an error occurs
  147894. */
  147895. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  147896. }
  147897. /**
  147898. * Defines the interface used by texture loading tasks
  147899. */
  147900. export interface ITextureAssetTask<TEX extends BaseTexture> {
  147901. /**
  147902. * Gets the loaded texture
  147903. */
  147904. texture: TEX;
  147905. }
  147906. /**
  147907. * Define a task used by AssetsManager to load 2D textures
  147908. */
  147909. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  147910. /**
  147911. * Defines the name of the task
  147912. */
  147913. name: string;
  147914. /**
  147915. * Defines the location of the file to load
  147916. */
  147917. url: string;
  147918. /**
  147919. * Defines if mipmap should not be generated (default is false)
  147920. */
  147921. noMipmap?: boolean | undefined;
  147922. /**
  147923. * Defines if texture must be inverted on Y axis (default is true)
  147924. */
  147925. invertY: boolean;
  147926. /**
  147927. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  147928. */
  147929. samplingMode: number;
  147930. /**
  147931. * Gets the loaded texture
  147932. */
  147933. texture: Texture;
  147934. /**
  147935. * Callback called when the task is successful
  147936. */
  147937. onSuccess: (task: TextureAssetTask) => void;
  147938. /**
  147939. * Callback called when the task is successful
  147940. */
  147941. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  147942. /**
  147943. * Creates a new TextureAssetTask object
  147944. * @param name defines the name of the task
  147945. * @param url defines the location of the file to load
  147946. * @param noMipmap defines if mipmap should not be generated (default is false)
  147947. * @param invertY defines if texture must be inverted on Y axis (default is true)
  147948. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  147949. */
  147950. constructor(
  147951. /**
  147952. * Defines the name of the task
  147953. */
  147954. name: string,
  147955. /**
  147956. * Defines the location of the file to load
  147957. */
  147958. url: string,
  147959. /**
  147960. * Defines if mipmap should not be generated (default is false)
  147961. */
  147962. noMipmap?: boolean | undefined,
  147963. /**
  147964. * Defines if texture must be inverted on Y axis (default is true)
  147965. */
  147966. invertY?: boolean,
  147967. /**
  147968. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  147969. */
  147970. samplingMode?: number);
  147971. /**
  147972. * Execute the current task
  147973. * @param scene defines the scene where you want your assets to be loaded
  147974. * @param onSuccess is a callback called when the task is successfully executed
  147975. * @param onError is a callback called if an error occurs
  147976. */
  147977. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  147978. }
  147979. /**
  147980. * Define a task used by AssetsManager to load cube textures
  147981. */
  147982. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  147983. /**
  147984. * Defines the name of the task
  147985. */
  147986. name: string;
  147987. /**
  147988. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  147989. */
  147990. url: string;
  147991. /**
  147992. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  147993. */
  147994. extensions?: string[] | undefined;
  147995. /**
  147996. * Defines if mipmaps should not be generated (default is false)
  147997. */
  147998. noMipmap?: boolean | undefined;
  147999. /**
  148000. * Defines the explicit list of files (undefined by default)
  148001. */
  148002. files?: string[] | undefined;
  148003. /**
  148004. * Gets the loaded texture
  148005. */
  148006. texture: CubeTexture;
  148007. /**
  148008. * Callback called when the task is successful
  148009. */
  148010. onSuccess: (task: CubeTextureAssetTask) => void;
  148011. /**
  148012. * Callback called when the task is successful
  148013. */
  148014. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  148015. /**
  148016. * Creates a new CubeTextureAssetTask
  148017. * @param name defines the name of the task
  148018. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  148019. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  148020. * @param noMipmap defines if mipmaps should not be generated (default is false)
  148021. * @param files defines the explicit list of files (undefined by default)
  148022. */
  148023. constructor(
  148024. /**
  148025. * Defines the name of the task
  148026. */
  148027. name: string,
  148028. /**
  148029. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  148030. */
  148031. url: string,
  148032. /**
  148033. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  148034. */
  148035. extensions?: string[] | undefined,
  148036. /**
  148037. * Defines if mipmaps should not be generated (default is false)
  148038. */
  148039. noMipmap?: boolean | undefined,
  148040. /**
  148041. * Defines the explicit list of files (undefined by default)
  148042. */
  148043. files?: string[] | undefined);
  148044. /**
  148045. * Execute the current task
  148046. * @param scene defines the scene where you want your assets to be loaded
  148047. * @param onSuccess is a callback called when the task is successfully executed
  148048. * @param onError is a callback called if an error occurs
  148049. */
  148050. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  148051. }
  148052. /**
  148053. * Define a task used by AssetsManager to load HDR cube textures
  148054. */
  148055. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  148056. /**
  148057. * Defines the name of the task
  148058. */
  148059. name: string;
  148060. /**
  148061. * Defines the location of the file to load
  148062. */
  148063. url: string;
  148064. /**
  148065. * Defines the desired size (the more it increases the longer the generation will be)
  148066. */
  148067. size: number;
  148068. /**
  148069. * Defines if mipmaps should not be generated (default is false)
  148070. */
  148071. noMipmap: boolean;
  148072. /**
  148073. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  148074. */
  148075. generateHarmonics: boolean;
  148076. /**
  148077. * 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)
  148078. */
  148079. gammaSpace: boolean;
  148080. /**
  148081. * Internal Use Only
  148082. */
  148083. reserved: boolean;
  148084. /**
  148085. * Gets the loaded texture
  148086. */
  148087. texture: HDRCubeTexture;
  148088. /**
  148089. * Callback called when the task is successful
  148090. */
  148091. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  148092. /**
  148093. * Callback called when the task is successful
  148094. */
  148095. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  148096. /**
  148097. * Creates a new HDRCubeTextureAssetTask object
  148098. * @param name defines the name of the task
  148099. * @param url defines the location of the file to load
  148100. * @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.
  148101. * @param noMipmap defines if mipmaps should not be generated (default is false)
  148102. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  148103. * @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)
  148104. * @param reserved Internal use only
  148105. */
  148106. constructor(
  148107. /**
  148108. * Defines the name of the task
  148109. */
  148110. name: string,
  148111. /**
  148112. * Defines the location of the file to load
  148113. */
  148114. url: string,
  148115. /**
  148116. * Defines the desired size (the more it increases the longer the generation will be)
  148117. */
  148118. size: number,
  148119. /**
  148120. * Defines if mipmaps should not be generated (default is false)
  148121. */
  148122. noMipmap?: boolean,
  148123. /**
  148124. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  148125. */
  148126. generateHarmonics?: boolean,
  148127. /**
  148128. * 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)
  148129. */
  148130. gammaSpace?: boolean,
  148131. /**
  148132. * Internal Use Only
  148133. */
  148134. reserved?: boolean);
  148135. /**
  148136. * Execute the current task
  148137. * @param scene defines the scene where you want your assets to be loaded
  148138. * @param onSuccess is a callback called when the task is successfully executed
  148139. * @param onError is a callback called if an error occurs
  148140. */
  148141. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  148142. }
  148143. /**
  148144. * Define a task used by AssetsManager to load Equirectangular cube textures
  148145. */
  148146. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  148147. /**
  148148. * Defines the name of the task
  148149. */
  148150. name: string;
  148151. /**
  148152. * Defines the location of the file to load
  148153. */
  148154. url: string;
  148155. /**
  148156. * Defines the desired size (the more it increases the longer the generation will be)
  148157. */
  148158. size: number;
  148159. /**
  148160. * Defines if mipmaps should not be generated (default is false)
  148161. */
  148162. noMipmap: boolean;
  148163. /**
  148164. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  148165. * but the standard material would require them in Gamma space) (default is true)
  148166. */
  148167. gammaSpace: boolean;
  148168. /**
  148169. * Gets the loaded texture
  148170. */
  148171. texture: EquiRectangularCubeTexture;
  148172. /**
  148173. * Callback called when the task is successful
  148174. */
  148175. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  148176. /**
  148177. * Callback called when the task is successful
  148178. */
  148179. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  148180. /**
  148181. * Creates a new EquiRectangularCubeTextureAssetTask object
  148182. * @param name defines the name of the task
  148183. * @param url defines the location of the file to load
  148184. * @param size defines the desired size (the more it increases the longer the generation will be)
  148185. * If the size is omitted this implies you are using a preprocessed cubemap.
  148186. * @param noMipmap defines if mipmaps should not be generated (default is false)
  148187. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  148188. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  148189. * (default is true)
  148190. */
  148191. constructor(
  148192. /**
  148193. * Defines the name of the task
  148194. */
  148195. name: string,
  148196. /**
  148197. * Defines the location of the file to load
  148198. */
  148199. url: string,
  148200. /**
  148201. * Defines the desired size (the more it increases the longer the generation will be)
  148202. */
  148203. size: number,
  148204. /**
  148205. * Defines if mipmaps should not be generated (default is false)
  148206. */
  148207. noMipmap?: boolean,
  148208. /**
  148209. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  148210. * but the standard material would require them in Gamma space) (default is true)
  148211. */
  148212. gammaSpace?: boolean);
  148213. /**
  148214. * Execute the current task
  148215. * @param scene defines the scene where you want your assets to be loaded
  148216. * @param onSuccess is a callback called when the task is successfully executed
  148217. * @param onError is a callback called if an error occurs
  148218. */
  148219. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  148220. }
  148221. /**
  148222. * This class can be used to easily import assets into a scene
  148223. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  148224. */
  148225. export class AssetsManager {
  148226. private _scene;
  148227. private _isLoading;
  148228. protected _tasks: AbstractAssetTask[];
  148229. protected _waitingTasksCount: number;
  148230. protected _totalTasksCount: number;
  148231. /**
  148232. * Callback called when all tasks are processed
  148233. */
  148234. onFinish: (tasks: AbstractAssetTask[]) => void;
  148235. /**
  148236. * Callback called when a task is successful
  148237. */
  148238. onTaskSuccess: (task: AbstractAssetTask) => void;
  148239. /**
  148240. * Callback called when a task had an error
  148241. */
  148242. onTaskError: (task: AbstractAssetTask) => void;
  148243. /**
  148244. * Callback called when a task is done (whatever the result is)
  148245. */
  148246. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  148247. /**
  148248. * Observable called when all tasks are processed
  148249. */
  148250. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  148251. /**
  148252. * Observable called when a task had an error
  148253. */
  148254. onTaskErrorObservable: Observable<AbstractAssetTask>;
  148255. /**
  148256. * Observable called when all tasks were executed
  148257. */
  148258. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  148259. /**
  148260. * Observable called when a task is done (whatever the result is)
  148261. */
  148262. onProgressObservable: Observable<IAssetsProgressEvent>;
  148263. /**
  148264. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  148265. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  148266. */
  148267. useDefaultLoadingScreen: boolean;
  148268. /**
  148269. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  148270. * when all assets have been downloaded.
  148271. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  148272. */
  148273. autoHideLoadingUI: boolean;
  148274. /**
  148275. * Creates a new AssetsManager
  148276. * @param scene defines the scene to work on
  148277. */
  148278. constructor(scene: Scene);
  148279. /**
  148280. * Add a MeshAssetTask to the list of active tasks
  148281. * @param taskName defines the name of the new task
  148282. * @param meshesNames defines the name of meshes to load
  148283. * @param rootUrl defines the root url to use to locate files
  148284. * @param sceneFilename defines the filename of the scene file
  148285. * @returns a new MeshAssetTask object
  148286. */
  148287. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  148288. /**
  148289. * Add a TextFileAssetTask to the list of active tasks
  148290. * @param taskName defines the name of the new task
  148291. * @param url defines the url of the file to load
  148292. * @returns a new TextFileAssetTask object
  148293. */
  148294. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  148295. /**
  148296. * Add a BinaryFileAssetTask to the list of active tasks
  148297. * @param taskName defines the name of the new task
  148298. * @param url defines the url of the file to load
  148299. * @returns a new BinaryFileAssetTask object
  148300. */
  148301. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  148302. /**
  148303. * Add a ImageAssetTask to the list of active tasks
  148304. * @param taskName defines the name of the new task
  148305. * @param url defines the url of the file to load
  148306. * @returns a new ImageAssetTask object
  148307. */
  148308. addImageTask(taskName: string, url: string): ImageAssetTask;
  148309. /**
  148310. * Add a TextureAssetTask to the list of active tasks
  148311. * @param taskName defines the name of the new task
  148312. * @param url defines the url of the file to load
  148313. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  148314. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  148315. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  148316. * @returns a new TextureAssetTask object
  148317. */
  148318. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  148319. /**
  148320. * Add a CubeTextureAssetTask to the list of active tasks
  148321. * @param taskName defines the name of the new task
  148322. * @param url defines the url of the file to load
  148323. * @param extensions defines the extension to use to load the cube map (can be null)
  148324. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  148325. * @param files defines the list of files to load (can be null)
  148326. * @returns a new CubeTextureAssetTask object
  148327. */
  148328. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  148329. /**
  148330. *
  148331. * Add a HDRCubeTextureAssetTask to the list of active tasks
  148332. * @param taskName defines the name of the new task
  148333. * @param url defines the url of the file to load
  148334. * @param size defines the size you want for the cubemap (can be null)
  148335. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  148336. * @param generateHarmonics defines if you want to automatically generate (true by default)
  148337. * @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)
  148338. * @param reserved Internal use only
  148339. * @returns a new HDRCubeTextureAssetTask object
  148340. */
  148341. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  148342. /**
  148343. *
  148344. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  148345. * @param taskName defines the name of the new task
  148346. * @param url defines the url of the file to load
  148347. * @param size defines the size you want for the cubemap (can be null)
  148348. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  148349. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  148350. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  148351. * @returns a new EquiRectangularCubeTextureAssetTask object
  148352. */
  148353. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  148354. /**
  148355. * Remove a task from the assets manager.
  148356. * @param task the task to remove
  148357. */
  148358. removeTask(task: AbstractAssetTask): void;
  148359. private _decreaseWaitingTasksCount;
  148360. private _runTask;
  148361. /**
  148362. * Reset the AssetsManager and remove all tasks
  148363. * @return the current instance of the AssetsManager
  148364. */
  148365. reset(): AssetsManager;
  148366. /**
  148367. * Start the loading process
  148368. * @return the current instance of the AssetsManager
  148369. */
  148370. load(): AssetsManager;
  148371. /**
  148372. * Start the loading process as an async operation
  148373. * @return a promise returning the list of failed tasks
  148374. */
  148375. loadAsync(): Promise<void>;
  148376. }
  148377. }
  148378. declare module BABYLON {
  148379. /**
  148380. * Wrapper class for promise with external resolve and reject.
  148381. */
  148382. export class Deferred<T> {
  148383. /**
  148384. * The promise associated with this deferred object.
  148385. */
  148386. readonly promise: Promise<T>;
  148387. private _resolve;
  148388. private _reject;
  148389. /**
  148390. * The resolve method of the promise associated with this deferred object.
  148391. */
  148392. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  148393. /**
  148394. * The reject method of the promise associated with this deferred object.
  148395. */
  148396. get reject(): (reason?: any) => void;
  148397. /**
  148398. * Constructor for this deferred object.
  148399. */
  148400. constructor();
  148401. }
  148402. }
  148403. declare module BABYLON {
  148404. /**
  148405. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  148406. */
  148407. export class MeshExploder {
  148408. private _centerMesh;
  148409. private _meshes;
  148410. private _meshesOrigins;
  148411. private _toCenterVectors;
  148412. private _scaledDirection;
  148413. private _newPosition;
  148414. private _centerPosition;
  148415. /**
  148416. * Explodes meshes from a center mesh.
  148417. * @param meshes The meshes to explode.
  148418. * @param centerMesh The mesh to be center of explosion.
  148419. */
  148420. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  148421. private _setCenterMesh;
  148422. /**
  148423. * Get class name
  148424. * @returns "MeshExploder"
  148425. */
  148426. getClassName(): string;
  148427. /**
  148428. * "Exploded meshes"
  148429. * @returns Array of meshes with the centerMesh at index 0.
  148430. */
  148431. getMeshes(): Array<Mesh>;
  148432. /**
  148433. * Explodes meshes giving a specific direction
  148434. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  148435. */
  148436. explode(direction?: number): void;
  148437. }
  148438. }
  148439. declare module BABYLON {
  148440. /**
  148441. * Class used to help managing file picking and drag'n'drop
  148442. */
  148443. export class FilesInput {
  148444. /**
  148445. * List of files ready to be loaded
  148446. */
  148447. static get FilesToLoad(): {
  148448. [key: string]: File;
  148449. };
  148450. /**
  148451. * Callback called when a file is processed
  148452. */
  148453. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  148454. private _engine;
  148455. private _currentScene;
  148456. private _sceneLoadedCallback;
  148457. private _progressCallback;
  148458. private _additionalRenderLoopLogicCallback;
  148459. private _textureLoadingCallback;
  148460. private _startingProcessingFilesCallback;
  148461. private _onReloadCallback;
  148462. private _errorCallback;
  148463. private _elementToMonitor;
  148464. private _sceneFileToLoad;
  148465. private _filesToLoad;
  148466. /**
  148467. * Creates a new FilesInput
  148468. * @param engine defines the rendering engine
  148469. * @param scene defines the hosting scene
  148470. * @param sceneLoadedCallback callback called when scene is loaded
  148471. * @param progressCallback callback called to track progress
  148472. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  148473. * @param textureLoadingCallback callback called when a texture is loading
  148474. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  148475. * @param onReloadCallback callback called when a reload is requested
  148476. * @param errorCallback callback call if an error occurs
  148477. */
  148478. 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);
  148479. private _dragEnterHandler;
  148480. private _dragOverHandler;
  148481. private _dropHandler;
  148482. /**
  148483. * Calls this function to listen to drag'n'drop events on a specific DOM element
  148484. * @param elementToMonitor defines the DOM element to track
  148485. */
  148486. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  148487. /**
  148488. * Release all associated resources
  148489. */
  148490. dispose(): void;
  148491. private renderFunction;
  148492. private drag;
  148493. private drop;
  148494. private _traverseFolder;
  148495. private _processFiles;
  148496. /**
  148497. * Load files from a drop event
  148498. * @param event defines the drop event to use as source
  148499. */
  148500. loadFiles(event: any): void;
  148501. private _processReload;
  148502. /**
  148503. * Reload the current scene from the loaded files
  148504. */
  148505. reload(): void;
  148506. }
  148507. }
  148508. declare module BABYLON {
  148509. /**
  148510. * Defines the root class used to create scene optimization to use with SceneOptimizer
  148511. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  148512. */
  148513. export class SceneOptimization {
  148514. /**
  148515. * Defines the priority of this optimization (0 by default which means first in the list)
  148516. */
  148517. priority: number;
  148518. /**
  148519. * Gets a string describing the action executed by the current optimization
  148520. * @returns description string
  148521. */
  148522. getDescription(): string;
  148523. /**
  148524. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  148525. * @param scene defines the current scene where to apply this optimization
  148526. * @param optimizer defines the current optimizer
  148527. * @returns true if everything that can be done was applied
  148528. */
  148529. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  148530. /**
  148531. * Creates the SceneOptimization object
  148532. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  148533. * @param desc defines the description associated with the optimization
  148534. */
  148535. constructor(
  148536. /**
  148537. * Defines the priority of this optimization (0 by default which means first in the list)
  148538. */
  148539. priority?: number);
  148540. }
  148541. /**
  148542. * Defines an optimization used to reduce the size of render target textures
  148543. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  148544. */
  148545. export class TextureOptimization extends SceneOptimization {
  148546. /**
  148547. * Defines the priority of this optimization (0 by default which means first in the list)
  148548. */
  148549. priority: number;
  148550. /**
  148551. * 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
  148552. */
  148553. maximumSize: number;
  148554. /**
  148555. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  148556. */
  148557. step: number;
  148558. /**
  148559. * Gets a string describing the action executed by the current optimization
  148560. * @returns description string
  148561. */
  148562. getDescription(): string;
  148563. /**
  148564. * Creates the TextureOptimization object
  148565. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  148566. * @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
  148567. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  148568. */
  148569. constructor(
  148570. /**
  148571. * Defines the priority of this optimization (0 by default which means first in the list)
  148572. */
  148573. priority?: number,
  148574. /**
  148575. * 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
  148576. */
  148577. maximumSize?: number,
  148578. /**
  148579. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  148580. */
  148581. step?: number);
  148582. /**
  148583. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  148584. * @param scene defines the current scene where to apply this optimization
  148585. * @param optimizer defines the current optimizer
  148586. * @returns true if everything that can be done was applied
  148587. */
  148588. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  148589. }
  148590. /**
  148591. * Defines an optimization used to increase or decrease the rendering resolution
  148592. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  148593. */
  148594. export class HardwareScalingOptimization extends SceneOptimization {
  148595. /**
  148596. * Defines the priority of this optimization (0 by default which means first in the list)
  148597. */
  148598. priority: number;
  148599. /**
  148600. * Defines the maximum scale to use (2 by default)
  148601. */
  148602. maximumScale: number;
  148603. /**
  148604. * Defines the step to use between two passes (0.5 by default)
  148605. */
  148606. step: number;
  148607. private _currentScale;
  148608. private _directionOffset;
  148609. /**
  148610. * Gets a string describing the action executed by the current optimization
  148611. * @return description string
  148612. */
  148613. getDescription(): string;
  148614. /**
  148615. * Creates the HardwareScalingOptimization object
  148616. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  148617. * @param maximumScale defines the maximum scale to use (2 by default)
  148618. * @param step defines the step to use between two passes (0.5 by default)
  148619. */
  148620. constructor(
  148621. /**
  148622. * Defines the priority of this optimization (0 by default which means first in the list)
  148623. */
  148624. priority?: number,
  148625. /**
  148626. * Defines the maximum scale to use (2 by default)
  148627. */
  148628. maximumScale?: number,
  148629. /**
  148630. * Defines the step to use between two passes (0.5 by default)
  148631. */
  148632. step?: number);
  148633. /**
  148634. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  148635. * @param scene defines the current scene where to apply this optimization
  148636. * @param optimizer defines the current optimizer
  148637. * @returns true if everything that can be done was applied
  148638. */
  148639. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  148640. }
  148641. /**
  148642. * Defines an optimization used to remove shadows
  148643. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  148644. */
  148645. export class ShadowsOptimization extends SceneOptimization {
  148646. /**
  148647. * Gets a string describing the action executed by the current optimization
  148648. * @return description string
  148649. */
  148650. getDescription(): string;
  148651. /**
  148652. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  148653. * @param scene defines the current scene where to apply this optimization
  148654. * @param optimizer defines the current optimizer
  148655. * @returns true if everything that can be done was applied
  148656. */
  148657. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  148658. }
  148659. /**
  148660. * Defines an optimization used to turn post-processes off
  148661. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  148662. */
  148663. export class PostProcessesOptimization extends SceneOptimization {
  148664. /**
  148665. * Gets a string describing the action executed by the current optimization
  148666. * @return description string
  148667. */
  148668. getDescription(): string;
  148669. /**
  148670. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  148671. * @param scene defines the current scene where to apply this optimization
  148672. * @param optimizer defines the current optimizer
  148673. * @returns true if everything that can be done was applied
  148674. */
  148675. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  148676. }
  148677. /**
  148678. * Defines an optimization used to turn lens flares off
  148679. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  148680. */
  148681. export class LensFlaresOptimization extends SceneOptimization {
  148682. /**
  148683. * Gets a string describing the action executed by the current optimization
  148684. * @return description string
  148685. */
  148686. getDescription(): string;
  148687. /**
  148688. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  148689. * @param scene defines the current scene where to apply this optimization
  148690. * @param optimizer defines the current optimizer
  148691. * @returns true if everything that can be done was applied
  148692. */
  148693. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  148694. }
  148695. /**
  148696. * Defines an optimization based on user defined callback.
  148697. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  148698. */
  148699. export class CustomOptimization extends SceneOptimization {
  148700. /**
  148701. * Callback called to apply the custom optimization.
  148702. */
  148703. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  148704. /**
  148705. * Callback called to get custom description
  148706. */
  148707. onGetDescription: () => string;
  148708. /**
  148709. * Gets a string describing the action executed by the current optimization
  148710. * @returns description string
  148711. */
  148712. getDescription(): string;
  148713. /**
  148714. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  148715. * @param scene defines the current scene where to apply this optimization
  148716. * @param optimizer defines the current optimizer
  148717. * @returns true if everything that can be done was applied
  148718. */
  148719. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  148720. }
  148721. /**
  148722. * Defines an optimization used to turn particles off
  148723. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  148724. */
  148725. export class ParticlesOptimization extends SceneOptimization {
  148726. /**
  148727. * Gets a string describing the action executed by the current optimization
  148728. * @return description string
  148729. */
  148730. getDescription(): string;
  148731. /**
  148732. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  148733. * @param scene defines the current scene where to apply this optimization
  148734. * @param optimizer defines the current optimizer
  148735. * @returns true if everything that can be done was applied
  148736. */
  148737. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  148738. }
  148739. /**
  148740. * Defines an optimization used to turn render targets off
  148741. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  148742. */
  148743. export class RenderTargetsOptimization extends SceneOptimization {
  148744. /**
  148745. * Gets a string describing the action executed by the current optimization
  148746. * @return description string
  148747. */
  148748. getDescription(): string;
  148749. /**
  148750. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  148751. * @param scene defines the current scene where to apply this optimization
  148752. * @param optimizer defines the current optimizer
  148753. * @returns true if everything that can be done was applied
  148754. */
  148755. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  148756. }
  148757. /**
  148758. * Defines an optimization used to merge meshes with compatible materials
  148759. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  148760. */
  148761. export class MergeMeshesOptimization extends SceneOptimization {
  148762. private static _UpdateSelectionTree;
  148763. /**
  148764. * Gets or sets a boolean which defines if optimization octree has to be updated
  148765. */
  148766. static get UpdateSelectionTree(): boolean;
  148767. /**
  148768. * Gets or sets a boolean which defines if optimization octree has to be updated
  148769. */
  148770. static set UpdateSelectionTree(value: boolean);
  148771. /**
  148772. * Gets a string describing the action executed by the current optimization
  148773. * @return description string
  148774. */
  148775. getDescription(): string;
  148776. private _canBeMerged;
  148777. /**
  148778. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  148779. * @param scene defines the current scene where to apply this optimization
  148780. * @param optimizer defines the current optimizer
  148781. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  148782. * @returns true if everything that can be done was applied
  148783. */
  148784. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  148785. }
  148786. /**
  148787. * Defines a list of options used by SceneOptimizer
  148788. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  148789. */
  148790. export class SceneOptimizerOptions {
  148791. /**
  148792. * Defines the target frame rate to reach (60 by default)
  148793. */
  148794. targetFrameRate: number;
  148795. /**
  148796. * Defines the interval between two checkes (2000ms by default)
  148797. */
  148798. trackerDuration: number;
  148799. /**
  148800. * Gets the list of optimizations to apply
  148801. */
  148802. optimizations: SceneOptimization[];
  148803. /**
  148804. * Creates a new list of options used by SceneOptimizer
  148805. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  148806. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  148807. */
  148808. constructor(
  148809. /**
  148810. * Defines the target frame rate to reach (60 by default)
  148811. */
  148812. targetFrameRate?: number,
  148813. /**
  148814. * Defines the interval between two checkes (2000ms by default)
  148815. */
  148816. trackerDuration?: number);
  148817. /**
  148818. * Add a new optimization
  148819. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  148820. * @returns the current SceneOptimizerOptions
  148821. */
  148822. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  148823. /**
  148824. * Add a new custom optimization
  148825. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  148826. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  148827. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  148828. * @returns the current SceneOptimizerOptions
  148829. */
  148830. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  148831. /**
  148832. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  148833. * @param targetFrameRate defines the target frame rate (60 by default)
  148834. * @returns a SceneOptimizerOptions object
  148835. */
  148836. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  148837. /**
  148838. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  148839. * @param targetFrameRate defines the target frame rate (60 by default)
  148840. * @returns a SceneOptimizerOptions object
  148841. */
  148842. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  148843. /**
  148844. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  148845. * @param targetFrameRate defines the target frame rate (60 by default)
  148846. * @returns a SceneOptimizerOptions object
  148847. */
  148848. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  148849. }
  148850. /**
  148851. * Class used to run optimizations in order to reach a target frame rate
  148852. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  148853. */
  148854. export class SceneOptimizer implements IDisposable {
  148855. private _isRunning;
  148856. private _options;
  148857. private _scene;
  148858. private _currentPriorityLevel;
  148859. private _targetFrameRate;
  148860. private _trackerDuration;
  148861. private _currentFrameRate;
  148862. private _sceneDisposeObserver;
  148863. private _improvementMode;
  148864. /**
  148865. * Defines an observable called when the optimizer reaches the target frame rate
  148866. */
  148867. onSuccessObservable: Observable<SceneOptimizer>;
  148868. /**
  148869. * Defines an observable called when the optimizer enables an optimization
  148870. */
  148871. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  148872. /**
  148873. * Defines an observable called when the optimizer is not able to reach the target frame rate
  148874. */
  148875. onFailureObservable: Observable<SceneOptimizer>;
  148876. /**
  148877. * Gets a boolean indicating if the optimizer is in improvement mode
  148878. */
  148879. get isInImprovementMode(): boolean;
  148880. /**
  148881. * Gets the current priority level (0 at start)
  148882. */
  148883. get currentPriorityLevel(): number;
  148884. /**
  148885. * Gets the current frame rate checked by the SceneOptimizer
  148886. */
  148887. get currentFrameRate(): number;
  148888. /**
  148889. * Gets or sets the current target frame rate (60 by default)
  148890. */
  148891. get targetFrameRate(): number;
  148892. /**
  148893. * Gets or sets the current target frame rate (60 by default)
  148894. */
  148895. set targetFrameRate(value: number);
  148896. /**
  148897. * Gets or sets the current interval between two checks (every 2000ms by default)
  148898. */
  148899. get trackerDuration(): number;
  148900. /**
  148901. * Gets or sets the current interval between two checks (every 2000ms by default)
  148902. */
  148903. set trackerDuration(value: number);
  148904. /**
  148905. * Gets the list of active optimizations
  148906. */
  148907. get optimizations(): SceneOptimization[];
  148908. /**
  148909. * Creates a new SceneOptimizer
  148910. * @param scene defines the scene to work on
  148911. * @param options defines the options to use with the SceneOptimizer
  148912. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  148913. * @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)
  148914. */
  148915. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  148916. /**
  148917. * Stops the current optimizer
  148918. */
  148919. stop(): void;
  148920. /**
  148921. * Reset the optimizer to initial step (current priority level = 0)
  148922. */
  148923. reset(): void;
  148924. /**
  148925. * Start the optimizer. By default it will try to reach a specific framerate
  148926. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  148927. */
  148928. start(): void;
  148929. private _checkCurrentState;
  148930. /**
  148931. * Release all resources
  148932. */
  148933. dispose(): void;
  148934. /**
  148935. * Helper function to create a SceneOptimizer with one single line of code
  148936. * @param scene defines the scene to work on
  148937. * @param options defines the options to use with the SceneOptimizer
  148938. * @param onSuccess defines a callback to call on success
  148939. * @param onFailure defines a callback to call on failure
  148940. * @returns the new SceneOptimizer object
  148941. */
  148942. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  148943. }
  148944. }
  148945. declare module BABYLON {
  148946. /**
  148947. * Class used to serialize a scene into a string
  148948. */
  148949. export class SceneSerializer {
  148950. /**
  148951. * Clear cache used by a previous serialization
  148952. */
  148953. static ClearCache(): void;
  148954. /**
  148955. * Serialize a scene into a JSON compatible object
  148956. * @param scene defines the scene to serialize
  148957. * @returns a JSON compatible object
  148958. */
  148959. static Serialize(scene: Scene): any;
  148960. /**
  148961. * Serialize a mesh into a JSON compatible object
  148962. * @param toSerialize defines the mesh to serialize
  148963. * @param withParents defines if parents must be serialized as well
  148964. * @param withChildren defines if children must be serialized as well
  148965. * @returns a JSON compatible object
  148966. */
  148967. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  148968. }
  148969. }
  148970. declare module BABYLON {
  148971. /**
  148972. * Class used to host texture specific utilities
  148973. */
  148974. export class TextureTools {
  148975. /**
  148976. * Uses the GPU to create a copy texture rescaled at a given size
  148977. * @param texture Texture to copy from
  148978. * @param width defines the desired width
  148979. * @param height defines the desired height
  148980. * @param useBilinearMode defines if bilinear mode has to be used
  148981. * @return the generated texture
  148982. */
  148983. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  148984. }
  148985. }
  148986. declare module BABYLON {
  148987. /**
  148988. * This represents the different options available for the video capture.
  148989. */
  148990. export interface VideoRecorderOptions {
  148991. /** Defines the mime type of the video. */
  148992. mimeType: string;
  148993. /** Defines the FPS the video should be recorded at. */
  148994. fps: number;
  148995. /** Defines the chunk size for the recording data. */
  148996. recordChunckSize: number;
  148997. /** The audio tracks to attach to the recording. */
  148998. audioTracks?: MediaStreamTrack[];
  148999. }
  149000. /**
  149001. * This can help with recording videos from BabylonJS.
  149002. * This is based on the available WebRTC functionalities of the browser.
  149003. *
  149004. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  149005. */
  149006. export class VideoRecorder {
  149007. private static readonly _defaultOptions;
  149008. /**
  149009. * Returns whether or not the VideoRecorder is available in your browser.
  149010. * @param engine Defines the Babylon Engine.
  149011. * @returns true if supported otherwise false.
  149012. */
  149013. static IsSupported(engine: Engine): boolean;
  149014. private readonly _options;
  149015. private _canvas;
  149016. private _mediaRecorder;
  149017. private _recordedChunks;
  149018. private _fileName;
  149019. private _resolve;
  149020. private _reject;
  149021. /**
  149022. * True when a recording is already in progress.
  149023. */
  149024. get isRecording(): boolean;
  149025. /**
  149026. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  149027. * @param engine Defines the BabylonJS Engine you wish to record.
  149028. * @param options Defines options that can be used to customize the capture.
  149029. */
  149030. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  149031. /**
  149032. * Stops the current recording before the default capture timeout passed in the startRecording function.
  149033. */
  149034. stopRecording(): void;
  149035. /**
  149036. * Starts recording the canvas for a max duration specified in parameters.
  149037. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  149038. * If null no automatic download will start and you can rely on the promise to get the data back.
  149039. * @param maxDuration Defines the maximum recording time in seconds.
  149040. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  149041. * @return A promise callback at the end of the recording with the video data in Blob.
  149042. */
  149043. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  149044. /**
  149045. * Releases internal resources used during the recording.
  149046. */
  149047. dispose(): void;
  149048. private _handleDataAvailable;
  149049. private _handleError;
  149050. private _handleStop;
  149051. }
  149052. }
  149053. declare module BABYLON {
  149054. /**
  149055. * Class containing a set of static utilities functions for screenshots
  149056. */
  149057. export class ScreenshotTools {
  149058. /**
  149059. * Captures a screenshot of the current rendering
  149060. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  149061. * @param engine defines the rendering engine
  149062. * @param camera defines the source camera
  149063. * @param size This parameter can be set to a single number or to an object with the
  149064. * following (optional) properties: precision, width, height. If a single number is passed,
  149065. * it will be used for both width and height. If an object is passed, the screenshot size
  149066. * will be derived from the parameters. The precision property is a multiplier allowing
  149067. * rendering at a higher or lower resolution
  149068. * @param successCallback defines the callback receives a single parameter which contains the
  149069. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  149070. * src parameter of an <img> to display it
  149071. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  149072. * Check your browser for supported MIME types
  149073. */
  149074. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  149075. /**
  149076. * Captures a screenshot of the current rendering
  149077. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  149078. * @param engine defines the rendering engine
  149079. * @param camera defines the source camera
  149080. * @param size This parameter can be set to a single number or to an object with the
  149081. * following (optional) properties: precision, width, height. If a single number is passed,
  149082. * it will be used for both width and height. If an object is passed, the screenshot size
  149083. * will be derived from the parameters. The precision property is a multiplier allowing
  149084. * rendering at a higher or lower resolution
  149085. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  149086. * Check your browser for supported MIME types
  149087. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  149088. * to the src parameter of an <img> to display it
  149089. */
  149090. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  149091. /**
  149092. * Generates an image screenshot from the specified camera.
  149093. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  149094. * @param engine The engine to use for rendering
  149095. * @param camera The camera to use for rendering
  149096. * @param size This parameter can be set to a single number or to an object with the
  149097. * following (optional) properties: precision, width, height. If a single number is passed,
  149098. * it will be used for both width and height. If an object is passed, the screenshot size
  149099. * will be derived from the parameters. The precision property is a multiplier allowing
  149100. * rendering at a higher or lower resolution
  149101. * @param successCallback The callback receives a single parameter which contains the
  149102. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  149103. * src parameter of an <img> to display it
  149104. * @param mimeType The MIME type of the screenshot image (default: image/png).
  149105. * Check your browser for supported MIME types
  149106. * @param samples Texture samples (default: 1)
  149107. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  149108. * @param fileName A name for for the downloaded file.
  149109. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  149110. */
  149111. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  149112. /**
  149113. * Generates an image screenshot from the specified camera.
  149114. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  149115. * @param engine The engine to use for rendering
  149116. * @param camera The camera to use for rendering
  149117. * @param size This parameter can be set to a single number or to an object with the
  149118. * following (optional) properties: precision, width, height. If a single number is passed,
  149119. * it will be used for both width and height. If an object is passed, the screenshot size
  149120. * will be derived from the parameters. The precision property is a multiplier allowing
  149121. * rendering at a higher or lower resolution
  149122. * @param mimeType The MIME type of the screenshot image (default: image/png).
  149123. * Check your browser for supported MIME types
  149124. * @param samples Texture samples (default: 1)
  149125. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  149126. * @param fileName A name for for the downloaded file.
  149127. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  149128. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  149129. * to the src parameter of an <img> to display it
  149130. */
  149131. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  149132. /**
  149133. * Gets height and width for screenshot size
  149134. * @private
  149135. */
  149136. private static _getScreenshotSize;
  149137. }
  149138. }
  149139. declare module BABYLON {
  149140. /**
  149141. * Interface for a data buffer
  149142. */
  149143. export interface IDataBuffer {
  149144. /**
  149145. * Reads bytes from the data buffer.
  149146. * @param byteOffset The byte offset to read
  149147. * @param byteLength The byte length to read
  149148. * @returns A promise that resolves when the bytes are read
  149149. */
  149150. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  149151. /**
  149152. * The byte length of the buffer.
  149153. */
  149154. readonly byteLength: number;
  149155. }
  149156. /**
  149157. * Utility class for reading from a data buffer
  149158. */
  149159. export class DataReader {
  149160. /**
  149161. * The data buffer associated with this data reader.
  149162. */
  149163. readonly buffer: IDataBuffer;
  149164. /**
  149165. * The current byte offset from the beginning of the data buffer.
  149166. */
  149167. byteOffset: number;
  149168. private _dataView;
  149169. private _dataByteOffset;
  149170. /**
  149171. * Constructor
  149172. * @param buffer The buffer to read
  149173. */
  149174. constructor(buffer: IDataBuffer);
  149175. /**
  149176. * Loads the given byte length.
  149177. * @param byteLength The byte length to load
  149178. * @returns A promise that resolves when the load is complete
  149179. */
  149180. loadAsync(byteLength: number): Promise<void>;
  149181. /**
  149182. * Read a unsigned 32-bit integer from the currently loaded data range.
  149183. * @returns The 32-bit integer read
  149184. */
  149185. readUint32(): number;
  149186. /**
  149187. * Read a byte array from the currently loaded data range.
  149188. * @param byteLength The byte length to read
  149189. * @returns The byte array read
  149190. */
  149191. readUint8Array(byteLength: number): Uint8Array;
  149192. /**
  149193. * Read a string from the currently loaded data range.
  149194. * @param byteLength The byte length to read
  149195. * @returns The string read
  149196. */
  149197. readString(byteLength: number): string;
  149198. /**
  149199. * Skips the given byte length the currently loaded data range.
  149200. * @param byteLength The byte length to skip
  149201. */
  149202. skipBytes(byteLength: number): void;
  149203. }
  149204. }
  149205. declare module BABYLON {
  149206. /**
  149207. * Class for storing data to local storage if available or in-memory storage otherwise
  149208. */
  149209. export class DataStorage {
  149210. private static _Storage;
  149211. private static _GetStorage;
  149212. /**
  149213. * Reads a string from the data storage
  149214. * @param key The key to read
  149215. * @param defaultValue The value if the key doesn't exist
  149216. * @returns The string value
  149217. */
  149218. static ReadString(key: string, defaultValue: string): string;
  149219. /**
  149220. * Writes a string to the data storage
  149221. * @param key The key to write
  149222. * @param value The value to write
  149223. */
  149224. static WriteString(key: string, value: string): void;
  149225. /**
  149226. * Reads a boolean from the data storage
  149227. * @param key The key to read
  149228. * @param defaultValue The value if the key doesn't exist
  149229. * @returns The boolean value
  149230. */
  149231. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  149232. /**
  149233. * Writes a boolean to the data storage
  149234. * @param key The key to write
  149235. * @param value The value to write
  149236. */
  149237. static WriteBoolean(key: string, value: boolean): void;
  149238. /**
  149239. * Reads a number from the data storage
  149240. * @param key The key to read
  149241. * @param defaultValue The value if the key doesn't exist
  149242. * @returns The number value
  149243. */
  149244. static ReadNumber(key: string, defaultValue: number): number;
  149245. /**
  149246. * Writes a number to the data storage
  149247. * @param key The key to write
  149248. * @param value The value to write
  149249. */
  149250. static WriteNumber(key: string, value: number): void;
  149251. }
  149252. }
  149253. declare module BABYLON {
  149254. /**
  149255. * An interface for all Hit test features
  149256. */
  149257. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  149258. /**
  149259. * Triggered when new babylon (transformed) hit test results are available
  149260. */
  149261. onHitTestResultObservable: Observable<T[]>;
  149262. }
  149263. /**
  149264. * Options used for hit testing
  149265. */
  149266. export interface IWebXRLegacyHitTestOptions {
  149267. /**
  149268. * Only test when user interacted with the scene. Default - hit test every frame
  149269. */
  149270. testOnPointerDownOnly?: boolean;
  149271. /**
  149272. * The node to use to transform the local results to world coordinates
  149273. */
  149274. worldParentNode?: TransformNode;
  149275. }
  149276. /**
  149277. * Interface defining the babylon result of raycasting/hit-test
  149278. */
  149279. export interface IWebXRLegacyHitResult {
  149280. /**
  149281. * Transformation matrix that can be applied to a node that will put it in the hit point location
  149282. */
  149283. transformationMatrix: Matrix;
  149284. /**
  149285. * The native hit test result
  149286. */
  149287. xrHitResult: XRHitResult | XRHitTestResult;
  149288. }
  149289. /**
  149290. * The currently-working hit-test module.
  149291. * Hit test (or Ray-casting) is used to interact with the real world.
  149292. * For further information read here - https://github.com/immersive-web/hit-test
  149293. */
  149294. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  149295. /**
  149296. * options to use when constructing this feature
  149297. */
  149298. readonly options: IWebXRLegacyHitTestOptions;
  149299. private _direction;
  149300. private _mat;
  149301. private _onSelectEnabled;
  149302. private _origin;
  149303. /**
  149304. * The module's name
  149305. */
  149306. static readonly Name: string;
  149307. /**
  149308. * The (Babylon) version of this module.
  149309. * This is an integer representing the implementation version.
  149310. * This number does not correspond to the WebXR specs version
  149311. */
  149312. static readonly Version: number;
  149313. /**
  149314. * Populated with the last native XR Hit Results
  149315. */
  149316. lastNativeXRHitResults: XRHitResult[];
  149317. /**
  149318. * Triggered when new babylon (transformed) hit test results are available
  149319. */
  149320. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  149321. /**
  149322. * Creates a new instance of the (legacy version) hit test feature
  149323. * @param _xrSessionManager an instance of WebXRSessionManager
  149324. * @param options options to use when constructing this feature
  149325. */
  149326. constructor(_xrSessionManager: WebXRSessionManager,
  149327. /**
  149328. * options to use when constructing this feature
  149329. */
  149330. options?: IWebXRLegacyHitTestOptions);
  149331. /**
  149332. * execute a hit test with an XR Ray
  149333. *
  149334. * @param xrSession a native xrSession that will execute this hit test
  149335. * @param xrRay the ray (position and direction) to use for ray-casting
  149336. * @param referenceSpace native XR reference space to use for the hit-test
  149337. * @param filter filter function that will filter the results
  149338. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  149339. */
  149340. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  149341. /**
  149342. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  149343. * @param event the (select) event to use to select with
  149344. * @param referenceSpace the reference space to use for this hit test
  149345. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  149346. */
  149347. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  149348. /**
  149349. * attach this feature
  149350. * Will usually be called by the features manager
  149351. *
  149352. * @returns true if successful.
  149353. */
  149354. attach(): boolean;
  149355. /**
  149356. * detach this feature.
  149357. * Will usually be called by the features manager
  149358. *
  149359. * @returns true if successful.
  149360. */
  149361. detach(): boolean;
  149362. /**
  149363. * Dispose this feature and all of the resources attached
  149364. */
  149365. dispose(): void;
  149366. protected _onXRFrame(frame: XRFrame): void;
  149367. private _onHitTestResults;
  149368. private _onSelect;
  149369. }
  149370. }
  149371. declare module BABYLON {
  149372. /**
  149373. * Options used for hit testing (version 2)
  149374. */
  149375. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  149376. /**
  149377. * Do not create a permanent hit test. Will usually be used when only
  149378. * transient inputs are needed.
  149379. */
  149380. disablePermanentHitTest?: boolean;
  149381. /**
  149382. * Enable transient (for example touch-based) hit test inspections
  149383. */
  149384. enableTransientHitTest?: boolean;
  149385. /**
  149386. * Offset ray for the permanent hit test
  149387. */
  149388. offsetRay?: Vector3;
  149389. /**
  149390. * Offset ray for the transient hit test
  149391. */
  149392. transientOffsetRay?: Vector3;
  149393. /**
  149394. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  149395. */
  149396. useReferenceSpace?: boolean;
  149397. }
  149398. /**
  149399. * Interface defining the babylon result of hit-test
  149400. */
  149401. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  149402. /**
  149403. * The input source that generated this hit test (if transient)
  149404. */
  149405. inputSource?: XRInputSource;
  149406. /**
  149407. * Is this a transient hit test
  149408. */
  149409. isTransient?: boolean;
  149410. /**
  149411. * Position of the hit test result
  149412. */
  149413. position: Vector3;
  149414. /**
  149415. * Rotation of the hit test result
  149416. */
  149417. rotationQuaternion: Quaternion;
  149418. /**
  149419. * The native hit test result
  149420. */
  149421. xrHitResult: XRHitTestResult;
  149422. }
  149423. /**
  149424. * The currently-working hit-test module.
  149425. * Hit test (or Ray-casting) is used to interact with the real world.
  149426. * For further information read here - https://github.com/immersive-web/hit-test
  149427. *
  149428. * Tested on chrome (mobile) 80.
  149429. */
  149430. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  149431. /**
  149432. * options to use when constructing this feature
  149433. */
  149434. readonly options: IWebXRHitTestOptions;
  149435. private _tmpMat;
  149436. private _tmpPos;
  149437. private _tmpQuat;
  149438. private _transientXrHitTestSource;
  149439. private _xrHitTestSource;
  149440. private initHitTestSource;
  149441. /**
  149442. * The module's name
  149443. */
  149444. static readonly Name: string;
  149445. /**
  149446. * The (Babylon) version of this module.
  149447. * This is an integer representing the implementation version.
  149448. * This number does not correspond to the WebXR specs version
  149449. */
  149450. static readonly Version: number;
  149451. /**
  149452. * When set to true, each hit test will have its own position/rotation objects
  149453. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  149454. * the developers will clone them or copy them as they see fit.
  149455. */
  149456. autoCloneTransformation: boolean;
  149457. /**
  149458. * Triggered when new babylon (transformed) hit test results are available
  149459. */
  149460. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  149461. /**
  149462. * Use this to temporarily pause hit test checks.
  149463. */
  149464. paused: boolean;
  149465. /**
  149466. * Creates a new instance of the hit test feature
  149467. * @param _xrSessionManager an instance of WebXRSessionManager
  149468. * @param options options to use when constructing this feature
  149469. */
  149470. constructor(_xrSessionManager: WebXRSessionManager,
  149471. /**
  149472. * options to use when constructing this feature
  149473. */
  149474. options?: IWebXRHitTestOptions);
  149475. /**
  149476. * attach this feature
  149477. * Will usually be called by the features manager
  149478. *
  149479. * @returns true if successful.
  149480. */
  149481. attach(): boolean;
  149482. /**
  149483. * detach this feature.
  149484. * Will usually be called by the features manager
  149485. *
  149486. * @returns true if successful.
  149487. */
  149488. detach(): boolean;
  149489. /**
  149490. * Dispose this feature and all of the resources attached
  149491. */
  149492. dispose(): void;
  149493. protected _onXRFrame(frame: XRFrame): void;
  149494. private _processWebXRHitTestResult;
  149495. }
  149496. }
  149497. declare module BABYLON {
  149498. /**
  149499. * Configuration options of the anchor system
  149500. */
  149501. export interface IWebXRAnchorSystemOptions {
  149502. /**
  149503. * a node that will be used to convert local to world coordinates
  149504. */
  149505. worldParentNode?: TransformNode;
  149506. /**
  149507. * If set to true a reference of the created anchors will be kept until the next session starts
  149508. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  149509. */
  149510. doNotRemoveAnchorsOnSessionEnded?: boolean;
  149511. }
  149512. /**
  149513. * A babylon container for an XR Anchor
  149514. */
  149515. export interface IWebXRAnchor {
  149516. /**
  149517. * A babylon-assigned ID for this anchor
  149518. */
  149519. id: number;
  149520. /**
  149521. * Transformation matrix to apply to an object attached to this anchor
  149522. */
  149523. transformationMatrix: Matrix;
  149524. /**
  149525. * The native anchor object
  149526. */
  149527. xrAnchor: XRAnchor;
  149528. /**
  149529. * if defined, this object will be constantly updated by the anchor's position and rotation
  149530. */
  149531. attachedNode?: TransformNode;
  149532. }
  149533. /**
  149534. * An implementation of the anchor system for WebXR.
  149535. * For further information see https://github.com/immersive-web/anchors/
  149536. */
  149537. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  149538. private _options;
  149539. private _lastFrameDetected;
  149540. private _trackedAnchors;
  149541. private _referenceSpaceForFrameAnchors;
  149542. private _futureAnchors;
  149543. /**
  149544. * The module's name
  149545. */
  149546. static readonly Name: string;
  149547. /**
  149548. * The (Babylon) version of this module.
  149549. * This is an integer representing the implementation version.
  149550. * This number does not correspond to the WebXR specs version
  149551. */
  149552. static readonly Version: number;
  149553. /**
  149554. * Observers registered here will be executed when a new anchor was added to the session
  149555. */
  149556. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  149557. /**
  149558. * Observers registered here will be executed when an anchor was removed from the session
  149559. */
  149560. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  149561. /**
  149562. * Observers registered here will be executed when an existing anchor updates
  149563. * This can execute N times every frame
  149564. */
  149565. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  149566. /**
  149567. * Set the reference space to use for anchor creation, when not using a hit test.
  149568. * Will default to the session's reference space if not defined
  149569. */
  149570. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  149571. /**
  149572. * constructs a new anchor system
  149573. * @param _xrSessionManager an instance of WebXRSessionManager
  149574. * @param _options configuration object for this feature
  149575. */
  149576. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  149577. private _tmpVector;
  149578. private _tmpQuaternion;
  149579. private _populateTmpTransformation;
  149580. /**
  149581. * Create a new anchor point using a hit test result at a specific point in the scene
  149582. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  149583. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  149584. *
  149585. * @param hitTestResult The hit test result to use for this anchor creation
  149586. * @param position an optional position offset for this anchor
  149587. * @param rotationQuaternion an optional rotation offset for this anchor
  149588. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  149589. */
  149590. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  149591. /**
  149592. * Add a new anchor at a specific position and rotation
  149593. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  149594. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  149595. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  149596. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  149597. *
  149598. * @param position the position in which to add an anchor
  149599. * @param rotationQuaternion an optional rotation for the anchor transformation
  149600. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  149601. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  149602. */
  149603. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  149604. /**
  149605. * detach this feature.
  149606. * Will usually be called by the features manager
  149607. *
  149608. * @returns true if successful.
  149609. */
  149610. detach(): boolean;
  149611. /**
  149612. * Dispose this feature and all of the resources attached
  149613. */
  149614. dispose(): void;
  149615. protected _onXRFrame(frame: XRFrame): void;
  149616. /**
  149617. * avoiding using Array.find for global support.
  149618. * @param xrAnchor the plane to find in the array
  149619. */
  149620. private _findIndexInAnchorArray;
  149621. private _updateAnchorWithXRFrame;
  149622. private _createAnchorAtTransformation;
  149623. }
  149624. }
  149625. declare module BABYLON {
  149626. /**
  149627. * Options used in the plane detector module
  149628. */
  149629. export interface IWebXRPlaneDetectorOptions {
  149630. /**
  149631. * The node to use to transform the local results to world coordinates
  149632. */
  149633. worldParentNode?: TransformNode;
  149634. /**
  149635. * If set to true a reference of the created planes will be kept until the next session starts
  149636. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  149637. */
  149638. doNotRemovePlanesOnSessionEnded?: boolean;
  149639. }
  149640. /**
  149641. * A babylon interface for a WebXR plane.
  149642. * A Plane is actually a polygon, built from N points in space
  149643. *
  149644. * Supported in chrome 79, not supported in canary 81 ATM
  149645. */
  149646. export interface IWebXRPlane {
  149647. /**
  149648. * a babylon-assigned ID for this polygon
  149649. */
  149650. id: number;
  149651. /**
  149652. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  149653. */
  149654. polygonDefinition: Array<Vector3>;
  149655. /**
  149656. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  149657. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  149658. */
  149659. transformationMatrix: Matrix;
  149660. /**
  149661. * the native xr-plane object
  149662. */
  149663. xrPlane: XRPlane;
  149664. }
  149665. /**
  149666. * The plane detector is used to detect planes in the real world when in AR
  149667. * For more information see https://github.com/immersive-web/real-world-geometry/
  149668. */
  149669. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  149670. private _options;
  149671. private _detectedPlanes;
  149672. private _enabled;
  149673. private _lastFrameDetected;
  149674. /**
  149675. * The module's name
  149676. */
  149677. static readonly Name: string;
  149678. /**
  149679. * The (Babylon) version of this module.
  149680. * This is an integer representing the implementation version.
  149681. * This number does not correspond to the WebXR specs version
  149682. */
  149683. static readonly Version: number;
  149684. /**
  149685. * Observers registered here will be executed when a new plane was added to the session
  149686. */
  149687. onPlaneAddedObservable: Observable<IWebXRPlane>;
  149688. /**
  149689. * Observers registered here will be executed when a plane is no longer detected in the session
  149690. */
  149691. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  149692. /**
  149693. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  149694. * This can execute N times every frame
  149695. */
  149696. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  149697. /**
  149698. * construct a new Plane Detector
  149699. * @param _xrSessionManager an instance of xr Session manager
  149700. * @param _options configuration to use when constructing this feature
  149701. */
  149702. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  149703. /**
  149704. * detach this feature.
  149705. * Will usually be called by the features manager
  149706. *
  149707. * @returns true if successful.
  149708. */
  149709. detach(): boolean;
  149710. /**
  149711. * Dispose this feature and all of the resources attached
  149712. */
  149713. dispose(): void;
  149714. protected _onXRFrame(frame: XRFrame): void;
  149715. private _init;
  149716. private _updatePlaneWithXRPlane;
  149717. /**
  149718. * avoiding using Array.find for global support.
  149719. * @param xrPlane the plane to find in the array
  149720. */
  149721. private findIndexInPlaneArray;
  149722. }
  149723. }
  149724. declare module BABYLON {
  149725. /**
  149726. * Options interface for the background remover plugin
  149727. */
  149728. export interface IWebXRBackgroundRemoverOptions {
  149729. /**
  149730. * Further background meshes to disable when entering AR
  149731. */
  149732. backgroundMeshes?: AbstractMesh[];
  149733. /**
  149734. * flags to configure the removal of the environment helper.
  149735. * If not set, the entire background will be removed. If set, flags should be set as well.
  149736. */
  149737. environmentHelperRemovalFlags?: {
  149738. /**
  149739. * Should the skybox be removed (default false)
  149740. */
  149741. skyBox?: boolean;
  149742. /**
  149743. * Should the ground be removed (default false)
  149744. */
  149745. ground?: boolean;
  149746. };
  149747. /**
  149748. * don't disable the environment helper
  149749. */
  149750. ignoreEnvironmentHelper?: boolean;
  149751. }
  149752. /**
  149753. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  149754. */
  149755. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  149756. /**
  149757. * read-only options to be used in this module
  149758. */
  149759. readonly options: IWebXRBackgroundRemoverOptions;
  149760. /**
  149761. * The module's name
  149762. */
  149763. static readonly Name: string;
  149764. /**
  149765. * The (Babylon) version of this module.
  149766. * This is an integer representing the implementation version.
  149767. * This number does not correspond to the WebXR specs version
  149768. */
  149769. static readonly Version: number;
  149770. /**
  149771. * registered observers will be triggered when the background state changes
  149772. */
  149773. onBackgroundStateChangedObservable: Observable<boolean>;
  149774. /**
  149775. * constructs a new background remover module
  149776. * @param _xrSessionManager the session manager for this module
  149777. * @param options read-only options to be used in this module
  149778. */
  149779. constructor(_xrSessionManager: WebXRSessionManager,
  149780. /**
  149781. * read-only options to be used in this module
  149782. */
  149783. options?: IWebXRBackgroundRemoverOptions);
  149784. /**
  149785. * attach this feature
  149786. * Will usually be called by the features manager
  149787. *
  149788. * @returns true if successful.
  149789. */
  149790. attach(): boolean;
  149791. /**
  149792. * detach this feature.
  149793. * Will usually be called by the features manager
  149794. *
  149795. * @returns true if successful.
  149796. */
  149797. detach(): boolean;
  149798. /**
  149799. * Dispose this feature and all of the resources attached
  149800. */
  149801. dispose(): void;
  149802. protected _onXRFrame(_xrFrame: XRFrame): void;
  149803. private _setBackgroundState;
  149804. }
  149805. }
  149806. declare module BABYLON {
  149807. /**
  149808. * Options for the controller physics feature
  149809. */
  149810. export class IWebXRControllerPhysicsOptions {
  149811. /**
  149812. * Should the headset get its own impostor
  149813. */
  149814. enableHeadsetImpostor?: boolean;
  149815. /**
  149816. * Optional parameters for the headset impostor
  149817. */
  149818. headsetImpostorParams?: {
  149819. /**
  149820. * The type of impostor to create. Default is sphere
  149821. */
  149822. impostorType: number;
  149823. /**
  149824. * the size of the impostor. Defaults to 10cm
  149825. */
  149826. impostorSize?: number | {
  149827. width: number;
  149828. height: number;
  149829. depth: number;
  149830. };
  149831. /**
  149832. * Friction definitions
  149833. */
  149834. friction?: number;
  149835. /**
  149836. * Restitution
  149837. */
  149838. restitution?: number;
  149839. };
  149840. /**
  149841. * The physics properties of the future impostors
  149842. */
  149843. physicsProperties?: {
  149844. /**
  149845. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  149846. * Note that this requires a physics engine that supports mesh impostors!
  149847. */
  149848. useControllerMesh?: boolean;
  149849. /**
  149850. * The type of impostor to create. Default is sphere
  149851. */
  149852. impostorType?: number;
  149853. /**
  149854. * the size of the impostor. Defaults to 10cm
  149855. */
  149856. impostorSize?: number | {
  149857. width: number;
  149858. height: number;
  149859. depth: number;
  149860. };
  149861. /**
  149862. * Friction definitions
  149863. */
  149864. friction?: number;
  149865. /**
  149866. * Restitution
  149867. */
  149868. restitution?: number;
  149869. };
  149870. /**
  149871. * the xr input to use with this pointer selection
  149872. */
  149873. xrInput: WebXRInput;
  149874. }
  149875. /**
  149876. * Add physics impostor to your webxr controllers,
  149877. * including naive calculation of their linear and angular velocity
  149878. */
  149879. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  149880. private readonly _options;
  149881. private _attachController;
  149882. private _controllers;
  149883. private _debugMode;
  149884. private _delta;
  149885. private _headsetImpostor?;
  149886. private _headsetMesh?;
  149887. private _lastTimestamp;
  149888. private _tmpQuaternion;
  149889. private _tmpVector;
  149890. /**
  149891. * The module's name
  149892. */
  149893. static readonly Name: string;
  149894. /**
  149895. * The (Babylon) version of this module.
  149896. * This is an integer representing the implementation version.
  149897. * This number does not correspond to the webxr specs version
  149898. */
  149899. static readonly Version: number;
  149900. /**
  149901. * Construct a new Controller Physics Feature
  149902. * @param _xrSessionManager the corresponding xr session manager
  149903. * @param _options options to create this feature with
  149904. */
  149905. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  149906. /**
  149907. * @hidden
  149908. * enable debugging - will show console outputs and the impostor mesh
  149909. */
  149910. _enablePhysicsDebug(): void;
  149911. /**
  149912. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  149913. * @param xrController the controller to add
  149914. */
  149915. addController(xrController: WebXRInputSource): void;
  149916. /**
  149917. * attach this feature
  149918. * Will usually be called by the features manager
  149919. *
  149920. * @returns true if successful.
  149921. */
  149922. attach(): boolean;
  149923. /**
  149924. * detach this feature.
  149925. * Will usually be called by the features manager
  149926. *
  149927. * @returns true if successful.
  149928. */
  149929. detach(): boolean;
  149930. /**
  149931. * Get the headset impostor, if enabled
  149932. * @returns the impostor
  149933. */
  149934. getHeadsetImpostor(): PhysicsImpostor | undefined;
  149935. /**
  149936. * Get the physics impostor of a specific controller.
  149937. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  149938. * @param controller the controller or the controller id of which to get the impostor
  149939. * @returns the impostor or null
  149940. */
  149941. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  149942. /**
  149943. * Update the physics properties provided in the constructor
  149944. * @param newProperties the new properties object
  149945. */
  149946. setPhysicsProperties(newProperties: {
  149947. impostorType?: number;
  149948. impostorSize?: number | {
  149949. width: number;
  149950. height: number;
  149951. depth: number;
  149952. };
  149953. friction?: number;
  149954. restitution?: number;
  149955. }): void;
  149956. protected _onXRFrame(_xrFrame: any): void;
  149957. private _detachController;
  149958. }
  149959. }
  149960. declare module BABYLON {
  149961. /**
  149962. * The motion controller class for all microsoft mixed reality controllers
  149963. */
  149964. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  149965. protected readonly _mapping: {
  149966. defaultButton: {
  149967. valueNodeName: string;
  149968. unpressedNodeName: string;
  149969. pressedNodeName: string;
  149970. };
  149971. defaultAxis: {
  149972. valueNodeName: string;
  149973. minNodeName: string;
  149974. maxNodeName: string;
  149975. };
  149976. buttons: {
  149977. "xr-standard-trigger": {
  149978. rootNodeName: string;
  149979. componentProperty: string;
  149980. states: string[];
  149981. };
  149982. "xr-standard-squeeze": {
  149983. rootNodeName: string;
  149984. componentProperty: string;
  149985. states: string[];
  149986. };
  149987. "xr-standard-touchpad": {
  149988. rootNodeName: string;
  149989. labelAnchorNodeName: string;
  149990. touchPointNodeName: string;
  149991. };
  149992. "xr-standard-thumbstick": {
  149993. rootNodeName: string;
  149994. componentProperty: string;
  149995. states: string[];
  149996. };
  149997. };
  149998. axes: {
  149999. "xr-standard-touchpad": {
  150000. "x-axis": {
  150001. rootNodeName: string;
  150002. };
  150003. "y-axis": {
  150004. rootNodeName: string;
  150005. };
  150006. };
  150007. "xr-standard-thumbstick": {
  150008. "x-axis": {
  150009. rootNodeName: string;
  150010. };
  150011. "y-axis": {
  150012. rootNodeName: string;
  150013. };
  150014. };
  150015. };
  150016. };
  150017. /**
  150018. * The base url used to load the left and right controller models
  150019. */
  150020. static MODEL_BASE_URL: string;
  150021. /**
  150022. * The name of the left controller model file
  150023. */
  150024. static MODEL_LEFT_FILENAME: string;
  150025. /**
  150026. * The name of the right controller model file
  150027. */
  150028. static MODEL_RIGHT_FILENAME: string;
  150029. profileId: string;
  150030. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  150031. protected _getFilenameAndPath(): {
  150032. filename: string;
  150033. path: string;
  150034. };
  150035. protected _getModelLoadingConstraints(): boolean;
  150036. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  150037. protected _setRootMesh(meshes: AbstractMesh[]): void;
  150038. protected _updateModel(): void;
  150039. }
  150040. }
  150041. declare module BABYLON {
  150042. /**
  150043. * The motion controller class for oculus touch (quest, rift).
  150044. * This class supports legacy mapping as well the standard xr mapping
  150045. */
  150046. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  150047. private _forceLegacyControllers;
  150048. private _modelRootNode;
  150049. /**
  150050. * The base url used to load the left and right controller models
  150051. */
  150052. static MODEL_BASE_URL: string;
  150053. /**
  150054. * The name of the left controller model file
  150055. */
  150056. static MODEL_LEFT_FILENAME: string;
  150057. /**
  150058. * The name of the right controller model file
  150059. */
  150060. static MODEL_RIGHT_FILENAME: string;
  150061. /**
  150062. * Base Url for the Quest controller model.
  150063. */
  150064. static QUEST_MODEL_BASE_URL: string;
  150065. profileId: string;
  150066. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  150067. protected _getFilenameAndPath(): {
  150068. filename: string;
  150069. path: string;
  150070. };
  150071. protected _getModelLoadingConstraints(): boolean;
  150072. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  150073. protected _setRootMesh(meshes: AbstractMesh[]): void;
  150074. protected _updateModel(): void;
  150075. /**
  150076. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  150077. * between the touch and touch 2.
  150078. */
  150079. private _isQuest;
  150080. }
  150081. }
  150082. declare module BABYLON {
  150083. /**
  150084. * The motion controller class for the standard HTC-Vive controllers
  150085. */
  150086. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  150087. private _modelRootNode;
  150088. /**
  150089. * The base url used to load the left and right controller models
  150090. */
  150091. static MODEL_BASE_URL: string;
  150092. /**
  150093. * File name for the controller model.
  150094. */
  150095. static MODEL_FILENAME: string;
  150096. profileId: string;
  150097. /**
  150098. * Create a new Vive motion controller object
  150099. * @param scene the scene to use to create this controller
  150100. * @param gamepadObject the corresponding gamepad object
  150101. * @param handedness the handedness of the controller
  150102. */
  150103. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  150104. protected _getFilenameAndPath(): {
  150105. filename: string;
  150106. path: string;
  150107. };
  150108. protected _getModelLoadingConstraints(): boolean;
  150109. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  150110. protected _setRootMesh(meshes: AbstractMesh[]): void;
  150111. protected _updateModel(): void;
  150112. }
  150113. }
  150114. declare module BABYLON {
  150115. /**
  150116. * A cursor which tracks a point on a path
  150117. */
  150118. export class PathCursor {
  150119. private path;
  150120. /**
  150121. * Stores path cursor callbacks for when an onchange event is triggered
  150122. */
  150123. private _onchange;
  150124. /**
  150125. * The value of the path cursor
  150126. */
  150127. value: number;
  150128. /**
  150129. * The animation array of the path cursor
  150130. */
  150131. animations: Animation[];
  150132. /**
  150133. * Initializes the path cursor
  150134. * @param path The path to track
  150135. */
  150136. constructor(path: Path2);
  150137. /**
  150138. * Gets the cursor point on the path
  150139. * @returns A point on the path cursor at the cursor location
  150140. */
  150141. getPoint(): Vector3;
  150142. /**
  150143. * Moves the cursor ahead by the step amount
  150144. * @param step The amount to move the cursor forward
  150145. * @returns This path cursor
  150146. */
  150147. moveAhead(step?: number): PathCursor;
  150148. /**
  150149. * Moves the cursor behind by the step amount
  150150. * @param step The amount to move the cursor back
  150151. * @returns This path cursor
  150152. */
  150153. moveBack(step?: number): PathCursor;
  150154. /**
  150155. * Moves the cursor by the step amount
  150156. * If the step amount is greater than one, an exception is thrown
  150157. * @param step The amount to move the cursor
  150158. * @returns This path cursor
  150159. */
  150160. move(step: number): PathCursor;
  150161. /**
  150162. * Ensures that the value is limited between zero and one
  150163. * @returns This path cursor
  150164. */
  150165. private ensureLimits;
  150166. /**
  150167. * Runs onchange callbacks on change (used by the animation engine)
  150168. * @returns This path cursor
  150169. */
  150170. private raiseOnChange;
  150171. /**
  150172. * Executes a function on change
  150173. * @param f A path cursor onchange callback
  150174. * @returns This path cursor
  150175. */
  150176. onchange(f: (cursor: PathCursor) => void): PathCursor;
  150177. }
  150178. }
  150179. declare module BABYLON {
  150180. /** @hidden */
  150181. export var blurPixelShader: {
  150182. name: string;
  150183. shader: string;
  150184. };
  150185. }
  150186. declare module BABYLON {
  150187. /** @hidden */
  150188. export var pointCloudVertexDeclaration: {
  150189. name: string;
  150190. shader: string;
  150191. };
  150192. }
  150193. // Mixins
  150194. interface Window {
  150195. mozIndexedDB: IDBFactory;
  150196. webkitIndexedDB: IDBFactory;
  150197. msIndexedDB: IDBFactory;
  150198. webkitURL: typeof URL;
  150199. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  150200. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  150201. WebGLRenderingContext: WebGLRenderingContext;
  150202. MSGesture: MSGesture;
  150203. CANNON: any;
  150204. AudioContext: AudioContext;
  150205. webkitAudioContext: AudioContext;
  150206. PointerEvent: any;
  150207. Math: Math;
  150208. Uint8Array: Uint8ArrayConstructor;
  150209. Float32Array: Float32ArrayConstructor;
  150210. mozURL: typeof URL;
  150211. msURL: typeof URL;
  150212. VRFrameData: any; // WebVR, from specs 1.1
  150213. DracoDecoderModule: any;
  150214. setImmediate(handler: (...args: any[]) => void): number;
  150215. }
  150216. interface HTMLCanvasElement {
  150217. requestPointerLock(): void;
  150218. msRequestPointerLock?(): void;
  150219. mozRequestPointerLock?(): void;
  150220. webkitRequestPointerLock?(): void;
  150221. /** Track wether a record is in progress */
  150222. isRecording: boolean;
  150223. /** Capture Stream method defined by some browsers */
  150224. captureStream(fps?: number): MediaStream;
  150225. }
  150226. interface CanvasRenderingContext2D {
  150227. msImageSmoothingEnabled: boolean;
  150228. }
  150229. interface MouseEvent {
  150230. mozMovementX: number;
  150231. mozMovementY: number;
  150232. webkitMovementX: number;
  150233. webkitMovementY: number;
  150234. msMovementX: number;
  150235. msMovementY: number;
  150236. }
  150237. interface Navigator {
  150238. mozGetVRDevices: (any: any) => any;
  150239. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  150240. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  150241. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  150242. webkitGetGamepads(): Gamepad[];
  150243. msGetGamepads(): Gamepad[];
  150244. webkitGamepads(): Gamepad[];
  150245. }
  150246. interface HTMLVideoElement {
  150247. mozSrcObject: any;
  150248. }
  150249. interface Math {
  150250. fround(x: number): number;
  150251. imul(a: number, b: number): number;
  150252. }
  150253. interface WebGLRenderingContext {
  150254. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  150255. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  150256. vertexAttribDivisor(index: number, divisor: number): void;
  150257. createVertexArray(): any;
  150258. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  150259. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  150260. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  150261. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  150262. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  150263. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  150264. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  150265. // Queries
  150266. createQuery(): WebGLQuery;
  150267. deleteQuery(query: WebGLQuery): void;
  150268. beginQuery(target: number, query: WebGLQuery): void;
  150269. endQuery(target: number): void;
  150270. getQueryParameter(query: WebGLQuery, pname: number): any;
  150271. getQuery(target: number, pname: number): any;
  150272. MAX_SAMPLES: number;
  150273. RGBA8: number;
  150274. READ_FRAMEBUFFER: number;
  150275. DRAW_FRAMEBUFFER: number;
  150276. UNIFORM_BUFFER: number;
  150277. HALF_FLOAT_OES: number;
  150278. RGBA16F: number;
  150279. RGBA32F: number;
  150280. R32F: number;
  150281. RG32F: number;
  150282. RGB32F: number;
  150283. R16F: number;
  150284. RG16F: number;
  150285. RGB16F: number;
  150286. RED: number;
  150287. RG: number;
  150288. R8: number;
  150289. RG8: number;
  150290. UNSIGNED_INT_24_8: number;
  150291. DEPTH24_STENCIL8: number;
  150292. MIN: number;
  150293. MAX: number;
  150294. /* Multiple Render Targets */
  150295. drawBuffers(buffers: number[]): void;
  150296. readBuffer(src: number): void;
  150297. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  150298. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  150299. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  150300. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  150301. // Occlusion Query
  150302. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  150303. ANY_SAMPLES_PASSED: number;
  150304. QUERY_RESULT_AVAILABLE: number;
  150305. QUERY_RESULT: number;
  150306. }
  150307. interface WebGLProgram {
  150308. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  150309. }
  150310. interface EXT_disjoint_timer_query {
  150311. QUERY_COUNTER_BITS_EXT: number;
  150312. TIME_ELAPSED_EXT: number;
  150313. TIMESTAMP_EXT: number;
  150314. GPU_DISJOINT_EXT: number;
  150315. QUERY_RESULT_EXT: number;
  150316. QUERY_RESULT_AVAILABLE_EXT: number;
  150317. queryCounterEXT(query: WebGLQuery, target: number): void;
  150318. createQueryEXT(): WebGLQuery;
  150319. beginQueryEXT(target: number, query: WebGLQuery): void;
  150320. endQueryEXT(target: number): void;
  150321. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  150322. deleteQueryEXT(query: WebGLQuery): void;
  150323. }
  150324. interface WebGLUniformLocation {
  150325. _currentState: any;
  150326. }
  150327. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  150328. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  150329. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  150330. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  150331. interface WebGLRenderingContext {
  150332. readonly RASTERIZER_DISCARD: number;
  150333. readonly DEPTH_COMPONENT24: number;
  150334. readonly TEXTURE_3D: number;
  150335. readonly TEXTURE_2D_ARRAY: number;
  150336. readonly TEXTURE_COMPARE_FUNC: number;
  150337. readonly TEXTURE_COMPARE_MODE: number;
  150338. readonly COMPARE_REF_TO_TEXTURE: number;
  150339. readonly TEXTURE_WRAP_R: number;
  150340. readonly HALF_FLOAT: number;
  150341. readonly RGB8: number;
  150342. readonly RED_INTEGER: number;
  150343. readonly RG_INTEGER: number;
  150344. readonly RGB_INTEGER: number;
  150345. readonly RGBA_INTEGER: number;
  150346. readonly R8_SNORM: number;
  150347. readonly RG8_SNORM: number;
  150348. readonly RGB8_SNORM: number;
  150349. readonly RGBA8_SNORM: number;
  150350. readonly R8I: number;
  150351. readonly RG8I: number;
  150352. readonly RGB8I: number;
  150353. readonly RGBA8I: number;
  150354. readonly R8UI: number;
  150355. readonly RG8UI: number;
  150356. readonly RGB8UI: number;
  150357. readonly RGBA8UI: number;
  150358. readonly R16I: number;
  150359. readonly RG16I: number;
  150360. readonly RGB16I: number;
  150361. readonly RGBA16I: number;
  150362. readonly R16UI: number;
  150363. readonly RG16UI: number;
  150364. readonly RGB16UI: number;
  150365. readonly RGBA16UI: number;
  150366. readonly R32I: number;
  150367. readonly RG32I: number;
  150368. readonly RGB32I: number;
  150369. readonly RGBA32I: number;
  150370. readonly R32UI: number;
  150371. readonly RG32UI: number;
  150372. readonly RGB32UI: number;
  150373. readonly RGBA32UI: number;
  150374. readonly RGB10_A2UI: number;
  150375. readonly R11F_G11F_B10F: number;
  150376. readonly RGB9_E5: number;
  150377. readonly RGB10_A2: number;
  150378. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  150379. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  150380. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  150381. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  150382. readonly DEPTH_COMPONENT32F: number;
  150383. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  150384. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  150385. 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;
  150386. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  150387. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  150388. readonly TRANSFORM_FEEDBACK: number;
  150389. readonly INTERLEAVED_ATTRIBS: number;
  150390. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  150391. createTransformFeedback(): WebGLTransformFeedback;
  150392. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  150393. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  150394. beginTransformFeedback(primitiveMode: number): void;
  150395. endTransformFeedback(): void;
  150396. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  150397. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  150398. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  150399. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  150400. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  150401. }
  150402. interface ImageBitmap {
  150403. readonly width: number;
  150404. readonly height: number;
  150405. close(): void;
  150406. }
  150407. interface WebGLQuery extends WebGLObject {
  150408. }
  150409. declare var WebGLQuery: {
  150410. prototype: WebGLQuery;
  150411. new(): WebGLQuery;
  150412. };
  150413. interface WebGLSampler extends WebGLObject {
  150414. }
  150415. declare var WebGLSampler: {
  150416. prototype: WebGLSampler;
  150417. new(): WebGLSampler;
  150418. };
  150419. interface WebGLSync extends WebGLObject {
  150420. }
  150421. declare var WebGLSync: {
  150422. prototype: WebGLSync;
  150423. new(): WebGLSync;
  150424. };
  150425. interface WebGLTransformFeedback extends WebGLObject {
  150426. }
  150427. declare var WebGLTransformFeedback: {
  150428. prototype: WebGLTransformFeedback;
  150429. new(): WebGLTransformFeedback;
  150430. };
  150431. interface WebGLVertexArrayObject extends WebGLObject {
  150432. }
  150433. declare var WebGLVertexArrayObject: {
  150434. prototype: WebGLVertexArrayObject;
  150435. new(): WebGLVertexArrayObject;
  150436. };
  150437. // Type definitions for WebVR API
  150438. // Project: https://w3c.github.io/webvr/
  150439. // Definitions by: six a <https://github.com/lostfictions>
  150440. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  150441. interface VRDisplay extends EventTarget {
  150442. /**
  150443. * Dictionary of capabilities describing the VRDisplay.
  150444. */
  150445. readonly capabilities: VRDisplayCapabilities;
  150446. /**
  150447. * z-depth defining the far plane of the eye view frustum
  150448. * enables mapping of values in the render target depth
  150449. * attachment to scene coordinates. Initially set to 10000.0.
  150450. */
  150451. depthFar: number;
  150452. /**
  150453. * z-depth defining the near plane of the eye view frustum
  150454. * enables mapping of values in the render target depth
  150455. * attachment to scene coordinates. Initially set to 0.01.
  150456. */
  150457. depthNear: number;
  150458. /**
  150459. * An identifier for this distinct VRDisplay. Used as an
  150460. * association point in the Gamepad API.
  150461. */
  150462. readonly displayId: number;
  150463. /**
  150464. * A display name, a user-readable name identifying it.
  150465. */
  150466. readonly displayName: string;
  150467. readonly isConnected: boolean;
  150468. readonly isPresenting: boolean;
  150469. /**
  150470. * If this VRDisplay supports room-scale experiences, the optional
  150471. * stage attribute contains details on the room-scale parameters.
  150472. */
  150473. readonly stageParameters: VRStageParameters | null;
  150474. /**
  150475. * Passing the value returned by `requestAnimationFrame` to
  150476. * `cancelAnimationFrame` will unregister the callback.
  150477. * @param handle Define the hanle of the request to cancel
  150478. */
  150479. cancelAnimationFrame(handle: number): void;
  150480. /**
  150481. * Stops presenting to the VRDisplay.
  150482. * @returns a promise to know when it stopped
  150483. */
  150484. exitPresent(): Promise<void>;
  150485. /**
  150486. * Return the current VREyeParameters for the given eye.
  150487. * @param whichEye Define the eye we want the parameter for
  150488. * @returns the eye parameters
  150489. */
  150490. getEyeParameters(whichEye: string): VREyeParameters;
  150491. /**
  150492. * Populates the passed VRFrameData with the information required to render
  150493. * the current frame.
  150494. * @param frameData Define the data structure to populate
  150495. * @returns true if ok otherwise false
  150496. */
  150497. getFrameData(frameData: VRFrameData): boolean;
  150498. /**
  150499. * Get the layers currently being presented.
  150500. * @returns the list of VR layers
  150501. */
  150502. getLayers(): VRLayer[];
  150503. /**
  150504. * Return a VRPose containing the future predicted pose of the VRDisplay
  150505. * when the current frame will be presented. The value returned will not
  150506. * change until JavaScript has returned control to the browser.
  150507. *
  150508. * The VRPose will contain the position, orientation, velocity,
  150509. * and acceleration of each of these properties.
  150510. * @returns the pose object
  150511. */
  150512. getPose(): VRPose;
  150513. /**
  150514. * Return the current instantaneous pose of the VRDisplay, with no
  150515. * prediction applied.
  150516. * @returns the current instantaneous pose
  150517. */
  150518. getImmediatePose(): VRPose;
  150519. /**
  150520. * The callback passed to `requestAnimationFrame` will be called
  150521. * any time a new frame should be rendered. When the VRDisplay is
  150522. * presenting the callback will be called at the native refresh
  150523. * rate of the HMD. When not presenting this function acts
  150524. * identically to how window.requestAnimationFrame acts. Content should
  150525. * make no assumptions of frame rate or vsync behavior as the HMD runs
  150526. * asynchronously from other displays and at differing refresh rates.
  150527. * @param callback Define the eaction to run next frame
  150528. * @returns the request handle it
  150529. */
  150530. requestAnimationFrame(callback: FrameRequestCallback): number;
  150531. /**
  150532. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  150533. * Repeat calls while already presenting will update the VRLayers being displayed.
  150534. * @param layers Define the list of layer to present
  150535. * @returns a promise to know when the request has been fulfilled
  150536. */
  150537. requestPresent(layers: VRLayer[]): Promise<void>;
  150538. /**
  150539. * Reset the pose for this display, treating its current position and
  150540. * orientation as the "origin/zero" values. VRPose.position,
  150541. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  150542. * updated when calling resetPose(). This should be called in only
  150543. * sitting-space experiences.
  150544. */
  150545. resetPose(): void;
  150546. /**
  150547. * The VRLayer provided to the VRDisplay will be captured and presented
  150548. * in the HMD. Calling this function has the same effect on the source
  150549. * canvas as any other operation that uses its source image, and canvases
  150550. * created without preserveDrawingBuffer set to true will be cleared.
  150551. * @param pose Define the pose to submit
  150552. */
  150553. submitFrame(pose?: VRPose): void;
  150554. }
  150555. declare var VRDisplay: {
  150556. prototype: VRDisplay;
  150557. new(): VRDisplay;
  150558. };
  150559. interface VRLayer {
  150560. leftBounds?: number[] | Float32Array | null;
  150561. rightBounds?: number[] | Float32Array | null;
  150562. source?: HTMLCanvasElement | null;
  150563. }
  150564. interface VRDisplayCapabilities {
  150565. readonly canPresent: boolean;
  150566. readonly hasExternalDisplay: boolean;
  150567. readonly hasOrientation: boolean;
  150568. readonly hasPosition: boolean;
  150569. readonly maxLayers: number;
  150570. }
  150571. interface VREyeParameters {
  150572. /** @deprecated */
  150573. readonly fieldOfView: VRFieldOfView;
  150574. readonly offset: Float32Array;
  150575. readonly renderHeight: number;
  150576. readonly renderWidth: number;
  150577. }
  150578. interface VRFieldOfView {
  150579. readonly downDegrees: number;
  150580. readonly leftDegrees: number;
  150581. readonly rightDegrees: number;
  150582. readonly upDegrees: number;
  150583. }
  150584. interface VRFrameData {
  150585. readonly leftProjectionMatrix: Float32Array;
  150586. readonly leftViewMatrix: Float32Array;
  150587. readonly pose: VRPose;
  150588. readonly rightProjectionMatrix: Float32Array;
  150589. readonly rightViewMatrix: Float32Array;
  150590. readonly timestamp: number;
  150591. }
  150592. interface VRPose {
  150593. readonly angularAcceleration: Float32Array | null;
  150594. readonly angularVelocity: Float32Array | null;
  150595. readonly linearAcceleration: Float32Array | null;
  150596. readonly linearVelocity: Float32Array | null;
  150597. readonly orientation: Float32Array | null;
  150598. readonly position: Float32Array | null;
  150599. readonly timestamp: number;
  150600. }
  150601. interface VRStageParameters {
  150602. sittingToStandingTransform?: Float32Array;
  150603. sizeX?: number;
  150604. sizeY?: number;
  150605. }
  150606. interface Navigator {
  150607. getVRDisplays(): Promise<VRDisplay[]>;
  150608. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  150609. }
  150610. interface Window {
  150611. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  150612. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  150613. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  150614. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  150615. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  150616. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  150617. }
  150618. interface Gamepad {
  150619. readonly displayId: number;
  150620. }
  150621. type XRSessionMode =
  150622. | "inline"
  150623. | "immersive-vr"
  150624. | "immersive-ar";
  150625. type XRReferenceSpaceType =
  150626. | "viewer"
  150627. | "local"
  150628. | "local-floor"
  150629. | "bounded-floor"
  150630. | "unbounded";
  150631. type XREnvironmentBlendMode =
  150632. | "opaque"
  150633. | "additive"
  150634. | "alpha-blend";
  150635. type XRVisibilityState =
  150636. | "visible"
  150637. | "visible-blurred"
  150638. | "hidden";
  150639. type XRHandedness =
  150640. | "none"
  150641. | "left"
  150642. | "right";
  150643. type XRTargetRayMode =
  150644. | "gaze"
  150645. | "tracked-pointer"
  150646. | "screen";
  150647. type XREye =
  150648. | "none"
  150649. | "left"
  150650. | "right";
  150651. type XREventType =
  150652. | "devicechange"
  150653. | "visibilitychange"
  150654. | "end"
  150655. | "inputsourceschange"
  150656. | "select"
  150657. | "selectstart"
  150658. | "selectend"
  150659. | "squeeze"
  150660. | "squeezestart"
  150661. | "squeezeend"
  150662. | "reset";
  150663. interface XRSpace extends EventTarget {
  150664. }
  150665. interface XRRenderState {
  150666. depthNear?: number;
  150667. depthFar?: number;
  150668. inlineVerticalFieldOfView?: number;
  150669. baseLayer?: XRWebGLLayer;
  150670. }
  150671. interface XRInputSource {
  150672. handedness: XRHandedness;
  150673. targetRayMode: XRTargetRayMode;
  150674. targetRaySpace: XRSpace;
  150675. gripSpace: XRSpace | undefined;
  150676. gamepad: Gamepad | undefined;
  150677. profiles: Array<string>;
  150678. }
  150679. interface XRSessionInit {
  150680. optionalFeatures?: string[];
  150681. requiredFeatures?: string[];
  150682. }
  150683. interface XRSession {
  150684. addEventListener: Function;
  150685. removeEventListener: Function;
  150686. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  150687. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  150688. requestAnimationFrame: Function;
  150689. end(): Promise<void>;
  150690. renderState: XRRenderState;
  150691. inputSources: Array<XRInputSource>;
  150692. // hit test
  150693. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  150694. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  150695. // legacy AR hit test
  150696. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  150697. // legacy plane detection
  150698. updateWorldTrackingState(options: {
  150699. planeDetectionState?: { enabled: boolean; }
  150700. }): void;
  150701. }
  150702. interface XRReferenceSpace extends XRSpace {
  150703. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  150704. onreset: any;
  150705. }
  150706. type XRPlaneSet = Set<XRPlane>;
  150707. type XRAnchorSet = Set<XRAnchor>;
  150708. interface XRFrame {
  150709. session: XRSession;
  150710. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  150711. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  150712. // AR
  150713. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  150714. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  150715. // Anchors
  150716. trackedAnchors?: XRAnchorSet;
  150717. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  150718. // Planes
  150719. worldInformation: {
  150720. detectedPlanes?: XRPlaneSet;
  150721. };
  150722. }
  150723. interface XRViewerPose extends XRPose {
  150724. views: Array<XRView>;
  150725. }
  150726. interface XRPose {
  150727. transform: XRRigidTransform;
  150728. emulatedPosition: boolean;
  150729. }
  150730. interface XRWebGLLayerOptions {
  150731. antialias?: boolean;
  150732. depth?: boolean;
  150733. stencil?: boolean;
  150734. alpha?: boolean;
  150735. multiview?: boolean;
  150736. framebufferScaleFactor?: number;
  150737. }
  150738. declare var XRWebGLLayer: {
  150739. prototype: XRWebGLLayer;
  150740. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  150741. };
  150742. interface XRWebGLLayer {
  150743. framebuffer: WebGLFramebuffer;
  150744. framebufferWidth: number;
  150745. framebufferHeight: number;
  150746. getViewport: Function;
  150747. }
  150748. declare class XRRigidTransform {
  150749. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  150750. position: DOMPointReadOnly;
  150751. orientation: DOMPointReadOnly;
  150752. matrix: Float32Array;
  150753. inverse: XRRigidTransform;
  150754. }
  150755. interface XRView {
  150756. eye: XREye;
  150757. projectionMatrix: Float32Array;
  150758. transform: XRRigidTransform;
  150759. }
  150760. interface XRInputSourceChangeEvent {
  150761. session: XRSession;
  150762. removed: Array<XRInputSource>;
  150763. added: Array<XRInputSource>;
  150764. }
  150765. interface XRInputSourceEvent extends Event {
  150766. readonly frame: XRFrame;
  150767. readonly inputSource: XRInputSource;
  150768. }
  150769. // Experimental(er) features
  150770. declare class XRRay {
  150771. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  150772. origin: DOMPointReadOnly;
  150773. direction: DOMPointReadOnly;
  150774. matrix: Float32Array;
  150775. }
  150776. declare enum XRHitTestTrackableType {
  150777. "point",
  150778. "plane"
  150779. }
  150780. interface XRHitResult {
  150781. hitMatrix: Float32Array;
  150782. }
  150783. interface XRTransientInputHitTestResult {
  150784. readonly inputSource: XRInputSource;
  150785. readonly results: Array<XRHitTestResult>;
  150786. }
  150787. interface XRHitTestResult {
  150788. getPose(baseSpace: XRSpace): XRPose | undefined;
  150789. // When anchor system is enabled
  150790. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  150791. }
  150792. interface XRHitTestSource {
  150793. cancel(): void;
  150794. }
  150795. interface XRTransientInputHitTestSource {
  150796. cancel(): void;
  150797. }
  150798. interface XRHitTestOptionsInit {
  150799. space: XRSpace;
  150800. entityTypes?: Array<XRHitTestTrackableType>;
  150801. offsetRay?: XRRay;
  150802. }
  150803. interface XRTransientInputHitTestOptionsInit {
  150804. profile: string;
  150805. entityTypes?: Array<XRHitTestTrackableType>;
  150806. offsetRay?: XRRay;
  150807. }
  150808. interface XRAnchor {
  150809. anchorSpace: XRSpace;
  150810. delete(): void;
  150811. }
  150812. interface XRPlane {
  150813. orientation: "Horizontal" | "Vertical";
  150814. planeSpace: XRSpace;
  150815. polygon: Array<DOMPointReadOnly>;
  150816. lastChangedTime: number;
  150817. }